* doc/sdccman.lyx: mentioned d52 and cmake, customizing startup code
[fw/sdcc] / doc / sdccman.lyx
1 #LyX 1.4.2 created this file. For more info see http://www.lyx.org/
2 \lyxformat 245
3 \begin_document
4 \begin_header
5 \textclass book
6 \begin_preamble
7 \pdfoptionpdfminorversion=3
8 \usepackage[
9   pdftitle={SDCC Compiler User Guide},
10   pdfauthor={SDCC development team},
11   pdfsubject={installation, user manual},
12   pdfkeywords={68hc08 8032 8051 ansi c compiler assembler CPU DS390 embedded development free Floating Point Arithmetic Freescale GPL HC08 inline Intel ISO/IEC 9899:1990 Linux MAC OS X manual Maxim mcs51 Microchip microcontroller open source PIC Unix Windows Z80 Zilog},
13   pdfpagemode=UseOutlines,
14   colorlinks=true,
15   linkcolor=blue] {hyperref}
16 %
17 \sloppy
18 \tolerance=500          
19 \emergencystretch=30pt 
20 %
21 \date{}
22 \end_preamble
23 \language english
24 \inputencoding default
25 \fontscheme pslatex
26 \graphics default
27 \paperfontsize default
28 \spacing single
29 \papersize letterpaper
30 \use_geometry true
31 \use_amsmath 1
32 \cite_engine basic
33 \use_bibtopic false
34 \paperorientation portrait
35 \leftmargin 30mm
36 \topmargin 20mm
37 \rightmargin 25mm
38 \bottommargin 20mm
39 \secnumdepth 3
40 \tocdepth 3
41 \paragraph_separation indent
42 \defskip medskip
43 \quotes_language swedish
44 \papercolumns 1
45 \papersides 1
46 \paperpagestyle fancy
47 \tracking_changes false
48 \output_changes true
49 \end_header
50
51 \begin_body
52
53 \begin_layout Standard
54 \begin_inset Note Note
55 status collapsed
56
57 \begin_layout Standard
58 Please note: double dashed longoptions (e.g.
59  --version) are written this way: -
60 \begin_inset ERT
61 status collapsed
62
63 \begin_layout Standard
64
65
66 \backslash
67 /
68 \end_layout
69
70 \end_inset
71
72 -
73 \end_layout
74
75 \begin_layout Standard
76 Two resp.
77  three consecutive dashes would otherwise result in a long resp.
78  extra long dash.
79 \end_layout
80
81 \begin_layout Standard
82 Architecture specific stuff (like memory models, code examples) should maybe
83  later go
84 \end_layout
85
86 \begin_layout Standard
87 into seperate sections/chapters/appendices (it is hard to document PIC or
88  Z80 in 
89 \end_layout
90
91 \begin_layout Standard
92 a 8051 centered document) - for now simply add.
93 \end_layout
94
95 \end_inset
96
97
98 \end_layout
99
100 \begin_layout Title
101 SDCC Compiler User Guide
102 \end_layout
103
104 \begin_layout Date
105
106 \size normal
107 SDCC 2.7.3
108 \size footnotesize
109
110 \newline
111 $Date::             $ 
112 \newline
113 $Revision$
114 \end_layout
115
116 \begin_layout Standard
117 \begin_inset Note Note
118 status collapsed
119
120 \begin_layout Standard
121 The above strings enclosed in $ are automatically updated by Subversion
122 \end_layout
123
124 \end_inset
125
126
127 \end_layout
128
129 \begin_layout Standard
130 \begin_inset LatexCommand \tableofcontents{}
131
132 \end_inset
133
134
135 \end_layout
136
137 \begin_layout Chapter
138 Introduction
139 \end_layout
140
141 \begin_layout Section
142 About SDCC
143 \end_layout
144
145 \begin_layout Standard
146
147 \series bold
148 SDCC
149 \series default
150  (
151 \emph on
152 S
153 \emph default
154 mall 
155 \emph on
156 D
157 \emph default
158 evice 
159 \emph on
160 C
161 \emph default
162  
163 \emph on
164 C
165 \emph default
166 ompiler) is free open source, retargettable, optimizing ANSI-C compiler
167  by 
168 \series bold
169 Sandeep Dutta
170 \series default
171  designed for 8 bit Microprocessors.
172  The current version targets Intel MCS51 based Microprocessors (8031, 8032,
173  8051, 8052
174 \begin_inset LatexCommand \index{8031, 8032, 8051, 8052, mcs51 CPU}
175
176 \end_inset
177
178 , etc.), Dallas DS80C390 variants, Freescale (formerly Motorola) HC08 and
179  Zilog Z80 based MCUs.
180  It can be retargeted for other microprocessors, support for Microchip PIC,
181  Atmel AVR is under development.
182  The entire source code for the compiler is distributed under GPL.
183  SDCC uses ASXXXX
184 \begin_inset LatexCommand \index{asXXXX (as-gbz80, as-hc08, asx8051, as-z80)}
185
186 \end_inset
187
188  & ASLINK
189 \begin_inset LatexCommand \index{aslink}
190
191 \end_inset
192
193 , an open source retargetable assembler & linker.
194  SDCC has extensive language extensions suitable for utilizing various microcont
195 rollers and underlying hardware effectively.
196  
197 \newline
198
199 \newline
200 In addition to the MCU specific optimizations SDCC also does a host of
201  standard optimizations like:
202 \end_layout
203
204 \begin_layout Itemize
205 global sub expression elimination, 
206 \end_layout
207
208 \begin_layout Itemize
209 loop optimizations (loop invariant, strength reduction of induction variables
210  and loop reversing), 
211 \end_layout
212
213 \begin_layout Itemize
214 constant folding & propagation, 
215 \end_layout
216
217 \begin_layout Itemize
218 copy propagation, 
219 \end_layout
220
221 \begin_layout Itemize
222 dead code elimination 
223 \end_layout
224
225 \begin_layout Itemize
226 jump tables for 
227 \emph on
228 switch
229 \emph default
230  statements.
231 \end_layout
232
233 \begin_layout Standard
234 For the back-end SDCC uses a global register allocation scheme which should
235  be well suited for other 8 bit MCUs.
236  
237 \newline
238
239 \newline
240 The peep hole optimizer uses a rule based substitution mechanism which
241  is MCU independent.
242  
243 \newline
244
245 \newline
246 Supported data-types are:
247 \end_layout
248
249 \begin_layout Standard
250 \begin_inset Tabular
251 <lyxtabular version="3" rows="8" columns="5">
252 <features>
253 <column alignment="center" valignment="top" leftline="true" width="0">
254 <column alignment="center" valignment="top" leftline="true" width="0">
255 <column alignment="center" valignment="top" leftline="true" width="0">
256 <column alignment="center" valignment="top" leftline="true" width="0">
257 <column alignment="block" valignment="top" leftline="true" rightline="true" width="20text%">
258 <row topline="true" bottomline="true">
259 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
260 \begin_inset Text
261
262 \begin_layout Standard
263 type
264 \end_layout
265
266 \end_inset
267 </cell>
268 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
269 \begin_inset Text
270
271 \begin_layout Standard
272 width
273 \end_layout
274
275 \end_inset
276 </cell>
277 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
278 \begin_inset Text
279
280 \begin_layout Standard
281 default
282 \end_layout
283
284 \end_inset
285 </cell>
286 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
287 \begin_inset Text
288
289 \begin_layout Standard
290 signed range
291 \end_layout
292
293 \end_inset
294 </cell>
295 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
296 \begin_inset Text
297
298 \begin_layout Standard
299 unsigned range
300 \end_layout
301
302 \end_inset
303 </cell>
304 </row>
305 <row topline="true">
306 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
307 \begin_inset Text
308
309 \begin_layout Standard
310 bool
311 \end_layout
312
313 \end_inset
314 </cell>
315 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
316 \begin_inset Text
317
318 \begin_layout Standard
319 1 bit
320 \end_layout
321
322 \end_inset
323 </cell>
324 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
325 \begin_inset Text
326
327 \begin_layout Standard
328 unsigned
329 \end_layout
330
331 \end_inset
332 </cell>
333 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
334 \begin_inset Text
335
336 \begin_layout Standard
337 -
338 \end_layout
339
340 \end_inset
341 </cell>
342 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
343 \begin_inset Text
344
345 \begin_layout Standard
346 0, 1
347 \end_layout
348
349 \end_inset
350 </cell>
351 </row>
352 <row topline="true">
353 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
354 \begin_inset Text
355
356 \begin_layout Standard
357 char
358 \end_layout
359
360 \end_inset
361 </cell>
362 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
363 \begin_inset Text
364
365 \begin_layout Standard
366 8 bits, 1 byte
367 \end_layout
368
369 \end_inset
370 </cell>
371 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
372 \begin_inset Text
373
374 \begin_layout Standard
375 signed
376 \end_layout
377
378 \end_inset
379 </cell>
380 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
381 \begin_inset Text
382
383 \begin_layout Standard
384 -128, +127
385 \end_layout
386
387 \end_inset
388 </cell>
389 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
390 \begin_inset Text
391
392 \begin_layout Standard
393 0, +255
394 \end_layout
395
396 \end_inset
397 </cell>
398 </row>
399 <row topline="true">
400 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
401 \begin_inset Text
402
403 \begin_layout Standard
404 short
405 \end_layout
406
407 \end_inset
408 </cell>
409 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
410 \begin_inset Text
411
412 \begin_layout Standard
413 16 bits, 2 bytes
414 \end_layout
415
416 \end_inset
417 </cell>
418 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
419 \begin_inset Text
420
421 \begin_layout Standard
422 signed
423 \end_layout
424
425 \end_inset
426 </cell>
427 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
428 \begin_inset Text
429
430 \begin_layout Standard
431 -32.768, +32.767
432 \end_layout
433
434 \end_inset
435 </cell>
436 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
437 \begin_inset Text
438
439 \begin_layout Standard
440 0, +65.535
441 \end_layout
442
443 \end_inset
444 </cell>
445 </row>
446 <row topline="true">
447 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
448 \begin_inset Text
449
450 \begin_layout Standard
451 int
452 \end_layout
453
454 \end_inset
455 </cell>
456 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
457 \begin_inset Text
458
459 \begin_layout Standard
460 16 bits, 2 bytes
461 \end_layout
462
463 \end_inset
464 </cell>
465 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
466 \begin_inset Text
467
468 \begin_layout Standard
469 signed
470 \end_layout
471
472 \end_inset
473 </cell>
474 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
475 \begin_inset Text
476
477 \begin_layout Standard
478 -32.768, +32.767
479 \end_layout
480
481 \end_inset
482 </cell>
483 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
484 \begin_inset Text
485
486 \begin_layout Standard
487 0, +65.535
488 \end_layout
489
490 \end_inset
491 </cell>
492 </row>
493 <row topline="true" bottomline="true">
494 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
495 \begin_inset Text
496
497 \begin_layout Standard
498 long
499 \end_layout
500
501 \end_inset
502 </cell>
503 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
504 \begin_inset Text
505
506 \begin_layout Standard
507 32 bits, 4 bytes
508 \end_layout
509
510 \end_inset
511 </cell>
512 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
513 \begin_inset Text
514
515 \begin_layout Standard
516 signed
517 \end_layout
518
519 \end_inset
520 </cell>
521 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
522 \begin_inset Text
523
524 \begin_layout Standard
525 -2.147.483.648, +2.147.483.647
526 \end_layout
527
528 \end_inset
529 </cell>
530 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
531 \begin_inset Text
532
533 \begin_layout Standard
534 0, +4.294.967.295
535 \end_layout
536
537 \end_inset
538 </cell>
539 </row>
540 <row topline="true" bottomline="true">
541 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
542 \begin_inset Text
543
544 \begin_layout Standard
545 float
546 \end_layout
547
548 \end_inset
549 </cell>
550 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
551 \begin_inset Text
552
553 \begin_layout Standard
554 4 bytes IEEE 754
555 \end_layout
556
557 \end_inset
558 </cell>
559 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
560 \begin_inset Text
561
562 \begin_layout Standard
563 signed
564 \end_layout
565
566 \end_inset
567 </cell>
568 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
569 \begin_inset Text
570
571 \begin_layout Standard
572
573 \end_layout
574
575 \end_inset
576 </cell>
577 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
578 \begin_inset Text
579
580 \begin_layout Standard
581 1.175494351E-38, 
582 \family roman
583 \series medium
584 \shape up
585 \size normal
586 \emph off
587 \bar no
588 \noun off
589 \color none
590 3.402823466E+38
591 \end_layout
592
593 \end_inset
594 </cell>
595 </row>
596 <row topline="true" bottomline="true">
597 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
598 \begin_inset Text
599
600 \begin_layout Standard
601 pointer
602 \end_layout
603
604 \end_inset
605 </cell>
606 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
607 \begin_inset Text
608
609 \begin_layout Standard
610 1, 2, 3 or 4 bytes
611 \end_layout
612
613 \end_inset
614 </cell>
615 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
616 \begin_inset Text
617
618 \begin_layout Standard
619 generic
620 \end_layout
621
622 \end_inset
623 </cell>
624 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
625 \begin_inset Text
626
627 \begin_layout Standard
628
629 \end_layout
630
631 \end_inset
632 </cell>
633 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
634 \begin_inset Text
635
636 \begin_layout Standard
637
638 \end_layout
639
640 \end_inset
641 </cell>
642 </row>
643 </lyxtabular>
644
645 \end_inset
646
647
648 \newline
649 The compiler also allows 
650 \emph on
651 inline assembler code
652 \emph default
653  to be embedded anywhere in a function.
654  In addition, routines developed in assembly can also be called.
655 \newline
656
657 \newline
658 SDCC also
659  provides an option (-
660 \begin_inset ERT
661 status collapsed
662
663 \begin_layout Standard
664
665
666 \backslash
667 /
668 \end_layout
669
670 \end_inset
671
672 -cyclomatic) to report the relative complexity of a function.
673  These functions can then be further optimized, or hand coded in assembly
674  if needed.
675  
676 \newline
677
678 \newline
679 SDCC also comes with a companion source level debugger SDCDB.
680  The debugger currently uses ucSim, a free open source simulator for 8051
681  and other micro-controllers.
682 \newline
683
684 \newline
685 The latest SDCC version can be downloaded from
686  
687 \begin_inset LatexCommand \url{http://sdcc.sourceforge.net/snap.php}
688
689 \end_inset
690
691 .
692
693 \series bold
694  
695 \series default
696 \emph on
697 Please note: the compiler will probably always be some steps ahead of this
698  documentation
699 \series bold
700 \emph default
701
702 \begin_inset LatexCommand \index{Status of documentation}
703
704 \end_inset
705
706
707 \begin_inset Foot
708 status open
709
710 \begin_layout Standard
711 Obviously this has pros and cons
712 \end_layout
713
714 \end_inset
715
716 .
717 \end_layout
718
719 \begin_layout Section
720 Open Source
721 \end_layout
722
723 \begin_layout Standard
724 All packages used in this compiler system are 
725 \emph on
726 open source
727 \emph default
728  and 
729 \emph on
730 freeware
731 \emph default
732 ; source code for all the sub-packages (pre-processor, assemblers, linkers
733  etc.) is distributed with the package.
734  This documentation is maintained using a free open source word processor
735  (LyX).
736 \newline
737 This program is free software; you can redistribute it and/or modify
738  it under the terms of the GNU General Public License
739 \begin_inset LatexCommand \index{GNU General Public License, GPL}
740
741 \end_inset
742
743  as published by the Free Software Foundation; either version 2, or (at
744  your option) any later version.
745  This program is distributed in the hope that it will be useful, but WITHOUT
746  ANY WARRANTY; without even the implied warranty
747 \begin_inset LatexCommand \index{warranty}
748
749 \end_inset
750
751  of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
752  See the GNU General Public License for more details.
753  You should have received a copy of the GNU General Public License along
754  with this program; if not, write to the Free Software Foundation, 59 Temple
755  Place - Suite 330, Boston, MA 02111-1307, USA.
756  In other words, you are welcome to use, share and improve this program.
757  You are forbidden to forbid anyone else to use, share and improve what
758  you give them.
759  Help stamp out software-hoarding! 
760 \end_layout
761
762 \begin_layout Section
763 Typographic conventions
764 \begin_inset LatexCommand \index{Typographic conventions}
765
766 \end_inset
767
768
769 \end_layout
770
771 \begin_layout Standard
772 Throughout this manual, we will use the following convention.
773  Commands you have to type in are printed in 
774 \family sans
775 \series bold
776 "sans serif"
777 \series default
778 .
779
780 \family default
781  Code samples are printed in 
782 \family typewriter
783 typewriter font.
784
785 \family default
786  Interesting items and new terms are printed in 
787 \emph on
788 italic.
789 \end_layout
790
791 \begin_layout Section
792 Compatibility
793 \begin_inset LatexCommand \label{sec:Compatibility-with-previous}
794
795 \end_inset
796
797  with previous versions
798 \begin_inset LatexCommand \index{Compatibility with previous versions}
799
800 \end_inset
801
802
803 \end_layout
804
805 \begin_layout Standard
806 Newer versions have usually numerous bug fixes compared with the previous
807  version.
808  But we also sometimes introduce some incompatibilities with older versions.
809  Not just for the fun of it, but to make the compiler more stable, efficient
810  and ANSI compliant
811 \begin_inset LatexCommand \index{ANSI-compliance}
812
813 \end_inset
814
815  (see section 
816 \begin_inset LatexCommand \ref{sub:ANSI-Compliance}
817
818 \end_inset
819
820  for ANSI-Compliance).
821  
822 \begin_inset Note Note
823 status collapsed
824
825 \begin_layout Standard
826 It would be fine to add to each item, in which version was it changed.
827 \end_layout
828
829 \end_inset
830
831
832 \newline
833
834 \end_layout
835
836 \begin_layout Itemize
837 short is now equivalent to int (16 bits), it used to be equivalent to char
838  (8 bits) which is not ANSI compliant.
839  To maintain compatibility, old programs may be compiled using the -
840 \begin_inset ERT
841 status collapsed
842
843 \begin_layout Standard
844
845
846 \backslash
847 /
848 \end_layout
849
850 \end_inset
851
852 -short-is-8bits commandline option (see 
853 \begin_inset LatexCommand \vref{lyx:--short-is-8bits}
854
855 \end_inset
856
857 ).
858 \end_layout
859
860 \begin_layout Itemize
861 the default directory for gcc-builds where include, library and documentation
862  files are stored is now in /usr/local/share.
863 \end_layout
864
865 \begin_layout Itemize
866 char type parameters to vararg
867 \begin_inset LatexCommand \index{vararg, va\_arg}
868
869 \end_inset
870
871  functions are casted to int unless explicitly casted
872 \begin_inset Marginal
873 status collapsed
874
875 \begin_layout Standard
876
877 \series bold
878 \InsetSpace ~
879 !
880 \end_layout
881
882 \end_inset
883
884 , e.g.: 
885 \newline
886
887 \family typewriter
888 \InsetSpace ~
889 \InsetSpace ~
890 char a=3;
891 \newline
892 \InsetSpace ~
893 \InsetSpace ~
894 printf ("%d %c
895 \backslash
896 n", a, (char)a);
897 \family default
898
899 \newline
900  will push a as an int and as a char resp.
901 \end_layout
902
903 \begin_layout Itemize
904 option -
905 \begin_inset ERT
906 status collapsed
907
908 \begin_layout Standard
909
910
911 \backslash
912 /
913 \end_layout
914
915 \end_inset
916
917 -regextend has been removed.
918 \end_layout
919
920 \begin_layout Itemize
921 option -
922 \begin_inset ERT
923 status collapsed
924
925 \begin_layout Standard
926
927
928 \backslash
929 /
930 \end_layout
931
932 \end_inset
933
934 -noregparms has been removed.
935 \end_layout
936
937 \begin_layout Itemize
938 option -
939 \begin_inset ERT
940 status collapsed
941
942 \begin_layout Standard
943
944
945 \backslash
946 /
947 \end_layout
948
949 \end_inset
950
951 -stack-after-data has been removed.
952 \end_layout
953
954 \begin_layout Itemize
955 bit
956 \begin_inset LatexCommand \index{bit}
957
958 \end_inset
959
960  and sbit
961 \begin_inset LatexCommand \index{sbit}
962
963 \end_inset
964
965
966 \begin_inset LatexCommand \index{\_\_sbit}
967
968 \end_inset
969
970  types now consistently behave like the C99 _Bool type with respect to type
971  conversion
972 \begin_inset LatexCommand \index{type conversion}
973
974 \end_inset
975
976
977 \begin_inset LatexCommand \index{type promotion}
978
979 \end_inset
980
981 .
982  The most common incompatibility resulting from this change is related to
983  bit toggling
984 \begin_inset LatexCommand \index{Bit toggling}
985
986 \end_inset
987
988  idioms, e.g.:
989 \newline
990
991 \family typewriter
992 \InsetSpace ~
993 \InsetSpace ~
994 bit b;
995 \newline
996 \InsetSpace ~
997 \InsetSpace ~
998 b = ~
999 \begin_inset LatexCommand \index{\~\/ Operator}
1000
1001 \end_inset
1002
1003 b; /* equivalent to b=1 instead of toggling b */
1004 \begin_inset Marginal
1005 status collapsed
1006
1007 \begin_layout Standard
1008
1009 \series bold
1010 \InsetSpace ~
1011 !
1012 \end_layout
1013
1014 \end_inset
1015
1016
1017 \newline
1018 \InsetSpace ~
1019 \InsetSpace ~
1020 b = !b; /* toggles b */
1021 \newline
1022
1023 \family default
1024 In previous versions, both forms would have toggled the bit.
1025 \end_layout
1026
1027 \begin_layout Standard
1028
1029 \emph on
1030 <pending: more incompatibilities?>
1031 \end_layout
1032
1033 \begin_layout Section
1034 System Requirements
1035 \end_layout
1036
1037 \begin_layout Standard
1038 What do you need before you start installation of SDCC? A computer, and
1039  a desire to compute.
1040  The preferred method of installation is to compile SDCC from source using
1041  GNU gcc and make.
1042  For Windows some pre-compiled binary distributions are available for your
1043  convenience.
1044  You should have some experience with command line tools and compiler use.
1045 \end_layout
1046
1047 \begin_layout Section
1048 Other Resources
1049 \end_layout
1050
1051 \begin_layout Standard
1052 The SDCC home page at 
1053 \begin_inset LatexCommand \url{http://sdcc.sourceforge.net/}
1054
1055 \end_inset
1056
1057  is a great place to find distribution sets.
1058  You can also find links to the user mailing lists that offer help or discuss
1059  SDCC with other SDCC users.
1060  Web links to other SDCC related sites can also be found here.
1061  This document can be found in the DOC directory of the source package as
1062  a text or HTML file.
1063  A pdf version of this document is available at 
1064 \begin_inset LatexCommand \url{http://sdcc.sourceforge.net/doc/sdccman.pdf}
1065
1066 \end_inset
1067
1068 .
1069  Some of the other tools (simulator and assembler) included with SDCC contain
1070  their own documentation and can be found in the source distribution.
1071  If you want the latest unreleased software, the complete source package
1072  is available directly from Subversion on https://sdcc.svn.sourceforge.net/svnroot/
1073 sdcc/trunk/sdcc.
1074 \end_layout
1075
1076 \begin_layout Section
1077 Wishes for the future
1078 \end_layout
1079
1080 \begin_layout Standard
1081 There are (and always will be) some things that could be done.
1082  Here are some I can think of:
1083 \newline
1084
1085 \end_layout
1086
1087 \begin_layout Standard
1088
1089 \family typewriter
1090 char KernelFunction3(char p) at 0x340;
1091 \newline
1092
1093 \end_layout
1094
1095 \begin_layout Standard
1096
1097 \family typewriter
1098 better code banking
1099 \begin_inset LatexCommand \index{code banking (limited support)}
1100
1101 \end_inset
1102
1103  support for mcs51
1104 \newline
1105
1106 \newline
1107
1108 \family default
1109 If you can think of some more, please see the section 
1110 \begin_inset LatexCommand \ref{sub:Requesting-Features}
1111
1112 \end_inset
1113
1114  about filing feature requests
1115 \begin_inset LatexCommand \index{Requesting features}
1116
1117 \end_inset
1118
1119
1120 \begin_inset LatexCommand \index{Feature request}
1121
1122 \end_inset
1123
1124 .
1125 \newline
1126
1127 \end_layout
1128
1129 \begin_layout Chapter
1130 Installing SDCC
1131 \begin_inset LatexCommand \index{Installation}
1132
1133 \end_inset
1134
1135
1136 \end_layout
1137
1138 \begin_layout Standard
1139 For most users it is sufficient to skip to either section 
1140 \begin_inset LatexCommand \ref{sub:Building-SDCC-on-Linux}
1141
1142 \end_inset
1143
1144  (Unix) or section 
1145 \begin_inset LatexCommand \ref{sub:Windows-Install}
1146
1147 \end_inset
1148
1149  (Windows).
1150  More detailed instructions follow below.
1151 \end_layout
1152
1153 \begin_layout Section
1154 Configure Options
1155 \begin_inset LatexCommand \index{Options SDCC configuration}
1156
1157 \end_inset
1158
1159
1160 \end_layout
1161
1162 \begin_layout Standard
1163 The install paths, search paths and other options are defined when running
1164  'configure'.
1165  The defaults can be overridden by:
1166 \end_layout
1167
1168 \begin_layout List
1169 \labelwidthstring 00.00.0000
1170 -
1171 \begin_inset ERT
1172 status collapsed
1173
1174 \begin_layout Standard
1175
1176
1177 \backslash
1178 /
1179 \end_layout
1180
1181 \end_inset
1182
1183 -prefix see table below
1184 \end_layout
1185
1186 \begin_layout List
1187 \labelwidthstring 00.00.0000
1188 -
1189 \begin_inset ERT
1190 status collapsed
1191
1192 \begin_layout Standard
1193
1194
1195 \backslash
1196 /
1197 \end_layout
1198
1199 \end_inset
1200
1201 -exec_prefix see table below
1202 \end_layout
1203
1204 \begin_layout List
1205 \labelwidthstring 00.00.0000
1206 -
1207 \begin_inset ERT
1208 status collapsed
1209
1210 \begin_layout Standard
1211
1212
1213 \backslash
1214 /
1215 \end_layout
1216
1217 \end_inset
1218
1219 -bindir see table below
1220 \end_layout
1221
1222 \begin_layout List
1223 \labelwidthstring 00.00.0000
1224 -
1225 \begin_inset ERT
1226 status collapsed
1227
1228 \begin_layout Standard
1229
1230
1231 \backslash
1232 /
1233 \end_layout
1234
1235 \end_inset
1236
1237 -datadir see table below
1238 \end_layout
1239
1240 \begin_layout List
1241 \labelwidthstring 00.00.0000
1242 -
1243 \begin_inset ERT
1244 status collapsed
1245
1246 \begin_layout Standard
1247
1248
1249 \backslash
1250 /
1251 \end_layout
1252
1253 \end_inset
1254
1255 -datarootdir see table below
1256 \newline
1257
1258 \end_layout
1259
1260 \begin_layout List
1261 \labelwidthstring 00.00.0000
1262 \InsetSpace ~
1263 \InsetSpace ~
1264 docdir environment variable, see table below
1265 \end_layout
1266
1267 \begin_layout List
1268 \labelwidthstring 00.00.0000
1269 \InsetSpace ~
1270 \InsetSpace ~
1271 include_dir_suffix environment variable, see table below
1272 \end_layout
1273
1274 \begin_layout List
1275 \labelwidthstring 00.00.0000
1276 \InsetSpace ~
1277 \InsetSpace ~
1278 lib_dir_suffix environment variable, see table below
1279 \end_layout
1280
1281 \begin_layout List
1282 \labelwidthstring 00.00.0000
1283 \InsetSpace ~
1284 \InsetSpace ~
1285 sdccconf_h_dir_separator environment variable, either / or 
1286 \backslash
1287
1288 \backslash
1289  makes sense here.
1290  This character will only be used in sdccconf.h; don't forget it's a C-header,
1291  therefore a double-backslash is needed there.
1292 \newline
1293
1294 \end_layout
1295
1296 \begin_layout List
1297 \labelwidthstring 00.00.0000
1298 -
1299 \begin_inset ERT
1300 status collapsed
1301
1302 \begin_layout Standard
1303
1304
1305 \backslash
1306 /
1307 \end_layout
1308
1309 \end_inset
1310
1311 -disable-mcs51-port Excludes the Intel mcs51 port
1312 \end_layout
1313
1314 \begin_layout List
1315 \labelwidthstring 00.00.0000
1316 -
1317 \begin_inset ERT
1318 status collapsed
1319
1320 \begin_layout Standard
1321
1322
1323 \backslash
1324 /
1325 \end_layout
1326
1327 \end_inset
1328
1329 -disable-gbz80-port Excludes the Gameboy gbz80 port
1330 \end_layout
1331
1332 \begin_layout List
1333 \labelwidthstring 00.00.0000
1334 -
1335 \begin_inset ERT
1336 status collapsed
1337
1338 \begin_layout Standard
1339
1340
1341 \backslash
1342 /
1343 \end_layout
1344
1345 \end_inset
1346
1347 -disable-z80-port Excludes the z80 port
1348 \end_layout
1349
1350 \begin_layout List
1351 \labelwidthstring 00.00.0000
1352 -
1353 \begin_inset ERT
1354 status collapsed
1355
1356 \begin_layout Standard
1357
1358
1359 \backslash
1360 /
1361 \end_layout
1362
1363 \end_inset
1364
1365 -disable-avr-port Excludes the AVR port
1366 \end_layout
1367
1368 \begin_layout List
1369 \labelwidthstring 00.00.0000
1370 -
1371 \begin_inset ERT
1372 status collapsed
1373
1374 \begin_layout Standard
1375
1376
1377 \backslash
1378 /
1379 \end_layout
1380
1381 \end_inset
1382
1383 -disable-ds390-port Excludes the DS390 port
1384 \end_layout
1385
1386 \begin_layout List
1387 \labelwidthstring 00.00.0000
1388 -
1389 \begin_inset ERT
1390 status collapsed
1391
1392 \begin_layout Standard
1393
1394
1395 \backslash
1396 /
1397 \end_layout
1398
1399 \end_inset
1400
1401 -disable-hc08-port Excludes the HC08 port
1402 \end_layout
1403
1404 \begin_layout List
1405 \labelwidthstring 00.00.0000
1406 -
1407 \begin_inset ERT
1408 status collapsed
1409
1410 \begin_layout Standard
1411
1412
1413 \backslash
1414 /
1415 \end_layout
1416
1417 \end_inset
1418
1419 -disable-pic-port Excludes the PIC14 port
1420 \end_layout
1421
1422 \begin_layout List
1423 \labelwidthstring 00.00.0000
1424 -
1425 \begin_inset ERT
1426 status collapsed
1427
1428 \begin_layout Standard
1429
1430
1431 \backslash
1432 /
1433 \end_layout
1434
1435 \end_inset
1436
1437 -disable-pic16-port Excludes the PIC16 port
1438 \end_layout
1439
1440 \begin_layout List
1441 \labelwidthstring 00.00.0000
1442 -
1443 \begin_inset ERT
1444 status collapsed
1445
1446 \begin_layout Standard
1447
1448
1449 \backslash
1450 /
1451 \end_layout
1452
1453 \end_inset
1454
1455 -disable-xa51-port Excludes the XA51 port
1456 \end_layout
1457
1458 \begin_layout List
1459 \labelwidthstring 00.00.0000
1460 -
1461 \begin_inset ERT
1462 status collapsed
1463
1464 \begin_layout Standard
1465
1466
1467 \backslash
1468 /
1469 \end_layout
1470
1471 \end_inset
1472
1473 -disable-ucsim Disables configuring and building of ucsim
1474 \end_layout
1475
1476 \begin_layout List
1477 \labelwidthstring 00.00.0000
1478 -
1479 \begin_inset ERT
1480 status collapsed
1481
1482 \begin_layout Standard
1483
1484
1485 \backslash
1486 /
1487 \end_layout
1488
1489 \end_inset
1490
1491 -disable-device-lib Disables automatically building device libraries
1492 \end_layout
1493
1494 \begin_layout List
1495 \labelwidthstring 00.00.0000
1496 -
1497 \begin_inset ERT
1498 status collapsed
1499
1500 \begin_layout Standard
1501
1502
1503 \backslash
1504 /
1505 \end_layout
1506
1507 \end_inset
1508
1509 -disable-packihx Disables building packihx
1510 \newline
1511
1512 \end_layout
1513
1514 \begin_layout List
1515 \labelwidthstring 00.00.0000
1516 -
1517 \begin_inset ERT
1518 status collapsed
1519
1520 \begin_layout Standard
1521
1522
1523 \backslash
1524 /
1525 \end_layout
1526
1527 \end_inset
1528
1529 -enable-doc Build pdf, html and txt files from the lyx sources
1530 \end_layout
1531
1532 \begin_layout List
1533 \labelwidthstring 00.00.0000
1534 -
1535 \begin_inset ERT
1536 status collapsed
1537
1538 \begin_layout Standard
1539
1540
1541 \backslash
1542 /
1543 \end_layout
1544
1545 \end_inset
1546
1547 -enable-libgc Use the Bohem memory allocator.
1548  Lower runtime footprint.
1549 \end_layout
1550
1551 \begin_layout Standard
1552 Furthermore the environment variables CC, CFLAGS, ...
1553  the tools and their arguments can be influenced.
1554  Please see `configure -
1555 \begin_inset ERT
1556 status collapsed
1557
1558 \begin_layout Standard
1559
1560
1561 \backslash
1562 /
1563 \end_layout
1564
1565 \end_inset
1566
1567 -help' and the man/info pages of `configure' for details.
1568 \newline
1569
1570 \newline
1571 The names of the
1572  standard libraries STD_LIB, STD_INT_LIB, STD_LONG_LIB, STD_FP_LIB, STD_DS390_LI
1573 B, STD_XA51_LIB and the environment variables SDCC_DIR_NAME, SDCC_INCLUDE_NAME,
1574  SDCC_LIB_NAME are defined by `configure' too.
1575  At the moment it's not possible to change the default settings (it was
1576  simply never required).
1577 \newline
1578
1579 \newline
1580 These configure options are compiled into the binaries,
1581  and can only be changed by rerunning 'configure' and recompiling SDCC.
1582  The configure options are written in 
1583 \emph on
1584 italics
1585 \emph default
1586  to distinguish them from run time environment variables (see section search
1587  paths).
1588 \newline
1589
1590 \newline
1591 The settings for 
1592 \begin_inset Quotes sld
1593 \end_inset
1594
1595 Win32 builds
1596 \begin_inset Quotes srd
1597 \end_inset
1598
1599  are used by the SDCC team to build the official Win32 binaries.
1600  The SDCC team uses Mingw32 to build the official Windows binaries, because
1601  it's
1602 \end_layout
1603
1604 \begin_layout Enumerate
1605 open source, 
1606 \end_layout
1607
1608 \begin_layout Enumerate
1609 a gcc compiler and last but not least
1610 \end_layout
1611
1612 \begin_layout Enumerate
1613 the binaries can be built by cross compiling on SDCC Distributed Compile
1614  Farm.
1615 \end_layout
1616
1617 \begin_layout Standard
1618 See the examples, how to pass the Win32 settings to 'configure'.
1619  The other Win32 builds using Borland, VC or whatever don't use 'configure',
1620  but a header file sdcc_vc_in.h is the same as sdccconf.h built by 'configure'
1621  for Win32.
1622 \newline
1623
1624 \newline
1625 These defaults are:
1626 \newline
1627
1628 \end_layout
1629
1630 \begin_layout Standard
1631 \align center
1632 \begin_inset Tabular
1633 <lyxtabular version="3" rows="9" columns="3">
1634 <features>
1635 <column alignment="block" valignment="top" leftline="true" width="0in">
1636 <column alignment="block" valignment="top" leftline="true" width="0in">
1637 <column alignment="block" valignment="top" leftline="true" rightline="true" width="0in">
1638 <row topline="true" bottomline="true">
1639 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1640 \begin_inset Text
1641
1642 \begin_layout Standard
1643 Variable
1644 \end_layout
1645
1646 \end_inset
1647 </cell>
1648 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1649 \begin_inset Text
1650
1651 \begin_layout Standard
1652 default
1653 \end_layout
1654
1655 \end_inset
1656 </cell>
1657 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1658 \begin_inset Text
1659
1660 \begin_layout Standard
1661 Win32 builds
1662 \end_layout
1663
1664 \end_inset
1665 </cell>
1666 </row>
1667 <row topline="true">
1668 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1669 \begin_inset Text
1670
1671 \begin_layout Standard
1672
1673 \emph on
1674 PREFIX
1675 \end_layout
1676
1677 \end_inset
1678 </cell>
1679 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1680 \begin_inset Text
1681
1682 \begin_layout Standard
1683 /usr/local
1684 \end_layout
1685
1686 \end_inset
1687 </cell>
1688 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1689 \begin_inset Text
1690
1691 \begin_layout Standard
1692
1693 \backslash
1694 sdcc
1695 \end_layout
1696
1697 \end_inset
1698 </cell>
1699 </row>
1700 <row topline="true">
1701 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1702 \begin_inset Text
1703
1704 \begin_layout Standard
1705
1706 \emph on
1707 EXEC_PREFIX
1708 \end_layout
1709
1710 \end_inset
1711 </cell>
1712 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1713 \begin_inset Text
1714
1715 \begin_layout Standard
1716
1717 \emph on
1718 $PREFIX
1719 \end_layout
1720
1721 \end_inset
1722 </cell>
1723 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1724 \begin_inset Text
1725
1726 \begin_layout Standard
1727
1728 \emph on
1729 $PREFIX
1730 \end_layout
1731
1732 \end_inset
1733 </cell>
1734 </row>
1735 <row topline="true">
1736 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1737 \begin_inset Text
1738
1739 \begin_layout Standard
1740
1741 \emph on
1742 BINDIR
1743 \end_layout
1744
1745 \end_inset
1746 </cell>
1747 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1748 \begin_inset Text
1749
1750 \begin_layout Standard
1751
1752 \emph on
1753 $EXEC_PREFIX
1754 \emph default
1755 /bin
1756 \end_layout
1757
1758 \end_inset
1759 </cell>
1760 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1761 \begin_inset Text
1762
1763 \begin_layout Standard
1764
1765 \emph on
1766 $EXEC_PREFIX
1767 \emph default
1768
1769 \backslash
1770 bin
1771 \end_layout
1772
1773 \end_inset
1774 </cell>
1775 </row>
1776 <row topline="true">
1777 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1778 \begin_inset Text
1779
1780 \begin_layout Standard
1781
1782 \emph on
1783 DATADIR
1784 \end_layout
1785
1786 \end_inset
1787 </cell>
1788 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1789 \begin_inset Text
1790
1791 \begin_layout Standard
1792
1793 \emph on
1794 $DATAROOTDIR
1795 \end_layout
1796
1797 \end_inset
1798 </cell>
1799 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1800 \begin_inset Text
1801
1802 \begin_layout Standard
1803
1804 \emph on
1805 $DATAROOTDIR
1806 \end_layout
1807
1808 \end_inset
1809 </cell>
1810 </row>
1811 <row topline="true">
1812 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1813 \begin_inset Text
1814
1815 \begin_layout Standard
1816
1817 \emph on
1818 DATAROOTDIR
1819 \end_layout
1820
1821 \end_inset
1822 </cell>
1823 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1824 \begin_inset Text
1825
1826 \begin_layout Standard
1827
1828 \emph on
1829 $PREFIX
1830 \emph default
1831 /share
1832 \end_layout
1833
1834 \end_inset
1835 </cell>
1836 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1837 \begin_inset Text
1838
1839 \begin_layout Standard
1840
1841 \emph on
1842 $PREFIX
1843 \end_layout
1844
1845 \end_inset
1846 </cell>
1847 </row>
1848 <row topline="true">
1849 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1850 \begin_inset Text
1851
1852 \begin_layout Standard
1853
1854 \emph on
1855 DOCDIR
1856 \end_layout
1857
1858 \end_inset
1859 </cell>
1860 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1861 \begin_inset Text
1862
1863 \begin_layout Standard
1864
1865 \emph on
1866 $DATAROOTDIR
1867 \emph default
1868 /sdcc/doc
1869 \end_layout
1870
1871 \end_inset
1872 </cell>
1873 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1874 \begin_inset Text
1875
1876 \begin_layout Standard
1877
1878 \emph on
1879 $DATAROOTDIR
1880 \emph default
1881
1882 \backslash
1883 doc
1884 \end_layout
1885
1886 \end_inset
1887 </cell>
1888 </row>
1889 <row topline="true">
1890 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1891 \begin_inset Text
1892
1893 \begin_layout Standard
1894
1895 \emph on
1896 INCLUDE_DIR_SUFFIX
1897 \end_layout
1898
1899 \end_inset
1900 </cell>
1901 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1902 \begin_inset Text
1903
1904 \begin_layout Standard
1905 sdcc/include
1906 \end_layout
1907
1908 \end_inset
1909 </cell>
1910 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1911 \begin_inset Text
1912
1913 \begin_layout Standard
1914 include
1915 \end_layout
1916
1917 \end_inset
1918 </cell>
1919 </row>
1920 <row topline="true" bottomline="true">
1921 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1922 \begin_inset Text
1923
1924 \begin_layout Standard
1925
1926 \emph on
1927 LIB_DIR_SUFFIX
1928 \end_layout
1929
1930 \end_inset
1931 </cell>
1932 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1933 \begin_inset Text
1934
1935 \begin_layout Standard
1936 sdcc/lib
1937 \end_layout
1938
1939 \end_inset
1940 </cell>
1941 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1942 \begin_inset Text
1943
1944 \begin_layout Standard
1945 lib
1946 \end_layout
1947
1948 \end_inset
1949 </cell>
1950 </row>
1951 </lyxtabular>
1952
1953 \end_inset
1954
1955
1956 \newline
1957
1958 \end_layout
1959
1960 \begin_layout Standard
1961 \noindent
1962 'configure' also computes relative paths.
1963  This is needed for full relocatability of a binary package and to complete
1964  search paths (see section search paths below):
1965 \newline
1966  
1967 \end_layout
1968
1969 \begin_layout Standard
1970 \align center
1971 \begin_inset Tabular
1972 <lyxtabular version="3" rows="4" columns="3">
1973 <features>
1974 <column alignment="block" valignment="top" leftline="true" width="0in">
1975 <column alignment="block" valignment="top" leftline="true" width="0in">
1976 <column alignment="block" valignment="top" leftline="true" rightline="true" width="0in">
1977 <row topline="true" bottomline="true">
1978 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1979 \begin_inset Text
1980
1981 \begin_layout Standard
1982 Variable (computed)
1983 \end_layout
1984
1985 \end_inset
1986 </cell>
1987 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1988 \begin_inset Text
1989
1990 \begin_layout Standard
1991 default
1992 \end_layout
1993
1994 \end_inset
1995 </cell>
1996 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1997 \begin_inset Text
1998
1999 \begin_layout Standard
2000 Win32 builds
2001 \end_layout
2002
2003 \end_inset
2004 </cell>
2005 </row>
2006 <row topline="true" bottomline="true">
2007 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2008 \begin_inset Text
2009
2010 \begin_layout Standard
2011
2012 \emph on
2013 BIN2DATA_DIR
2014 \end_layout
2015
2016 \end_inset
2017 </cell>
2018 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2019 \begin_inset Text
2020
2021 \begin_layout Standard
2022 ../share
2023 \end_layout
2024
2025 \end_inset
2026 </cell>
2027 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2028 \begin_inset Text
2029
2030 \begin_layout Standard
2031 ..
2032 \end_layout
2033
2034 \end_inset
2035 </cell>
2036 </row>
2037 <row bottomline="true">
2038 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2039 \begin_inset Text
2040
2041 \begin_layout Standard
2042
2043 \emph on
2044 PREFIX2BIN_DIR
2045 \end_layout
2046
2047 \end_inset
2048 </cell>
2049 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2050 \begin_inset Text
2051
2052 \begin_layout Standard
2053 bin
2054 \end_layout
2055
2056 \end_inset
2057 </cell>
2058 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2059 \begin_inset Text
2060
2061 \begin_layout Standard
2062 bin
2063 \end_layout
2064
2065 \end_inset
2066 </cell>
2067 </row>
2068 <row bottomline="true">
2069 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2070 \begin_inset Text
2071
2072 \begin_layout Standard
2073
2074 \emph on
2075 PREFIX2DATA_DIR
2076 \end_layout
2077
2078 \end_inset
2079 </cell>
2080 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2081 \begin_inset Text
2082
2083 \begin_layout Standard
2084 share/sdcc
2085 \end_layout
2086
2087 \end_inset
2088 </cell>
2089 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2090 \begin_inset Text
2091
2092 \begin_layout Standard
2093
2094 \end_layout
2095
2096 \end_inset
2097 </cell>
2098 </row>
2099 </lyxtabular>
2100
2101 \end_inset
2102
2103
2104 \newline
2105
2106 \end_layout
2107
2108 \begin_layout Standard
2109 \noindent
2110 Examples:
2111 \end_layout
2112
2113 \begin_layout LyX-Code
2114 ./configure
2115 \newline
2116 ./configure -
2117 \begin_inset ERT
2118 status collapsed
2119
2120 \begin_layout Standard
2121
2122
2123 \backslash
2124 /
2125 \end_layout
2126
2127 \end_inset
2128
2129 -prefix=
2130 \begin_inset Quotes srd
2131 \end_inset
2132
2133 /usr/bin
2134 \begin_inset Quotes srd
2135 \end_inset
2136
2137  -
2138 \begin_inset ERT
2139 status collapsed
2140
2141 \begin_layout Standard
2142
2143
2144 \backslash
2145 /
2146 \end_layout
2147
2148 \end_inset
2149
2150 -datarootdir=
2151 \begin_inset Quotes srd
2152 \end_inset
2153
2154 /usr/share
2155 \begin_inset Quotes srd
2156 \end_inset
2157
2158
2159 \newline
2160 ./configure -
2161 \begin_inset ERT
2162 status collapsed
2163
2164 \begin_layout Standard
2165
2166
2167 \backslash
2168 /
2169 \end_layout
2170
2171 \end_inset
2172
2173 -disable-avr-port -
2174 \begin_inset ERT
2175 status collapsed
2176
2177 \begin_layout Standard
2178
2179
2180 \backslash
2181 /
2182 \end_layout
2183
2184 \end_inset
2185
2186 -disable-xa51-port
2187 \end_layout
2188
2189 \begin_layout Standard
2190 To cross compile on linux for Mingw32 (see also 'sdcc/support/scripts/sdcc_mingw
2191 32'):
2192 \end_layout
2193
2194 \begin_layout LyX-Code
2195 ./configure 
2196 \backslash
2197
2198 \newline
2199 CC=
2200 \begin_inset Quotes srd
2201 \end_inset
2202
2203 i586-mingw32msvc-gcc
2204 \begin_inset Quotes srd
2205 \end_inset
2206
2207  CXX=
2208 \begin_inset Quotes srd
2209 \end_inset
2210
2211 i586-mingw32msvc-g++
2212 \begin_inset Quotes srd
2213 \end_inset
2214
2215  
2216 \backslash
2217  
2218 \newline
2219 RANLIB=
2220 \begin_inset Quotes srd
2221 \end_inset
2222
2223 i586-mingw32msvc-ranlib
2224 \begin_inset Quotes srd
2225 \end_inset
2226
2227  
2228 \backslash
2229
2230 \newline
2231 STRIP=
2232 \begin_inset Quotes srd
2233 \end_inset
2234
2235 i586-mingw32msvc-strip
2236 \begin_inset Quotes srd
2237 \end_inset
2238
2239  
2240 \backslash
2241
2242 \newline
2243 -
2244 \begin_inset ERT
2245 status collapsed
2246
2247 \begin_layout Standard
2248
2249
2250 \backslash
2251 /
2252 \end_layout
2253
2254 \end_inset
2255
2256 -prefix=
2257 \begin_inset Quotes srd
2258 \end_inset
2259
2260 /sdcc
2261 \begin_inset Quotes srd
2262 \end_inset
2263
2264  
2265 \backslash
2266
2267 \newline
2268 -
2269 \begin_inset ERT
2270 status collapsed
2271
2272 \begin_layout Standard
2273
2274
2275 \backslash
2276 /
2277 \end_layout
2278
2279 \end_inset
2280
2281 -datarootdir=
2282 \begin_inset Quotes srd
2283 \end_inset
2284
2285 /sdcc
2286 \begin_inset Quotes srd
2287 \end_inset
2288
2289  
2290 \backslash
2291
2292 \newline
2293 docdir=
2294 \begin_inset Quotes srd
2295 \end_inset
2296
2297
2298 \backslash
2299 ${datarootdir}/doc
2300 \begin_inset Quotes srd
2301 \end_inset
2302
2303  
2304 \backslash
2305
2306 \newline
2307 include_dir_suffix=
2308 \begin_inset Quotes srd
2309 \end_inset
2310
2311 include
2312 \begin_inset Quotes srd
2313 \end_inset
2314
2315  
2316 \backslash
2317
2318 \newline
2319 lib_dir_suffix=
2320 \begin_inset Quotes srd
2321 \end_inset
2322
2323 lib
2324 \begin_inset Quotes srd
2325 \end_inset
2326
2327  
2328 \backslash
2329
2330 \newline
2331 sdccconf_h_dir_separator=
2332 \begin_inset Quotes srd
2333 \end_inset
2334
2335
2336 \backslash
2337
2338 \backslash
2339
2340 \backslash
2341
2342 \backslash
2343
2344 \begin_inset Quotes srd
2345 \end_inset
2346
2347  
2348 \backslash
2349
2350 \newline
2351 -
2352 \begin_inset ERT
2353 status collapsed
2354
2355 \begin_layout Standard
2356
2357
2358 \backslash
2359 /
2360 \end_layout
2361
2362 \end_inset
2363
2364 -disable-device-lib
2365 \backslash
2366
2367 \newline
2368 -
2369 \begin_inset ERT
2370 status collapsed
2371
2372 \begin_layout Standard
2373
2374
2375 \backslash
2376 /
2377 \end_layout
2378
2379 \end_inset
2380
2381 -host=i586-mingw32msvc
2382 \backslash
2383
2384 \newline
2385 -
2386 \begin_inset ERT
2387 status collapsed
2388
2389 \begin_layout Standard
2390
2391
2392 \backslash
2393 /
2394 \end_layout
2395
2396 \end_inset
2397
2398 -build=unknown-unknown-linux-gnu
2399 \end_layout
2400
2401 \begin_layout Standard
2402 To 
2403 \begin_inset Quotes sld
2404 \end_inset
2405
2406 cross
2407 \begin_inset Quotes srd
2408 \end_inset
2409
2410 compile on Cygwin for Mingw32 (see also sdcc/support/scripts/sdcc_cygwin_mingw32
2411 ):
2412 \end_layout
2413
2414 \begin_layout LyX-Code
2415 ./configure -C 
2416 \backslash
2417
2418 \newline
2419 -
2420 \begin_inset ERT
2421 status collapsed
2422
2423 \begin_layout Standard
2424
2425
2426 \backslash
2427 /
2428 \end_layout
2429
2430 \end_inset
2431
2432 -prefix=
2433 \begin_inset Quotes srd
2434 \end_inset
2435
2436 /sdcc
2437 \begin_inset Quotes srd
2438 \end_inset
2439
2440  
2441 \backslash
2442
2443 \newline
2444 -
2445 \begin_inset ERT
2446 status collapsed
2447
2448 \begin_layout Standard
2449
2450
2451 \backslash
2452 /
2453 \end_layout
2454
2455 \end_inset
2456
2457 -datarootdir=
2458 \begin_inset Quotes srd
2459 \end_inset
2460
2461 /sdcc
2462 \begin_inset Quotes srd
2463 \end_inset
2464
2465  
2466 \backslash
2467
2468 \newline
2469 docdir=
2470 \begin_inset Quotes srd
2471 \end_inset
2472
2473
2474 \backslash
2475 ${datarootdir}/doc
2476 \begin_inset Quotes srd
2477 \end_inset
2478
2479  
2480 \backslash
2481  
2482 \newline
2483 include_dir_suffix=
2484 \begin_inset Quotes srd
2485 \end_inset
2486
2487 include
2488 \begin_inset Quotes srd
2489 \end_inset
2490
2491  
2492 \backslash
2493
2494 \newline
2495 lib_dir_suffix=
2496 \begin_inset Quotes srd
2497 \end_inset
2498
2499 lib
2500 \begin_inset Quotes srd
2501 \end_inset
2502
2503  
2504 \backslash
2505
2506 \newline
2507 sdccconf_h_dir_separator=
2508 \begin_inset Quotes srd
2509 \end_inset
2510
2511
2512 \backslash
2513
2514 \backslash
2515
2516 \backslash
2517
2518 \backslash
2519
2520 \begin_inset Quotes srd
2521 \end_inset
2522
2523  
2524 \backslash
2525
2526 \newline
2527 CC=
2528 \begin_inset Quotes srd
2529 \end_inset
2530
2531 gcc -mno-cygwin
2532 \begin_inset Quotes srd
2533 \end_inset
2534
2535  
2536 \backslash
2537
2538 \newline
2539 CXX=
2540 \begin_inset Quotes srd
2541 \end_inset
2542
2543 g++ -mno-cygwin
2544 \begin_inset Quotes srd
2545 \end_inset
2546
2547  
2548 \end_layout
2549
2550 \begin_layout Standard
2551 'configure' is quite slow on Cygwin (at least on windows before Win2000/XP).
2552  The option '-
2553 \begin_inset ERT
2554 status collapsed
2555
2556 \begin_layout Standard
2557
2558
2559 \backslash
2560 /
2561 \end_layout
2562
2563 \end_inset
2564
2565 -C' turns on caching, which gives a little bit extra speed.
2566  However if options are changed, it can be necessary to delete the config.cache
2567  file.
2568 \end_layout
2569
2570 \begin_layout Section
2571 Install paths
2572 \begin_inset LatexCommand \label{sub:Install-paths}
2573
2574 \end_inset
2575
2576
2577 \begin_inset LatexCommand \index{Install paths}
2578
2579 \end_inset
2580
2581
2582 \end_layout
2583
2584 \begin_layout Standard
2585 \begin_inset VSpace medskip
2586 \end_inset
2587
2588
2589 \end_layout
2590
2591 \begin_layout Standard
2592 \align center
2593 \begin_inset Tabular
2594 <lyxtabular version="3" rows="5" columns="4">
2595 <features>
2596 <column alignment="left" valignment="top" leftline="true" width="0">
2597 <column alignment="left" valignment="top" leftline="true" width="0">
2598 <column alignment="left" valignment="top" leftline="true" width="0">
2599 <column alignment="left" valignment="top" leftline="true" rightline="true" width="0">
2600 <row topline="true" bottomline="true">
2601 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2602 \begin_inset Text
2603
2604 \begin_layout Standard
2605
2606 \series bold
2607 Description
2608 \end_layout
2609
2610 \end_inset
2611 </cell>
2612 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2613 \begin_inset Text
2614
2615 \begin_layout Standard
2616
2617 \series bold
2618 Path
2619 \end_layout
2620
2621 \end_inset
2622 </cell>
2623 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2624 \begin_inset Text
2625
2626 \begin_layout Standard
2627
2628 \series bold
2629 Default
2630 \end_layout
2631
2632 \end_inset
2633 </cell>
2634 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2635 \begin_inset Text
2636
2637 \begin_layout Standard
2638
2639 \series bold
2640 Win32 builds
2641 \end_layout
2642
2643 \end_inset
2644 </cell>
2645 </row>
2646 <row topline="true">
2647 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2648 \begin_inset Text
2649
2650 \begin_layout Standard
2651 Binary files*
2652 \end_layout
2653
2654 \end_inset
2655 </cell>
2656 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2657 \begin_inset Text
2658
2659 \begin_layout Standard
2660
2661 \emph on
2662 $EXEC_PREFIX
2663 \end_layout
2664
2665 \end_inset
2666 </cell>
2667 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2668 \begin_inset Text
2669
2670 \begin_layout Standard
2671 /usr/local/bin
2672 \end_layout
2673
2674 \end_inset
2675 </cell>
2676 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2677 \begin_inset Text
2678
2679 \begin_layout Standard
2680
2681 \backslash
2682 sdcc
2683 \backslash
2684 bin
2685 \end_layout
2686
2687 \end_inset
2688 </cell>
2689 </row>
2690 <row topline="true">
2691 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2692 \begin_inset Text
2693
2694 \begin_layout Standard
2695 Include files
2696 \end_layout
2697
2698 \end_inset
2699 </cell>
2700 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2701 \begin_inset Text
2702
2703 \begin_layout Standard
2704
2705 \emph on
2706 $DATADIR/ $INCLUDE_DIR_SUFFIX
2707 \end_layout
2708
2709 \end_inset
2710 </cell>
2711 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2712 \begin_inset Text
2713
2714 \begin_layout Standard
2715 /usr/local/share/sdcc/include
2716 \end_layout
2717
2718 \end_inset
2719 </cell>
2720 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2721 \begin_inset Text
2722
2723 \begin_layout Standard
2724
2725 \backslash
2726 sdcc
2727 \backslash
2728 include
2729 \end_layout
2730
2731 \end_inset
2732 </cell>
2733 </row>
2734 <row topline="true">
2735 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2736 \begin_inset Text
2737
2738 \begin_layout Standard
2739 Library file**
2740 \end_layout
2741
2742 \end_inset
2743 </cell>
2744 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2745 \begin_inset Text
2746
2747 \begin_layout Standard
2748
2749 \emph on
2750 $DATADIR/$LIB_DIR_SUFFIX
2751 \end_layout
2752
2753 \end_inset
2754 </cell>
2755 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2756 \begin_inset Text
2757
2758 \begin_layout Standard
2759 /usr/local/share/sdcc/lib
2760 \end_layout
2761
2762 \end_inset
2763 </cell>
2764 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2765 \begin_inset Text
2766
2767 \begin_layout Standard
2768
2769 \backslash
2770 sdcc
2771 \backslash
2772 lib
2773 \end_layout
2774
2775 \end_inset
2776 </cell>
2777 </row>
2778 <row topline="true" bottomline="true">
2779 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2780 \begin_inset Text
2781
2782 \begin_layout Standard
2783 Documentation
2784 \end_layout
2785
2786 \end_inset
2787 </cell>
2788 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2789 \begin_inset Text
2790
2791 \begin_layout Standard
2792
2793 \emph on
2794 $DOCDIR
2795 \end_layout
2796
2797 \end_inset
2798 </cell>
2799 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2800 \begin_inset Text
2801
2802 \begin_layout Standard
2803 /usr/local/share/sdcc/doc
2804 \end_layout
2805
2806 \end_inset
2807 </cell>
2808 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2809 \begin_inset Text
2810
2811 \begin_layout Standard
2812
2813 \backslash
2814 sdcc
2815 \backslash
2816 doc
2817 \end_layout
2818
2819 \end_inset
2820 </cell>
2821 </row>
2822 </lyxtabular>
2823
2824 \end_inset
2825
2826
2827 \end_layout
2828
2829 \begin_layout Verse
2830
2831 \size footnotesize
2832 *compiler, preprocessor, assembler, and linker
2833 \newline
2834 **the 
2835 \shape italic
2836 model
2837 \shape default
2838  is auto-appended by the compiler, e.g.
2839  small, large, z80, ds390 etc
2840 \end_layout
2841
2842 \begin_layout Standard
2843 \noindent
2844 The install paths can still be changed during `make install' with e.g.:
2845 \end_layout
2846
2847 \begin_layout LyX-Code
2848 make install prefix=$(HOME)/local/sdcc
2849 \end_layout
2850
2851 \begin_layout Standard
2852 Of course this doesn't change the search paths compiled into the binaries.
2853 \newline
2854
2855 \newline
2856 Moreove
2857 r the install path can be changed by defining DESTDIR
2858 \begin_inset LatexCommand \index{DESTDIR}
2859
2860 \end_inset
2861
2862 :
2863 \end_layout
2864
2865 \begin_layout LyX-Code
2866 make install DESTDIR=$(HOME)/sdcc.rpm/
2867 \end_layout
2868
2869 \begin_layout Standard
2870 Please note that DESTDIR must have a trailing slash!
2871 \end_layout
2872
2873 \begin_layout Section
2874 Search Paths
2875 \begin_inset LatexCommand \label{sub:Search-Paths}
2876
2877 \end_inset
2878
2879
2880 \begin_inset LatexCommand \index{Search path}
2881
2882 \end_inset
2883
2884
2885 \end_layout
2886
2887 \begin_layout Standard
2888 Some search paths or parts of them are determined by configure variables
2889  (in 
2890 \emph on
2891 italics
2892 \emph default
2893 , see section above).
2894  Further search paths are determined by environment variables during runtime.
2895  
2896 \newline
2897 The paths searched when running the compiler are as follows (the first
2898  catch wins):
2899 \newline
2900
2901 \newline
2902 1.
2903  Binary files (preprocessor, assembler and linker)
2904 \newline
2905
2906 \end_layout
2907
2908 \begin_layout Standard
2909 \align center
2910 \begin_inset Tabular
2911 <lyxtabular version="3" rows="4" columns="3">
2912 <features>
2913 <column alignment="block" valignment="top" leftline="true" width="0in">
2914 <column alignment="block" valignment="top" leftline="true" width="0in">
2915 <column alignment="block" valignment="top" leftline="true" rightline="true" width="0in">
2916 <row topline="true" bottomline="true">
2917 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2918 \begin_inset Text
2919
2920 \begin_layout Standard
2921 Search path
2922 \end_layout
2923
2924 \end_inset
2925 </cell>
2926 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2927 \begin_inset Text
2928
2929 \begin_layout Standard
2930 default
2931 \end_layout
2932
2933 \end_inset
2934 </cell>
2935 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2936 \begin_inset Text
2937
2938 \begin_layout Standard
2939 Win32 builds
2940 \end_layout
2941
2942 \end_inset
2943 </cell>
2944 </row>
2945 <row topline="true">
2946 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2947 \begin_inset Text
2948
2949 \begin_layout Standard
2950 $SDCC_HOME/
2951 \emph on
2952 $PPREFIX2BIN_DIR
2953 \end_layout
2954
2955 \end_inset
2956 </cell>
2957 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2958 \begin_inset Text
2959
2960 \begin_layout Standard
2961 $SDCC_HOME/bin
2962 \end_layout
2963
2964 \end_inset
2965 </cell>
2966 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2967 \begin_inset Text
2968
2969 \begin_layout Standard
2970 $SDCC_HOME
2971 \backslash
2972 bin
2973 \end_layout
2974
2975 \end_inset
2976 </cell>
2977 </row>
2978 <row topline="true">
2979 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2980 \begin_inset Text
2981
2982 \begin_layout Standard
2983 Path of argv[0] (if available)
2984 \end_layout
2985
2986 \end_inset
2987 </cell>
2988 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2989 \begin_inset Text
2990
2991 \begin_layout Standard
2992 Path of argv[0]
2993 \end_layout
2994
2995 \end_inset
2996 </cell>
2997 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2998 \begin_inset Text
2999
3000 \begin_layout Standard
3001 Path of argv[0]
3002 \end_layout
3003
3004 \end_inset
3005 </cell>
3006 </row>
3007 <row topline="true" bottomline="true">
3008 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3009 \begin_inset Text
3010
3011 \begin_layout Standard
3012 $PATH
3013 \end_layout
3014
3015 \end_inset
3016 </cell>
3017 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3018 \begin_inset Text
3019
3020 \begin_layout Standard
3021 $PATH
3022 \end_layout
3023
3024 \end_inset
3025 </cell>
3026 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3027 \begin_inset Text
3028
3029 \begin_layout Standard
3030 $PATH
3031 \end_layout
3032
3033 \end_inset
3034 </cell>
3035 </row>
3036 </lyxtabular>
3037
3038 \end_inset
3039
3040  
3041 \newline
3042
3043 \end_layout
3044
3045 \begin_layout Standard
3046 \noindent
3047 2.
3048  Include files
3049 \newline
3050
3051 \end_layout
3052
3053 \begin_layout Standard
3054 \align center
3055 \begin_inset Tabular
3056 <lyxtabular version="3" rows="6" columns="3">
3057 <features>
3058 <column alignment="block" valignment="top" leftline="true" width="1.5in">
3059 <column alignment="block" valignment="top" leftline="true" width="1.5in">
3060 <column alignment="block" valignment="top" leftline="true" rightline="true" width="0in">
3061 <row topline="true" bottomline="true">
3062 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3063 \begin_inset Text
3064
3065 \begin_layout Standard
3066 Search path
3067 \end_layout
3068
3069 \end_inset
3070 </cell>
3071 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3072 \begin_inset Text
3073
3074 \begin_layout Standard
3075 default
3076 \end_layout
3077
3078 \end_inset
3079 </cell>
3080 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3081 \begin_inset Text
3082
3083 \begin_layout Standard
3084 Win32 builds
3085 \end_layout
3086
3087 \end_inset
3088 </cell>
3089 </row>
3090 <row topline="true">
3091 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3092 \begin_inset Text
3093
3094 \begin_layout Standard
3095 -
3096 \begin_inset ERT
3097 status collapsed
3098
3099 \begin_layout Standard
3100
3101
3102 \backslash
3103 /
3104 \end_layout
3105
3106 \end_inset
3107
3108 -I dir
3109 \end_layout
3110
3111 \end_inset
3112 </cell>
3113 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3114 \begin_inset Text
3115
3116 \begin_layout Standard
3117 -
3118 \begin_inset ERT
3119 status collapsed
3120
3121 \begin_layout Standard
3122
3123
3124 \backslash
3125 /
3126 \end_layout
3127
3128 \end_inset
3129
3130 -I dir
3131 \end_layout
3132
3133 \end_inset
3134 </cell>
3135 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3136 \begin_inset Text
3137
3138 \begin_layout Standard
3139 -
3140 \begin_inset ERT
3141 status collapsed
3142
3143 \begin_layout Standard
3144
3145
3146 \backslash
3147 /
3148 \end_layout
3149
3150 \end_inset
3151
3152 -I dir
3153 \end_layout
3154
3155 \end_inset
3156 </cell>
3157 </row>
3158 <row topline="true">
3159 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
3160 \begin_inset Text
3161
3162 \begin_layout Standard
3163 $SDCC_INCLUDE
3164 \end_layout
3165
3166 \end_inset
3167 </cell>
3168 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3169 \begin_inset Text
3170
3171 \begin_layout Standard
3172 $SDCC_INCLUDE
3173 \end_layout
3174
3175 \end_inset
3176 </cell>
3177 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3178 \begin_inset Text
3179
3180 \begin_layout Standard
3181 $SDCC_INCLUDE
3182 \end_layout
3183
3184 \end_inset
3185 </cell>
3186 </row>
3187 <row topline="true">
3188 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
3189 \begin_inset Text
3190
3191 \begin_layout Standard
3192 $SDCC_HOME/
3193 \newline
3194
3195 \emph on
3196 $PREFIX2DATA_DIR/
3197 \newline
3198 $INCLUDE_DIR_SUFFIX
3199 \end_layout
3200
3201 \end_inset
3202 </cell>
3203 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
3204 \begin_inset Text
3205
3206 \begin_layout Standard
3207 $SDCC_ HOME/
3208 \newline
3209 share/sdcc/
3210 \newline
3211 include
3212 \end_layout
3213
3214 \end_inset
3215 </cell>
3216 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3217 \begin_inset Text
3218
3219 \begin_layout Standard
3220 $SDCC_HOME
3221 \backslash
3222 include
3223 \end_layout
3224
3225 \end_inset
3226 </cell>
3227 </row>
3228 <row topline="true">
3229 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
3230 \begin_inset Text
3231
3232 \begin_layout Standard
3233 path(argv[0])/
3234 \newline
3235
3236 \emph on
3237 $BIN2DATADIR/
3238 \emph default
3239
3240 \newline
3241
3242 \emph on
3243 $INCLUDE_DIR_SUFFIX
3244 \end_layout
3245
3246 \end_inset
3247 </cell>
3248 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3249 \begin_inset Text
3250
3251 \begin_layout Standard
3252 path(argv[0])/
3253 \newline
3254 ../sdcc/include
3255 \newline
3256 \InsetSpace ~
3257 \InsetSpace ~
3258 \InsetSpace ~
3259 \InsetSpace ~
3260 \InsetSpace ~
3261 \InsetSpace ~
3262 \InsetSpace ~
3263 \InsetSpace ~
3264 \InsetSpace ~
3265 \InsetSpace ~
3266 \InsetSpace ~
3267 \InsetSpace ~
3268 \InsetSpace ~
3269 \InsetSpace ~
3270 \InsetSpace ~
3271 \InsetSpace ~
3272 \InsetSpace ~
3273 \InsetSpace ~
3274 \InsetSpace ~
3275 \InsetSpace ~
3276 \InsetSpace ~
3277 \InsetSpace ~
3278 \InsetSpace ~
3279 \InsetSpace ~
3280 \InsetSpace ~
3281 \InsetSpace ~
3282 \InsetSpace ~
3283 \InsetSpace ~
3284 \InsetSpace ~
3285 \InsetSpace ~
3286 \InsetSpace ~
3287 \InsetSpace ~
3288 \InsetSpace ~
3289 \InsetSpace ~
3290 \InsetSpace ~
3291 \InsetSpace ~
3292 \InsetSpace ~
3293 \InsetSpace ~
3294
3295 \end_layout
3296
3297 \end_inset
3298 </cell>
3299 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3300 \begin_inset Text
3301
3302 \begin_layout Standard
3303 path(argv[0])
3304 \backslash
3305 ..
3306 \backslash
3307 include
3308 \end_layout
3309
3310 \end_inset
3311 </cell>
3312 </row>
3313 <row topline="true" bottomline="true">
3314 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
3315 \begin_inset Text
3316
3317 \begin_layout Standard
3318
3319 \emph on
3320 $DATADIR/
3321 \emph default
3322
3323 \newline
3324
3325 \emph on
3326 $INCLUDE_DIR_SUFFIX
3327 \end_layout
3328
3329 \end_inset
3330 </cell>
3331 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
3332 \begin_inset Text
3333
3334 \begin_layout Standard
3335 /usr/local/share/sdcc/
3336 \newline
3337 include
3338 \end_layout
3339
3340 \end_inset
3341 </cell>
3342 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3343 \begin_inset Text
3344
3345 \begin_layout Standard
3346 (not on Win32)
3347 \end_layout
3348
3349 \end_inset
3350 </cell>
3351 </row>
3352 </lyxtabular>
3353
3354 \end_inset
3355
3356  
3357 \newline
3358
3359 \end_layout
3360
3361 \begin_layout Standard
3362 \noindent
3363 The option -
3364 \begin_inset ERT
3365 status collapsed
3366
3367 \begin_layout Standard
3368
3369
3370 \backslash
3371 /
3372 \end_layout
3373
3374 \end_inset
3375
3376 -nostdinc disables the last two search paths.
3377 \newline
3378
3379 \newline
3380 3.
3381  Library files 
3382 \newline
3383
3384 \end_layout
3385
3386 \begin_layout Standard
3387 With the exception of 
3388 \begin_inset Quotes sld
3389 \end_inset
3390
3391 -
3392 \begin_inset ERT
3393 status collapsed
3394
3395 \begin_layout Standard
3396
3397
3398 \backslash
3399 /
3400 \end_layout
3401
3402 \end_inset
3403
3404 -L dir
3405 \begin_inset Quotes srd
3406 \end_inset
3407
3408  the 
3409 \shape italic
3410 model
3411 \shape default
3412  is auto-appended by the compiler (e.g.
3413  small, large, z80, ds390 etc.).
3414  
3415 \newline
3416
3417 \end_layout
3418
3419 \begin_layout Standard
3420 \align center
3421 \begin_inset Tabular
3422 <lyxtabular version="3" rows="6" columns="3">
3423 <features>
3424 <column alignment="block" valignment="top" leftline="true" width="1.7in">
3425 <column alignment="block" valignment="top" leftline="true" width="1.2in">
3426 <column alignment="block" valignment="top" leftline="true" rightline="true" width="1.2in">
3427 <row topline="true" bottomline="true">
3428 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
3429 \begin_inset Text
3430
3431 \begin_layout Standard
3432 Search path
3433 \end_layout
3434
3435 \end_inset
3436 </cell>
3437 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
3438 \begin_inset Text
3439
3440 \begin_layout Standard
3441 default
3442 \end_layout
3443
3444 \end_inset
3445 </cell>
3446 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3447 \begin_inset Text
3448
3449 \begin_layout Standard
3450 Win32 builds
3451 \end_layout
3452
3453 \end_inset
3454 </cell>
3455 </row>
3456 <row topline="true">
3457 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
3458 \begin_inset Text
3459
3460 \begin_layout Standard
3461 -
3462 \begin_inset ERT
3463 status collapsed
3464
3465 \begin_layout Standard
3466
3467
3468 \backslash
3469 /
3470 \end_layout
3471
3472 \end_inset
3473
3474 -L dir
3475 \end_layout
3476
3477 \end_inset
3478 </cell>
3479 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3480 \begin_inset Text
3481
3482 \begin_layout Standard
3483 -
3484 \begin_inset ERT
3485 status collapsed
3486
3487 \begin_layout Standard
3488
3489
3490 \backslash
3491 /
3492 \end_layout
3493
3494 \end_inset
3495
3496 -L dir
3497 \end_layout
3498
3499 \end_inset
3500 </cell>
3501 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3502 \begin_inset Text
3503
3504 \begin_layout Standard
3505 -
3506 \begin_inset ERT
3507 status collapsed
3508
3509 \begin_layout Standard
3510
3511
3512 \backslash
3513 /
3514 \end_layout
3515
3516 \end_inset
3517
3518 -L dir
3519 \end_layout
3520
3521 \end_inset
3522 </cell>
3523 </row>
3524 <row topline="true">
3525 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3526 \begin_inset Text
3527
3528 \begin_layout Standard
3529 $SDCC_LIB/
3530 \newline
3531
3532 \emph on
3533 <model>
3534 \end_layout
3535
3536 \end_inset
3537 </cell>
3538 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
3539 \begin_inset Text
3540
3541 \begin_layout Standard
3542 $SDCC_LIB/
3543 \newline
3544
3545 \emph on
3546 <model>
3547 \end_layout
3548
3549 \end_inset
3550 </cell>
3551 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3552 \begin_inset Text
3553
3554 \begin_layout Standard
3555 $SDCC_LIB
3556 \backslash
3557
3558 \newline
3559
3560 \emph on
3561 <model>
3562 \end_layout
3563
3564 \end_inset
3565 </cell>
3566 </row>
3567 <row topline="true">
3568 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
3569 \begin_inset Text
3570
3571 \begin_layout Standard
3572 $SDCC_HOME/
3573 \newline
3574
3575 \emph on
3576 $PREFIX2DATA_DIR/
3577 \newline
3578 $LIB_DIR_SUFFIX/<model>
3579 \end_layout
3580
3581 \end_inset
3582 </cell>
3583 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
3584 \begin_inset Text
3585
3586 \begin_layout Standard
3587 $SDCC_HOME/
3588 \newline
3589 share/sdcc/
3590 \newline
3591 lib/
3592 \emph on
3593 <model>
3594 \end_layout
3595
3596 \end_inset
3597 </cell>
3598 <cell alignment="left" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3599 \begin_inset Text
3600
3601 \begin_layout Standard
3602 $SDCC_HOME
3603 \backslash
3604 lib
3605 \backslash
3606
3607 \emph on
3608
3609 \newline
3610 <model>
3611 \end_layout
3612
3613 \end_inset
3614 </cell>
3615 </row>
3616 <row topline="true">
3617 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
3618 \begin_inset Text
3619
3620 \begin_layout Standard
3621 path(argv[0])/
3622 \newline
3623
3624 \emph on
3625 $BIN2DATADIR/
3626 \emph default
3627
3628 \newline
3629
3630 \emph on
3631 $LIB_DIR_SUFFIX/<model>
3632 \end_layout
3633
3634 \end_inset
3635 </cell>
3636 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
3637 \begin_inset Text
3638
3639 \begin_layout Standard
3640 path(argv[0])/
3641 \newline
3642 ../sdcc/lib/
3643 \emph on
3644 <model>
3645 \newline
3646 \InsetSpace ~
3647 \InsetSpace ~
3648 \InsetSpace ~
3649 \InsetSpace ~
3650 \InsetSpace ~
3651 \InsetSpace ~
3652 \InsetSpace ~
3653 \InsetSpace ~
3654 \InsetSpace ~
3655 \InsetSpace ~
3656 \InsetSpace ~
3657 \InsetSpace ~
3658 \InsetSpace ~
3659 \InsetSpace ~
3660 \InsetSpace ~
3661 \InsetSpace ~
3662 \InsetSpace ~
3663 \InsetSpace ~
3664 \InsetSpace ~
3665 \InsetSpace ~
3666 \InsetSpace ~
3667 \InsetSpace ~
3668 \InsetSpace ~
3669 \InsetSpace ~
3670 \InsetSpace ~
3671 \InsetSpace ~
3672 \InsetSpace ~
3673 \InsetSpace ~
3674 \InsetSpace ~
3675 \InsetSpace ~
3676 \InsetSpace ~
3677 \InsetSpace ~
3678 \InsetSpace ~
3679 \InsetSpace ~
3680 \InsetSpace ~
3681 \InsetSpace ~
3682 \InsetSpace ~
3683 \InsetSpace ~
3684 \InsetSpace ~
3685
3686 \end_layout
3687
3688 \end_inset
3689 </cell>
3690 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3691 \begin_inset Text
3692
3693 \begin_layout Standard
3694 path(argv[0])
3695 \backslash
3696
3697 \newline
3698 ..
3699 \backslash
3700 lib
3701 \backslash
3702
3703 \emph on
3704 <model>
3705 \newline
3706 \InsetSpace ~
3707 \InsetSpace ~
3708 \InsetSpace ~
3709 \InsetSpace ~
3710 \InsetSpace ~
3711 \InsetSpace ~
3712 \InsetSpace ~
3713 \InsetSpace ~
3714 \InsetSpace ~
3715 \InsetSpace ~
3716 \InsetSpace ~
3717 \InsetSpace ~
3718 \InsetSpace ~
3719 \InsetSpace ~
3720 \InsetSpace ~
3721 \InsetSpace ~
3722 \InsetSpace ~
3723 \InsetSpace ~
3724 \InsetSpace ~
3725 \InsetSpace ~
3726 \InsetSpace ~
3727 \InsetSpace ~
3728 \InsetSpace ~
3729 \InsetSpace ~
3730 \InsetSpace ~
3731 \InsetSpace ~
3732 \InsetSpace ~
3733 \InsetSpace ~
3734 \InsetSpace ~
3735 \InsetSpace ~
3736 \InsetSpace ~
3737 \InsetSpace ~
3738 \InsetSpace ~
3739 \InsetSpace ~
3740 \InsetSpace ~
3741
3742 \end_layout
3743
3744 \end_inset
3745 </cell>
3746 </row>
3747 <row topline="true" bottomline="true">
3748 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3749 \begin_inset Text
3750
3751 \begin_layout Standard
3752
3753 \emph on
3754 $DATADIR/
3755 \newline
3756 $LIB_DIR_SUFFIX/<model>
3757 \end_layout
3758
3759 \end_inset
3760 </cell>
3761 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3762 \begin_inset Text
3763
3764 \begin_layout Standard
3765 /usr/local/share/sdcc/
3766 \newline
3767 lib/
3768 \emph on
3769 <model>
3770 \end_layout
3771
3772 \end_inset
3773 </cell>
3774 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3775 \begin_inset Text
3776
3777 \begin_layout Standard
3778 (not on Win32)
3779 \end_layout
3780
3781 \end_inset
3782 </cell>
3783 </row>
3784 </lyxtabular>
3785
3786 \end_inset
3787
3788
3789 \newline
3790
3791 \end_layout
3792
3793 \begin_layout Standard
3794 \begin_inset Note Note
3795 status collapsed
3796
3797 \begin_layout Standard
3798 Don't delete any of the stray spaces in the table above without checking
3799  the HTML output (last line)!
3800 \end_layout
3801
3802 \end_inset
3803
3804
3805 \end_layout
3806
3807 \begin_layout Standard
3808 \InsetSpace ~
3809
3810 \newline
3811 The option -
3812 \begin_inset ERT
3813 status collapsed
3814
3815 \begin_layout Standard
3816
3817
3818 \backslash
3819 /
3820 \end_layout
3821
3822 \end_inset
3823
3824 -nostdlib disables the last two search paths.
3825 \end_layout
3826
3827 \begin_layout Section
3828 Building SDCC
3829 \begin_inset LatexCommand \index{Building SDCC}
3830
3831 \end_inset
3832
3833
3834 \end_layout
3835
3836 \begin_layout Subsection
3837 Building SDCC on Linux
3838 \begin_inset LatexCommand \label{sub:Building-SDCC-on-Linux}
3839
3840 \end_inset
3841
3842
3843 \end_layout
3844
3845 \begin_layout Enumerate
3846
3847 \series medium
3848 Download the source package
3849 \series default
3850  either from the SDCC Subversion repository or from snapshot builds
3851 \series medium
3852 , it will be named something like sdcc
3853 \series default
3854 -src
3855 \series medium
3856 -yyyymmdd-rrrr.t
3857 \series default
3858 ar.
3859 \series medium
3860 bz2
3861 \series default
3862  
3863 \begin_inset LatexCommand \url{http://sdcc.sourceforge.net/snap.php}
3864
3865 \end_inset
3866
3867 .
3868 \end_layout
3869
3870 \begin_layout Enumerate
3871
3872 \series medium
3873 Bring up a command line terminal, such as xterm.
3874 \end_layout
3875
3876 \begin_layout Enumerate
3877
3878 \series medium
3879 Unpack the file using a command like: 
3880 \family sans
3881 \series bold
3882 "tar -xvzf sdcc-src-yyyymmdd-rrrr.tar.bz2
3883 \begin_inset Quotes srd
3884 \end_inset
3885
3886
3887 \family default
3888 \series medium
3889 , this will create a sub-directory called sdcc with all of the sources.
3890 \end_layout
3891
3892 \begin_layout Enumerate
3893 Change directory into the main SDCC directory, for example type: 
3894 \family sans
3895 \series bold
3896 "cd sdcc
3897 \series default
3898 ".
3899 \end_layout
3900
3901 \begin_layout Enumerate
3902
3903 \series medium
3904 Type 
3905 \family sans
3906 \series bold
3907 "./configure
3908 \family default
3909 \series default
3910 ".
3911  This configures the package for compilation on your system.
3912 \end_layout
3913
3914 \begin_layout Enumerate
3915
3916 \series medium
3917 Type 
3918 \family sans
3919 \series bold
3920 "make
3921 \family default
3922 \series default
3923 "
3924 \series medium
3925 .
3926
3927 \series default
3928  All of the source packages will compile, this can take a while.
3929 \end_layout
3930
3931 \begin_layout Enumerate
3932
3933 \series medium
3934 Type 
3935 \family sans
3936 \series bold
3937 "make install"
3938 \family default
3939 \series default
3940  as root
3941 \series medium
3942 .
3943
3944 \series default
3945  This copies the binary executables, the include files, the libraries and
3946  the documentation to the install directories.
3947  Proceed with section 
3948 \begin_inset LatexCommand \ref{sec:Testing-the-SDCC}
3949
3950 \end_inset
3951
3952 .
3953 \end_layout
3954
3955 \begin_layout Subsection
3956 Building SDCC on Mac OS X
3957 \end_layout
3958
3959 \begin_layout Standard
3960 Follow the instruction for Linux.
3961 \newline
3962
3963 \newline
3964 On Mac OS X 10.2.x it was reported, that the
3965  default gcc (version 3.1 20020420 (prerelease)) fails to compile SDCC.
3966  Fortunately there's also gcc 2.9.x installed, which works fine.
3967  This compiler can be selected by running 'configure' with:
3968 \end_layout
3969
3970 \begin_layout LyX-Code
3971 ./configure CC=gcc2 CXX=g++2
3972 \end_layout
3973
3974 \begin_layout Subsection
3975 Cross compiling SDCC on Linux for Windows
3976 \end_layout
3977
3978 \begin_layout Standard
3979 With the Mingw32 gcc cross compiler it's easy to compile SDCC for Win32.
3980  See section 'Configure Options'.
3981 \end_layout
3982
3983 \begin_layout Subsection
3984 Building SDCC using Cygwin and Mingw32
3985 \end_layout
3986
3987 \begin_layout Standard
3988 For building and installing a Cygwin executable follow the instructions
3989  for Linux.
3990 \newline
3991
3992 \newline
3993 On Cygwin a 
3994 \begin_inset Quotes sld
3995 \end_inset
3996
3997 native
3998 \begin_inset Quotes srd
3999 \end_inset
4000
4001  Win32-binary can be built, which will not need the Cygwin-DLL.
4002  For the necessary 'configure' options see section 'configure options' or
4003  the script 'sdcc/support/scripts/sdcc_cygwin_mingw32'.
4004 \newline
4005
4006 \newline
4007 In order to install
4008  Cygwin on Windows download setup.exe from 
4009 \begin_inset LatexCommand \url[www.cygwin.com]{http://www.cygwin.com/}
4010
4011 \end_inset
4012
4013 .
4014  Run it, set the 
4015 \begin_inset Quotes sld
4016 \end_inset
4017
4018 default text file type
4019 \begin_inset Quotes srd
4020 \end_inset
4021
4022  to 
4023 \begin_inset Quotes sld
4024 \end_inset
4025
4026 unix
4027 \begin_inset Quotes srd
4028 \end_inset
4029
4030  and download/install at least the following packages.
4031  Some packages are selected by default, others will be automatically selected
4032  because of dependencies with the manually selected packages.
4033  Never deselect these packages!
4034 \end_layout
4035
4036 \begin_layout Itemize
4037 flex
4038 \end_layout
4039
4040 \begin_layout Itemize
4041 bison
4042 \end_layout
4043
4044 \begin_layout Itemize
4045 gcc ; version 3.x is fine, no need to use the old 2.9x
4046 \end_layout
4047
4048 \begin_layout Itemize
4049 binutils ; selected with gcc
4050 \end_layout
4051
4052 \begin_layout Itemize
4053 make
4054 \end_layout
4055
4056 \begin_layout Itemize
4057 rxvt ; a nice console, which makes life much easier under windoze (see below)
4058 \end_layout
4059
4060 \begin_layout Itemize
4061 man ; not really needed for building SDCC, but you'll miss it sooner or
4062  later
4063 \end_layout
4064
4065 \begin_layout Itemize
4066 less ; not really needed for building SDCC, but you'll miss it sooner or
4067  later
4068 \end_layout
4069
4070 \begin_layout Itemize
4071 svn ; only if you use Subversion access
4072 \end_layout
4073
4074 \begin_layout Standard
4075 If you want to develop something you'll need:
4076 \end_layout
4077
4078 \begin_layout Itemize
4079 python ; for the regression tests
4080 \end_layout
4081
4082 \begin_layout Itemize
4083 gdb ; the gnu debugger, together with the nice GUI 
4084 \begin_inset Quotes sld
4085 \end_inset
4086
4087 insight
4088 \begin_inset Quotes srd
4089 \end_inset
4090
4091
4092 \end_layout
4093
4094 \begin_layout Itemize
4095 openssh ; to access the CF or commit changes
4096 \end_layout
4097
4098 \begin_layout Itemize
4099 autoconf and autoconf-devel ; if you want to fight with 'configure', don't
4100  use autoconf-stable!
4101 \end_layout
4102
4103 \begin_layout Standard
4104 rxvt is a nice console with history.
4105  Replace in your cygwin.bat the line
4106 \end_layout
4107
4108 \begin_layout LyX-Code
4109 bash -
4110 \begin_inset ERT
4111 status collapsed
4112
4113 \begin_layout Standard
4114
4115
4116 \backslash
4117 /
4118 \end_layout
4119
4120 \end_inset
4121
4122 -login -i 
4123 \end_layout
4124
4125 \begin_layout Standard
4126 with (one line):
4127 \end_layout
4128
4129 \begin_layout LyX-Code
4130 rxvt -sl 1000 -fn "Lucida Console-12" -sr -cr red
4131 \end_layout
4132
4133 \begin_layout LyX-Code
4134      -bg black -fg white -geometry 100x65 -e bash -
4135 \begin_inset ERT
4136 status collapsed
4137
4138 \begin_layout Standard
4139
4140
4141 \backslash
4142 /
4143 \end_layout
4144
4145 \end_inset
4146
4147 -login
4148 \end_layout
4149
4150 \begin_layout Standard
4151 Text selected with the mouse is automatically copied to the clipboard, pasting
4152  works with shift-insert.
4153 \newline
4154
4155 \newline
4156 The other good tip is to make sure you have no //c/-styl
4157 e paths anywhere, use /cygdrive/c/ instead.
4158  Using // invokes a network lookup which is very slow.
4159  If you think 
4160 \begin_inset Quotes sld
4161 \end_inset
4162
4163 cygdrive
4164 \begin_inset Quotes srd
4165 \end_inset
4166
4167  is too long, you can change it with e.g.
4168 \end_layout
4169
4170 \begin_layout LyX-Code
4171 mount -s -u -c /mnt
4172 \end_layout
4173
4174 \begin_layout Standard
4175 SDCC sources use the unix line ending LF.
4176  Life is much easier, if you store the source tree on a drive which is mounted
4177  in binary mode.
4178  And use an editor which can handle LF-only line endings.
4179  Make sure not to commit files with windows line endings.
4180  The tabulator spacing
4181 \begin_inset LatexCommand \index{tabulator spacing (8 columns)}
4182
4183 \end_inset
4184
4185  used in the project is 8.
4186  Although a tabulator spacing of 8 is a sensible choice for programmers
4187  (it's a power of 2 and allows to display 8/16 bit signed variables without
4188  loosing columns) the plan is to move towards using only spaces in the source.
4189 \end_layout
4190
4191 \begin_layout Subsection
4192 Building SDCC Using Microsoft Visual C++ 6.0/NET (MSVC)
4193 \end_layout
4194
4195 \begin_layout Standard
4196
4197 \series medium
4198 Download the source package
4199 \series default
4200  either from the SDCC Subversion repository or from the 
4201 \begin_inset LatexCommand \url[snapshot builds]{http://sdcc.sourceforge.net/snap.php}
4202
4203 \end_inset
4204
4205
4206 \series medium
4207 , it will be named something like sdcc
4208 \series default
4209 -src
4210 \series medium
4211 -yyyymmdd-rrrr.tar.bz2.
4212
4213 \series default
4214  SDCC is distributed with all the projects, workspaces, and files you need
4215  to build it using Visual C++ 6.0/NET (except for SDCDB and ucSim).
4216  The workspace name is 'sdcc.dsw'.
4217  Please note that as it is now, all the executables are created in a folder
4218  called sdcc
4219 \backslash
4220 bin_vc.
4221  Once built you need to copy the executables from sdcc
4222 \backslash
4223 bin_vc to sdcc
4224 \backslash
4225 bin before running SDCC.
4226  
4227 \newline
4228
4229 \newline
4230 WARNING: Visual studio is very picky with line terminations; it expects
4231  the 0x0d, 0x0a DOS style line endings, not the 0x0a Unix style line endings.
4232  When using the Subversion repository it's easiest to configure the svn
4233  client to convert automatically for you.
4234  If however you are getting a message such as "This makefile was not generated
4235  by Developer Studio etc.
4236  etc.
4237 \begin_inset Quotes srd
4238 \end_inset
4239
4240  when opening the sdcc.dsw workspace or any of the *.dsp projects, then you
4241  need to convert the Unix style line endings to DOS style line endings.
4242  To do so you can use the 
4243 \begin_inset Quotes sld
4244 \end_inset
4245
4246 unix2dos
4247 \begin_inset Quotes srd
4248 \end_inset
4249
4250  utility freely available on the internet.
4251  Doug Hawkins reported in the sdcc-user list that this works:
4252 \newline
4253
4254 \newline
4255 C:
4256 \backslash
4257 Programming
4258 \backslash
4259 SDCC> unix2dos sdcc.dsw
4260 \newline
4261 C:
4262 \backslash
4263 Programming
4264 \backslash
4265 SDCC> for /R %I in (*.dsp) do @unix2dos "%I"
4266 \newline
4267
4268 \newline
4269 In order to build SDCC with MSVC
4270  you need win32 executables of bison.exe, flex.exe, and gawk.exe.
4271  One good place to get them is 
4272 \begin_inset LatexCommand \url[here]{http://unxutils.sourceforge.net}
4273
4274 \end_inset
4275
4276
4277 \newline
4278
4279 \newline
4280 Download the file UnxUtils
4281 \begin_inset LatexCommand \index{UnxUtils}
4282
4283 \end_inset
4284
4285 .zip.
4286  Now you have to install the utilities and setup MSVC so it can locate the
4287  required programs.
4288  Here there are two alternatives (choose one!):
4289 \end_layout
4290
4291 \begin_layout Enumerate
4292 The easy way:
4293 \newline
4294
4295 \newline
4296 a) Extract UnxUtils.zip to your C:
4297 \backslash
4298  hard disk PRESERVING the original paths, otherwise bison won't work.
4299  (If you are using WinZip make certain that 'Use folder names' is selected)
4300 \newline
4301
4302 \newline
4303 b)
4304  In the Visual C++ IDE click Tools, Options, select the Directory tab, in
4305  'Show directories for:' select 'Executable files', and in the directories
4306  window add a new path: 'C:
4307 \backslash
4308 user
4309 \backslash
4310 local
4311 \backslash
4312 wbin', click ok.
4313 \newline
4314
4315 \newline
4316 (As a side effect, you get a bunch of Unix utilities that
4317  could be useful, such as diff and patch.)
4318 \end_layout
4319
4320 \begin_layout Enumerate
4321 A more compact way:
4322 \newline
4323
4324 \newline
4325 This one avoids extracting a bunch of files you may not
4326  use, but requires some extra work:
4327 \newline
4328
4329 \newline
4330 a) Create a directory were to put the
4331  tools needed, or use a directory already present.
4332  Say for example 'C:
4333 \backslash
4334 util'.
4335 \newline
4336
4337 \newline
4338 b) Extract 'bison.exe', 'bison.hairy', 'bison.simple', 'flex.exe', and
4339  gawk.exe to such directory WITHOUT preserving the original paths.
4340  (If you are using WinZip make certain that 'Use folder names' is not selected)
4341 \newline
4342
4343 \newline
4344 c
4345 ) Rename bison.exe to '_bison.exe'.
4346 \newline
4347
4348 \newline
4349 d) Create a batch file 'bison.bat' in 'C:
4350 \backslash
4351 util
4352 \backslash
4353 ' and add these lines: 
4354 \newline
4355 \InsetSpace ~
4356 \InsetSpace ~
4357 set BISON_SIMPLE=C:
4358 \backslash
4359 util
4360 \backslash
4361 bison.simple 
4362 \newline
4363 \InsetSpace ~
4364 \InsetSpace ~
4365 set BISON_HAIRY=C:
4366 \backslash
4367 util
4368 \backslash
4369 bison.hairy
4370 \newline
4371 \InsetSpace ~
4372 \InsetSpace ~
4373 _bison %1 %2 %3 %4 %5 %6 %7 %8 %9
4374 \newline
4375
4376 \newline
4377 Steps 'c' and 'd' are needed
4378  because bison requires by default that the files 'bison.simple' and 'bison.hairy'
4379  reside in some weird Unix directory, '/usr/local/share/' I think.
4380  So it is necessary to tell bison where those files are located if they
4381  are not in such directory.
4382  That is the function of the environment variables BISON_SIMPLE and BISON_HAIRY.
4383 \newline
4384
4385 \newline
4386 e
4387 ) In the Visual C++ IDE click Tools, Options, select the Directory tab,
4388  in 'Show directories for:' select 'Executable files', and in the directories
4389  window add a new path: 'c:
4390 \backslash
4391 util', click ok.
4392  Note that you can use any other path instead of 'c:
4393 \backslash
4394 util', even the path where the Visual C++ tools are, probably: 'C:
4395 \backslash
4396 Program Files
4397 \backslash
4398 Microsoft Visual Studio
4399 \backslash
4400 Common
4401 \backslash
4402 Tools'.
4403  So you don't have to execute step 'e' :)
4404 \end_layout
4405
4406 \begin_layout Standard
4407 That is it.
4408  Open 'sdcc.dsw' in Visual Studio, click 'build all', when it finishes copy
4409  the executables from sdcc
4410 \backslash
4411 bin_vc to sdcc
4412 \backslash
4413 bin, and you can compile using SDCC.
4414 \end_layout
4415
4416 \begin_layout Subsection
4417 Building SDCC Using Borland
4418 \end_layout
4419
4420 \begin_layout Enumerate
4421 From the sdcc directory, run the command "make -f Makefile.bcc".
4422  This should regenerate all the .exe files in the bin directory except for
4423  SDCDB and ucSim.
4424 \end_layout
4425
4426 \begin_layout Enumerate
4427 If you modify any source files and need to rebuild, be aware that the dependenci
4428 es may not be correctly calculated.
4429  The safest option is to delete all .obj files and run the build again.
4430  From a Cygwin BASH prompt, this can easily be done with the command (be
4431  sure you are in the sdcc directory):
4432 \newline
4433
4434 \newline
4435
4436 \family sans
4437 \series bold
4438 find .
4439  
4440 \backslash
4441 ( -name '*.obj' -o -name '*.lib' -o -name '*.rul' 
4442 \backslash
4443 ) -print -exec rm {} 
4444 \backslash
4445 ;
4446 \family default
4447 \series default
4448
4449 \newline
4450
4451 \newline
4452 or on Windows NT/2000/XP from the command prompt with the command:
4453 \newline
4454
4455 \family sans
4456 \series bold
4457
4458 \newline
4459 del /s *.obj *.lib *.rul
4460 \family default
4461 \series default
4462  from the sdcc directory.
4463 \end_layout
4464
4465 \begin_layout Subsection
4466 Windows Install Using a ZIP Package
4467 \end_layout
4468
4469 \begin_layout Enumerate
4470 Download the binary zip package from 
4471 \begin_inset LatexCommand \url{http://sdcc.sf.net/snap.php}
4472
4473 \end_inset
4474
4475  and unpack it using your favorite unpacking tool (gunzip, WinZip, etc).
4476  This should unpack to a group of sub-directories.
4477  An example directory structure after unpacking the mingw32 package is:
4478  c:
4479 \backslash
4480 sdcc
4481 \backslash
4482 bin for the executables, c:
4483 \backslash
4484 sdcc
4485 \backslash
4486 include and c:
4487 \backslash
4488 sdcc
4489 \backslash
4490 lib for the include and libraries.
4491 \end_layout
4492
4493 \begin_layout Enumerate
4494 Adjust your environment variable PATH to include the location of the bin
4495  directory or start sdcc using the full path.
4496 \end_layout
4497
4498 \begin_layout Subsection
4499 Windows Install Using the Setup Program
4500 \begin_inset LatexCommand \label{sub:Windows-Install}
4501
4502 \end_inset
4503
4504
4505 \end_layout
4506
4507 \begin_layout Standard
4508 Download the setup program 
4509 \emph on
4510 sdcc-x.y.z-setup.exe
4511 \emph default
4512  for an official release from 
4513 \newline
4514
4515 \begin_inset LatexCommand \url{http://sf.net/project/showfiles.php?group_id=599}
4516
4517 \end_inset
4518
4519  or a setup program for one of the snapshots 
4520 \emph on
4521 sdcc-yyyymmdd-xxxx-setup.exe
4522 \emph default
4523  from 
4524 \begin_inset LatexCommand \url{http://sdcc.sf.net/snap.php}
4525
4526 \end_inset
4527
4528  and execute it.
4529  A windows typical installer will guide you through the installation process.
4530 \end_layout
4531
4532 \begin_layout Subsection
4533 VPATH
4534 \begin_inset LatexCommand \index{VPATH}
4535
4536 \end_inset
4537
4538  feature
4539 \end_layout
4540
4541 \begin_layout Standard
4542 SDCC supports the VPATH feature provided by configure and make.
4543  It allows to separate the source and build trees.
4544  Here's an example:
4545 \end_layout
4546
4547 \begin_layout Standard
4548
4549 \family typewriter
4550 cd ~\InsetSpace ~
4551 \InsetSpace ~
4552 \InsetSpace ~
4553 \InsetSpace ~
4554 \InsetSpace ~
4555 \InsetSpace ~
4556 \InsetSpace ~
4557 \InsetSpace ~
4558 \InsetSpace ~
4559 \InsetSpace ~
4560 \InsetSpace ~
4561 \InsetSpace ~
4562 \InsetSpace ~
4563 \InsetSpace ~
4564 \InsetSpace ~
4565 \InsetSpace ~
4566 \InsetSpace ~
4567 \InsetSpace ~
4568 \InsetSpace ~
4569 \InsetSpace ~
4570 \InsetSpace ~
4571 # cd $HOME
4572 \end_layout
4573
4574 \begin_layout Standard
4575
4576 \family typewriter
4577 tar -xzf sdcc.src.tar.gz\InsetSpace ~
4578 # extract source to directory sdcc
4579 \end_layout
4580
4581 \begin_layout Standard
4582
4583 \family typewriter
4584 mkdir sdcc.build\InsetSpace ~
4585 \InsetSpace ~
4586 \InsetSpace ~
4587 \InsetSpace ~
4588 \InsetSpace ~
4589 \InsetSpace ~
4590 \InsetSpace ~
4591 \InsetSpace ~
4592 \InsetSpace ~
4593 # put output in sdcc.build
4594 \end_layout
4595
4596 \begin_layout Standard
4597
4598 \family typewriter
4599 cd sdcc.build
4600 \end_layout
4601
4602 \begin_layout Standard
4603
4604 \family typewriter
4605 ../sdcc/configure\InsetSpace ~
4606 \InsetSpace ~
4607 \InsetSpace ~
4608 \InsetSpace ~
4609 \InsetSpace ~
4610 \InsetSpace ~
4611 \InsetSpace ~
4612 \InsetSpace ~
4613 # configure is doing all the magic!
4614 \end_layout
4615
4616 \begin_layout Standard
4617
4618 \family typewriter
4619 make
4620 \end_layout
4621
4622 \begin_layout Standard
4623 \noindent
4624 That's it! 
4625 \series bold
4626 configure
4627 \series default
4628  will create the directory tree will all the necessary Makefiles in ~/sdcc.build.
4629  It automagically computes the variables srcdir, top_srcdir and top_buildir
4630  for each directory.
4631  After running 
4632 \series bold
4633 make
4634 \series default
4635  the generated files will be in ~/sdcc.build, while the source files stay
4636  in ~/sdcc.
4637 \newline
4638 This is not only usefull for building different binaries, e.g.
4639  when cross compiling.
4640  It also gives you a much better overview in the source tree when all the
4641  generated files are not scattered between the source files.
4642  And the best thing is: if you want to change a file you can leave the original
4643  file untouched in the source directory.
4644  Simply copy it to the build directory, edit it, enter `make clean', `rm
4645  Makefile.dep' and `make'.
4646  
4647 \series bold
4648 make
4649 \series default
4650  will do the rest for you!
4651 \end_layout
4652
4653 \begin_layout Section
4654 Building the Documentation
4655 \end_layout
4656
4657 \begin_layout Standard
4658 Add -
4659 \begin_inset ERT
4660 status collapsed
4661
4662 \begin_layout Standard
4663
4664
4665 \backslash
4666 /
4667 \end_layout
4668
4669 \end_inset
4670
4671 -enable-doc to the configure arguments to build the documentation together
4672  with all the other stuff.
4673  You will need several tools (LyX, LaTeX, LaTeX2HTML, pdflatex, dvipdf,
4674  dvips and makeindex) to get the job done.
4675  Another possibility is to change to the doc directory and to type 
4676 \family sans
4677 \series bold
4678
4679 \begin_inset Quotes srd
4680 \end_inset
4681
4682 make
4683 \begin_inset Quotes srd
4684 \end_inset
4685
4686
4687 \family default
4688 \series default
4689  there.
4690  You're invited to make changes and additions to this manual (sdcc/doc/sdccman.ly
4691 x).
4692  Using LyX 
4693 \begin_inset LatexCommand \url{http://www.lyx.org}
4694
4695 \end_inset
4696
4697  as editor is straightforward.
4698  Prebuilt documentation in html and pdf format is available from 
4699 \begin_inset LatexCommand \url{http://sdcc.sf.net/snap.php}
4700
4701 \end_inset
4702
4703 .
4704 \end_layout
4705
4706 \begin_layout Section
4707 Reading the Documentation
4708 \begin_inset LatexCommand \index{Documentation}
4709
4710 \end_inset
4711
4712
4713 \end_layout
4714
4715 \begin_layout Standard
4716 Currently reading the document in pdf format is recommended, as for unknown
4717  reason the hyperlinks are working there whereas in the html version they
4718  are not
4719 \begin_inset Foot
4720 status open
4721
4722 \begin_layout Standard
4723 If you should know why please drop us a note
4724 \end_layout
4725
4726 \end_inset
4727
4728 .
4729  
4730 \newline
4731 You'll find the pdf version
4732 \begin_inset LatexCommand \index{PDF version of this document}
4733
4734 \end_inset
4735
4736  at 
4737 \begin_inset LatexCommand \url{http://sdcc.sf.net/doc/sdccman.pdf}
4738
4739 \end_inset
4740
4741 .
4742  
4743 \newline
4744 A html version
4745 \begin_inset LatexCommand \index{HTML version of this document}
4746
4747 \end_inset
4748
4749  should be online at 
4750 \begin_inset LatexCommand \url{http://sdcc.sf.net/doc/sdccman.html/index.html}
4751
4752 \end_inset
4753
4754 .
4755 \newline
4756 This documentation is in some aspects different from a commercial documentation:
4757  
4758 \end_layout
4759
4760 \begin_layout Itemize
4761 It tries to document SDCC for several processor architectures in one document
4762  (commercially these probably would be separate documents/products).
4763  This document
4764 \begin_inset LatexCommand \index{Status of documentation}
4765
4766 \end_inset
4767
4768  currently matches SDCC for mcs51 and DS390 best and does give too few informati
4769 on about f.e.
4770  Z80, PIC14, PIC16 and HC08.
4771 \end_layout
4772
4773 \begin_layout Itemize
4774 There are many references pointing away from this documentation.
4775  Don't let this distract you.
4776  If there f.e.
4777  was a reference like 
4778 \begin_inset LatexCommand \url{http://www.opencores.org}
4779
4780 \end_inset
4781
4782  together with a statement 
4783 \begin_inset Quotes sld
4784 \end_inset
4785
4786 some processors which are targetted by SDCC can be implemented in a 
4787 \emph on
4788 f
4789 \emph default
4790 ield 
4791 \emph on
4792 p
4793 \emph default
4794 rogrammable 
4795 \emph on
4796 g
4797 \emph default
4798 ate 
4799 \emph on
4800 a
4801 \emph default
4802 rray
4803 \begin_inset LatexCommand \index{FPGA (field programmable gate array)}
4804
4805 \end_inset
4806
4807
4808 \begin_inset Quotes srd
4809 \end_inset
4810
4811  or 
4812 \begin_inset LatexCommand \url{http://sf.net/projects/fpgac}
4813
4814 \end_inset
4815
4816
4817 \begin_inset LatexCommand \index{FpgaC ((subset of) C to FPGA compiler)}
4818
4819 \end_inset
4820
4821  
4822 \begin_inset Quotes sld
4823 \end_inset
4824
4825 have you ever heard of an open source compiler that compiles a subset of
4826  C for an FPGA?
4827 \begin_inset Quotes srd
4828 \end_inset
4829
4830  we expect you to have a quick look there and come back.
4831  If you read this you are on the right track.
4832 \end_layout
4833
4834 \begin_layout Itemize
4835 Some sections attribute more space to problems, restrictions and warnings
4836  than to the solution.
4837 \end_layout
4838
4839 \begin_layout Itemize
4840 The installation section and the section about the debugger is intimidating.
4841 \end_layout
4842
4843 \begin_layout Itemize
4844 There are still lots of typos and there are more different writing styles
4845  than pictures.
4846 \end_layout
4847
4848 \begin_layout Section
4849 Testing the SDCC Compiler
4850 \begin_inset LatexCommand \label{sec:Testing-the-SDCC}
4851
4852 \end_inset
4853
4854
4855 \end_layout
4856
4857 \begin_layout Standard
4858 The first thing you should do after installing your SDCC compiler is to
4859  see if it runs.
4860  Type 
4861 \family sans
4862 \series bold
4863 "sdcc -
4864 \begin_inset ERT
4865 status collapsed
4866
4867 \begin_layout Standard
4868
4869
4870 \backslash
4871 /
4872 \end_layout
4873
4874 \end_inset
4875
4876 -version"
4877 \begin_inset LatexCommand \index{version}
4878
4879 \end_inset
4880
4881
4882 \family default
4883 \series default
4884  at the prompt, and the program should run and output its version like:
4885  
4886 \newline
4887
4888 \family typewriter
4889 SDCC : mcs51/z80/avr/ds390/pic16/pic14/ds400/hc08 2.5.6 #4169 (May 8 2006)
4890  (UNIX)
4891 \end_layout
4892
4893 \begin_layout Standard
4894 If it doesn't run, or gives a message about not finding sdcc program, then
4895  you need to check over your installation.
4896  Make sure that the sdcc bin directory is in your executable search path
4897  defined by the PATH environment setting (
4898 \series medium
4899 see 
4900 \series default
4901 section 
4902 \begin_inset LatexCommand \ref{sub:Install-Trouble-shooting}
4903
4904 \end_inset
4905
4906 \InsetSpace ~
4907
4908 \series medium
4909 Install trouble-shooting for suggestions
4910 \series default
4911 ).
4912  Make sure that the sdcc program is in the bin folder, if not perhaps something
4913  did not install correctly.
4914 \newline
4915
4916 \newline
4917
4918 \series medium
4919 SDCC 
4920 \series default
4921 is commonly installed as described in section 
4922 \begin_inset Quotes sld
4923 \end_inset
4924
4925 Install and search paths
4926 \begin_inset Quotes srd
4927 \end_inset
4928
4929 .
4930 \newline
4931
4932 \newline
4933
4934 \series medium
4935 Make sure the compiler works on a very simple example.
4936  Type in the following test.c program using your favorite 
4937 \series default
4938 ASCII 
4939 \series medium
4940 editor:
4941 \end_layout
4942
4943 \begin_layout Verse
4944
4945 \family typewriter
4946 char test;
4947 \newline
4948
4949 \newline
4950 void main(void) {
4951 \newline
4952 \InsetSpace ~
4953 \InsetSpace ~
4954 \InsetSpace ~
4955 \InsetSpace ~
4956 test=0;
4957 \newline
4958 }
4959 \end_layout
4960
4961 \begin_layout Standard
4962
4963 \series medium
4964 Compile this using the following command: 
4965 \family sans
4966 \series bold
4967 "sdcc -c test.c".
4968
4969 \family default
4970 \series default
4971  
4972 \series medium
4973 If all goes well, the compiler will generate a test.asm and test.rel file.
4974  Congratulations, you've just compiled your first program with SDCC.
4975  We used the -c option to tell SDCC not to link the generated code, just
4976  to keep things simple for this step.
4977 \series default
4978
4979 \newline
4980
4981 \newline
4982
4983 \series medium
4984 The next step is to try it with the linker.
4985  Type in 
4986 \family sans
4987 \series bold
4988 "sdcc test.c
4989 \family default
4990 \series default
4991 "
4992 \series medium
4993 .
4994  If all goes well the compiler will link with the libraries and produce
4995  a test.ihx output file.
4996  If this step fails
4997 \series default
4998  
4999 \series medium
5000 (no test.ihx, and the linker generates warnings), then the problem is most
5001  likely that 
5002 \series default
5003 SDCC
5004 \series medium
5005  cannot find the 
5006 \series default
5007 /
5008 \series medium
5009 usr/local/share/sdcc/lib directory
5010 \series default
5011  
5012 \series medium
5013 (see 
5014 \series default
5015 section 
5016 \begin_inset LatexCommand \ref{sub:Install-Trouble-shooting}
5017
5018 \end_inset
5019
5020 \InsetSpace ~
5021
5022 \series medium
5023 Install trouble-shooting for suggestions).
5024 \series default
5025
5026 \newline
5027
5028 \newline
5029
5030 \series medium
5031 The final test is to ensure 
5032 \series default
5033 SDCC
5034 \series medium
5035  can use the 
5036 \series default
5037 standard
5038 \series medium
5039  header files and libraries.
5040  Edit test.c and change it to the following:
5041 \end_layout
5042
5043 \begin_layout Verse
5044
5045 \family typewriter
5046 #include <string.h>
5047 \newline
5048
5049 \newline
5050 char str1[10];
5051 \newline
5052
5053 \newline
5054 void main(void) {
5055 \newline
5056 \InsetSpace ~
5057 \InsetSpace ~
5058 strcpy(str1, "testing");
5059 \newline
5060 }
5061 \end_layout
5062
5063 \begin_layout Standard
5064
5065 \series medium
5066 Compile this by typing 
5067 \family sans
5068 \series bold
5069 "sdcc test.c"
5070 \family default
5071 \series medium
5072 .
5073  This should generate a test.ihx output file, and it should give no warnings
5074  such as not finding the string.h file.
5075  If it cannot find the string.h file, then the problem is that 
5076 \series default
5077 SDCC
5078 \series medium
5079  cannot find the /usr/local/share/sdcc/include directory
5080 \series default
5081  
5082 \series medium
5083 (see the 
5084 \series default
5085 section 
5086 \begin_inset LatexCommand \ref{sub:Install-Trouble-shooting}
5087
5088 \end_inset
5089
5090 \InsetSpace ~
5091
5092 \series medium
5093 Install trouble-shooting section for suggestions).
5094
5095 \series default
5096  Use option 
5097 \series bold
5098 -
5099 \begin_inset ERT
5100 status collapsed
5101
5102 \begin_layout Standard
5103
5104
5105 \backslash
5106 /
5107 \end_layout
5108
5109 \end_inset
5110
5111 -print-search-dirs
5112 \series default
5113
5114 \begin_inset LatexCommand \index{-\/-print-search-dirs}
5115
5116 \end_inset
5117
5118  to find exactly where SDCC is looking for the include and lib files.
5119 \end_layout
5120
5121 \begin_layout Section
5122 Install Trouble-shooting
5123 \begin_inset LatexCommand \label{sub:Install-Trouble-shooting}
5124
5125 \end_inset
5126
5127
5128 \begin_inset LatexCommand \index{Install trouble-shooting}
5129
5130 \end_inset
5131
5132
5133 \end_layout
5134
5135 \begin_layout Subsection
5136 If SDCC does not build correctly
5137 \end_layout
5138
5139 \begin_layout Standard
5140 A thing to try is starting from scratch by unpacking the .tgz source package
5141  again in an empty directory.
5142  Configure it like:
5143 \newline
5144
5145 \newline
5146
5147 \family sans
5148 \series bold
5149 ./configure 2>&1 | tee configure.log
5150 \family default
5151 \series default
5152
5153 \newline
5154
5155 \newline
5156 and build it like:
5157 \newline
5158
5159 \newline
5160
5161 \family sans
5162 \series bold
5163 make 2>&1 | tee make.log
5164 \family default
5165 \series default
5166
5167 \newline
5168
5169 \newline
5170 If anything goes wrong, you can review the log files to locate the problem.
5171  Or a relevant part of this can be attached to an email that could be helpful
5172  when requesting help from the mailing list.
5173 \end_layout
5174
5175 \begin_layout Subsection
5176 What the 
5177 \begin_inset Quotes sld
5178 \end_inset
5179
5180 ./configure
5181 \begin_inset Quotes srd
5182 \end_inset
5183
5184  does
5185 \end_layout
5186
5187 \begin_layout Standard
5188 The 
5189 \begin_inset Quotes sld
5190 \end_inset
5191
5192 ./configure
5193 \begin_inset Quotes srd
5194 \end_inset
5195
5196  command is a script that analyzes your system and performs some configuration
5197  to ensure the source package compiles on your system.
5198  It will take a few minutes to run, and will compile a few tests to determine
5199  what compiler features are installed.
5200 \end_layout
5201
5202 \begin_layout Subsection
5203 What the 
5204 \begin_inset Quotes sld
5205 \end_inset
5206
5207 make
5208 \begin_inset Quotes srd
5209 \end_inset
5210
5211  does
5212 \end_layout
5213
5214 \begin_layout Standard
5215 This runs the GNU make tool, which automatically compiles all the source
5216  packages into the final installed binary executables.
5217 \end_layout
5218
5219 \begin_layout Subsection
5220 What the 
5221 \begin_inset Quotes sld
5222 \end_inset
5223
5224 make install
5225 \begin_inset Quotes erd
5226 \end_inset
5227
5228  command does.
5229 \end_layout
5230
5231 \begin_layout Standard
5232 This will install the compiler, other executables libraries and include
5233  files into the appropriate directories.
5234  See sections 
5235 \begin_inset LatexCommand \ref{sub:Install-paths}
5236
5237 \end_inset
5238
5239 ,\InsetSpace ~
5240
5241 \begin_inset LatexCommand \ref{sub:Search-Paths}
5242
5243 \end_inset
5244
5245 \InsetSpace ~
5246 about install and search paths.
5247 \newline
5248 On most systems you will need super-user privilege
5249 s to do this.
5250 \end_layout
5251
5252 \begin_layout Section
5253 Components of SDCC
5254 \end_layout
5255
5256 \begin_layout Standard
5257 SDCC is not just a compiler, but a collection of tools by various developers.
5258  These include linkers, assemblers, simulators and other components.
5259  Here is a summary of some of the components.
5260  Note that the included simulator and assembler have separate documentation
5261  which you can find in the source package in their respective directories.
5262  As SDCC grows to include support for other processors, other packages from
5263  various developers are included and may have their own sets of documentation.
5264 \newline
5265
5266 \newline
5267 You
5268  might want to look at the files which are installed in <installdir>.
5269  At the time of this writing, we find the following programs for gcc-builds:
5270 \newline
5271
5272  
5273 \newline
5274 In <installdir>/bin:
5275 \end_layout
5276
5277 \begin_layout Itemize
5278 sdcc - The compiler.
5279 \end_layout
5280
5281 \begin_layout Itemize
5282 sdcpp - The C preprocessor.
5283 \end_layout
5284
5285 \begin_layout Itemize
5286 asx8051 - The assembler for 8051 type processors.
5287 \end_layout
5288
5289 \begin_layout Itemize
5290 as-z80
5291 \series bold
5292
5293 \series default
5294 as-gbz80 - The Z80 and GameBoy Z80 assemblers.
5295 \end_layout
5296
5297 \begin_layout Itemize
5298 aslink -The linker for 8051 type processors.
5299 \end_layout
5300
5301 \begin_layout Itemize
5302 link-z80
5303 \series bold
5304
5305 \series default
5306 link-gbz80 - The Z80 and GameBoy Z80 linkers.
5307 \end_layout
5308
5309 \begin_layout Itemize
5310 s51 - The ucSim 8051 simulator.
5311 \end_layout
5312
5313 \begin_layout Itemize
5314 sdcdb - The source debugger.
5315 \end_layout
5316
5317 \begin_layout Itemize
5318 packihx - A tool to pack (compress) Intel hex files.
5319 \end_layout
5320
5321 \begin_layout Standard
5322 In <installdir>/share/sdcc/include
5323 \end_layout
5324
5325 \begin_layout Itemize
5326 the include files
5327 \end_layout
5328
5329 \begin_layout Standard
5330 In <installdir>/share/sdcc/lib
5331 \end_layout
5332
5333 \begin_layout Itemize
5334 the subdirs src and small, large, z80, gbz80 and ds390 with the precompiled
5335  relocatables.
5336 \end_layout
5337
5338 \begin_layout Standard
5339 In <installdir>/share/sdcc/doc
5340 \end_layout
5341
5342 \begin_layout Itemize
5343 the documentation
5344 \end_layout
5345
5346 \begin_layout Standard
5347 As development for other processors proceeds, this list will expand to include
5348  executables to support processors like AVR, PIC, etc.
5349 \end_layout
5350
5351 \begin_layout Subsection
5352 sdcc - The Compiler
5353 \end_layout
5354
5355 \begin_layout Standard
5356 This is the actual compiler, it in turn uses the c-preprocessor and invokes
5357  the assembler and linkage editor.
5358 \end_layout
5359
5360 \begin_layout Subsection
5361 sdcpp - The C-Preprocessor
5362 \end_layout
5363
5364 \begin_layout Standard
5365 The preprocessor
5366 \begin_inset LatexCommand \index{sdcpp (preprocessor)}
5367
5368 \end_inset
5369
5370  is a modified version of the GNU cpp
5371 \begin_inset LatexCommand \index{cpp|see{sdcpp}}
5372
5373 \end_inset
5374
5375  preprocessor 
5376 \begin_inset LatexCommand \url{http://gcc.gnu.org/}
5377
5378 \end_inset
5379
5380 .
5381  The C preprocessor is used to pull in #include sources, process #ifdef
5382  statements, #defines and so on.
5383 \end_layout
5384
5385 \begin_layout Subsection
5386 as
5387 \emph on
5388 xxxx
5389 \emph default
5390 , aslink, link-
5391 \emph on
5392 xxx
5393 \emph default
5394  - The Assemblers and Linkage Editors
5395 \end_layout
5396
5397 \begin_layout Standard
5398 This is retargettable assembler & linkage editor, it was developed by Alan
5399  Baldwin.
5400  John Hartman created the version for 8051, and I (Sandeep) have made some
5401  enhancements and bug fixes for it to work properly with SDCC.
5402 \end_layout
5403
5404 \begin_layout Subsection
5405 s51 - The Simulator
5406 \end_layout
5407
5408 \begin_layout Standard
5409 S51
5410 \begin_inset LatexCommand \index{s51}
5411
5412 \end_inset
5413
5414  is a free open source simulator developed by Daniel Drotos.
5415  The simulator is built as part of the build process.
5416  For more information visit Daniel's web site at: 
5417 \begin_inset LatexCommand \url{http://mazsola.iit.uni-miskolc.hu/~drdani/embedded/s51}
5418
5419 \end_inset
5420
5421 .
5422  It currently supports the core mcs51, the Dallas DS80C390 and the Phillips
5423  XA51 family.
5424 \end_layout
5425
5426 \begin_layout Subsection
5427 sdcdb - Source Level Debugger
5428 \end_layout
5429
5430 \begin_layout Standard
5431 SDCDB
5432 \begin_inset LatexCommand \index{SDCDB (debugger)}
5433
5434 \end_inset
5435
5436  is the companion source level debugger.
5437  More about SDCDB in section 
5438 \begin_inset LatexCommand \ref{cha:Debugging-with-SDCDB}
5439
5440 \end_inset
5441
5442 .
5443  The current version of the debugger uses Daniel's Simulator S51
5444 \begin_inset LatexCommand \index{s51}
5445
5446 \end_inset
5447
5448 , but can be easily changed to use other simulators.
5449 \end_layout
5450
5451 \begin_layout Chapter
5452 Using SDCC
5453 \end_layout
5454
5455 \begin_layout Section
5456 Compiling
5457 \end_layout
5458
5459 \begin_layout Subsection
5460 Single Source File Projects
5461 \end_layout
5462
5463 \begin_layout Standard
5464 For single source file 8051 projects the process is very simple.
5465  Compile your programs with the following command 
5466 \family sans
5467 \series bold
5468 "sdcc sourcefile.c".
5469
5470 \family default
5471 \series default
5472  This will compile, assemble and link your source file.
5473  Output files are as follows:
5474 \end_layout
5475
5476 \begin_layout Itemize
5477 sourcefile.asm
5478 \begin_inset LatexCommand \index{<file>.asm}
5479
5480 \end_inset
5481
5482  - Assembler source
5483 \begin_inset LatexCommand \index{Assembler source}
5484
5485 \end_inset
5486
5487  file created by the compiler
5488 \end_layout
5489
5490 \begin_layout Itemize
5491 sourcefile.lst
5492 \begin_inset LatexCommand \index{<file>.lst}
5493
5494 \end_inset
5495
5496  - Assembler listing
5497 \begin_inset LatexCommand \index{Assembler listing}
5498
5499 \end_inset
5500
5501  file created by the Assembler
5502 \end_layout
5503
5504 \begin_layout Itemize
5505 sourcefile.rst
5506 \begin_inset LatexCommand \index{<file>.rst}
5507
5508 \end_inset
5509
5510  - Assembler listing
5511 \begin_inset LatexCommand \index{Assembler listing}
5512
5513 \end_inset
5514
5515  file updated with linkedit information, created by linkage editor
5516 \end_layout
5517
5518 \begin_layout Itemize
5519 sourcefile.sym
5520 \begin_inset LatexCommand \index{<file>.sym}
5521
5522 \end_inset
5523
5524  - symbol listing
5525 \begin_inset LatexCommand \index{Symbol listing}
5526
5527 \end_inset
5528
5529  for the sourcefile, created by the assembler
5530 \end_layout
5531
5532 \begin_layout Itemize
5533 sourcefile.rel
5534 \begin_inset LatexCommand \index{<file>.rel}
5535
5536 \end_inset
5537
5538  or sourcefile.o
5539 \begin_inset LatexCommand \index{<file>.o}
5540
5541 \end_inset
5542
5543  - Object file
5544 \begin_inset LatexCommand \index{Object file}
5545
5546 \end_inset
5547
5548  created by the assembler, input to Linkage editor
5549 \end_layout
5550
5551 \begin_layout Itemize
5552 sourcefile.map
5553 \begin_inset LatexCommand \index{<file>.map}
5554
5555 \end_inset
5556
5557  - The memory map
5558 \begin_inset LatexCommand \index{Memory map}
5559
5560 \end_inset
5561
5562  for the load module, created by the Linker
5563 \end_layout
5564
5565 \begin_layout Itemize
5566 sourcefile.mem
5567 \begin_inset LatexCommand \index{<file>.mem}
5568
5569 \end_inset
5570
5571  - A file with a summary of the memory usage
5572 \end_layout
5573
5574 \begin_layout Itemize
5575 sourcefile.ihx
5576 \begin_inset LatexCommand \index{<file>.ihx}
5577
5578 \end_inset
5579
5580  - The load module in Intel hex format
5581 \begin_inset LatexCommand \index{Intel hex format}
5582
5583 \end_inset
5584
5585  (you can select the Motorola S19 format
5586 \begin_inset LatexCommand \index{Motorola S19 format}
5587
5588 \end_inset
5589
5590  with -
5591 \begin_inset ERT
5592 status collapsed
5593
5594 \begin_layout Standard
5595
5596
5597 \backslash
5598 /
5599 \end_layout
5600
5601 \end_inset
5602
5603 -out-fmt-s19
5604 \begin_inset LatexCommand \index{-\/-out-fmt-s19}
5605
5606 \end_inset
5607
5608 .
5609  If you need another format you might want to use 
5610 \family sans
5611 \shape italic
5612 objdump
5613 \family default
5614 \shape default
5615
5616 \begin_inset LatexCommand \index{objdump (tool)}
5617
5618 \end_inset
5619
5620  or
5621 \family sans
5622 \shape italic
5623  srecord
5624 \family default
5625 \shape default
5626
5627 \begin_inset LatexCommand \index{srecord (bin, hex, ... tool)}
5628
5629 \end_inset
5630
5631
5632 \begin_inset Note Note
5633 status collapsed
5634
5635 \begin_layout Standard
5636 hyperlinks needed
5637 \end_layout
5638
5639 \end_inset
5640
5641  - see also section 
5642 \begin_inset LatexCommand \vref{sub:Postprocessing-the-Intel}
5643
5644 \end_inset
5645
5646 ).
5647  Both formats are documented in the documentation of srecord
5648 \begin_inset LatexCommand \index{srecord (bin, hex, ... tool)}
5649
5650 \end_inset
5651
5652
5653 \end_layout
5654
5655 \begin_layout Itemize
5656 sourcefile.adb
5657 \begin_inset LatexCommand \index{<file>.adb}
5658
5659 \end_inset
5660
5661  - An intermediate file containing debug information needed to create the
5662  .cdb file (with -
5663 \begin_inset ERT
5664 status collapsed
5665
5666 \begin_layout Standard
5667
5668
5669 \backslash
5670 /
5671 \end_layout
5672
5673 \end_inset
5674
5675 -debug
5676 \begin_inset LatexCommand \index{-\/-debug}
5677
5678 \end_inset
5679
5680
5681 \end_layout
5682
5683 \begin_layout Itemize
5684 sourcefile.cdb
5685 \begin_inset LatexCommand \index{<file>.cdb}
5686
5687 \end_inset
5688
5689  - An optional file (with -
5690 \begin_inset ERT
5691 status collapsed
5692
5693 \begin_layout Standard
5694
5695
5696 \backslash
5697 /
5698 \end_layout
5699
5700 \end_inset
5701
5702 -debug) containing debug information.
5703  The format is documented in cdbfileformat.pdf
5704 \end_layout
5705
5706 \begin_layout Itemize
5707 sourcefile.
5708  - (no extension)
5709 \begin_inset LatexCommand \index{<file> (no extension)}
5710
5711 \end_inset
5712
5713  An optional AOMF or AOMF51
5714 \begin_inset LatexCommand \index{AOMF, AOMF51}
5715
5716 \end_inset
5717
5718  
5719 \begin_inset LatexCommand \label{OMF file}
5720
5721 \end_inset
5722
5723 file containing debug information (generated with option -
5724 \begin_inset ERT
5725 status collapsed
5726
5727 \begin_layout Standard
5728
5729
5730 \backslash
5731 /
5732 \end_layout
5733
5734 \end_inset
5735
5736 -debug).
5737  The (Intel)
5738 \emph on
5739  a
5740 \emph default
5741 bsolute 
5742 \emph on
5743 o
5744 \emph default
5745 bject 
5746 \emph on
5747 m
5748 \emph default
5749 odule 
5750 \emph on
5751 f
5752 \emph default
5753 ormat is a subformat of the OMF51 format and is commonly used by third party
5754  tools (debuggers
5755 \begin_inset LatexCommand \index{Debugger}
5756
5757 \end_inset
5758
5759 , simulators, emulators).
5760 \end_layout
5761
5762 \begin_layout Itemize
5763 sourcefile.dump*
5764 \begin_inset LatexCommand \index{<file>.dump*}
5765
5766 \end_inset
5767
5768  - Dump file to debug the compiler it self (generated with option -
5769 \begin_inset ERT
5770 status collapsed
5771
5772 \begin_layout Standard
5773
5774
5775 \backslash
5776 /
5777 \end_layout
5778
5779 \end_inset
5780
5781 -dumpall) (see section 
5782 \begin_inset LatexCommand \ref{sub:Intermediate-Dump-Options}
5783
5784 \end_inset
5785
5786 \InsetSpace ~
5787  and section 
5788 \begin_inset LatexCommand \ref{sub:The-anatomy-of}
5789
5790 \end_inset
5791
5792 \InsetSpace ~
5793
5794 \begin_inset Quotes sld
5795 \end_inset
5796
5797 Anatomy of the compiler
5798 \begin_inset Quotes srd
5799 \end_inset
5800
5801 ).
5802 \end_layout
5803
5804 \begin_layout Subsection
5805 Postprocessing the Intel Hex
5806 \begin_inset LatexCommand \index{Intel hex format}
5807
5808 \end_inset
5809
5810  file
5811 \begin_inset LatexCommand \label{sub:Postprocessing-the-Intel}
5812
5813 \end_inset
5814
5815
5816 \end_layout
5817
5818 \begin_layout Standard
5819 In most cases this won't be needed but the Intel Hex file
5820 \begin_inset LatexCommand \index{<file>.ihx}
5821
5822 \end_inset
5823
5824  which is generated by SDCC might include lines of varying length and the
5825  addresses within the file are not guaranteed to be strictly ascending.
5826  If your toolchain or a bootloader does not like this you can use the tool
5827  
5828 \family typewriter
5829 packihx
5830 \family default
5831
5832 \begin_inset LatexCommand \index{packihx (tool)}
5833
5834 \end_inset
5835
5836  which is part of the SDCC distribution: 
5837 \newline
5838
5839 \newline
5840
5841 \family sans
5842 \series bold
5843  packihx sourcefile.ihx >sourcefile.hex
5844 \family default
5845 \series default
5846
5847 \newline
5848
5849 \newline
5850 The separately available
5851 \emph on
5852  srecord
5853 \emph default
5854
5855 \begin_inset LatexCommand \index{srecord (bin, hex, ... tool)}
5856
5857 \end_inset
5858
5859  package additionally allows to set undefined locations to a predefined
5860  value, to insert checksums
5861 \begin_inset LatexCommand \index{checksum}
5862
5863 \end_inset
5864
5865  of various flavours (crc, add, xor) and to perform other manipulations
5866  (convert, split, crop, offset, ...).
5867  
5868 \newline
5869
5870 \newline
5871
5872 \family sans
5873 \series bold
5874 srec_cat\InsetSpace ~
5875 \InsetSpace ~
5876 sourcefile.ihx -intel\InsetSpace ~
5877 \InsetSpace ~
5878 -o sourcefile.hex -intel
5879 \newline
5880
5881 \newline
5882
5883 \family default
5884 \series default
5885 An example for a more complex command line
5886 \begin_inset Foot
5887 status open
5888
5889 \begin_layout Standard
5890 the command backfills
5891 \begin_inset LatexCommand \index{backfill unused memory}
5892
5893 \end_inset
5894
5895  unused memory with 0x12 and the overall 16 bit sum of the complete 64 kByte
5896  block is zero.
5897  If the program counter on an mcs51 runs wild the backfill pattern 0x12
5898  will be interpreted as an 
5899 \family typewriter
5900 lcall
5901 \family default
5902  to address 
5903 \family typewriter
5904 0x1212
5905 \family default
5906  (where an emergency routine could sit).
5907 \end_layout
5908
5909 \end_inset
5910
5911  could look like:
5912 \newline
5913
5914 \newline
5915
5916 \family sans
5917 \series bold
5918 \size footnotesize
5919 srec_cat\InsetSpace ~
5920 sourcefile.ihx -intel\InsetSpace ~
5921 \InsetSpace ~
5922 -fill 0x12 0x0000 0xfffe\InsetSpace ~
5923 -little-endian-checksum-nega
5924 tive 0xfffe 0x02 0x02\InsetSpace ~
5925 \InsetSpace ~
5926 -o sourcefile.hex -intel
5927 \size default
5928
5929 \newline
5930
5931 \newline
5932
5933 \family default
5934 \series default
5935 The srecord package is available at 
5936 \begin_inset LatexCommand \url{http://sf.net/projects/srecord}
5937
5938 \end_inset
5939
5940  .
5941 \end_layout
5942
5943 \begin_layout Subsection
5944 Projects with Multiple Source Files
5945 \end_layout
5946
5947 \begin_layout Standard
5948 SDCC can compile only ONE file at a time.
5949  Let us for example assume that you have a project containing the following
5950  files:
5951 \newline
5952
5953 \newline
5954 foo1.c (contains some functions)
5955 \newline
5956 foo2.c (contains some more functions)
5957 \newline
5958 foomai
5959 n.c (contains more functions and the function main)
5960 \newline
5961
5962 \size footnotesize
5963
5964 \newline
5965
5966 \size default
5967 The first two files will need to be compiled separately with the commands:
5968 \size footnotesize
5969  
5970 \size default
5971
5972 \newline
5973
5974 \newline
5975
5976 \family sans
5977 \series bold
5978 sdcc\InsetSpace ~
5979 -c\InsetSpace ~
5980 foo1.c
5981 \family default
5982 \series default
5983 \size footnotesize
5984
5985 \newline
5986
5987 \family sans
5988 \series bold
5989 \size default
5990 sdcc\InsetSpace ~
5991 -c\InsetSpace ~
5992 foo2.c
5993 \family default
5994 \series default
5995
5996 \newline
5997
5998 \newline
5999 Then compile the source file containing the 
6000 \emph on
6001 main()
6002 \emph default
6003  function and link
6004 \begin_inset LatexCommand \index{Linker}
6005
6006 \end_inset
6007
6008  the files together with the following command: 
6009 \newline
6010
6011 \newline
6012
6013 \family sans
6014 \series bold
6015 sdcc\InsetSpace ~
6016 foomain.c\InsetSpace ~
6017 foo1.rel\InsetSpace ~
6018 foo2.rel
6019 \family default
6020 \series default
6021
6022 \begin_inset LatexCommand \index{<file>.rel}
6023
6024 \end_inset
6025
6026
6027 \newline
6028
6029 \newline
6030 Alternatively, 
6031 \emph on
6032 foomain.c 
6033 \emph default
6034 can be separately compiled as well: 
6035 \family sans
6036 \series bold
6037
6038 \newline
6039
6040 \newline
6041 sdcc\InsetSpace ~
6042 -c\InsetSpace ~
6043 foomain.c
6044 \newline
6045 sdcc foomain.rel foo1.rel foo2.rel
6046 \newline
6047
6048 \newline
6049
6050 \family default
6051 \series default
6052 The file containing the 
6053 \emph on
6054 main()
6055 \emph default
6056  function
6057 \emph on
6058  
6059 \emph default
6060 \noun on
6061 must
6062 \noun default
6063  be the 
6064 \noun on
6065 first
6066 \noun default
6067  file specified in the command line, since the linkage editor processes
6068  file in the order they are presented to it.
6069  The linker is invoked from SDCC using a script file with extension .lnk
6070 \begin_inset LatexCommand \index{<file>.lnk}
6071
6072 \end_inset
6073
6074 .
6075  You can view this file to troubleshoot linking problems such as those arising
6076  from missing libraries.
6077 \end_layout
6078
6079 \begin_layout Subsection
6080 Projects with Additional Libraries
6081 \begin_inset LatexCommand \index{Libraries}
6082
6083 \end_inset
6084
6085
6086 \end_layout
6087
6088 \begin_layout Standard
6089 Some reusable routines may be compiled into a library, see the documentation
6090  for the assembler and linkage editor (which are in <installdir>/share/sdcc/doc)
6091  for how to create a 
6092 \emph on
6093 .lib
6094 \begin_inset LatexCommand \index{<file>.lib}
6095
6096 \end_inset
6097
6098
6099 \emph default
6100  library file.
6101  Libraries created in this manner can be included in the command line.
6102  Make sure you include the -L <library-path> option to tell the linker where
6103  to look for these files if they are not in the current directory.
6104  Here is an example, assuming you have the source file 
6105 \emph on
6106 foomain.c
6107 \emph default
6108  and a library
6109 \emph on
6110  foolib.lib
6111 \emph default
6112  in the directory 
6113 \emph on
6114 mylib
6115 \emph default
6116  (if that is not the same as your current project):
6117 \newline
6118
6119 \newline
6120
6121 \family sans
6122 \series bold
6123 sdcc foomain.c foolib.lib -L mylib
6124 \newline
6125
6126 \newline
6127
6128 \family default
6129 \series default
6130 Note here that
6131 \emph on
6132  mylib
6133 \emph default
6134  must be an absolute path name.
6135 \newline
6136
6137 \newline
6138 The most efficient way to use libraries is
6139  to keep separate modules in separate source files.
6140  The lib file now should name all the modules.rel
6141 \begin_inset LatexCommand \index{<file>.rel}
6142
6143 \end_inset
6144
6145  files.
6146  For an example see the standard library file 
6147 \emph on
6148 libsdcc.lib
6149 \emph default
6150  in the directory <installdir>/share/lib/small.
6151 \end_layout
6152
6153 \begin_layout Subsection
6154 Using sdcclib to Create and Manage Libraries
6155 \begin_inset LatexCommand \index{sdcclib}
6156
6157 \end_inset
6158
6159
6160 \end_layout
6161
6162 \begin_layout Standard
6163 Alternatively, instead of having a .rel file for each entry on the library
6164  file as described in the preceding section, sdcclib can be used to embed
6165  all the modules belonging to such library in the library file itself.
6166  This results in a larger library file, but it greatly reduces the number
6167  of disk files accessed by the linker.
6168   Additionally, the packed library file contains an index of all include
6169  modules and symbols that significantly speeds up the linking process.
6170  To display a list of options supported by sdcclib type:
6171 \newline
6172
6173 \end_layout
6174
6175 \begin_layout Standard
6176
6177 \family sans
6178 \series bold
6179 sdcclib -?
6180 \begin_inset LatexCommand \index{sdcclib}
6181
6182 \end_inset
6183
6184
6185 \newline
6186
6187 \newline
6188
6189 \family default
6190 \series default
6191 To create a new library file, start by compiling all the required modules.
6192  For example:
6193 \newline
6194
6195 \end_layout
6196
6197 \begin_layout Standard
6198
6199 \family sans
6200 \series bold
6201 sdcc -c _divsint.c
6202 \end_layout
6203
6204 \begin_layout Standard
6205
6206 \family sans
6207 \series bold
6208 sdcc -c _divuint.c
6209 \end_layout
6210
6211 \begin_layout Standard
6212
6213 \family sans
6214 \series bold
6215 sdcc -c _modsint.c
6216 \end_layout
6217
6218 \begin_layout Standard
6219
6220 \family sans
6221 \series bold
6222 sdcc -c _moduint.c
6223 \end_layout
6224
6225 \begin_layout Standard
6226
6227 \family sans
6228 \series bold
6229 sdcc -c _mulint.c
6230 \newline
6231
6232 \end_layout
6233
6234 \begin_layout Standard
6235 This will create files _divsint.rel, _divuint.rel, _modsint.rel, _moduint.rel,
6236  and _mulint.rel.
6237  The next step is to add the .rel files to the library file:
6238 \newline
6239
6240 \end_layout
6241
6242 \begin_layout Standard
6243
6244 \family sans
6245 \series bold
6246 sdcclib libint.lib _divsint.rel
6247 \family default
6248
6249 \begin_inset LatexCommand \index{sdcclib}
6250
6251 \end_inset
6252
6253
6254 \end_layout
6255
6256 \begin_layout Standard
6257
6258 \family sans
6259 \series bold
6260 sdcclib libint.lib _divuint.rel
6261 \end_layout
6262
6263 \begin_layout Standard
6264
6265 \family sans
6266 \series bold
6267 sdcclib libint.lib _modsint.rel
6268 \end_layout
6269
6270 \begin_layout Standard
6271
6272 \family sans
6273 \series bold
6274 sdcclib libint.lib _moduint.rel
6275 \end_layout
6276
6277 \begin_layout Standard
6278
6279 \family sans
6280 \series bold
6281 sdcclib libint.lib _mulint.rel
6282 \family default
6283 \series default
6284
6285 \newline
6286
6287 \end_layout
6288
6289 \begin_layout Standard
6290 Or, if you preffer:
6291 \family sans
6292 \series bold
6293
6294 \newline
6295
6296 \end_layout
6297
6298 \begin_layout Standard
6299
6300 \family sans
6301 \series bold
6302 sdcclib libint.lib _divsint.rel _divuint.rel _modsint.rel _moduint.rel _mulint.rel
6303 \family default
6304 \series default
6305
6306 \newline
6307
6308 \end_layout
6309
6310 \begin_layout Standard
6311 If the file already exists in the library, it will be replaced.
6312  If a list of .rel files is available, you can tell sdcclib to add those
6313  files to a library.
6314  For example, if the file 'myliblist.txt' contains
6315 \family sans
6316 \series bold
6317
6318 \newline
6319
6320 \end_layout
6321
6322 \begin_layout Standard
6323
6324 \family sans
6325 \series bold
6326 _divsint.rel
6327 \end_layout
6328
6329 \begin_layout Standard
6330
6331 \family sans
6332 \series bold
6333 _divuint.rel
6334 \end_layout
6335
6336 \begin_layout Standard
6337
6338 \family sans
6339 \series bold
6340 _modsint.rel
6341 \end_layout
6342
6343 \begin_layout Standard
6344
6345 \family sans
6346 \series bold
6347 _moduint.rel
6348 \end_layout
6349
6350 \begin_layout Standard
6351
6352 \family sans
6353 \series bold
6354 _mulint.rel
6355 \family default
6356 \series default
6357
6358 \newline
6359
6360 \end_layout
6361
6362 \begin_layout Standard
6363 Use
6364 \family sans
6365 \series bold
6366
6367 \newline
6368
6369 \end_layout
6370
6371 \begin_layout Standard
6372
6373 \family sans
6374 \series bold
6375 sdcclib -l libint.lib myliblist.txt
6376 \family default
6377 \series default
6378
6379 \newline
6380
6381 \end_layout
6382
6383 \begin_layout Standard
6384 Additionally, you can instruct sdcclib to compiles the files before adding
6385  them to the library.
6386  This is achieved using the environment variables SDCCLIB_CC and/or SDCCLIB_AS.
6387  For example:
6388 \family sans
6389 \series bold
6390
6391 \newline
6392
6393 \end_layout
6394
6395 \begin_layout Standard
6396
6397 \family sans
6398 \series bold
6399 set SDCCLIB_CC=sdcc -c
6400 \end_layout
6401
6402 \begin_layout Standard
6403
6404 \family sans
6405 \series bold
6406 sdcclib -l libint.lib myliblist.txt
6407 \family default
6408 \series default
6409
6410 \newline
6411
6412 \end_layout
6413
6414 \begin_layout Standard
6415 To see what modules and symbols are included in the library, options -s
6416  and -m are available.
6417  For example:
6418 \newline
6419
6420 \newline
6421
6422 \family sans
6423 \series bold
6424 sdcclib -s libint.lib
6425 \family default
6426
6427 \begin_inset LatexCommand \index{sdcclib}
6428
6429 \end_inset
6430
6431
6432 \newline
6433
6434 \family typewriter
6435 \series default
6436 _divsint.rel:
6437 \end_layout
6438
6439 \begin_layout Standard
6440
6441 \family typewriter
6442 __divsint_a_1_1
6443 \end_layout
6444
6445 \begin_layout Standard
6446
6447 \family typewriter
6448 __divsint_PARM_2
6449 \end_layout
6450
6451 \begin_layout Standard
6452
6453 \family typewriter
6454 __divsint
6455 \newline
6456 _divuint.rel:
6457 \end_layout
6458
6459 \begin_layout Standard
6460
6461 \family typewriter
6462 __divuint_a_1_1
6463 \end_layout
6464
6465 \begin_layout Standard
6466
6467 \family typewriter
6468 __divuint_PARM_2
6469 \end_layout
6470
6471 \begin_layout Standard
6472
6473 \family typewriter
6474 __divuint_reste_1_1
6475 \end_layout
6476
6477 \begin_layout Standard
6478
6479 \family typewriter
6480 __divuint_count_1_1
6481 \end_layout
6482
6483 \begin_layout Standard
6484
6485 \family typewriter
6486 __divuint
6487 \newline
6488 _modsint.rel:
6489 \end_layout
6490
6491 \begin_layout Standard
6492
6493 \family typewriter
6494 __modsint_a_1_1
6495 \end_layout
6496
6497 \begin_layout Standard
6498
6499 \family typewriter
6500 __modsint_PARM_2
6501 \end_layout
6502
6503 \begin_layout Standard
6504
6505 \family typewriter
6506 __modsint
6507 \newline
6508 _moduint.rel:
6509 \end_layout
6510
6511 \begin_layout Standard
6512
6513 \family typewriter
6514 __moduint_a_1_1
6515 \end_layout
6516
6517 \begin_layout Standard
6518
6519 \family typewriter
6520 __moduint_PARM_2
6521 \end_layout
6522
6523 \begin_layout Standard
6524
6525 \family typewriter
6526 __moduint_count_1_1
6527 \end_layout
6528
6529 \begin_layout Standard
6530
6531 \family typewriter
6532 __moduint
6533 \newline
6534 _mulint.rel:
6535 \end_layout
6536
6537 \begin_layout Standard
6538
6539 \family typewriter
6540 __mulint_PARM_2
6541 \end_layout
6542
6543 \begin_layout Standard
6544
6545 \family typewriter
6546 __mulint
6547 \family default
6548 \series bold
6549
6550 \newline
6551
6552 \end_layout
6553
6554 \begin_layout Standard
6555 If the source files are compiled using -
6556 \begin_inset ERT
6557 status collapsed
6558
6559 \begin_layout Standard
6560
6561
6562 \backslash
6563 /
6564 \end_layout
6565
6566 \end_inset
6567
6568 -debug
6569 \begin_inset LatexCommand \index{-\/-debug}
6570
6571 \end_inset
6572
6573 , the corresponding debug information file .adb will be include in the library
6574  file as well.
6575  The library files created with sdcclib are plain text files, so they can
6576  be viewed with a text editor.
6577  It is not recomended to modify a library file created with sdcclib using
6578  a text editor, as there are file indexes numbers located accross the file
6579  used by the linker to quickly locate the required module to link.
6580  Once a .rel file (as well as a .adb file) is added to a library using sdcclib,
6581  it can be safely deleted, since all the information required for linking
6582  is embedded in the library file itself.
6583  Library files created using sdcclib are used as described in the preceding
6584  sections.
6585 \begin_inset VSpace bigskip
6586 \end_inset
6587
6588
6589 \end_layout
6590
6591 \begin_layout Section
6592 Command Line Options
6593 \begin_inset LatexCommand \index{Command Line Options}
6594
6595 \end_inset
6596
6597
6598 \begin_inset LatexCommand \label{sec:Command-Line-Options}
6599
6600 \end_inset
6601
6602
6603 \end_layout
6604
6605 \begin_layout Subsection
6606 Processor Selection Options
6607 \begin_inset LatexCommand \index{Options processor selection}
6608
6609 \end_inset
6610
6611
6612 \begin_inset LatexCommand \index{Processor selection options}
6613
6614 \end_inset
6615
6616
6617 \end_layout
6618
6619 \begin_layout List
6620 \labelwidthstring 00.00.0000
6621
6622 \series bold
6623 -mmcs51
6624 \begin_inset LatexCommand \index{-mmcs51}
6625
6626 \end_inset
6627
6628
6629 \series default
6630  Generate code for the Intel MCS51
6631 \begin_inset LatexCommand \index{MCS51}
6632
6633 \end_inset
6634
6635  family of processors.
6636  This is the default processor target.
6637 \end_layout
6638
6639 \begin_layout List
6640 \labelwidthstring 00.00.0000
6641
6642 \series bold
6643 -mds390
6644 \begin_inset LatexCommand \index{-mds390}
6645
6646 \end_inset
6647
6648
6649 \series default
6650  Generate code for the Dallas DS80C390
6651 \begin_inset LatexCommand \index{DS80C390}
6652
6653 \end_inset
6654
6655  processor.
6656 \end_layout
6657
6658 \begin_layout List
6659 \labelwidthstring 00.00.0000
6660
6661 \series bold
6662 -mds400
6663 \begin_inset LatexCommand \index{-mds400}
6664
6665 \end_inset
6666
6667
6668 \series default
6669  Generate code for the Dallas DS80C400
6670 \begin_inset LatexCommand \index{DS80C400}
6671
6672 \end_inset
6673
6674  processor.
6675 \end_layout
6676
6677 \begin_layout List
6678 \labelwidthstring 00.00.0000
6679
6680 \series bold
6681 -mhc08
6682 \begin_inset LatexCommand \index{-mhc08}
6683
6684 \end_inset
6685
6686
6687 \series default
6688  Generate code for the Freescale/Motorola HC08
6689 \begin_inset LatexCommand \index{HC08}
6690
6691 \end_inset
6692
6693  family of processors.
6694 \end_layout
6695
6696 \begin_layout List
6697 \labelwidthstring 00.00.0000
6698
6699 \series bold
6700 -mz80
6701 \begin_inset LatexCommand \index{-mz80}
6702
6703 \end_inset
6704
6705
6706 \series default
6707  Generate code for the Zilog Z80
6708 \begin_inset LatexCommand \index{Z80}
6709
6710 \end_inset
6711
6712  family of processors.
6713 \end_layout
6714
6715 \begin_layout List
6716 \labelwidthstring 00.00.0000
6717
6718 \series bold
6719 -mgbz80
6720 \begin_inset LatexCommand \index{-mgbz80}
6721
6722 \end_inset
6723
6724
6725 \series default
6726  Generate code for the GameBoy Z80
6727 \begin_inset LatexCommand \index{gbz80 (GameBoy Z80)}
6728
6729 \end_inset
6730
6731  processor (Not actively maintained).
6732 \end_layout
6733
6734 \begin_layout List
6735 \labelwidthstring 00.00.0000
6736
6737 \series bold
6738 -mavr
6739 \begin_inset LatexCommand \index{-mavr}
6740
6741 \end_inset
6742
6743
6744 \series default
6745  Generate code for the Atmel AVR
6746 \begin_inset LatexCommand \index{AVR}
6747
6748 \end_inset
6749
6750  processor (Not maintained, not complete).
6751  AVR users should probably have a look at winavr 
6752 \begin_inset LatexCommand \url{http://sourceforge.net/projects/winavr}
6753
6754 \end_inset
6755
6756  or 
6757 \begin_inset LatexCommand \url{http://www.avrfreaks.net/index.php?name=PNphpBB2&file=index}
6758
6759 \end_inset
6760
6761 , which is based on AVR-port of the gcc compiler.
6762 \end_layout
6763
6764 \begin_layout Standard
6765 \begin_inset Note Note
6766 status collapsed
6767
6768 \begin_layout Standard
6769 I think it is fair to direct users there for now.
6770  Open source is also about avoiding unnecessary work .
6771  But I didn't find the 'official' link.
6772 \end_layout
6773
6774 \end_inset
6775
6776
6777 \end_layout
6778
6779 \begin_layout List
6780 \labelwidthstring 00.00.0000
6781
6782 \series bold
6783 -mpic14
6784 \begin_inset LatexCommand \index{-mpic14}
6785
6786 \end_inset
6787
6788
6789 \series default
6790  Generate code for the Microchip PIC 14
6791 \begin_inset LatexCommand \index{PIC14}
6792
6793 \end_inset
6794
6795 -bit processors (p16f84 and variants.
6796  In development, not complete).
6797 \end_layout
6798
6799 \begin_layout Standard
6800 \begin_inset Note Note
6801 status collapsed
6802
6803 \begin_layout Standard
6804 p16f627 p16f628 p16f84 p16f873 p16f877?
6805 \end_layout
6806
6807 \end_inset
6808
6809
6810 \end_layout
6811
6812 \begin_layout List
6813 \labelwidthstring 00.00.0000
6814
6815 \series bold
6816 -mpic16
6817 \begin_inset LatexCommand \index{-mpic16}
6818
6819 \end_inset
6820
6821
6822 \series default
6823  Generate code for the Microchip PIC 16
6824 \begin_inset LatexCommand \index{PIC16}
6825
6826 \end_inset
6827
6828 -bit processors (p18f452 and variants.
6829  In development, not complete).
6830 \end_layout
6831
6832 \begin_layout List
6833 \labelwidthstring 00.00.0000
6834
6835 \series bold
6836 -mtlcs900h
6837 \series default
6838  Generate code for the Toshiba TLCS-900H
6839 \begin_inset LatexCommand \index{TLCS-900H}
6840
6841 \end_inset
6842
6843  processor (Not maintained, not complete).
6844 \end_layout
6845
6846 \begin_layout List
6847 \labelwidthstring 00.00.0000
6848
6849 \series bold
6850 -mxa51
6851 \begin_inset LatexCommand \index{-mxa51}
6852
6853 \end_inset
6854
6855
6856 \series default
6857  Generate code for the Phillips XA51
6858 \begin_inset LatexCommand \index{XA51}
6859
6860 \end_inset
6861
6862  processor (Not maintained, not complete).
6863 \end_layout
6864
6865 \begin_layout Standard
6866 \begin_inset VSpace bigskip
6867 \end_inset
6868
6869
6870 \end_layout
6871
6872 \begin_layout Subsection
6873 Preprocessor Options
6874 \begin_inset LatexCommand \index{Options preprocessor}
6875
6876 \end_inset
6877
6878
6879 \begin_inset LatexCommand \index{Preprocessor options}
6880
6881 \end_inset
6882
6883
6884 \begin_inset LatexCommand \index{sdcpp (preprocessor)}
6885
6886 \end_inset
6887
6888
6889 \end_layout
6890
6891 \begin_layout List
6892 \labelwidthstring 00.00.0000
6893
6894 \series bold
6895 -I<path>
6896 \begin_inset LatexCommand \index{-I<path>}
6897
6898 \end_inset
6899
6900
6901 \series default
6902  The additional location where the preprocessor will look for <..h> or 
6903 \begin_inset Quotes eld
6904 \end_inset
6905
6906 ..h
6907 \begin_inset Quotes erd
6908 \end_inset
6909
6910  files.
6911 \end_layout
6912
6913 \begin_layout List
6914 \labelwidthstring 00.00.0000
6915
6916 \series bold
6917 -D<macro[=value]>
6918 \begin_inset LatexCommand \index{-D<macro[=value]>}
6919
6920 \end_inset
6921
6922
6923 \series default
6924  Command line definition of macros.
6925  Passed to the preprocessor.
6926 \end_layout
6927
6928 \begin_layout List
6929 \labelwidthstring 00.00.0000
6930
6931 \series bold
6932 -M
6933 \begin_inset LatexCommand \index{-M}
6934
6935 \end_inset
6936
6937
6938 \series default
6939  Tell the preprocessor to output a rule suitable for make describing the
6940  dependencies of each object file.
6941  For each source file, the preprocessor outputs one make-rule whose target
6942  is the object file name for that source file and whose dependencies are
6943  all the files `#include'd in it.
6944  This rule may be a single line or may be continued with `
6945 \backslash
6946 '-newline if it is long.
6947  The list of rules is printed on standard output instead of the preprocessed
6948  C program.
6949  `-M' implies `-E
6950 \begin_inset LatexCommand \index{-E}
6951
6952 \end_inset
6953
6954 '.
6955 \end_layout
6956
6957 \begin_layout List
6958 \labelwidthstring 00.00.0000
6959
6960 \series bold
6961 -C
6962 \begin_inset LatexCommand \index{-C}
6963
6964 \end_inset
6965
6966
6967 \series default
6968  Tell the preprocessor not to discard comments.
6969  Used with the `-E' option.
6970 \end_layout
6971
6972 \begin_layout List
6973 \labelwidthstring 00.00.0000
6974
6975 \series bold
6976 -MM
6977 \begin_inset LatexCommand \index{-MM}
6978
6979 \end_inset
6980
6981
6982 \size large
6983 \bar under
6984  
6985 \series default
6986 \size default
6987 \bar default
6988 Like `-M' but the output mentions only the user header files included with
6989  `#include 
6990 \begin_inset Quotes eld
6991 \end_inset
6992
6993 file"'.
6994  System header files included with `#include <file>' are omitted.
6995 \end_layout
6996
6997 \begin_layout List
6998 \labelwidthstring 00.00.0000
6999
7000 \series bold
7001 -Aquestion(answer)
7002 \begin_inset LatexCommand \index{-Aquestion(answer)}
7003
7004 \end_inset
7005
7006
7007 \series default
7008  Assert the answer answer for question, in case it is tested with a preprocessor
7009  conditional such as `#if #question(answer)'.
7010  `-A-' disables the standard assertions that normally describe the target
7011  machine.
7012 \end_layout
7013
7014 \begin_layout List
7015 \labelwidthstring 00.00.0000
7016
7017 \series bold
7018 -Umacro
7019 \begin_inset LatexCommand \index{-Umacro}
7020
7021 \end_inset
7022
7023
7024 \series default
7025  Undefine macro macro.
7026  `-U' options are evaluated after all `-D' options, but before any `-include'
7027  and `-imacros' options.
7028 \end_layout
7029
7030 \begin_layout List
7031 \labelwidthstring 00.00.0000
7032
7033 \series bold
7034 -dM
7035 \begin_inset LatexCommand \index{-dM}
7036
7037 \end_inset
7038
7039
7040 \series default
7041  Tell the preprocessor to output only a list of the macro definitions that
7042  are in effect at the end of preprocessing.
7043  Used with the `-E' option.
7044 \end_layout
7045
7046 \begin_layout List
7047 \labelwidthstring 00.00.0000
7048
7049 \series bold
7050 -dD
7051 \begin_inset LatexCommand \index{-dD}
7052
7053 \end_inset
7054
7055
7056 \series default
7057  Tell the preprocessor to pass all macro definitions into the output, in
7058  their proper sequence in the rest of the output.
7059 \end_layout
7060
7061 \begin_layout List
7062 \labelwidthstring 00.00.0000
7063
7064 \series bold
7065 -dN
7066 \begin_inset LatexCommand \index{-dN}
7067
7068 \end_inset
7069
7070
7071 \size large
7072 \bar under
7073  
7074 \series default
7075 \size default
7076 \bar default
7077 Like `-dD' except that the macro arguments and contents are omitted.
7078  Only `#define name' is included in the output.
7079 \end_layout
7080
7081 \begin_layout List
7082 \labelwidthstring 00.00.0000
7083
7084 \series bold
7085 -pedantic-parse-number
7086 \begin_inset LatexCommand \index{pedantic}
7087
7088 \end_inset
7089
7090
7091 \begin_inset LatexCommand \index{-pedantic-parse-number}
7092
7093 \end_inset
7094
7095
7096 \size large
7097 \bar under
7098
7099 \begin_inset LatexCommand \label{lyx:-pedantic-parse-number}
7100
7101 \end_inset
7102
7103  
7104 \series default
7105 \size default
7106 \bar default
7107 Pedantic parse numbers so that situations like 0xfe-LO_B(3) are parsed properly
7108  and the macro LO_B(3) gets expanded.
7109  See also #pragma pedantic_parse_number 
7110 \begin_inset LatexCommand \vpageref{ite:pedantic_parse_number}
7111
7112 \end_inset
7113
7114  in section
7115 \begin_inset LatexCommand \ref{sec:Pragmas}
7116
7117 \end_inset
7118
7119  
7120 \emph on
7121 Note: this functionality is not in conformance with C99 standard!
7122 \end_layout
7123
7124 \begin_layout List
7125 \labelwidthstring 00.00.0000
7126
7127 \series bold
7128 -Wp\InsetSpace ~
7129 preprocessorOption[,preprocessorOption]
7130 \series default
7131
7132 \begin_inset LatexCommand \index{-Wp preprocessorOption[,preprocessorOption]}
7133
7134 \end_inset
7135
7136 ...
7137  Pass the preprocessorOption to the preprocessor 
7138 \family typewriter
7139 sdcpp
7140 \family default
7141
7142 \begin_inset LatexCommand \index{sdcpp (preprocessor)}
7143
7144 \end_inset
7145
7146 .
7147  SDCC uses an adapted version of the preprocessor 
7148 \emph on
7149 cpp
7150 \emph default
7151  of the GNU Compiler Collection
7152 \begin_inset LatexCommand \index{gcc (GNU Compiler Collection)}
7153
7154 \end_inset
7155
7156  (
7157 \emph on
7158 gcc
7159 \emph default
7160  
7161 \begin_inset LatexCommand \url{http://gcc.gnu.org/}
7162
7163 \end_inset
7164
7165 ), if you need more dedicated options please refer to the GCC\InsetSpace ~
7166 4.1.1\InsetSpace ~
7167 CPP\InsetSpace ~
7168 Manual
7169  at 
7170 \begin_inset LatexCommand \htmlurl{http://www.gnu.org/software/gcc/onlinedocs/}
7171
7172 \end_inset
7173
7174 .
7175 \end_layout
7176
7177 \begin_layout Standard
7178 \begin_inset VSpace bigskip
7179 \end_inset
7180
7181
7182 \end_layout
7183
7184 \begin_layout Subsection
7185 Linker Options
7186 \begin_inset LatexCommand \index{Options linker}
7187
7188 \end_inset
7189
7190
7191 \begin_inset LatexCommand \index{Linker options}
7192
7193 \end_inset
7194
7195
7196 \end_layout
7197
7198 \begin_layout List
7199 \labelwidthstring 00.00.0000
7200
7201 \series bold
7202 -L\InsetSpace ~
7203 -
7204 \series default
7205
7206 \begin_inset ERT
7207 status collapsed
7208
7209 \begin_layout Standard
7210
7211
7212 \backslash
7213 /
7214 \end_layout
7215
7216 \end_inset
7217
7218
7219 \series bold
7220 -lib-path
7221 \begin_inset LatexCommand \index{-\/-lib-path <path>}
7222
7223 \end_inset
7224
7225
7226 \begin_inset LatexCommand \index{-L -\/-lib-path}
7227
7228 \end_inset
7229
7230
7231 \series default
7232 \InsetSpace ~
7233 <absolute path to additional libraries> This option is passed to the linkage
7234  editor's additional libraries
7235 \begin_inset LatexCommand \index{Libraries}
7236
7237 \end_inset
7238
7239  search path.
7240  The path name must be absolute.
7241  Additional library files may be specified in the command line.
7242  See section Compiling programs for more details.
7243 \end_layout
7244
7245 \begin_layout List
7246 \labelwidthstring 00.00.0000
7247
7248 \series bold
7249 -
7250 \begin_inset ERT
7251 status collapsed
7252
7253 \begin_layout Standard
7254
7255
7256 \backslash
7257 /
7258 \end_layout
7259
7260 \end_inset
7261
7262 -xram-loc
7263 \series default
7264
7265 \begin_inset LatexCommand \index{-\/-xram-loc <Value>}
7266
7267 \end_inset
7268
7269 \InsetSpace ~
7270 <Value> The start location of the external ram
7271 \begin_inset LatexCommand \index{xdata (mcs51, ds390 storage class)}
7272
7273 \end_inset
7274
7275 , default value is 0.
7276  The value entered can be in Hexadecimal or Decimal format, e.g.: -
7277 \begin_inset ERT
7278 status collapsed
7279
7280 \begin_layout Standard
7281
7282
7283 \backslash
7284 /
7285 \end_layout
7286
7287 \end_inset
7288
7289 -xram-loc 0x8000 or -
7290 \begin_inset ERT
7291 status collapsed
7292
7293 \begin_layout Standard
7294
7295
7296 \backslash
7297 /
7298 \end_layout
7299
7300 \end_inset
7301
7302 -xram-loc 32768.
7303 \end_layout
7304
7305 \begin_layout List
7306 \labelwidthstring 00.00.0000
7307
7308 \series bold
7309 -
7310 \begin_inset ERT
7311 status collapsed
7312
7313 \begin_layout Standard
7314
7315
7316 \backslash
7317 /
7318 \end_layout
7319
7320 \end_inset
7321
7322 -code-loc
7323 \series default
7324
7325 \begin_inset LatexCommand \index{-\/-code-loc <Value>}
7326
7327 \end_inset
7328
7329 \InsetSpace ~
7330 <Value> The start location of the code
7331 \begin_inset LatexCommand \index{code}
7332
7333 \end_inset
7334
7335  segment, default value 0.
7336  Note when this option is used the interrupt vector table
7337 \begin_inset LatexCommand \index{interrupt vector table}
7338
7339 \end_inset
7340
7341  is also relocated to the given address.
7342  The value entered can be in Hexadecimal or Decimal format, e.g.: -
7343 \begin_inset ERT
7344 status collapsed
7345
7346 \begin_layout Standard
7347
7348
7349 \backslash
7350 /
7351 \end_layout
7352
7353 \end_inset
7354
7355 -code-loc 0x8000 or -
7356 \begin_inset ERT
7357 status collapsed
7358
7359 \begin_layout Standard
7360
7361
7362 \backslash
7363 /
7364 \end_layout
7365
7366 \end_inset
7367
7368 -code-loc 32768.
7369 \end_layout
7370
7371 \begin_layout List
7372 \labelwidthstring 00.00.0000
7373
7374 \series bold
7375 -
7376 \begin_inset ERT
7377 status collapsed
7378
7379 \begin_layout Standard
7380
7381
7382 \backslash
7383 /
7384 \end_layout
7385
7386 \end_inset
7387
7388 -stack-loc
7389 \series default
7390
7391 \begin_inset LatexCommand \index{-\/-stack-loc <Value>}
7392
7393 \end_inset
7394
7395 \InsetSpace ~
7396 <Value> By default the stack
7397 \begin_inset LatexCommand \index{stack}
7398
7399 \end_inset
7400
7401  is placed after the data segment.
7402  Using this option the stack can be placed anywhere in the internal memory
7403  space of the 8051.
7404  The value entered can be in Hexadecimal or Decimal format, e.g.
7405  -
7406 \begin_inset ERT
7407 status collapsed
7408
7409 \begin_layout Standard
7410
7411
7412 \backslash
7413 /
7414 \end_layout
7415
7416 \end_inset
7417
7418 -stack-loc 0x20 or -
7419 \begin_inset ERT
7420 status collapsed
7421
7422 \begin_layout Standard
7423
7424
7425 \backslash
7426 /
7427 \end_layout
7428
7429 \end_inset
7430
7431 -stack-loc 32.
7432  Since the sp register is incremented before a push or call, the initial
7433  sp will be set to one byte prior the provided value.
7434  The provided value should not overlap any other memory areas such as used
7435  register banks or the data segment and with enough space for the current
7436  application.
7437  The 
7438 \series bold
7439 -
7440 \begin_inset ERT
7441 status collapsed
7442
7443 \begin_layout Standard
7444
7445
7446 \backslash
7447 /
7448 \end_layout
7449
7450 \end_inset
7451
7452 -pack-iram
7453 \series default
7454 \InsetSpace ~
7455
7456 \begin_inset LatexCommand \index{-\/-pack-iram}
7457
7458 \end_inset
7459
7460  option (which is now a default setting) will override this setting, so
7461  you should also specify the 
7462 \series bold
7463 -
7464 \begin_inset ERT
7465 status collapsed
7466
7467 \begin_layout Standard
7468
7469
7470 \backslash
7471 /
7472 \end_layout
7473
7474 \end_inset
7475
7476 -no-pack-iram
7477 \series default
7478 \InsetSpace ~
7479
7480 \begin_inset LatexCommand \index{-\/-no-pack-iram}
7481
7482 \end_inset
7483
7484  option if you need to manually place the stack.
7485 \end_layout
7486
7487 \begin_layout List
7488 \labelwidthstring 00.00.0000
7489
7490 \series bold
7491 -
7492 \begin_inset ERT
7493 status collapsed
7494
7495 \begin_layout Standard
7496
7497
7498 \backslash
7499 /
7500 \end_layout
7501
7502 \end_inset
7503
7504 -xstack-loc
7505 \series default
7506
7507 \begin_inset LatexCommand \index{-\/-xstack-loc <Value>}
7508
7509 \end_inset
7510
7511 \InsetSpace ~
7512 <Value> By default the external stack
7513 \begin_inset LatexCommand \index{xstack}
7514
7515 \end_inset
7516
7517  is placed after the pdata
7518 \begin_inset LatexCommand \index{pdata (mcs51, ds390 storage class)}
7519
7520 \end_inset
7521
7522  segment.
7523  Using this option the xstack can be placed anywhere in the external memory
7524  space of the 8051.
7525  The value entered can be in Hexadecimal or Decimal format, e.g.
7526  -
7527 \begin_inset ERT
7528 status collapsed
7529
7530 \begin_layout Standard
7531
7532
7533 \backslash
7534 /
7535 \end_layout
7536
7537 \end_inset
7538
7539 -xstack-loc 0x8000 or -
7540 \begin_inset ERT
7541 status collapsed
7542
7543 \begin_layout Standard
7544
7545
7546 \backslash
7547 /
7548 \end_layout
7549
7550 \end_inset
7551
7552 -stack-loc 32768.
7553  The provided value should not overlap any other memory areas such as the
7554  pdata or xdata segment and with enough space for the current application.
7555 \end_layout
7556
7557 \begin_layout List
7558 \labelwidthstring 00.00.0000
7559
7560 \series bold
7561 -
7562 \begin_inset ERT
7563 status collapsed
7564
7565 \begin_layout Standard
7566
7567
7568 \backslash
7569 /
7570 \end_layout
7571
7572 \end_inset
7573
7574 -data-loc
7575 \series default
7576
7577 \begin_inset LatexCommand \index{-\/-data-loc <Value>}
7578
7579 \end_inset
7580
7581 \InsetSpace ~
7582 <Value> The start location of the internal ram data
7583 \begin_inset LatexCommand \index{data (mcs51, ds390 storage class)}
7584
7585 \end_inset
7586
7587  segment.
7588  The value entered can be in Hexadecimal or Decimal format, eg.
7589  -
7590 \begin_inset ERT
7591 status collapsed
7592
7593 \begin_layout Standard
7594
7595
7596 \backslash
7597 /
7598 \end_layout
7599
7600 \end_inset
7601
7602 -data-loc 0x20 or -
7603 \begin_inset ERT
7604 status collapsed
7605
7606 \begin_layout Standard
7607
7608
7609 \backslash
7610 /
7611 \end_layout
7612
7613 \end_inset
7614
7615 -data-loc 32.
7616  (By default, the start location of the internal ram data segment  is set
7617  as low as possible in memory, taking into account the used register banks
7618  and the bit segment at address 0x20.
7619  For example if register banks 0 and 1 are used without bit variables, the
7620  data segment will be set, if -
7621 \begin_inset ERT
7622 status collapsed
7623
7624 \begin_layout Standard
7625
7626
7627 \backslash
7628 /
7629 \end_layout
7630
7631 \end_inset
7632
7633 -data-loc is not used, to location 0x10.)
7634 \end_layout
7635
7636 \begin_layout List
7637 \labelwidthstring 00.00.0000
7638
7639 \series bold
7640 -
7641 \begin_inset ERT
7642 status collapsed
7643
7644 \begin_layout Standard
7645
7646
7647 \backslash
7648 /
7649 \end_layout
7650
7651 \end_inset
7652
7653 -idata-loc
7654 \series default
7655
7656 \begin_inset LatexCommand \index{-\/-idata-loc <Value>}
7657
7658 \end_inset
7659
7660 \InsetSpace ~
7661 <Value> The start location of the indirectly addressable internal ram
7662 \begin_inset LatexCommand \index{idata (mcs51, ds390 storage class)}
7663
7664 \end_inset
7665
7666  of the 8051, default value is 0x80.
7667  The value entered can be in Hexadecimal or Decimal format, eg.
7668  -
7669 \begin_inset ERT
7670 status collapsed
7671
7672 \begin_layout Standard
7673
7674
7675 \backslash
7676 /
7677 \end_layout
7678
7679 \end_inset
7680
7681 -idata-loc 0x88 or -
7682 \begin_inset ERT
7683 status collapsed
7684
7685 \begin_layout Standard
7686
7687
7688 \backslash
7689 /
7690 \end_layout
7691
7692 \end_inset
7693
7694 -idata-loc 136.
7695 \end_layout
7696
7697 \begin_layout List
7698 \labelwidthstring 00.00.0000
7699
7700 \series bold
7701 -
7702 \begin_inset ERT
7703 status collapsed
7704
7705 \begin_layout Standard
7706
7707
7708 \backslash
7709 /
7710 \end_layout
7711
7712 \end_inset
7713
7714 -bit-loc
7715 \series default
7716 \InsetSpace ~
7717 <Value> The start location of the bit
7718 \begin_inset LatexCommand \index{bit}
7719
7720 \end_inset
7721
7722  addressable internal ram of the 8051.
7723  This is 
7724 \emph on
7725 not
7726 \emph default
7727  implemented yet.
7728  Instead an option can be passed directly to the linker: -Wl\InsetSpace ~
7729 -bBSEG=<Value>.
7730 \end_layout
7731
7732 \begin_layout List
7733 \labelwidthstring 00.00.0000
7734
7735 \series bold
7736 -
7737 \begin_inset ERT
7738 status collapsed
7739
7740 \begin_layout Standard
7741
7742
7743 \backslash
7744 /
7745 \end_layout
7746
7747 \end_inset
7748
7749 -out-fmt-ihx
7750 \begin_inset LatexCommand \index{-\/-out-fmt-ihx}
7751
7752 \end_inset
7753
7754
7755 \bar under
7756  
7757 \series default
7758 \bar default
7759 The linker output (final object code) is in Intel Hex format.
7760 \begin_inset LatexCommand \index{Intel hex format}
7761
7762 \end_inset
7763
7764  This is the default option.
7765  The format itself is documented in the documentation of srecord
7766 \begin_inset LatexCommand \index{srecord (bin, hex, ... tool)}
7767
7768 \end_inset
7769
7770 .
7771 \end_layout
7772
7773 \begin_layout List
7774 \labelwidthstring 00.00.0000
7775
7776 \series bold
7777 -
7778 \begin_inset ERT
7779 status collapsed
7780
7781 \begin_layout Standard
7782
7783
7784 \backslash
7785 /
7786 \end_layout
7787
7788 \end_inset
7789
7790 -out-fmt-s19
7791 \begin_inset LatexCommand \index{-\/-out-fmt-s19}
7792
7793 \end_inset
7794
7795
7796 \bar under
7797  
7798 \series default
7799 \bar default
7800 The linker output (final object code) is in Motorola S19 format
7801 \begin_inset LatexCommand \index{Motorola S19 format}
7802
7803 \end_inset
7804
7805 .
7806  The format itself is documented in the documentation of srecord.
7807 \end_layout
7808
7809 \begin_layout List
7810 \labelwidthstring 00.00.0000
7811
7812 \series bold
7813 -
7814 \begin_inset ERT
7815 status collapsed
7816
7817 \begin_layout Standard
7818
7819
7820 \backslash
7821 /
7822 \end_layout
7823
7824 \end_inset
7825
7826 -out-fmt-elf
7827 \begin_inset LatexCommand \index{-\/-out-fmt-s19}
7828
7829 \end_inset
7830
7831
7832 \begin_inset LatexCommand \index{HC08!Options!-\/-out-fmt-elf}
7833
7834 \end_inset
7835
7836
7837 \bar under
7838  
7839 \series default
7840 \bar default
7841 The linker output (final object code) is in ELF format
7842 \begin_inset LatexCommand \index{ELF format}
7843
7844 \end_inset
7845
7846 .
7847  (Currently only supported for the HC08
7848 \begin_inset LatexCommand \index{HC08}
7849
7850 \end_inset
7851
7852  processors)
7853 \end_layout
7854
7855 \begin_layout List
7856 \labelwidthstring 00.00.0000
7857
7858 \series bold
7859 -Wl\InsetSpace ~
7860 linkOption[,linkOption]
7861 \series default
7862
7863 \begin_inset LatexCommand \index{-Wl linkOption[,linkOption]}
7864
7865 \end_inset
7866
7867 ...
7868  Pass the linkOption to the linker.
7869  If a bootloader is used an option like 
7870 \begin_inset Quotes sld
7871 \end_inset
7872
7873 -Wl\InsetSpace ~
7874 -bCSEG=0x1000
7875 \begin_inset Quotes srd
7876 \end_inset
7877
7878  would be typical to set the start of the code segment.
7879  See also #pragma constseg and #pragma codeseg in section 
7880 \begin_inset LatexCommand \ref{sec:Pragmas}
7881
7882 \end_inset
7883
7884  .
7885  File sdcc/as/doc/asxhtm.html has more on linker options.
7886 \end_layout
7887
7888 \begin_layout Standard
7889 \begin_inset VSpace bigskip
7890 \end_inset
7891
7892
7893 \end_layout
7894
7895 \begin_layout Subsection
7896 MCS51 Options
7897 \begin_inset LatexCommand \index{Options MCS51}
7898
7899 \end_inset
7900
7901
7902 \begin_inset LatexCommand \index{MCS51 options}
7903
7904 \end_inset
7905
7906
7907 \end_layout
7908
7909 \begin_layout List
7910 \labelwidthstring 00.00.0000
7911
7912 \series bold
7913 -
7914 \begin_inset ERT
7915 status collapsed
7916
7917 \begin_layout Standard
7918
7919
7920 \backslash
7921 /
7922 \end_layout
7923
7924 \end_inset
7925
7926 -model-small
7927 \begin_inset LatexCommand \index{-\/-model-small}
7928
7929 \end_inset
7930
7931
7932 \series default
7933 \size large
7934 \emph on
7935  
7936 \size default
7937 \emph default
7938 Generate code for Small Model programs, see section Memory Models for more
7939  details.
7940  This is the default model.
7941 \end_layout
7942
7943 \begin_layout List
7944 \labelwidthstring 00.00.0000
7945
7946 \series bold
7947 -
7948 \begin_inset ERT
7949 status collapsed
7950
7951 \begin_layout Standard
7952
7953
7954 \backslash
7955 /
7956 \end_layout
7957
7958 \end_inset
7959
7960 -model-medium
7961 \begin_inset LatexCommand \index{-\/-model-medium}
7962
7963 \end_inset
7964
7965
7966 \series default
7967  Generate code for Medium model programs, see section Memory Models for
7968  more details.
7969  If this option is used all source files in the project have to be compiled
7970  with this option.
7971  It must also be used when invoking the linker.
7972 \end_layout
7973
7974 \begin_layout List
7975 \labelwidthstring 00.00.0000
7976
7977 \series bold
7978 -
7979 \begin_inset ERT
7980 status collapsed
7981
7982 \begin_layout Standard
7983
7984
7985 \backslash
7986 /
7987 \end_layout
7988
7989 \end_inset
7990
7991 -model-large
7992 \begin_inset LatexCommand \index{-\/-model-large}
7993
7994 \end_inset
7995
7996
7997 \series default
7998  Generate code for Large model programs, see section Memory Models for more
7999  details.
8000  If this option is used all source files in the project have to be compiled
8001  with this option.
8002  It must also be used when invoking the linker.
8003 \end_layout
8004
8005 \begin_layout List
8006 \labelwidthstring 00.00.0000
8007
8008 \series bold
8009 -
8010 \begin_inset ERT
8011 status collapsed
8012
8013 \begin_layout Standard
8014
8015
8016 \backslash
8017 /
8018 \end_layout
8019
8020 \end_inset
8021
8022 -xstack
8023 \begin_inset LatexCommand \index{-\/-xstack}
8024
8025 \end_inset
8026
8027
8028 \series default
8029  Uses a pseudo stack in the pdata
8030 \begin_inset LatexCommand \index{pdata (mcs51, ds390 storage class)}
8031
8032 \end_inset
8033
8034  area (usually the first 256 bytes in the external ram) for allocating variables
8035  and passing parameters.
8036  See section 
8037 \begin_inset LatexCommand \ref{sub:External-Stack}
8038
8039 \end_inset
8040
8041 \InsetSpace ~
8042  External Stack for more details.
8043 \end_layout
8044
8045 \begin_layout List
8046 \labelwidthstring 00.00.0000
8047
8048 \series bold
8049 -
8050 \begin_inset ERT
8051 status collapsed
8052
8053 \begin_layout Standard
8054
8055
8056 \backslash
8057 /
8058 \end_layout
8059
8060 \end_inset
8061
8062 -iram-size
8063 \series default
8064 \InsetSpace ~
8065 <Value>
8066 \begin_inset LatexCommand \index{-\/-iram-size <Value>}
8067
8068 \end_inset
8069
8070  Causes the linker to check if the internal ram usage is within limits of
8071  the given value.
8072 \end_layout
8073
8074 \begin_layout List
8075 \labelwidthstring 00.00.0000
8076
8077 \series bold
8078 -
8079 \begin_inset ERT
8080 status collapsed
8081
8082 \begin_layout Standard
8083
8084
8085 \backslash
8086 /
8087 \end_layout
8088
8089 \end_inset
8090
8091 -xram-size
8092 \series default
8093 \InsetSpace ~
8094 <Value>
8095 \begin_inset LatexCommand \index{-\/-xram-size <Value>}
8096
8097 \end_inset
8098
8099  Causes the linker to check if the external ram usage is within limits of
8100  the given value.
8101 \end_layout
8102
8103 \begin_layout List
8104 \labelwidthstring 00.00.0000
8105
8106 \series bold
8107 -
8108 \begin_inset ERT
8109 status collapsed
8110
8111 \begin_layout Standard
8112
8113
8114 \backslash
8115 /
8116 \end_layout
8117
8118 \end_inset
8119
8120 -code-size
8121 \series default
8122 \InsetSpace ~
8123 <Value>
8124 \begin_inset LatexCommand \index{-\/-code-size <Value>}
8125
8126 \end_inset
8127
8128  Causes the linker to check if the code memory usage is within limits of
8129  the given value.
8130 \end_layout
8131
8132 \begin_layout List
8133 \labelwidthstring 00.00.0000
8134
8135 \series bold
8136 -
8137 \begin_inset ERT
8138 status collapsed
8139
8140 \begin_layout Standard
8141
8142
8143 \backslash
8144 /
8145 \end_layout
8146
8147 \end_inset
8148
8149 -stack-size
8150 \series default
8151 \InsetSpace ~
8152 <Value>
8153 \begin_inset LatexCommand \index{-\/-stack-size <Value>}
8154
8155 \end_inset
8156
8157  Causes the linker to check if there is at minimum <Value> bytes for stack.
8158 \end_layout
8159
8160 \begin_layout List
8161 \labelwidthstring 00.00.0000
8162
8163 \series bold
8164 -
8165 \begin_inset ERT
8166 status collapsed
8167
8168 \begin_layout Standard
8169
8170
8171 \backslash
8172 /
8173 \end_layout
8174
8175 \end_inset
8176
8177 -pack-iram
8178 \series default
8179 \InsetSpace ~
8180
8181 \begin_inset LatexCommand \index{-\/-pack-iram}
8182
8183 \end_inset
8184
8185  Causes the linker to use unused register banks for data variables and pack
8186  data, idata and stack together.
8187  This is the default now.
8188 \end_layout
8189
8190 \begin_layout List
8191 \labelwidthstring 00.00.0000
8192
8193 \series bold
8194 -
8195 \begin_inset ERT
8196 status collapsed
8197
8198 \begin_layout Standard
8199
8200
8201 \backslash
8202 /
8203 \end_layout
8204
8205 \end_inset
8206
8207 -no-pack-iram
8208 \series default
8209 \InsetSpace ~
8210
8211 \begin_inset LatexCommand \index{-\/-no-pack-iram}
8212
8213 \end_inset
8214
8215  Causes the linker to use old style for allocating memory areas.
8216 \end_layout
8217
8218 \begin_layout List
8219 \labelwidthstring 00.00.0000
8220
8221 \series bold
8222 -
8223 \begin_inset ERT
8224 status collapsed
8225
8226 \begin_layout Standard
8227
8228
8229 \backslash
8230 /
8231 \end_layout
8232
8233 \end_inset
8234
8235 -acall-ajmp
8236 \series default
8237 \InsetSpace ~
8238
8239 \begin_inset LatexCommand \index{-\/-acall-ajmp}
8240
8241 \end_inset
8242
8243  Replaces the three byte instructions lcall/ljmp with the two byte instructions
8244  acall/ajmp.
8245  Only use this option if your code is in the same 2k block of memory.
8246  You may need to use this option for some 8051 derivatives which lack the
8247  lcall/ljmp instructions..
8248 \end_layout
8249
8250 \begin_layout Standard
8251 \begin_inset VSpace bigskip
8252 \end_inset
8253
8254
8255 \end_layout
8256
8257 \begin_layout Subsection
8258 DS390 / DS400 Options
8259 \begin_inset LatexCommand \index{Options DS390}
8260
8261 \end_inset
8262
8263
8264 \begin_inset LatexCommand \index{DS390}
8265
8266 \end_inset
8267
8268
8269 \end_layout
8270
8271 \begin_layout List
8272 \labelwidthstring 00.00.0000
8273
8274 \series bold
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 -model-flat24
8289 \series default
8290
8291 \begin_inset LatexCommand \index{DS390!Options!-\/-model-flat24}
8292
8293 \end_inset
8294
8295
8296 \size large
8297 \emph on
8298  
8299 \size default
8300 \emph default
8301 Generate 24-bit flat mode code.
8302  This is the one and only that the ds390 code generator supports right now
8303  and is default when using 
8304 \emph on
8305 -mds390
8306 \emph default
8307 .
8308  See section Memory Models for more details.
8309 \end_layout
8310
8311 \begin_layout List
8312 \labelwidthstring 00.00.0000
8313
8314 \series bold
8315 -
8316 \begin_inset ERT
8317 status collapsed
8318
8319 \begin_layout Standard
8320
8321
8322 \backslash
8323 /
8324 \end_layout
8325
8326 \end_inset
8327
8328 -protect-sp-update
8329 \begin_inset LatexCommand \index{DS390!Options!-\/-protect-sp-update}
8330
8331 \end_inset
8332
8333
8334 \series default
8335  disable interrupts during ESP:SP updates.
8336 \end_layout
8337
8338 \begin_layout List
8339 \labelwidthstring 00.00.0000
8340
8341 \series bold
8342 -
8343 \begin_inset ERT
8344 status collapsed
8345
8346 \begin_layout Standard
8347
8348
8349 \backslash
8350 /
8351 \end_layout
8352
8353 \end_inset
8354
8355 -stack-10bit
8356 \series default
8357
8358 \begin_inset LatexCommand \index{DS390!Options!-\/-stack-10bit}
8359
8360 \end_inset
8361
8362  Generate code for the 10 bit stack mode of the Dallas DS80C390 part.
8363  This is the one and only that the ds390 code generator supports right now
8364  and is default when using 
8365 \emph on
8366 -mds390
8367 \emph default
8368 .
8369  In this mode, the stack is located in the lower 1K of the internal RAM,
8370  which is mapped to 0x400000.
8371  Note that the support is incomplete, since it still uses a single byte
8372  as the stack pointer.
8373  This means that only the lower 256 bytes of the potential 1K stack space
8374  will actually be used.
8375  However, this does allow you to reclaim the precious 256 bytes of low RAM
8376  for use for the DATA and IDATA segments.
8377  The compiler will not generate any code to put the processor into 10 bit
8378  stack mode.
8379  It is important to ensure that the processor is in this mode before calling
8380  any re-entrant functions compiled with this option.
8381  In principle, this should work with the 
8382 \emph on
8383 -
8384 \begin_inset ERT
8385 status collapsed
8386
8387 \begin_layout Standard
8388
8389
8390 \backslash
8391 /
8392 \end_layout
8393
8394 \end_inset
8395
8396 -stack-auto
8397 \begin_inset LatexCommand \index{-\/-stack-auto}
8398
8399 \end_inset
8400
8401
8402 \emph default
8403  option, but that has not been tested.
8404  It is incompatible with the 
8405 \emph on
8406 -
8407 \begin_inset ERT
8408 status collapsed
8409
8410 \begin_layout Standard
8411
8412
8413 \backslash
8414 /
8415 \end_layout
8416
8417 \end_inset
8418
8419 -xstack
8420 \begin_inset LatexCommand \index{-\/-xstack}
8421
8422 \end_inset
8423
8424
8425 \emph default
8426  option.
8427  It also only makes sense if the processor is in 24 bit contiguous addressing
8428  mode (see the 
8429 \emph on
8430 -
8431 \begin_inset ERT
8432 status collapsed
8433
8434 \begin_layout Standard
8435
8436
8437 \backslash
8438 /
8439 \end_layout
8440
8441 \end_inset
8442
8443 -model-flat24 option
8444 \emph default
8445 ).
8446 \series bold
8447
8448 \begin_inset Note Note
8449 status collapsed
8450
8451 \begin_layout List
8452 \labelwidthstring 00.00.0000
8453
8454 \series bold
8455 -
8456 \begin_inset ERT
8457 status open
8458
8459 \begin_layout Standard
8460
8461
8462 \backslash
8463 /
8464 \end_layout
8465
8466 \end_inset
8467
8468 -stack-8-bit - switches off the 10-bit mode
8469 \end_layout
8470
8471 \end_inset
8472
8473
8474 \end_layout
8475
8476 \begin_layout List
8477 \labelwidthstring 00.00.0000
8478
8479 \series bold
8480 -
8481 \begin_inset ERT
8482 status collapsed
8483
8484 \begin_layout Standard
8485
8486
8487 \backslash
8488 /
8489 \end_layout
8490
8491 \end_inset
8492
8493 -stack-probe
8494 \begin_inset LatexCommand \index{DS390!Options!-\/-stack-probe}
8495
8496 \end_inset
8497
8498
8499 \series default
8500  insert call to function __stack_probe at each function prologue.
8501 \end_layout
8502
8503 \begin_layout List
8504 \labelwidthstring 00.00.0000
8505
8506 \series bold
8507 -
8508 \begin_inset ERT
8509 status open
8510
8511 \begin_layout Standard
8512
8513
8514 \backslash
8515 /
8516 \end_layout
8517
8518 \end_inset
8519
8520 -tini-libid
8521 \begin_inset LatexCommand \index{DS390!Options!-\/-tini-libid}
8522
8523 \end_inset
8524
8525
8526 \series default
8527  <nnnn> LibraryID used in -mTININative.
8528  
8529 \end_layout
8530
8531 \begin_layout List
8532 \labelwidthstring 00.00.0000
8533
8534 \series bold
8535 -
8536 \begin_inset ERT
8537 status collapsed
8538
8539 \begin_layout Standard
8540
8541
8542 \backslash
8543 /
8544 \end_layout
8545
8546 \end_inset
8547
8548 -use-accelerator
8549 \begin_inset LatexCommand \index{DS390!Options!-\/-use-accelerator}
8550
8551 \end_inset
8552
8553
8554 \series default
8555  generate code for DS390 Arithmetic Accelerator.
8556  
8557 \end_layout
8558
8559 \begin_layout Standard
8560 \begin_inset VSpace bigskip
8561 \end_inset
8562
8563
8564 \end_layout
8565
8566 \begin_layout Subsection
8567 Z80 Options
8568 \begin_inset LatexCommand \index{Options Z80}
8569
8570 \end_inset
8571
8572
8573 \begin_inset LatexCommand \index{Z80}
8574
8575 \end_inset
8576
8577
8578 \end_layout
8579
8580 \begin_layout List
8581 \labelwidthstring 00.00.0000
8582
8583 \series bold
8584 -
8585 \begin_inset ERT
8586 status collapsed
8587
8588 \begin_layout Standard
8589
8590
8591 \backslash
8592 /
8593 \end_layout
8594
8595 \end_inset
8596
8597 -callee-saves-bc
8598 \series default
8599
8600 \begin_inset LatexCommand \index{Z80!Options!-\/-callee-saves-bc}
8601
8602 \end_inset
8603
8604
8605 \size large
8606 \emph on
8607  
8608 \size default
8609 \emph default
8610 Force a called function to always save BC.
8611 \end_layout
8612
8613 \begin_layout List
8614 \labelwidthstring 00.00.0000
8615
8616 \series bold
8617 -
8618 \begin_inset ERT
8619 status collapsed
8620
8621 \begin_layout Standard
8622
8623
8624 \backslash
8625 /
8626 \end_layout
8627
8628 \end_inset
8629
8630 -no-std-crt0
8631 \series default
8632
8633 \begin_inset LatexCommand \index{Z80!Options!-\/-no-std-crt0}
8634
8635 \end_inset
8636
8637  When linking, skip the standard crt0.o object file.
8638  You must provide your own crt0.o for your system when linking.
8639 \end_layout
8640
8641 \begin_layout List
8642 \labelwidthstring 00.00.0000
8643
8644 \series bold
8645 -
8646 \begin_inset ERT
8647 status collapsed
8648
8649 \begin_layout Standard
8650
8651
8652 \backslash
8653 /
8654 \end_layout
8655
8656 \end_inset
8657
8658 -portmode=
8659 \series default
8660 <Value>
8661 \begin_inset LatexCommand \index{Z80!Options!-\/-portmode=<Value>}
8662
8663 \end_inset
8664
8665  Determinate PORT I/O mode (<Value> is z80 or z180).
8666 \end_layout
8667
8668 \begin_layout List
8669 \labelwidthstring 00.00.0000
8670
8671 \series bold
8672 -
8673 \begin_inset ERT
8674 status collapsed
8675
8676 \begin_layout Standard
8677
8678
8679 \backslash
8680 /
8681 \end_layout
8682
8683 \end_inset
8684
8685 -asm=
8686 \series default
8687 <Value>
8688 \begin_inset LatexCommand \index{Z80!Options!-\/-asm=<Value>}
8689
8690 \end_inset
8691
8692  Define assembler name (<Value> is rgbds, asxxxx, isas or z80asm).
8693 \end_layout
8694
8695 \begin_layout List
8696 \labelwidthstring 00.00.0000
8697
8698 \series bold
8699 -
8700 \begin_inset ERT
8701 status collapsed
8702
8703 \begin_layout Standard
8704
8705
8706 \backslash
8707 /
8708 \end_layout
8709
8710 \end_inset
8711
8712 -codeseg
8713 \series default
8714 \InsetSpace ~
8715 <Value>
8716 \begin_inset LatexCommand \index{Z80!Options!-\/-codeseg <Value>}
8717
8718 \end_inset
8719
8720  Use <Value> for the code segment name.
8721 \end_layout
8722
8723 \begin_layout List
8724 \labelwidthstring 00.00.0000
8725
8726 \series bold
8727 -
8728 \begin_inset ERT
8729 status collapsed
8730
8731 \begin_layout Standard
8732
8733
8734 \backslash
8735 /
8736 \end_layout
8737
8738 \end_inset
8739
8740 -constseg
8741 \series default
8742 \InsetSpace ~
8743 <Value>
8744 \begin_inset LatexCommand \index{Z80!Options!-\/-constseg <Value>}
8745
8746 \end_inset
8747
8748  Use <Value> for the const segment name.
8749 \end_layout
8750
8751 \begin_layout List
8752 \labelwidthstring 00.00.0000
8753 \begin_inset VSpace bigskip
8754 \end_inset
8755
8756
8757 \end_layout
8758
8759 \begin_layout Subsection
8760 GBZ80 Options
8761 \begin_inset LatexCommand \index{Options GBZ80}
8762
8763 \end_inset
8764
8765
8766 \begin_inset LatexCommand \index{GBZ80}
8767
8768 \end_inset
8769
8770
8771 \end_layout
8772
8773 \begin_layout List
8774 \labelwidthstring 00.00.0000
8775
8776 \series bold
8777 -
8778 \begin_inset ERT
8779 status collapsed
8780
8781 \begin_layout Standard
8782
8783
8784 \backslash
8785 /
8786 \end_layout
8787
8788 \end_inset
8789
8790 -callee-saves-bc
8791 \series default
8792
8793 \begin_inset LatexCommand \index{GBZ80!Options!-\/-callee-saves-bc}
8794
8795 \end_inset
8796
8797
8798 \size large
8799 \emph on
8800  
8801 \size default
8802 \emph default
8803 Force a called function to always save BC.
8804 \end_layout
8805
8806 \begin_layout List
8807 \labelwidthstring 00.00.0000
8808
8809 \series bold
8810 -bo
8811 \series default
8812 \InsetSpace ~
8813 <Num>
8814 \begin_inset LatexCommand \index{GBZ80!Options!-bo <Num>}
8815
8816 \end_inset
8817
8818  Use code bank <Num>.
8819 \end_layout
8820
8821 \begin_layout List
8822 \labelwidthstring 00.00.0000
8823
8824 \series bold
8825 -ba
8826 \series default
8827 \InsetSpace ~
8828 <Num>
8829 \begin_inset LatexCommand \index{GBZ80!Options!-ba <Num>}
8830
8831 \end_inset
8832
8833  Use data bank <Num>.
8834 \end_layout
8835
8836 \begin_layout List
8837 \labelwidthstring 00.00.0000
8838
8839 \series bold
8840 -
8841 \begin_inset ERT
8842 status collapsed
8843
8844 \begin_layout Standard
8845
8846
8847 \backslash
8848 /
8849 \end_layout
8850
8851 \end_inset
8852
8853 -codeseg
8854 \series default
8855 \InsetSpace ~
8856 <Value>
8857 \begin_inset LatexCommand \index{GBZ80!Options!-\/-codeseg <Value>}
8858
8859 \end_inset
8860
8861  Use <Value> for the code segment name.
8862 \end_layout
8863
8864 \begin_layout List
8865 \labelwidthstring 00.00.0000
8866
8867 \series bold
8868 -
8869 \begin_inset ERT
8870 status collapsed
8871
8872 \begin_layout Standard
8873
8874
8875 \backslash
8876 /
8877 \end_layout
8878
8879 \end_inset
8880
8881 -constseg
8882 \series default
8883 \InsetSpace ~
8884 <Value>
8885 \begin_inset LatexCommand \index{GBZ80!Options!-\/-constseg <Value>}
8886
8887 \end_inset
8888
8889  Use <Value> for the const segment name.
8890 \end_layout
8891
8892 \begin_layout Standard
8893 \begin_inset VSpace bigskip
8894 \end_inset
8895
8896
8897 \end_layout
8898
8899 \begin_layout Subsection
8900 Optimization Options
8901 \begin_inset LatexCommand \index{Options optimization}
8902
8903 \end_inset
8904
8905
8906 \begin_inset LatexCommand \index{Optimization options}
8907
8908 \end_inset
8909
8910
8911 \end_layout
8912
8913 \begin_layout List
8914 \labelwidthstring 00.00.0000
8915
8916 \series bold
8917 -
8918 \begin_inset ERT
8919 status collapsed
8920
8921 \begin_layout Standard
8922
8923
8924 \backslash
8925 /
8926 \end_layout
8927
8928 \end_inset
8929
8930 -nogcse
8931 \begin_inset LatexCommand \index{-\/-nogcse}
8932
8933 \end_inset
8934
8935
8936 \series default
8937  Will not do global subexpression elimination, this option may be used when
8938  the compiler creates undesirably large stack/data spaces to store compiler
8939  temporaries (
8940 \emph on
8941 s
8942 \emph default
8943 pill 
8944 \emph on
8945 loc
8946 \emph default
8947 ations, sloc
8948 \begin_inset LatexCommand \index{sloc (spill location)}
8949
8950 \end_inset
8951
8952 ).
8953  A warning message will be generated when this happens and the compiler
8954  will indicate the number of extra bytes it allocated.
8955  It is recommended that this option NOT be used, #pragma\InsetSpace ~
8956 nogcse
8957 \begin_inset LatexCommand \index{\#pragma nogcse}
8958
8959 \end_inset
8960
8961  can be used to turn off global subexpression elimination
8962 \begin_inset LatexCommand \index{Subexpression elimination}
8963
8964 \end_inset
8965
8966  for a given function only.
8967 \end_layout
8968
8969 \begin_layout List
8970 \labelwidthstring 00.00.0000
8971
8972 \series bold
8973 -
8974 \begin_inset ERT
8975 status collapsed
8976
8977 \begin_layout Standard
8978
8979
8980 \backslash
8981 /
8982 \end_layout
8983
8984 \end_inset
8985
8986 -noinvariant
8987 \begin_inset LatexCommand \index{-\/-noinvariant}
8988
8989 \end_inset
8990
8991
8992 \series default
8993  Will not do loop invariant optimizations, this may be turned off for reasons
8994  explained for the previous option.
8995  For more details of loop optimizations performed see Loop Invariants in
8996  section 
8997 \begin_inset LatexCommand \ref{sub:Loop-Optimizations}
8998
8999 \end_inset
9000
9001 .
9002  It is recommended that this option NOT be used, #pragma\InsetSpace ~
9003 noinvariant
9004 \begin_inset LatexCommand \index{\#pragma noinvariant}
9005
9006 \end_inset
9007
9008  can be used to turn off invariant optimizations for a given function only.
9009 \end_layout
9010
9011 \begin_layout List
9012 \labelwidthstring 00.00.0000
9013
9014 \series bold
9015 -
9016 \begin_inset ERT
9017 status collapsed
9018
9019 \begin_layout Standard
9020
9021
9022 \backslash
9023 /
9024 \end_layout
9025
9026 \end_inset
9027
9028 -noinduction
9029 \begin_inset LatexCommand \index{-\/-noinduction}
9030
9031 \end_inset
9032
9033
9034 \series default
9035  Will not do loop induction optimizations, see section strength reduction
9036  for more details.
9037  It is recommended that this option is NOT used, #pragma\InsetSpace ~
9038 noinduction
9039 \begin_inset LatexCommand \index{\#pragma noinduction}
9040
9041 \end_inset
9042
9043  can be used to turn off induction optimizations for a given function only.
9044 \end_layout
9045
9046 \begin_layout List
9047 \labelwidthstring 00.00.0000
9048
9049 \series bold
9050 -
9051 \begin_inset ERT
9052 status collapsed
9053
9054 \begin_layout Standard
9055
9056
9057 \backslash
9058 /
9059 \end_layout
9060
9061 \end_inset
9062
9063 -nojtbound
9064 \begin_inset LatexCommand \index{-\/-nojtbound}
9065
9066 \end_inset
9067
9068
9069 \size large
9070 \bar under
9071  
9072 \series default
9073 \size default
9074 \bar default
9075  Will not generate boundary condition check when switch statements
9076 \begin_inset LatexCommand \index{switch statement}
9077
9078 \end_inset
9079
9080  are implemented using jump-tables.
9081  See section 
9082 \begin_inset LatexCommand \ref{sub:'switch'-Statements}
9083
9084 \end_inset
9085
9086 \InsetSpace ~
9087 Switch Statements for more details.
9088  It is recommended that this option is NOT used, #pragma\InsetSpace ~
9089 nojtbound
9090 \begin_inset LatexCommand \index{\#pragma nojtbound}
9091
9092 \end_inset
9093
9094  can be used to turn off boundary checking for jump tables for a given function
9095  only.
9096 \end_layout
9097
9098 \begin_layout List
9099 \labelwidthstring 00.00.0000
9100
9101 \series bold
9102 -
9103 \begin_inset ERT
9104 status collapsed
9105
9106 \begin_layout Standard
9107
9108
9109 \backslash
9110 /
9111 \end_layout
9112
9113 \end_inset
9114
9115 -noloopreverse
9116 \begin_inset LatexCommand \index{-\/-noloopreverse}
9117
9118 \end_inset
9119
9120
9121 \series default
9122 \size large
9123  
9124 \size default
9125 Will not do loop reversal 
9126 \begin_inset LatexCommand \index{Loop reversing}
9127
9128 \end_inset
9129
9130 optimization.
9131 \end_layout
9132
9133 \begin_layout List
9134 \labelwidthstring 00.00.0000
9135 -
9136 \begin_inset ERT
9137 status collapsed
9138
9139 \begin_layout Standard
9140
9141
9142 \backslash
9143 /
9144 \end_layout
9145
9146 \end_inset
9147
9148 -
9149 \series bold
9150 nolabelopt
9151 \series default
9152  
9153 \begin_inset LatexCommand \index{-\/-nolabelopt }
9154
9155 \end_inset
9156
9157 Will not optimize labels (makes the dumpfiles more readable).
9158 \end_layout
9159
9160 \begin_layout List
9161 \labelwidthstring 00.00.0000
9162
9163 \series bold
9164 -
9165 \begin_inset ERT
9166 status collapsed
9167
9168 \begin_layout Standard
9169
9170
9171 \backslash
9172 /
9173 \end_layout
9174
9175 \end_inset
9176
9177 -no-xinit-opt
9178 \begin_inset LatexCommand \index{-\/-no-xinit-opt}
9179
9180 \end_inset
9181
9182
9183 \series default
9184  Will not memcpy initialized data from code space into xdata space.
9185  This saves a few bytes in code space if you don't have initialized data
9186 \begin_inset LatexCommand \index{Variable initialization}
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 -nooverlay
9211 \begin_inset LatexCommand \index{-\/-nooverlay}
9212
9213 \end_inset
9214
9215
9216 \series default
9217   The compiler will not overlay parameters and local variables of any function,
9218  see section Parameters and local variables for more details.
9219 \end_layout
9220
9221 \begin_layout List
9222 \labelwidthstring 00.00.0000
9223
9224 \series bold
9225 -
9226 \begin_inset ERT
9227 status collapsed
9228
9229 \begin_layout Standard
9230
9231
9232 \backslash
9233 /
9234 \end_layout
9235
9236 \end_inset
9237
9238 -no-peep
9239 \begin_inset LatexCommand \index{-\/-no-peep}
9240
9241 \end_inset
9242
9243
9244 \series default
9245  Disable peep-hole optimization with built-in rules.
9246 \end_layout
9247
9248 \begin_layout List
9249 \labelwidthstring 00.00.0000
9250
9251 \series bold
9252 -
9253 \begin_inset ERT
9254 status collapsed
9255
9256 \begin_layout Standard
9257
9258
9259 \backslash
9260 /
9261 \end_layout
9262
9263 \end_inset
9264
9265 -peep-file
9266 \series default
9267
9268 \begin_inset LatexCommand \index{-\/-peep-file}
9269
9270 \end_inset
9271
9272 \InsetSpace ~
9273 <filename> This option can be used to use additional rules to be used by
9274  the peep hole optimizer.
9275  See section 
9276 \begin_inset LatexCommand \ref{sub:Peephole-Optimizer}
9277
9278 \end_inset
9279
9280 \InsetSpace ~
9281 Peep Hole optimizations for details on how to write these rules.
9282 \end_layout
9283
9284 \begin_layout List
9285 \labelwidthstring 00.00.0000
9286
9287 \series bold
9288 -
9289 \begin_inset ERT
9290 status collapsed
9291
9292 \begin_layout Standard
9293
9294
9295 \backslash
9296 /
9297 \end_layout
9298
9299 \end_inset
9300
9301 -peep-asm
9302 \begin_inset LatexCommand \index{-\/-peep-asm}
9303
9304 \end_inset
9305
9306
9307 \series default
9308  Pass the inline assembler code through the peep hole optimizer.
9309  This can cause unexpected changes to inline assembler code, please go through
9310  the peephole optimizer
9311 \begin_inset LatexCommand \index{Peephole optimizer}
9312
9313 \end_inset
9314
9315  rules defined in the source file tree '<target>/peeph.def' before using
9316  this option.
9317 \end_layout
9318
9319 \begin_layout List
9320 \labelwidthstring 00.00.0000
9321
9322 \series bold
9323 -
9324 \begin_inset ERT
9325 status collapsed
9326
9327 \begin_layout Standard
9328
9329
9330 \backslash
9331 /
9332 \end_layout
9333
9334 \end_inset
9335
9336 -opt-code-speed
9337 \begin_inset LatexCommand \index{-\/-opt-code-speed}
9338
9339 \end_inset
9340
9341
9342 \series default
9343  The compiler will optimize code generation towards fast code, possibly
9344  at the expense of code size.
9345 \end_layout
9346
9347 \begin_layout List
9348 \labelwidthstring 00.00.0000
9349
9350 \series bold
9351 -
9352 \begin_inset ERT
9353 status collapsed
9354
9355 \begin_layout Standard
9356
9357
9358 \backslash
9359 /
9360 \end_layout
9361
9362 \end_inset
9363
9364 -opt-code-size
9365 \begin_inset LatexCommand \index{-\/-opt-code-size}
9366
9367 \end_inset
9368
9369
9370 \series default
9371  The compiler will optimize code generation towards compact code, possibly
9372  at the expense of code speed.
9373 \end_layout
9374
9375 \begin_layout Standard
9376 \begin_inset VSpace bigskip
9377 \end_inset
9378
9379
9380 \end_layout
9381
9382 \begin_layout Subsection
9383 Other Options
9384 \begin_inset LatexCommand \index{Options other}
9385
9386 \end_inset
9387
9388
9389 \end_layout
9390
9391 \begin_layout List
9392 \labelwidthstring 00.00.0000
9393
9394 \series bold
9395 -c\InsetSpace ~
9396 -
9397 \begin_inset ERT
9398 status collapsed
9399
9400 \begin_layout Standard
9401
9402
9403 \backslash
9404 /
9405 \end_layout
9406
9407 \end_inset
9408
9409 -compile-only
9410 \begin_inset LatexCommand \index{-\/-compile-only}
9411
9412 \end_inset
9413
9414
9415 \begin_inset LatexCommand \index{-c -\/-compile-only}
9416
9417 \end_inset
9418
9419
9420 \series default
9421  will compile and assemble the source, but will not call the linkage editor.
9422 \end_layout
9423
9424 \begin_layout List
9425 \labelwidthstring 00.00.0000
9426
9427 \series bold
9428 -
9429 \series default
9430
9431 \begin_inset ERT
9432 status collapsed
9433
9434 \begin_layout Standard
9435
9436
9437 \backslash
9438 /
9439 \end_layout
9440
9441 \end_inset
9442
9443
9444 \series bold
9445 -c1mode
9446 \begin_inset LatexCommand \index{-\/-c1mode}
9447
9448 \end_inset
9449
9450
9451 \series default
9452  reads the preprocessed source from standard input and compiles it.
9453  The file name for the assembler output must be specified using the -o option.
9454 \end_layout
9455
9456 \begin_layout List
9457 \labelwidthstring 00.00.0000
9458
9459 \series bold
9460 -E
9461 \begin_inset LatexCommand \index{-E}
9462
9463 \end_inset
9464
9465
9466 \series default
9467  Run only the C preprocessor.
9468  Preprocess all the C source files specified and output the results to standard
9469  output.
9470 \end_layout
9471
9472 \begin_layout List
9473 \labelwidthstring 00.00.0000
9474
9475 \series bold
9476 -o\InsetSpace ~
9477 <path/file>
9478 \begin_inset LatexCommand \index{-o <path/file>}
9479
9480 \end_inset
9481
9482  
9483 \series default
9484 The output path where everything will be placed or the file name used for
9485  all generated output files.
9486  If the parameter is a path, it must have a trailing slash (or backslash
9487  for the Windows binaries) to be recognized as a path.
9488
9489 \emph on
9490  
9491 \emph default
9492 Note for Windows users: if the path contains spaces, it should be surrounded
9493  by quotes.
9494  The trailing backslash should be doubled in order to prevent escaping the
9495  final quote, for example: 
9496 \emph on
9497 -o 
9498 \begin_inset Quotes sld
9499 \end_inset
9500
9501 F:
9502 \backslash
9503 Projects
9504 \backslash
9505 test3
9506 \backslash
9507 output 1
9508 \backslash
9509
9510 \backslash
9511
9512 \begin_inset Quotes srd
9513 \end_inset
9514
9515
9516 \emph default
9517  or put after the final quote, for example: 
9518 \emph on
9519 -o 
9520 \begin_inset Quotes sld
9521 \end_inset
9522
9523 F:
9524 \backslash
9525 Projects
9526 \backslash
9527 test3
9528 \backslash
9529 output 1
9530 \begin_inset Quotes srd
9531 \end_inset
9532
9533
9534 \backslash
9535
9536 \emph default
9537 .
9538  The path using slashes for directory delimiters can be used too, for example:
9539  
9540 \emph on
9541 -o 
9542 \begin_inset Quotes sld
9543 \end_inset
9544
9545 F:/Projects/test3/output 1/
9546 \begin_inset Quotes srd
9547 \end_inset
9548
9549
9550 \emph default
9551 .
9552 \end_layout
9553
9554 \begin_layout List
9555 \labelwidthstring 00.00.0000
9556
9557 \series bold
9558 -
9559 \begin_inset ERT
9560 status collapsed
9561
9562 \begin_layout Standard
9563
9564
9565 \backslash
9566 /
9567 \end_layout
9568
9569 \end_inset
9570
9571 -stack-auto
9572 \begin_inset LatexCommand \index{-\/-stack-auto}
9573
9574 \end_inset
9575
9576
9577 \series default
9578 \size large
9579 \emph on
9580  
9581 \size default
9582 \emph default
9583 All functions in the source file will be compiled as 
9584 \emph on
9585 reentrant
9586 \emph default
9587
9588 \begin_inset LatexCommand \index{reentrant}
9589
9590 \end_inset
9591
9592 , i.e.
9593  the parameters and local variables will be allocated on the stack
9594 \begin_inset LatexCommand \index{stack}
9595
9596 \end_inset
9597
9598 .
9599  See section 
9600 \begin_inset LatexCommand \ref{sec:Parameters-and-Local-Variables}
9601
9602 \end_inset
9603
9604  Parameters and Local Variables for more details.
9605  If this option is used all source files in the project should be compiled
9606  with this option.
9607  It automatically implies -
9608 \series bold
9609
9610 \begin_inset ERT
9611 status open
9612
9613 \begin_layout Standard
9614
9615
9616 \backslash
9617 /
9618 \end_layout
9619
9620 \end_inset
9621
9622
9623 \series default
9624 -int-long-reent and -
9625 \series bold
9626
9627 \begin_inset ERT
9628 status open
9629
9630 \begin_layout Standard
9631
9632
9633 \backslash
9634 /
9635 \end_layout
9636
9637 \end_inset
9638
9639
9640 \series default
9641 -float-reent.
9642  
9643 \end_layout
9644
9645 \begin_layout List
9646 \labelwidthstring 00.00.0000
9647
9648 \series bold
9649 -
9650 \begin_inset ERT
9651 status collapsed
9652
9653 \begin_layout Standard
9654
9655
9656 \backslash
9657 /
9658 \end_layout
9659
9660 \end_inset
9661
9662 -callee-saves
9663 \begin_inset LatexCommand \index{-\/-callee-saves}
9664
9665 \end_inset
9666
9667  
9668 \begin_inset LatexCommand \label{lyx:--callee-saves-function1[,function2][,function3]...}
9669
9670 \end_inset
9671
9672 function1[,function2][,function3]....
9673
9674 \series default
9675  The compiler by default uses a caller saves convention for register saving
9676  across function calls, however this can cause unnecessary register pushing
9677  and popping when calling small functions from larger functions.
9678  This option can be used to switch the register saving convention for the
9679  function names specified.
9680  The compiler will not save registers when calling these functions, no extra
9681  code will be generated at the entry and exit (function prologue
9682 \series bold
9683
9684 \begin_inset LatexCommand \index{function prologue}
9685
9686 \end_inset
9687
9688
9689 \series default
9690  and epilogue
9691 \series bold
9692
9693 \begin_inset LatexCommand \index{function epilogue}
9694
9695 \end_inset
9696
9697
9698 \series default
9699 ) for these functions to save and restore the registers used by these functions,
9700  this can SUBSTANTIALLY reduce code and improve run time performance of
9701  the generated code.
9702  In the future the compiler (with inter procedural analysis) will be able
9703  to determine the appropriate scheme to use for each function call.
9704  DO NOT use this option for built-in functions such as _mulint..., if this
9705  option is used for a library function the appropriate library function
9706  needs to be recompiled with the same option.
9707  If the project consists of multiple source files then all the source file
9708  should be compiled with the same -
9709 \begin_inset ERT
9710 status collapsed
9711
9712 \begin_layout Standard
9713
9714
9715 \backslash
9716 /
9717 \end_layout
9718
9719 \end_inset
9720
9721 -callee-saves option string.
9722  Also see #pragma\InsetSpace ~
9723 callee_saves 
9724 \begin_inset LatexCommand \index{\#pragma callee\_saves}
9725
9726 \end_inset
9727
9728  
9729 \begin_inset LatexCommand \vpageref{ite:callee_saves-function1[,function2[,function3...]]--}
9730
9731 \end_inset
9732
9733 .
9734 \end_layout
9735
9736 \begin_layout List
9737 \labelwidthstring 00.00.0000
9738
9739 \series bold
9740 -
9741 \begin_inset ERT
9742 status collapsed
9743
9744 \begin_layout Standard
9745
9746
9747 \backslash
9748 /
9749 \end_layout
9750
9751 \end_inset
9752
9753 -all-callee-saves
9754 \begin_inset LatexCommand \index{-\/-all-callee-saves}
9755
9756 \end_inset
9757
9758  
9759 \series default
9760 Function of
9761 \series bold
9762  
9763 \series default
9764 -
9765 \begin_inset ERT
9766 status collapsed
9767
9768 \begin_layout Standard
9769
9770
9771 \backslash
9772 /
9773 \end_layout
9774
9775 \end_inset
9776
9777 -callee-saves will be applied to all functions by default.
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 -debug
9798 \begin_inset LatexCommand \index{-\/-debug}
9799
9800 \end_inset
9801
9802
9803 \bar under
9804  
9805 \series default
9806 \bar default
9807 When this option is used the compiler will generate debug information.
9808  The debug information collected in a file with .cdb extension can be used
9809  with the SDCDB.
9810  For more information see documentation for SDCDB.
9811  Another file with no extension contains debug information in AOMF or AOMF51
9812 \begin_inset LatexCommand \index{AOMF, AOMF51}
9813
9814 \end_inset
9815
9816  format which is commonly used by third party tools.
9817 \end_layout
9818
9819 \begin_layout List
9820 \labelwidthstring 00.00.0000
9821
9822 \series bold
9823 -S
9824 \begin_inset LatexCommand \index{-S}
9825
9826 \end_inset
9827
9828
9829 \size large
9830 \bar under
9831  
9832 \series default
9833 \size default
9834 \bar default
9835 Stop after the stage of compilation proper; do not assemble.
9836  The output is an assembler code file for the input file specified.
9837 \end_layout
9838
9839 \begin_layout List
9840 \labelwidthstring 00.00.0000
9841
9842 \series bold
9843 -
9844 \begin_inset ERT
9845 status collapsed
9846
9847 \begin_layout Standard
9848
9849
9850 \backslash
9851 /
9852 \end_layout
9853
9854 \end_inset
9855
9856 -int-long-reent
9857 \begin_inset LatexCommand \index{-\/-int-long-reent}
9858
9859 \end_inset
9860
9861
9862 \series default
9863  Integer (16 bit) and long (32 bit) libraries have been compiled as reentrant.
9864  Note by default these libraries are compiled as non-reentrant.
9865  See section Installation for more details.
9866 \end_layout
9867
9868 \begin_layout List
9869 \labelwidthstring 00.00.0000
9870
9871 \series bold
9872 -
9873 \begin_inset ERT
9874 status collapsed
9875
9876 \begin_layout Standard
9877
9878
9879 \backslash
9880 /
9881 \end_layout
9882
9883 \end_inset
9884
9885 -cyclomatic
9886 \begin_inset LatexCommand \index{-\/-cyclomatic}
9887
9888 \end_inset
9889
9890
9891 \bar under
9892  
9893 \series default
9894 \bar default
9895 This option will cause the compiler to generate an information message for
9896  each function in the source file.
9897  The message contains some 
9898 \emph on
9899 important
9900 \emph default
9901  information about the function.
9902  The number of edges and nodes the compiler detected in the control flow
9903  graph of the function, and most importantly the 
9904 \emph on
9905 cyclomatic complexity
9906 \begin_inset LatexCommand \index{Cyclomatic complexity}
9907
9908 \end_inset
9909
9910
9911 \emph default
9912  see section on Cyclomatic Complexity for more details.
9913 \end_layout
9914
9915 \begin_layout List
9916 \labelwidthstring 00.00.0000
9917
9918 \series bold
9919 -
9920 \begin_inset ERT
9921 status collapsed
9922
9923 \begin_layout Standard
9924
9925
9926 \backslash
9927 /
9928 \end_layout
9929
9930 \end_inset
9931
9932 -float-reent
9933 \begin_inset LatexCommand \index{-\/-float-reent}
9934
9935 \end_inset
9936
9937
9938 \series default
9939  Floating point library is compiled as reentrant
9940 \begin_inset LatexCommand \index{reentrant}
9941
9942 \end_inset
9943
9944 .
9945  See section Installation for more details.
9946 \end_layout
9947
9948 \begin_layout List
9949 \labelwidthstring 00.00.0000
9950
9951 \series bold
9952 -
9953 \begin_inset ERT
9954 status collapsed
9955
9956 \begin_layout Standard
9957
9958
9959 \backslash
9960 /
9961 \end_layout
9962
9963 \end_inset
9964
9965 -funsigned-char
9966 \begin_inset LatexCommand \index{-\/-funsigned-char}
9967
9968 \end_inset
9969
9970
9971 \series default
9972  The default signedness for every type is
9973 \family typewriter
9974  signed
9975 \family default
9976 .
9977  In some embedded environments the default signedness of
9978 \family typewriter
9979  char
9980 \family default
9981  is
9982 \family typewriter
9983  unsigned
9984 \family default
9985 .
9986  To set the signess for characters to unsigned, use the option -
9987 \series bold
9988
9989 \begin_inset ERT
9990 status open
9991
9992 \begin_layout Standard
9993
9994
9995 \backslash
9996 /
9997 \end_layout
9998
9999 \end_inset
10000
10001
10002 \series default
10003 -funsigned-char.
10004  If this option is set and no signedness keyword (unsigned/signed) is given,
10005  a char will be signed.
10006  All other types are unaffected.
10007 \end_layout
10008
10009 \begin_layout List
10010 \labelwidthstring 00.00.0000
10011
10012 \series bold
10013 -
10014 \begin_inset ERT
10015 status collapsed
10016
10017 \begin_layout Standard
10018
10019
10020 \backslash
10021 /
10022 \end_layout
10023
10024 \end_inset
10025
10026 -main-return
10027 \begin_inset LatexCommand \index{-\/-main-return}
10028
10029 \end_inset
10030
10031
10032 \series default
10033  This option can be used if the code generated is called by a monitor program
10034  or if the main routine includes an endless loop.
10035  This option results in slightly smaller code and saves two bytes of stack
10036  space.
10037  The return from the 'main'
10038 \begin_inset LatexCommand \index{main return}
10039
10040 \end_inset
10041
10042  function will return to the function calling main.
10043  The default setting is to lock up i.e.
10044  generate a '
10045 \family typewriter
10046 sjmp .
10047 \family default
10048 '.
10049 \end_layout
10050
10051 \begin_layout List
10052 \labelwidthstring 00.00.0000
10053
10054 \series bold
10055 -
10056 \begin_inset ERT
10057 status collapsed
10058
10059 \begin_layout Standard
10060
10061
10062 \backslash
10063 /
10064 \end_layout
10065
10066 \end_inset
10067
10068 -nostdinc
10069 \begin_inset LatexCommand \index{-\/-nostdinc}
10070
10071 \end_inset
10072
10073
10074 \series default
10075  This will prevent the compiler from passing on the default include path
10076  to the preprocessor.
10077 \end_layout
10078
10079 \begin_layout List
10080 \labelwidthstring 00.00.0000
10081
10082 \series bold
10083 -
10084 \begin_inset ERT
10085 status collapsed
10086
10087 \begin_layout Standard
10088
10089
10090 \backslash
10091 /
10092 \end_layout
10093
10094 \end_inset
10095
10096 -nostdlib
10097 \begin_inset LatexCommand \index{-\/-nostdlib}
10098
10099 \end_inset
10100
10101
10102 \series default
10103  This will prevent the compiler from passing on the default library
10104 \begin_inset LatexCommand \index{Libraries}
10105
10106 \end_inset
10107
10108  path to the linker.
10109 \end_layout
10110
10111 \begin_layout List
10112 \labelwidthstring 00.00.0000
10113
10114 \series bold
10115 -
10116 \begin_inset ERT
10117 status collapsed
10118
10119 \begin_layout Standard
10120
10121
10122 \backslash
10123 /
10124 \end_layout
10125
10126 \end_inset
10127
10128 -verbose
10129 \begin_inset LatexCommand \index{-\/-verbose}
10130
10131 \end_inset
10132
10133
10134 \series default
10135  Shows the various actions the compiler is performing.
10136 \end_layout
10137
10138 \begin_layout List
10139 \labelwidthstring 00.00.0000
10140
10141 \series bold
10142 -V
10143 \begin_inset LatexCommand \index{-V}
10144
10145 \end_inset
10146
10147
10148 \series default
10149  Shows the actual commands the compiler is executing.
10150 \end_layout
10151
10152 \begin_layout List
10153 \labelwidthstring 00.00.0000
10154
10155 \series bold
10156 -
10157 \begin_inset ERT
10158 status collapsed
10159
10160 \begin_layout Standard
10161
10162
10163 \backslash
10164 /
10165 \end_layout
10166
10167 \end_inset
10168
10169 -no-c-code-in-asm
10170 \begin_inset LatexCommand \index{-\/-no-c-code-in-asm}
10171
10172 \end_inset
10173
10174
10175 \series default
10176  Hides your ugly and inefficient c-code from the asm file, so you can always
10177  blame the compiler :)
10178 \end_layout
10179
10180 \begin_layout List
10181 \labelwidthstring 00.00.0000
10182
10183 \series bold
10184 -
10185 \begin_inset ERT
10186 status collapsed
10187
10188 \begin_layout Standard
10189
10190
10191 \backslash
10192 /
10193 \end_layout
10194
10195 \end_inset
10196
10197 -fverbose-asm
10198 \begin_inset LatexCommand \index{-\/-no-gen-comments}
10199
10200 \end_inset
10201
10202
10203 \series default
10204  Include code generator and peep-hole comments in the generated asm files.
10205 \end_layout
10206
10207 \begin_layout List
10208 \labelwidthstring 00.00.0000
10209
10210 \series bold
10211 -
10212 \begin_inset ERT
10213 status collapsed
10214
10215 \begin_layout Standard
10216
10217
10218 \backslash
10219 /
10220 \end_layout
10221
10222 \end_inset
10223
10224 -no-peep-comments
10225 \begin_inset LatexCommand \index{-\/-no-peep-comments}
10226
10227 \end_inset
10228
10229
10230 \series default
10231  Don't include peep-hole comments in the generated asm files even if -
10232 \series bold
10233
10234 \begin_inset ERT
10235 status open
10236
10237 \begin_layout Standard
10238
10239
10240 \backslash
10241 /
10242 \end_layout
10243
10244 \end_inset
10245
10246
10247 \series default
10248 -fverbose-asm option is specified.
10249 \end_layout
10250
10251 \begin_layout List
10252 \labelwidthstring 00.00.0000
10253
10254 \series bold
10255 -
10256 \begin_inset ERT
10257 status collapsed
10258
10259 \begin_layout Standard
10260
10261
10262 \backslash
10263 /
10264 \end_layout
10265
10266 \end_inset
10267
10268 -i-code-in-asm
10269 \begin_inset LatexCommand \index{-\/-i-code-in-asm}
10270
10271 \end_inset
10272
10273
10274 \series default
10275  Include i-codes in the asm file.
10276  Sounds like noise but is most helpful for debugging the compiler itself.
10277 \end_layout
10278
10279 \begin_layout List
10280 \labelwidthstring 00.00.0000
10281
10282 \series bold
10283 -
10284 \begin_inset ERT
10285 status collapsed
10286
10287 \begin_layout Standard
10288
10289
10290 \backslash
10291 /
10292 \end_layout
10293
10294 \end_inset
10295
10296 -less-pedantic
10297 \begin_inset LatexCommand \index{pedantic}
10298
10299 \end_inset
10300
10301
10302 \begin_inset LatexCommand \index{-\/-less-pedantic}
10303
10304 \end_inset
10305
10306
10307 \series default
10308
10309 \begin_inset LatexCommand \label{lyx:--less-pedantic}
10310
10311 \end_inset
10312
10313  Disable some of the more pedantic warnings
10314 \begin_inset LatexCommand \index{Warnings}
10315
10316 \end_inset
10317
10318 .
10319  For more details, see the less_pedantic pragma 
10320 \begin_inset LatexCommand \vpageref{ite:less_pedantic}
10321
10322 \end_inset
10323
10324 .
10325 \end_layout
10326
10327 \begin_layout List
10328 \labelwidthstring 00.00.0000
10329
10330 \series bold
10331 -
10332 \begin_inset ERT
10333 status collapsed
10334
10335 \begin_layout Standard
10336
10337
10338 \backslash
10339 /
10340 \end_layout
10341
10342 \end_inset
10343
10344 -disable-warning\InsetSpace ~
10345 <nnnn>
10346 \begin_inset LatexCommand \index{-\/-disable-warning}
10347
10348 \end_inset
10349
10350
10351 \series default
10352  Disable specific warning with number <nnnn>.
10353 \end_layout
10354
10355 \begin_layout List
10356 \labelwidthstring 00.00.0000
10357
10358 \series bold
10359 -
10360 \begin_inset ERT
10361 status collapsed
10362
10363 \begin_layout Standard
10364
10365
10366 \backslash
10367 /
10368 \end_layout
10369
10370 \end_inset
10371
10372 -print-search-dirs
10373 \begin_inset LatexCommand \index{-\/-print-search-dirs}
10374
10375 \end_inset
10376
10377
10378 \series default
10379  Display the directories in the compiler's search path
10380 \end_layout
10381
10382 \begin_layout List
10383 \labelwidthstring 00.00.0000
10384
10385 \series bold
10386 -
10387 \begin_inset ERT
10388 status collapsed
10389
10390 \begin_layout Standard
10391
10392
10393 \backslash
10394 /
10395 \end_layout
10396
10397 \end_inset
10398
10399 -vc
10400 \begin_inset LatexCommand \index{-\/-vc}
10401
10402 \end_inset
10403
10404
10405 \series default
10406  Display errors and warnings using MSVC style, so you can use SDCC with
10407  the visual studio IDE
10408 \begin_inset LatexCommand \index{IDE}
10409
10410 \end_inset
10411
10412 .
10413  With SDCC both offering a GCC-like (the default) and a MSVC-like
10414 \begin_inset LatexCommand \index{MSVC output style}
10415
10416 \end_inset
10417
10418  output style, integration into most programming editors should be straightforwa
10419 rd.
10420 \end_layout
10421
10422 \begin_layout List
10423 \labelwidthstring 00.00.0000
10424
10425 \series bold
10426 -
10427 \begin_inset ERT
10428 status collapsed
10429
10430 \begin_layout Standard
10431
10432
10433 \backslash
10434 /
10435 \end_layout
10436
10437 \end_inset
10438
10439 -use-stdout
10440 \begin_inset LatexCommand \index{-\/-use-stdout}
10441
10442 \end_inset
10443
10444
10445 \series default
10446  Send errors and warnings to stdout instead of stderr.
10447 \end_layout
10448
10449 \begin_layout List
10450 \labelwidthstring 00.00.0000
10451
10452 \series bold
10453 -Wa\InsetSpace ~
10454 asmOption[,asmOption]
10455 \series default
10456
10457 \begin_inset LatexCommand \index{-Wa asmOption[,asmOption]}
10458
10459 \end_inset
10460
10461 ...
10462  Pass the asmOption to the assembler
10463 \begin_inset LatexCommand \index{Options assembler}
10464
10465 \end_inset
10466
10467
10468 \begin_inset LatexCommand \index{Assembler options}
10469
10470 \end_inset
10471
10472 .
10473  See file sdcc/as/doc/asxhtm.html for assembler options.cd
10474 \end_layout
10475
10476 \begin_layout List
10477 \labelwidthstring 00.00.0000
10478
10479 \series bold
10480 -
10481 \begin_inset ERT
10482 status collapsed
10483
10484 \begin_layout Standard
10485
10486
10487 \backslash
10488 /
10489 \end_layout
10490
10491 \end_inset
10492
10493 -std-sdcc89
10494 \begin_inset LatexCommand \index{-\/-std-sdcc89}
10495
10496 \end_inset
10497
10498
10499 \series default
10500  Generally follow the C89 standard, but allow SDCC features that conflict
10501  with the standard (default).
10502 \end_layout
10503
10504 \begin_layout List
10505 \labelwidthstring 00.00.0000
10506
10507 \series bold
10508 -
10509 \begin_inset ERT
10510 status collapsed
10511
10512 \begin_layout Standard
10513
10514
10515 \backslash
10516 /
10517 \end_layout
10518
10519 \end_inset
10520
10521 -std-c89
10522 \begin_inset LatexCommand \index{-\/-std-c89}
10523
10524 \end_inset
10525
10526
10527 \series default
10528  Follow the C89 standard and disable SDCC features that conflict with the
10529  standard.
10530 \end_layout
10531
10532 \begin_layout List
10533 \labelwidthstring 00.00.0000
10534
10535 \series bold
10536 -
10537 \begin_inset ERT
10538 status collapsed
10539
10540 \begin_layout Standard
10541
10542
10543 \backslash
10544 /
10545 \end_layout
10546
10547 \end_inset
10548
10549 -std-sdcc99
10550 \begin_inset LatexCommand \index{-\/-std-sdcc99}
10551
10552 \end_inset
10553
10554
10555 \series default
10556  Generally follow the C99 standard, but allow SDCC features that conflict
10557  with the standard (incomplete support).
10558 \end_layout
10559
10560 \begin_layout List
10561 \labelwidthstring 00.00.0000
10562
10563 \series bold
10564 -
10565 \begin_inset ERT
10566 status collapsed
10567
10568 \begin_layout Standard
10569
10570
10571 \backslash
10572 /
10573 \end_layout
10574
10575 \end_inset
10576
10577 -std-c99
10578 \begin_inset LatexCommand \index{-\/-std-sdcc99}
10579
10580 \end_inset
10581
10582
10583 \series default
10584  Follow the C99 standard and disable SDCC features that conflict with the
10585  standard (incomplete support).
10586 \end_layout
10587
10588 \begin_layout List
10589 \labelwidthstring 00.00.0000
10590
10591 \series bold
10592 -
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 -codeseg
10606 \series default
10607
10608 \begin_inset LatexCommand \index{-\/-codeseg <Value>}
10609
10610 \end_inset
10611
10612 \InsetSpace ~
10613 <Name> The name to be used for the code
10614 \begin_inset LatexCommand \index{code}
10615
10616 \end_inset
10617
10618  segment, default CSEG.
10619  This is useful if you need to tell the compiler to put the code in a special
10620  segment so you can later on tell the linker to put this segment in a special
10621  place in memory.
10622  Can be used for instance when using bank switching to put the code in a
10623  bank.
10624 \end_layout
10625
10626 \begin_layout List
10627 \labelwidthstring 00.00.0000
10628
10629 \series bold
10630 -
10631 \begin_inset ERT
10632 status collapsed
10633
10634 \begin_layout Standard
10635
10636
10637 \backslash
10638 /
10639 \end_layout
10640
10641 \end_inset
10642
10643 -constseg
10644 \series default
10645
10646 \begin_inset LatexCommand \index{-\/-constseg <Value>}
10647
10648 \end_inset
10649
10650 \InsetSpace ~
10651 <Name> The name to be used for the const
10652 \begin_inset LatexCommand \index{const}
10653
10654 \end_inset
10655
10656  segment, default CONST.
10657  This is useful if you need to tell the compiler to put the const data in
10658  a special segment so you can later on tell the linker to put this segment
10659  in a special place in memory.
10660  Can be used for instance when using bank switching to put the const data
10661  in a bank.
10662 \end_layout
10663
10664 \begin_layout List
10665 \labelwidthstring 00.00.0000
10666
10667 \series bold
10668 -
10669 \begin_inset ERT
10670 status collapsed
10671
10672 \begin_layout Standard
10673
10674
10675 \backslash
10676 /
10677 \end_layout
10678
10679 \end_inset
10680
10681 -fdollars-in-identifiers
10682 \begin_inset LatexCommand \index{-\/-fdollars-in-identifiers}
10683
10684 \end_inset
10685
10686
10687 \series default
10688  Permit '$' as an identifier character.
10689 \end_layout
10690
10691 \begin_layout List
10692 \labelwidthstring 00.00.0000
10693
10694 \series bold
10695 -
10696 \begin_inset ERT
10697 status collapsed
10698
10699 \begin_layout Standard
10700
10701
10702 \backslash
10703 /
10704 \end_layout
10705
10706 \end_inset
10707
10708 -more-pedantic
10709 \series default
10710
10711 \begin_inset LatexCommand \index{-\/-more-pedantic}
10712
10713 \end_inset
10714
10715
10716 \begin_inset LatexCommand \index{pedantic}
10717
10718 \end_inset
10719
10720  Actually this is 
10721 \series bold
10722 \emph on
10723 not
10724 \series default
10725 \emph default
10726  a SDCC compiler option but if you want 
10727 \emph on
10728 more
10729 \emph default
10730  warnings you can use a separate tool dedicated to syntax checking like
10731  splint
10732 \begin_inset LatexCommand \label{lyx:more-pedantic-SPLINT}
10733
10734 \end_inset
10735
10736
10737 \begin_inset LatexCommand \index{lint (syntax checking tool)}
10738
10739 \end_inset
10740
10741  
10742 \begin_inset LatexCommand \url{http://www.splint.org}
10743
10744 \end_inset
10745
10746 .
10747  To make your source files parseable by splint you will have to include
10748  
10749 \family sans
10750 lint.h
10751 \family default
10752
10753 \begin_inset LatexCommand \index{splint (syntax checking tool)}
10754
10755 \end_inset
10756
10757  in your source file and add brackets around extended keywords (like 
10758 \family sans
10759
10760 \begin_inset Quotes sld
10761 \end_inset
10762
10763 __at\InsetSpace ~
10764
10765 \series bold
10766 (
10767 \series default
10768 0xab
10769 \series bold
10770 )
10771 \series default
10772
10773 \begin_inset Quotes srd
10774 \end_inset
10775
10776
10777 \family default
10778  and 
10779 \family sans
10780
10781 \begin_inset Quotes sld
10782 \end_inset
10783
10784 __interrupt\InsetSpace ~
10785 (2)
10786 \begin_inset Quotes srd
10787 \end_inset
10788
10789
10790 \family default
10791 ).
10792  
10793 \newline
10794 Splint has an excellent on line manual at 
10795 \begin_inset LatexCommand \url{http://www.splint.org/manual/}
10796
10797 \end_inset
10798
10799  and it's capabilities go beyond pure syntax checking.
10800  You'll need to tell splint the location of SDCC's include files so a typical
10801  command line could look like this: 
10802 \newline
10803
10804 \family sans
10805 splint\InsetSpace ~
10806 -I\InsetSpace ~
10807 /usr/local/share/sdcc/include/mcs51/\InsetSpace ~
10808 \InsetSpace ~
10809 myprogram.c
10810 \end_layout
10811
10812 \begin_layout List
10813 \labelwidthstring 00.00.0000
10814
10815 \series bold
10816 -
10817 \begin_inset ERT
10818 status collapsed
10819
10820 \begin_layout Standard
10821
10822
10823 \backslash
10824 /
10825 \end_layout
10826
10827 \end_inset
10828
10829 -short-is-8bits
10830 \series default
10831
10832 \begin_inset LatexCommand \index{-\/-short-is-8bits}
10833
10834 \end_inset
10835
10836
10837 \begin_inset LatexCommand \label{lyx:--short-is-8bits}
10838
10839 \end_inset
10840
10841  Treat short as 8-bit (for backward compatibility with older versions of
10842  compiler - see section 
10843 \begin_inset LatexCommand \ref{sec:Compatibility-with-previous}
10844
10845 \end_inset
10846
10847 )
10848 \end_layout
10849
10850 \begin_layout Standard
10851 \begin_inset VSpace bigskip
10852 \end_inset
10853
10854
10855 \end_layout
10856
10857 \begin_layout Subsection
10858 Intermediate Dump Options
10859 \begin_inset LatexCommand \label{sub:Intermediate-Dump-Options}
10860
10861 \end_inset
10862
10863
10864 \begin_inset LatexCommand \index{Options intermediate dump}
10865
10866 \end_inset
10867
10868
10869 \begin_inset LatexCommand \index{Intermediate dump options}
10870
10871 \end_inset
10872
10873
10874 \end_layout
10875
10876 \begin_layout Standard
10877 The following options are provided for the purpose of retargetting and debugging
10878  the compiler.
10879  They provide a means to dump the intermediate code (iCode
10880 \begin_inset LatexCommand \index{iCode}
10881
10882 \end_inset
10883
10884 ) generated by the compiler in human readable form at various stages of
10885  the compilation process.
10886  More on iCodes see chapter 
10887 \begin_inset LatexCommand \ref{sub:The-anatomy-of}
10888
10889 \end_inset
10890
10891  
10892 \begin_inset Quotes srd
10893 \end_inset
10894
10895 The anatomy of the compiler
10896 \begin_inset Quotes srd
10897 \end_inset
10898
10899 .
10900 \end_layout
10901
10902 \begin_layout List
10903 \labelwidthstring 00.00.0000
10904
10905 \series bold
10906 -
10907 \begin_inset ERT
10908 status collapsed
10909
10910 \begin_layout Standard
10911
10912
10913 \backslash
10914 /
10915 \end_layout
10916
10917 \end_inset
10918
10919 -dumpraw
10920 \begin_inset LatexCommand \index{-\/-dumpraw}
10921
10922 \end_inset
10923
10924
10925 \series default
10926  This option will cause the compiler to dump the intermediate code into
10927  a file of named 
10928 \emph on
10929 <source filename>.dumpraw
10930 \emph default
10931  just after the intermediate code has been generated for a function, i.e.
10932  before any optimizations are done.
10933  The basic blocks
10934 \begin_inset LatexCommand \index{Basic blocks}
10935
10936 \end_inset
10937
10938  at this stage ordered in the depth first number, so they may not be in
10939  sequence of execution.
10940 \end_layout
10941
10942 \begin_layout List
10943 \labelwidthstring 00.00.0000
10944
10945 \series bold
10946 -
10947 \begin_inset ERT
10948 status collapsed
10949
10950 \begin_layout Standard
10951
10952
10953 \backslash
10954 /
10955 \end_layout
10956
10957 \end_inset
10958
10959 -dumpgcse
10960 \begin_inset LatexCommand \index{-\/-dumpgcse}
10961
10962 \end_inset
10963
10964
10965 \series default
10966  Will create a dump of iCodes, after global subexpression elimination
10967 \begin_inset LatexCommand \index{Global subexpression elimination}
10968
10969 \end_inset
10970
10971 , into a file named 
10972 \emph on
10973 <source filename>.dumpgcse.
10974 \end_layout
10975
10976 \begin_layout List
10977 \labelwidthstring 00.00.0000
10978
10979 \series bold
10980 -
10981 \begin_inset ERT
10982 status collapsed
10983
10984 \begin_layout Standard
10985
10986
10987 \backslash
10988 /
10989 \end_layout
10990
10991 \end_inset
10992
10993 -dumpdeadcode
10994 \begin_inset LatexCommand \index{-\/-dumpdeadcode}
10995
10996 \end_inset
10997
10998
10999 \series default
11000  Will create a dump of iCodes, after deadcode elimination
11001 \begin_inset LatexCommand \index{Dead-code elimination}
11002
11003 \end_inset
11004
11005 , into a file named 
11006 \emph on
11007 <source filename>.dumpdeadcode.
11008 \end_layout
11009
11010 \begin_layout List
11011 \labelwidthstring 00.00.0000
11012
11013 \series bold
11014 -
11015 \begin_inset ERT
11016 status collapsed
11017
11018 \begin_layout Standard
11019
11020
11021 \backslash
11022 /
11023 \end_layout
11024
11025 \end_inset
11026
11027 -dumploop
11028 \begin_inset LatexCommand \index{-\/-dumploop}
11029
11030 \end_inset
11031
11032
11033 \series default
11034 \size large
11035  
11036 \size default
11037 Will create a dump of iCodes, after loop optimizations
11038 \begin_inset LatexCommand \index{Loop optimization}
11039
11040 \end_inset
11041
11042 , into a file named 
11043 \emph on
11044 <source filename>.dumploop.
11045 \end_layout
11046
11047 \begin_layout List
11048 \labelwidthstring 00.00.0000
11049
11050 \series bold
11051 -
11052 \begin_inset ERT
11053 status collapsed
11054
11055 \begin_layout Standard
11056
11057
11058 \backslash
11059 /
11060 \end_layout
11061
11062 \end_inset
11063
11064 -dumprange
11065 \begin_inset LatexCommand \index{-\/-dumprange}
11066
11067 \end_inset
11068
11069
11070 \series default
11071 \size large
11072  
11073 \size default
11074 Will create a dump of iCodes, after live range analysis
11075 \begin_inset LatexCommand \index{Live range analysis}
11076
11077 \end_inset
11078
11079 , into a file named 
11080 \emph on
11081 <source filename>.dumprange.
11082 \end_layout
11083
11084 \begin_layout List
11085 \labelwidthstring 00.00.0000
11086
11087 \series bold
11088 -
11089 \begin_inset ERT
11090 status collapsed
11091
11092 \begin_layout Standard
11093
11094
11095 \backslash
11096 /
11097 \end_layout
11098
11099 \end_inset
11100
11101 -dumlrange
11102 \begin_inset LatexCommand \index{-\/-dumlrange}
11103
11104 \end_inset
11105
11106
11107 \series default
11108  Will dump the life ranges
11109 \begin_inset LatexCommand \index{Live range analysis}
11110
11111 \end_inset
11112
11113  for all symbols.
11114 \end_layout
11115
11116 \begin_layout List
11117 \labelwidthstring 00.00.0000
11118
11119 \series bold
11120 -
11121 \begin_inset ERT
11122 status collapsed
11123
11124 \begin_layout Standard
11125
11126
11127 \backslash
11128 /
11129 \end_layout
11130
11131 \end_inset
11132
11133 -dumpregassign
11134 \begin_inset LatexCommand \index{-\/-dumpregassign}
11135
11136 \end_inset
11137
11138
11139 \bar under
11140  
11141 \series default
11142 \bar default
11143 Will create a dump of iCodes, after register assignment
11144 \begin_inset LatexCommand \index{Register assignment}
11145
11146 \end_inset
11147
11148 , into a file named 
11149 \emph on
11150 <source filename>.dumprassgn.
11151 \end_layout
11152
11153 \begin_layout List
11154 \labelwidthstring 00.00.0000
11155
11156 \series bold
11157 -
11158 \begin_inset ERT
11159 status collapsed
11160
11161 \begin_layout Standard
11162
11163
11164 \backslash
11165 /
11166 \end_layout
11167
11168 \end_inset
11169
11170 -dumplrange
11171 \begin_inset LatexCommand \index{-\/-dumplrange}
11172
11173 \end_inset
11174
11175
11176 \series default
11177  Will create a dump of the live ranges of iTemp's
11178 \end_layout
11179
11180 \begin_layout List
11181 \labelwidthstring 00.00.0000
11182
11183 \series bold
11184 -
11185 \begin_inset ERT
11186 status collapsed
11187
11188 \begin_layout Standard
11189
11190
11191 \backslash
11192 /
11193 \end_layout
11194
11195 \end_inset
11196
11197 -dumpall
11198 \begin_inset LatexCommand \index{-\/-dumpall}
11199
11200 \end_inset
11201
11202
11203 \size large
11204 \bar under
11205  
11206 \series default
11207 \size default
11208 \bar default
11209 Will cause all the above mentioned dumps to be created.
11210 \end_layout
11211
11212 \begin_layout Standard
11213 \begin_inset VSpace bigskip
11214 \end_inset
11215
11216
11217 \end_layout
11218
11219 \begin_layout Subsection
11220 Redirecting output on Windows Shells
11221 \end_layout
11222
11223 \begin_layout Standard
11224 By default SDCC writes its error messages to 
11225 \begin_inset Quotes sld
11226 \end_inset
11227
11228 standard error
11229 \begin_inset Quotes srd
11230 \end_inset
11231
11232 .
11233  To force all messages to 
11234 \begin_inset Quotes sld
11235 \end_inset
11236
11237 standard output
11238 \begin_inset Quotes srd
11239 \end_inset
11240
11241  use 
11242 \series bold
11243 -
11244 \series default
11245 \emph on
11246
11247 \begin_inset ERT
11248 status collapsed
11249
11250 \begin_layout Standard
11251
11252
11253 \backslash
11254 /
11255 \end_layout
11256
11257 \end_inset
11258
11259
11260 \series bold
11261 \emph default
11262 -
11263 \series default
11264 use-stdout
11265 \begin_inset LatexCommand \index{-\/-use-stdout}
11266
11267 \end_inset
11268
11269 .
11270  Additionally, if you happen to have visual studio installed in your windows
11271  machine, you can use it to compile your sources using a custom build and
11272  the SDCC -
11273 \emph on
11274
11275 \begin_inset ERT
11276 status collapsed
11277
11278 \begin_layout Standard
11279
11280
11281 \backslash
11282 /
11283 \end_layout
11284
11285 \end_inset
11286
11287
11288 \emph default
11289 -vc
11290 \begin_inset LatexCommand \index{-\/-vc}
11291
11292 \end_inset
11293
11294  option.
11295  Something like this should work:
11296 \newline
11297
11298 \newline
11299
11300 \series bold
11301 c:
11302 \backslash
11303 sdcc
11304 \backslash
11305 bin
11306 \backslash
11307 sdcc.exe -
11308 \series default
11309 \emph on
11310
11311 \begin_inset ERT
11312 status collapsed
11313
11314 \begin_layout Standard
11315
11316
11317 \backslash
11318 /
11319 \end_layout
11320
11321 \end_inset
11322
11323
11324 \series bold
11325 \emph default
11326 -vc -
11327 \series default
11328 \emph on
11329
11330 \begin_inset ERT
11331 status collapsed
11332
11333 \begin_layout Standard
11334
11335
11336 \backslash
11337 /
11338 \end_layout
11339
11340 \end_inset
11341
11342
11343 \series bold
11344 \emph default
11345 -model-large -c $(InputPath)
11346 \series default
11347
11348 \begin_inset VSpace bigskip
11349 \end_inset
11350
11351
11352 \end_layout
11353
11354 \begin_layout Section
11355 Environment variables
11356 \begin_inset LatexCommand \index{Environment variables}
11357
11358 \end_inset
11359
11360
11361 \end_layout
11362
11363 \begin_layout Standard
11364 SDCC recognizes the following environment variables:
11365 \end_layout
11366
11367 \begin_layout List
11368 \labelwidthstring 00.00.0000
11369
11370 \series bold
11371 SDCC_LEAVE_SIGNALS
11372 \begin_inset LatexCommand \index{SDCC\_LEAVE\_SIGNALS}
11373
11374 \end_inset
11375
11376
11377 \series default
11378  SDCC installs a signal handler
11379 \begin_inset LatexCommand \index{signal handler}
11380
11381 \end_inset
11382
11383  to be able to delete temporary files after an user break (^C) or an exception.
11384  If this environment variable is set, SDCC won't install the signal handler
11385  in order to be able to debug SDCC.
11386 \end_layout
11387
11388 \begin_layout List
11389 \labelwidthstring 00.00.0000
11390
11391 \series bold
11392 TMP,\InsetSpace ~
11393 TEMP,\InsetSpace ~
11394 TMPDIR
11395 \begin_inset LatexCommand \index{TMP, TEMP, TMPDIR}
11396
11397 \end_inset
11398
11399
11400 \series default
11401  Path, where temporary files will be created.
11402  The order of the variables is the search order.
11403  In a standard *nix environment these variables are not set, and there's
11404  no need to set them.
11405  On Windows it's recommended to set one of them.
11406 \end_layout
11407
11408 \begin_layout List
11409 \labelwidthstring 00.00.0000
11410
11411 \series bold
11412 SDCC_HOME
11413 \begin_inset LatexCommand \index{SDCC\_HOME}
11414
11415 \end_inset
11416
11417
11418 \series default
11419  Path, see section 
11420 \begin_inset LatexCommand \ref{sub:Install-paths}
11421
11422 \end_inset
11423
11424 \InsetSpace ~
11425
11426 \begin_inset Quotes sld
11427 \end_inset
11428
11429  Install Paths
11430 \begin_inset Quotes srd
11431 \end_inset
11432
11433 .
11434 \end_layout
11435
11436 \begin_layout List
11437 \labelwidthstring 00.00.0000
11438
11439 \series bold
11440 SDCC_INCLUDE
11441 \begin_inset LatexCommand \index{SDCC\_INCLUDE}
11442
11443 \end_inset
11444
11445
11446 \series default
11447  Path, see section 
11448 \begin_inset LatexCommand \ref{sub:Search-Paths}
11449
11450 \end_inset
11451
11452 \InsetSpace ~
11453
11454 \begin_inset Quotes sld
11455 \end_inset
11456
11457 Search Paths
11458 \begin_inset Quotes srd
11459 \end_inset
11460
11461 .
11462 \end_layout
11463
11464 \begin_layout List
11465 \labelwidthstring 00.00.0000
11466
11467 \series bold
11468 SDCC_LIB
11469 \begin_inset LatexCommand \index{SDCC\_LIB}
11470
11471 \end_inset
11472
11473
11474 \series default
11475  Path, see section 
11476 \begin_inset LatexCommand \ref{sub:Search-Paths}
11477
11478 \end_inset
11479
11480 \InsetSpace ~
11481
11482 \begin_inset Quotes sld
11483 \end_inset
11484
11485 Search Paths
11486 \begin_inset Quotes srd
11487 \end_inset
11488
11489 ..
11490 \end_layout
11491
11492 \begin_layout Standard
11493 There are some more environment variables recognized by SDCC, but these
11494  are solely used for debugging purposes.
11495  They can change or disappear very quickly, and will never be documented.
11496 \begin_inset VSpace bigskip
11497 \end_inset
11498
11499
11500 \end_layout
11501
11502 \begin_layout Section
11503 Storage Class Language Extensions
11504 \end_layout
11505
11506 \begin_layout Subsection
11507 MCS51/DS390 Storage Class
11508 \begin_inset LatexCommand \index{Storage class}
11509
11510 \end_inset
11511
11512  Language Extensions
11513 \end_layout
11514
11515 \begin_layout Standard
11516 In addition to the ANSI storage classes SDCC allows the following MCS51
11517  specific storage classes:
11518 \end_layout
11519
11520 \begin_layout Subsubsection
11521 data
11522 \begin_inset LatexCommand \index{data (mcs51, ds390 storage class)}
11523
11524 \end_inset
11525
11526
11527 \begin_inset LatexCommand \index{\_\_data (mcs51, ds390 storage class)}
11528
11529 \end_inset
11530
11531  / near
11532 \begin_inset LatexCommand \index{near (storage class)}
11533
11534 \end_inset
11535
11536
11537 \begin_inset LatexCommand \index{\_\_near (storage class)}
11538
11539 \end_inset
11540
11541
11542 \end_layout
11543
11544 \begin_layout Standard
11545 This is the 
11546 \series bold
11547 default
11548 \series default
11549  storage class for the Small Memory model (
11550 \emph on
11551 data
11552 \emph default
11553  and 
11554 \emph on
11555 near
11556 \emph default
11557  or the more ANSI-C compliant forms 
11558 \emph on
11559 __data
11560 \emph default
11561  and 
11562 \emph on
11563 __near
11564 \emph default
11565  can be used synonymously).
11566  Variables declared with this storage class will be allocated in the directly
11567  addressable portion of the internal RAM of a 8051, e.g.:
11568 \end_layout
11569
11570 \begin_layout Verse
11571
11572 \family typewriter
11573 __data unsigned char test_data;
11574 \end_layout
11575
11576 \begin_layout Standard
11577 Writing 0x01 to this variable generates the assembly code:
11578 \end_layout
11579
11580 \begin_layout Verse
11581
11582 \family typewriter
11583 75*00 01\InsetSpace ~
11584 \InsetSpace ~
11585 \InsetSpace ~
11586 mov\InsetSpace ~
11587 \InsetSpace ~
11588 _test_data,#0x01
11589 \end_layout
11590
11591 \begin_layout Subsubsection
11592 xdata
11593 \begin_inset LatexCommand \index{xdata (mcs51, ds390 storage class)}
11594
11595 \end_inset
11596
11597
11598 \begin_inset LatexCommand \index{\_\_xdata (mcs51, ds390 storage class)}
11599
11600 \end_inset
11601
11602  / far
11603 \begin_inset LatexCommand \index{far (storage class)}
11604
11605 \end_inset
11606
11607
11608 \begin_inset LatexCommand \index{\_\_far (storage class)}
11609
11610 \end_inset
11611
11612
11613 \end_layout
11614
11615 \begin_layout Standard
11616 Variables declared with this storage class will be placed in the external
11617  RAM.
11618  This is the 
11619 \series bold
11620 default
11621 \series default
11622  storage class for the Large Memory model, e.g.:
11623 \end_layout
11624
11625 \begin_layout Verse
11626
11627 \family typewriter
11628 __xdata unsigned char test_xdata;
11629 \end_layout
11630
11631 \begin_layout Standard
11632 Writing 0x01 to this variable generates the assembly code:
11633 \end_layout
11634
11635 \begin_layout Verse
11636
11637 \family typewriter
11638 90s00r00\InsetSpace ~
11639 \InsetSpace ~
11640 \InsetSpace ~
11641 mov\InsetSpace ~
11642 \InsetSpace ~
11643 dptr,#_test_xdata 
11644 \newline
11645 74\InsetSpace ~
11646 01\InsetSpace ~
11647 \InsetSpace ~
11648 \InsetSpace ~
11649 \InsetSpace ~
11650 \InsetSpace ~
11651 \InsetSpace ~
11652 mov\InsetSpace ~
11653 \InsetSpace ~
11654 a,#0x01 
11655 \newline
11656 F0\InsetSpace ~
11657 \InsetSpace ~
11658 \InsetSpace ~
11659 \InsetSpace ~
11660 \InsetSpace ~
11661 \InsetSpace ~
11662 \InsetSpace ~
11663 \InsetSpace ~
11664 \InsetSpace ~
11665 movx\InsetSpace ~
11666 @dptr,a 
11667 \end_layout
11668
11669 \begin_layout Subsubsection
11670 idata
11671 \begin_inset LatexCommand \index{idata (mcs51, ds390 storage class)}
11672
11673 \end_inset
11674
11675
11676 \begin_inset LatexCommand \index{\_\_idata (mcs51, ds390 storage class)}
11677
11678 \end_inset
11679
11680
11681 \end_layout
11682
11683 \begin_layout Standard
11684 Variables declared with this storage class will be allocated into the indirectly
11685  addressable portion of the internal ram of a 8051, e.g.:
11686 \end_layout
11687
11688 \begin_layout Verse
11689
11690 \family typewriter
11691 __idata unsigned char test_idata;
11692 \end_layout
11693
11694 \begin_layout Standard
11695 Writing 0x01 to this variable generates the assembly code:
11696 \end_layout
11697
11698 \begin_layout Verse
11699
11700 \family typewriter
11701 78r00\InsetSpace ~
11702 \InsetSpace ~
11703 \InsetSpace ~
11704 \InsetSpace ~
11705 \InsetSpace ~
11706 \InsetSpace ~
11707 \InsetSpace ~
11708 mov\InsetSpace ~
11709 \InsetSpace ~
11710 r0,#_test_idata
11711 \newline
11712 76\InsetSpace ~
11713 01\InsetSpace ~
11714 \InsetSpace ~
11715 \InsetSpace ~
11716 \InsetSpace ~
11717 \InsetSpace ~
11718 \InsetSpace ~
11719 \InsetSpace ~
11720 mov\InsetSpace ~
11721 \InsetSpace ~
11722 @r0,#0x01
11723 \end_layout
11724
11725 \begin_layout Standard
11726 Please note, the first 128 byte of idata physically access the same RAM
11727  as the data memory.
11728  The original 8051 had 128 byte idata memory, nowadays most devices have
11729  256 byte idata memory.
11730  The stack
11731 \begin_inset LatexCommand \index{stack}
11732
11733 \end_inset
11734
11735  is located in idata memory.
11736 \end_layout
11737
11738 \begin_layout Subsubsection
11739 pdata
11740 \begin_inset LatexCommand \index{pdata (mcs51, ds390 storage class)}
11741
11742 \end_inset
11743
11744
11745 \begin_inset LatexCommand \index{\_\_pdata (mcs51, ds390 storage class)}
11746
11747 \end_inset
11748
11749
11750 \end_layout
11751
11752 \begin_layout Standard
11753 Paged xdata access is just as straightforward as using the other addressing
11754  modes of a 8051.
11755  It is typically located at the start of xdata and has a maximum size of
11756  256 bytes.
11757  The following example writes 0x01 to the pdata variable.
11758  Please note, pdata access physically accesses xdata memory.
11759  The high byte of the address is determined by port P2 
11760 \begin_inset LatexCommand \index{P2 (mcs51 sfr)}
11761
11762 \end_inset
11763
11764 (or in case of some 8051 variants by a separate Special Function Register,
11765  see section 
11766 \begin_inset LatexCommand \ref{sub:MCS51-variants}
11767
11768 \end_inset
11769
11770 ).
11771  This is the 
11772 \series bold
11773 default
11774 \series default
11775  storage class for the Medium Memory model, e.g.:
11776 \end_layout
11777
11778 \begin_layout Verse
11779
11780 \family typewriter
11781 __pdata unsigned char test_pdata;
11782 \end_layout
11783
11784 \begin_layout Standard
11785 Writing 0x01 to this variable generates the assembly code:
11786 \end_layout
11787
11788 \begin_layout Verse
11789
11790 \family typewriter
11791 78r00\InsetSpace ~
11792 \InsetSpace ~
11793 \InsetSpace ~
11794 \InsetSpace ~
11795 \InsetSpace ~
11796 \InsetSpace ~
11797 mov r0,#_test_pdata
11798 \newline
11799 74 01\InsetSpace ~
11800 \InsetSpace ~
11801 \InsetSpace ~
11802 \InsetSpace ~
11803 \InsetSpace ~
11804 \InsetSpace ~
11805 mov a,#0x01 
11806 \newline
11807 F2\InsetSpace ~
11808 \InsetSpace ~
11809 \InsetSpace ~
11810 \InsetSpace ~
11811 \InsetSpace ~
11812 \InsetSpace ~
11813 \InsetSpace ~
11814 \InsetSpace ~
11815 \InsetSpace ~
11816 movx @r0,a
11817 \end_layout
11818
11819 \begin_layout Standard
11820 If the -
11821 \begin_inset ERT
11822 status collapsed
11823
11824 \begin_layout Standard
11825
11826
11827 \backslash
11828 /
11829 \end_layout
11830
11831 \end_inset
11832
11833 -xstack
11834 \begin_inset LatexCommand \index{-\/-xstack}
11835
11836 \end_inset
11837
11838  option is used the pdata memory area is followed by the xstack memory area
11839  and the sum of their sizes is limited to 256 bytes.
11840 \end_layout
11841
11842 \begin_layout Subsubsection
11843 code
11844 \begin_inset LatexCommand \index{code}
11845
11846 \end_inset
11847
11848
11849 \begin_inset LatexCommand \index{\_\_code}
11850
11851 \end_inset
11852
11853
11854 \end_layout
11855
11856 \begin_layout Standard
11857 'Variables' declared with this storage class will be placed in the code
11858  memory:
11859 \end_layout
11860
11861 \begin_layout Verse
11862
11863 \family typewriter
11864 __code unsigned char test_code;
11865 \end_layout
11866
11867 \begin_layout Standard
11868 Read access to this variable generates the assembly code:
11869 \end_layout
11870
11871 \begin_layout Verse
11872
11873 \family typewriter
11874 90s00r6F\InsetSpace ~
11875 \InsetSpace ~
11876 \InsetSpace ~
11877 mov dptr,#_test_code
11878 \newline
11879 E4\InsetSpace ~
11880 \InsetSpace ~
11881 \InsetSpace ~
11882 \InsetSpace ~
11883 \InsetSpace ~
11884 \InsetSpace ~
11885 \InsetSpace ~
11886 \InsetSpace ~
11887 \InsetSpace ~
11888 clr a
11889 \newline
11890 93\InsetSpace ~
11891 \InsetSpace ~
11892 \InsetSpace ~
11893 \InsetSpace ~
11894 \InsetSpace ~
11895 \InsetSpace ~
11896 \InsetSpace ~
11897 \InsetSpace ~
11898 \InsetSpace ~
11899 movc a,@a+dptr 
11900 \end_layout
11901
11902 \begin_layout Standard
11903
11904 \family typewriter
11905 char
11906 \family default
11907  indexed arrays of characters in code memory can be accessed efficiently:
11908 \end_layout
11909
11910 \begin_layout Verse
11911
11912 \family typewriter
11913 __code char test_array[] = {'c','h','e','a','p'}; 
11914 \end_layout
11915
11916 \begin_layout Standard
11917 Read access to this array using an 8-bit unsigned index generates the assembly
11918  code:
11919 \end_layout
11920
11921 \begin_layout Verse
11922
11923 \family typewriter
11924 E5*00\InsetSpace ~
11925 \InsetSpace ~
11926 \InsetSpace ~
11927 \InsetSpace ~
11928 \InsetSpace ~
11929 \InsetSpace ~
11930 mov a,_index 
11931 \end_layout
11932
11933 \begin_layout Verse
11934
11935 \family typewriter
11936 90s00r41\InsetSpace ~
11937 \InsetSpace ~
11938 \InsetSpace ~
11939 mov dptr,#_test_array
11940 \end_layout
11941
11942 \begin_layout Verse
11943
11944 \family typewriter
11945 93\InsetSpace ~
11946 \InsetSpace ~
11947 \InsetSpace ~
11948 \InsetSpace ~
11949 \InsetSpace ~
11950 \InsetSpace ~
11951 \InsetSpace ~
11952 \InsetSpace ~
11953 \InsetSpace ~
11954 movc a,@a+dptr 
11955 \end_layout
11956
11957 \begin_layout Subsubsection
11958 bit
11959 \begin_inset LatexCommand \index{bit}
11960
11961 \end_inset
11962
11963
11964 \begin_inset LatexCommand \index{\_\_bit}
11965
11966 \end_inset
11967
11968
11969 \end_layout
11970
11971 \begin_layout Standard
11972 This is a data-type and a storage class specifier.
11973  When a variable is declared as a bit, it is allocated into the bit addressable
11974  memory of 8051, e.g.:
11975 \end_layout
11976
11977 \begin_layout Verse
11978
11979 \family typewriter
11980 __bit test_bit;
11981 \end_layout
11982
11983 \begin_layout Standard
11984 Writing 1 to this variable generates the assembly code:
11985 \end_layout
11986
11987 \begin_layout Verse
11988
11989 \family typewriter
11990 D2*00\InsetSpace ~
11991 \InsetSpace ~
11992 \InsetSpace ~
11993 \InsetSpace ~
11994 \InsetSpace ~
11995 \InsetSpace ~
11996 \InsetSpace ~
11997 setb\InsetSpace ~
11998 _test_bit
11999 \end_layout
12000
12001 \begin_layout Standard
12002 The bit addressable memory consists of 128 bits which are located from 0x20
12003  to 0x2f in data memory.
12004  
12005 \newline
12006 Apart from this 8051 specific storage class most architectures support
12007  ANSI-C bitfields
12008 \begin_inset LatexCommand \index{bitfields}
12009
12010 \end_inset
12011
12012
12013 \begin_inset Foot
12014 status open
12015
12016 \begin_layout Standard
12017 Not really meant as examples, but nevertheless showing what bitfields are
12018  about: device/include/mc68hc908qy.h and support/regression/tests/bitfields.c
12019 \end_layout
12020
12021 \end_inset
12022
12023 .
12024  In accordance with ISO/IEC 9899 bits and bitfields without an explicit
12025  signed modifier are implemented as unsigned.
12026 \end_layout
12027
12028 \begin_layout Subsubsection
12029 sfr
12030 \begin_inset LatexCommand \index{sfr}
12031
12032 \end_inset
12033
12034
12035 \begin_inset LatexCommand \index{\_\_sfr}
12036
12037 \end_inset
12038
12039  / sfr16
12040 \begin_inset LatexCommand \index{sfr16}
12041
12042 \end_inset
12043
12044
12045 \begin_inset LatexCommand \index{\_\_sfr16}
12046
12047 \end_inset
12048
12049  / sfr32
12050 \begin_inset LatexCommand \index{sfr32}
12051
12052 \end_inset
12053
12054
12055 \begin_inset LatexCommand \index{\_\_sfr32}
12056
12057 \end_inset
12058
12059  / sbit
12060 \begin_inset LatexCommand \index{\_\_sbit}
12061
12062 \end_inset
12063
12064
12065 \begin_inset LatexCommand \index{sbit}
12066
12067 \end_inset
12068
12069
12070 \end_layout
12071
12072 \begin_layout Standard
12073 Like the bit keyword, 
12074 \emph on
12075 sfr / sfr16 / sfr32 / sbit 
12076 \emph default
12077 signify both a data-type and storage class, they are used to describe the
12078  
12079 \emph on
12080 s
12081 \emph default
12082 pecial 
12083 \emph on
12084 f
12085 \emph default
12086 unction 
12087 \emph on
12088 r
12089 \emph default
12090 egisters and 
12091 \emph on
12092 s
12093 \emph default
12094 pecial 
12095 \emph on
12096 bit
12097 \emph default
12098  variables of a 8051, eg:
12099 \end_layout
12100
12101 \begin_layout Verse
12102
12103 \family typewriter
12104 __sfr __at
12105 \begin_inset LatexCommand \index{at}
12106
12107 \end_inset
12108
12109
12110 \begin_inset LatexCommand \index{\_\_at}
12111
12112 \end_inset
12113
12114  (0x80) P0;\InsetSpace ~
12115  /* special function register P0 at location 0x80 */
12116 \newline
12117
12118 \newline
12119 /* 16 bit
12120  special function register combination for timer 0
12121 \newline
12122 \InsetSpace ~
12123 \InsetSpace ~
12124  with the high byte at
12125  location 0x8C and the low byte at location 0x8A */
12126 \newline
12127 __sfr16 __at (0x8C8A)
12128  TMR0;
12129 \newline
12130
12131 \newline
12132 __sbit __at
12133 \begin_inset LatexCommand \index{at}
12134
12135 \end_inset
12136
12137
12138 \begin_inset LatexCommand \index{\_\_at}
12139
12140 \end_inset
12141
12142  (0xd7) CY;\InsetSpace ~
12143  /* CY (Carry Flag
12144 \begin_inset LatexCommand \index{Flags}
12145
12146 \end_inset
12147
12148
12149 \begin_inset LatexCommand \index{Carry flag}
12150
12151 \end_inset
12152
12153 ) */
12154 \end_layout
12155
12156 \begin_layout Standard
12157 Special function registers which are located on an address dividable by
12158  8 are bit-addressable, an
12159 \emph on
12160  sbit
12161 \emph default
12162  addresses a specific bit within these sfr.
12163 \newline
12164 16 Bit and 32 bit special function
12165  register combinations which require a certain access order are better not
12166  declared using 
12167 \emph on
12168 sfr16
12169 \emph default
12170  or 
12171 \emph on
12172 sfr32.
12173
12174 \emph default
12175  Allthough SDCC usually accesses them Least Significant Byte (LSB) first,
12176  this is not guaranteed.
12177 \newline
12178
12179 \end_layout
12180
12181 \begin_layout Standard
12182 Please note, if you use a header file which was written for another compiler
12183  then the sfr / sfr16 / sfr32 / sbit Storage Class extensions will most
12184  likely be 
12185 \emph on
12186 not 
12187 \emph default
12188 compatible.
12189  Specifically the syntax 
12190 \family typewriter
12191 \InsetSpace ~
12192 sfr P0 = 0x80;\InsetSpace ~
12193
12194 \family default
12195  is compiled 
12196 \emph on
12197 without warning
12198 \emph default
12199  by SDCC to an assignment of 0x80 to a variable called P0 
12200 \family typewriter
12201
12202 \begin_inset Marginal
12203 status collapsed
12204
12205 \begin_layout Standard
12206
12207 \series bold
12208 \InsetSpace ~
12209 !
12210 \end_layout
12211
12212 \end_inset
12213
12214 .
12215  
12216 \family default
12217 Nevertheless it is possible to write header files
12218 \begin_inset LatexCommand \index{Header files}
12219
12220 \end_inset
12221
12222
12223 \begin_inset LatexCommand \index{Include files}
12224
12225 \end_inset
12226
12227  which can be shared among different compilers (see section 
12228 \begin_inset LatexCommand \ref{sec:Porting-code-to-other-compilers}
12229
12230 \end_inset
12231
12232 ).
12233  
12234 \end_layout
12235
12236 \begin_layout Subsubsection
12237 Pointers
12238 \begin_inset LatexCommand \index{Pointer}
12239
12240 \end_inset
12241
12242  to MCS51/DS390 specific memory spaces
12243 \end_layout
12244
12245 \begin_layout Standard
12246 SDCC allows (via language extensions) pointers to explicitly point to any
12247  of the memory spaces
12248 \begin_inset LatexCommand \index{Memory model}
12249
12250 \end_inset
12251
12252  of the 8051.
12253  In addition to the explicit pointers, the compiler uses (by default) generic
12254  pointers which can be used to point to any of the memory spaces.
12255 \newline
12256
12257 \newline
12258 Pointer
12259  declaration examples:
12260 \end_layout
12261
12262 \begin_layout Verse
12263
12264 \family typewriter
12265 /* pointer physically in internal ram pointing to object in external ram
12266  */ 
12267 \newline
12268 __xdata unsigned char * __data p;
12269 \newline
12270
12271 \newline
12272 /* pointer physically in external ram
12273  pointing to object in internal ram */ 
12274 \newline
12275 __data unsigned char * __xdata p;
12276 \newline
12277
12278 \newline
12279 /*
12280  pointer physically in code rom pointing to data in xdata space */ 
12281 \newline
12282 __xdata
12283  unsigned char * __code p;
12284 \newline
12285
12286 \newline
12287 /* pointer physically in code space pointing to
12288  data in code space */ 
12289 \newline
12290 __code unsigned char * __code p;
12291 \newline
12292
12293 \newline
12294 /* generic pointer
12295  physically located in xdata space */
12296 \newline
12297 unsigned char * __xdata p;
12298 \newline
12299
12300 \newline
12301 /* generic
12302  pointer physically located in default memory space */
12303 \newline
12304 unsigned char * p;
12305 \newline
12306
12307 \newline
12308 /*
12309  the following is a function pointer
12310 \begin_inset LatexCommand \index{function pointer}
12311
12312 \end_inset
12313
12314  physically located in data space */
12315 \newline
12316 char (* __data fp)(void);
12317 \end_layout
12318
12319 \begin_layout Standard
12320 Well you get the idea.
12321  
12322 \newline
12323
12324 \newline
12325 All unqualified pointers are treated as 3-byte (4-byte for the ds390) 
12326 \emph on
12327 generic
12328 \emph default
12329  pointers.
12330  
12331 \size small
12332
12333 \newline
12334
12335 \newline
12336
12337 \size default
12338 The highest order byte of the 
12339 \emph on
12340 generic
12341 \emph default
12342  pointers contains the data space information.
12343  Assembler support routines are called whenever data is stored or retrieved
12344  using 
12345 \emph on
12346 generic
12347 \emph default
12348  pointers.
12349  These are useful for developing reusable library
12350 \begin_inset LatexCommand \index{Libraries}
12351
12352 \end_inset
12353
12354  routines.
12355  Explicitly specifying the pointer
12356 \begin_inset LatexCommand \index{pointer}
12357
12358 \end_inset
12359
12360  type will generate the most efficient code.
12361 \end_layout
12362
12363 \begin_layout Subsubsection
12364 Notes on MCS51 memory
12365 \begin_inset LatexCommand \index{MCS51 memory}
12366
12367 \end_inset
12368
12369  layout
12370 \end_layout
12371
12372 \begin_layout Standard
12373 The 8051 family of microcontrollers have a minimum of 128 bytes of internal
12374  RAM memory which is structured as follows:
12375 \newline
12376
12377 \newline
12378 - Bytes 00-1F - 32 bytes to hold
12379  up to 4 banks of the registers R0 to R7, 
12380 \newline
12381 - Bytes 20-2F - 16 bytes to hold
12382  128 bit
12383 \begin_inset LatexCommand \index{bit}
12384
12385 \end_inset
12386
12387  variables and, 
12388 \newline
12389 - Bytes 30-7F - 80 bytes for general purpose use.
12390 \newline
12391
12392 \end_layout
12393
12394 \begin_layout Standard
12395 Additionally some members of the MCS51 family may have up to 128 bytes of
12396  additional, indirectly addressable, internal RAM memory (
12397 \emph on
12398 idata
12399 \emph default
12400
12401 \begin_inset LatexCommand \index{idata (mcs51, ds390 storage class)}
12402
12403 \end_inset
12404
12405
12406 \begin_inset LatexCommand \index{\_\_idata (mcs51, ds390 storage class)}
12407
12408 \end_inset
12409
12410 ).
12411  Furthermore, some chips may have some built in external memory (
12412 \emph on
12413 xdata
12414 \emph default
12415
12416 \begin_inset LatexCommand \index{xdata (mcs51, ds390 storage class)}
12417
12418 \end_inset
12419
12420
12421 \begin_inset LatexCommand \index{\_\_xdata (mcs51, ds390 storage class)}
12422
12423 \end_inset
12424
12425 ) which should not be confused with the internal, directly addressable RAM
12426  memory (
12427 \emph on
12428 data
12429 \emph default
12430
12431 \begin_inset LatexCommand \index{data (mcs51, ds390 storage class)}
12432
12433 \end_inset
12434
12435
12436 \begin_inset LatexCommand \index{\_\_data (mcs51, ds390 storage class)}
12437
12438 \end_inset
12439
12440 ).
12441  Sometimes this built in 
12442 \emph on
12443 xdata
12444 \emph default
12445  memory has to be activated before using it (you can probably find this
12446  information on the datasheet of the microcontroller your are using, see
12447  also section 
12448 \begin_inset LatexCommand \ref{sub:Startup-Code}
12449
12450 \end_inset
12451
12452 \InsetSpace ~
12453 Startup-Code).
12454 \end_layout
12455
12456 \begin_layout Standard
12457 Normally SDCC will only use the first bank
12458 \begin_inset LatexCommand \index{register bank (mcs51, ds390)}
12459
12460 \end_inset
12461
12462  of registers (register bank 0), but it is possible to specify that other
12463  banks of registers (keyword 
12464 \emph on
12465 using
12466 \emph default
12467  
12468 \emph on
12469
12470 \begin_inset LatexCommand \index{using (mcs51, ds390 register bank)}
12471
12472 \end_inset
12473
12474
12475 \begin_inset LatexCommand \index{\_\_using (mcs51, ds390 register bank)}
12476
12477 \end_inset
12478
12479
12480 \emph default
12481 ) should be used for example in interrupt
12482 \begin_inset LatexCommand \index{interrupt}
12483
12484 \end_inset
12485
12486
12487 \begin_inset LatexCommand \index{\_\_interrupt}
12488
12489 \end_inset
12490
12491  routines.
12492  By default, the compiler will place the stack after the last byte of allocated
12493  memory for variables.
12494  For example, if the first 2 banks of registers are used, and only four
12495  bytes are used for 
12496 \emph on
12497 data
12498 \emph default
12499  variables, it will position the base of the internal stack at address 20
12500  (0x14).
12501  This implies that as the stack
12502 \begin_inset LatexCommand \index{stack}
12503
12504 \end_inset
12505
12506  grows, it will use up the remaining register banks, and the 16 bytes used
12507  by the 128 bit variables, and 80 bytes for general purpose use.
12508  If any bit variables are used, the data variables will be placed in unused
12509  register banks and after the byte holding the last bit variable.
12510  For example, if register banks 0 and 1 are used, and there are 9 bit variables
12511  (two bytes used), 
12512 \emph on
12513 data
12514 \emph default
12515  variables will be placed starting from address 0x10 to 0x20 and continue
12516  at address 0x22.
12517  You can also use -
12518 \begin_inset ERT
12519 status collapsed
12520
12521 \begin_layout Standard
12522
12523
12524 \backslash
12525 /
12526 \end_layout
12527
12528 \end_inset
12529
12530 -data-loc
12531 \begin_inset LatexCommand \index{-\/-data-loc <Value>}
12532
12533 \end_inset
12534
12535  to specify the start address of the 
12536 \emph on
12537 data
12538 \emph default
12539  and -
12540 \begin_inset ERT
12541 status collapsed
12542
12543 \begin_layout Standard
12544
12545
12546 \backslash
12547 /
12548 \end_layout
12549
12550 \end_inset
12551
12552 -iram-size
12553 \begin_inset LatexCommand \index{-\/-iram-size <Value>}
12554
12555 \end_inset
12556
12557  to specify the size of the total internal RAM (
12558 \emph on
12559 data
12560 \emph default
12561 +
12562 \emph on
12563 idata
12564 \emph default
12565 ).
12566  
12567 \newline
12568
12569 \end_layout
12570
12571 \begin_layout Standard
12572 By default the 8051 linker will place the stack after the last byte of (i)data
12573  variables.
12574  Option -
12575 \begin_inset ERT
12576 status collapsed
12577
12578 \begin_layout Standard
12579
12580
12581 \backslash
12582 /
12583 \end_layout
12584
12585 \end_inset
12586
12587 -stack-loc
12588 \begin_inset LatexCommand \index{-\/-stack-loc <Value>}
12589
12590 \end_inset
12591
12592  allows you to specify the start of the stack, i.e.
12593  you could start it after any data in the general purpose area.
12594  If your microcontroller has additional indirectly addressable internal
12595  RAM (
12596 \emph on
12597 idata
12598 \emph default
12599 ) you can place the stack on it.
12600  You may also need to use -
12601 \begin_inset ERT
12602 status collapsed
12603
12604 \begin_layout Standard
12605
12606
12607 \backslash
12608 /
12609 \end_layout
12610
12611 \end_inset
12612
12613 -xdata-loc
12614 \begin_inset LatexCommand \index{-\/-xdata-loc<Value>}
12615
12616 \end_inset
12617
12618  to set the start address of the external RAM (
12619 \emph on
12620 xdata
12621 \emph default
12622 ) and -
12623 \begin_inset ERT
12624 status collapsed
12625
12626 \begin_layout Standard
12627
12628
12629 \backslash
12630 /
12631 \end_layout
12632
12633 \end_inset
12634
12635 -xram-size
12636 \begin_inset LatexCommand \index{-\/-xram-size <Value>}
12637
12638 \end_inset
12639
12640  to specify its size.
12641  Same goes for the code memory, using -
12642 \begin_inset ERT
12643 status collapsed
12644
12645 \begin_layout Standard
12646
12647
12648 \backslash
12649 /
12650 \end_layout
12651
12652 \end_inset
12653
12654 -code-loc
12655 \begin_inset LatexCommand \index{-\/-code-loc <Value>}
12656
12657 \end_inset
12658
12659  and -
12660 \begin_inset ERT
12661 status collapsed
12662
12663 \begin_layout Standard
12664
12665
12666 \backslash
12667 /
12668 \end_layout
12669
12670 \end_inset
12671
12672 -code-size
12673 \begin_inset LatexCommand \index{-\/-code-size <Value>}
12674
12675 \end_inset
12676
12677 .
12678  If in doubt, don't specify any options and see if the resulting memory
12679  layout is appropriate, then you can adjust it.
12680 \end_layout
12681
12682 \begin_layout Standard
12683 The linker generates two files with memory allocation information.
12684  The first, with extension .map
12685 \begin_inset LatexCommand \index{<file>.map}
12686
12687 \end_inset
12688
12689  shows all the variables and segments.
12690  The second with extension .mem
12691 \begin_inset LatexCommand \index{<file>.mem}
12692
12693 \end_inset
12694
12695  shows the final memory layout.
12696  The linker will complain either if memory segments overlap, there is not
12697  enough memory, or there is not enough space for stack.
12698  If you get any linking warnings and/or errors related to stack or segments
12699  allocation, take a look at either the .map or .mem files to find out what
12700  the problem is.
12701  The .mem file may even suggest a solution to the problem.
12702 \begin_inset VSpace bigskip
12703 \end_inset
12704
12705
12706 \end_layout
12707
12708 \begin_layout Subsection
12709 Z80/Z180 Storage Class
12710 \begin_inset LatexCommand \index{Z80!Storage class}
12711
12712 \end_inset
12713
12714  Language Extensions
12715 \end_layout
12716
12717 \begin_layout Subsubsection
12718 sfr
12719 \begin_inset LatexCommand \index{sfr}
12720
12721 \end_inset
12722
12723
12724 \begin_inset LatexCommand \index{\_\_sfr}
12725
12726 \end_inset
12727
12728  (in/out to 8-bit addresses)
12729 \end_layout
12730
12731 \begin_layout Standard
12732 The Z80
12733 \begin_inset LatexCommand \index{Z80}
12734
12735 \end_inset
12736
12737  family has separate address spaces for memory and 
12738 \emph on
12739 i
12740 \emph default
12741 nput/
12742 \emph on
12743 o
12744 \emph default
12745 utput memory.
12746  I/O memory
12747 \begin_inset LatexCommand \index{I/O memory (Z80, Z180)}
12748
12749 \end_inset
12750
12751
12752 \begin_inset LatexCommand \index{Z80!I/O memory}
12753
12754 \end_inset
12755
12756
12757 \begin_inset LatexCommand \index{Z180!I/O memory}
12758
12759 \end_inset
12760
12761  is accessed with special instructions, e.g.:
12762 \end_layout
12763
12764 \begin_layout Verse
12765
12766 \family typewriter
12767 sfr at 0x78 IoPort;\InsetSpace ~
12768 \InsetSpace ~
12769 /* define a var in I/O space at 78h called IoPort */
12770  
12771 \end_layout
12772
12773 \begin_layout Standard
12774 Writing 0x01 to this variable generates the assembly code:
12775 \end_layout
12776
12777 \begin_layout Verse
12778
12779 \family typewriter
12780 3E 01\InsetSpace ~
12781 \InsetSpace ~
12782 \InsetSpace ~
12783 \InsetSpace ~
12784 \InsetSpace ~
12785 \InsetSpace ~
12786 ld a,#0x01
12787 \newline
12788 D3 78\InsetSpace ~
12789 \InsetSpace ~
12790 \InsetSpace ~
12791 \InsetSpace ~
12792 \InsetSpace ~
12793 \InsetSpace ~
12794 out (_IoPort),a 
12795 \end_layout
12796
12797 \begin_layout Subsubsection
12798 banked sfr
12799 \begin_inset LatexCommand \index{sfr}
12800
12801 \end_inset
12802
12803
12804 \begin_inset LatexCommand \index{\_\_sfr}
12805
12806 \end_inset
12807
12808  (in/out to 16-bit addresses)
12809 \end_layout
12810
12811 \begin_layout Standard
12812 The keyword 
12813 \emph on
12814 banked
12815 \emph default
12816  is used to support 16 bit addresses in I/O memory e.g.:
12817 \end_layout
12818
12819 \begin_layout Verse
12820
12821 \family typewriter
12822 sfr banked at
12823 \begin_inset LatexCommand \index{at}
12824
12825 \end_inset
12826
12827
12828 \begin_inset LatexCommand \index{\_\_at}
12829
12830 \end_inset
12831
12832  0x123 IoPort; 
12833 \end_layout
12834
12835 \begin_layout Standard
12836 Writing 0x01 to this variable generates the assembly code:
12837 \end_layout
12838
12839 \begin_layout Verse
12840
12841 \family typewriter
12842 01 23 01\InsetSpace ~
12843 \InsetSpace ~
12844 \InsetSpace ~
12845 ld bc,#_IoPort
12846 \newline
12847 3E 01\InsetSpace ~
12848 \InsetSpace ~
12849 \InsetSpace ~
12850 \InsetSpace ~
12851 \InsetSpace ~
12852 \InsetSpace ~
12853 ld a,#0x01 
12854 \newline
12855 ED 79\InsetSpace ~
12856 \InsetSpace ~
12857 \InsetSpace ~
12858 \InsetSpace ~
12859 \InsetSpace ~
12860 \InsetSpace ~
12861 out (c),a 
12862 \end_layout
12863
12864 \begin_layout Subsubsection
12865 sfr
12866 \begin_inset LatexCommand \index{sfr}
12867
12868 \end_inset
12869
12870
12871 \begin_inset LatexCommand \index{\_\_sfr}
12872
12873 \end_inset
12874
12875  (in0/out0 to 8 bit addresses on Z180
12876 \begin_inset LatexCommand \index{Z180}
12877
12878 \end_inset
12879
12880 /HD64180
12881 \begin_inset LatexCommand \index{HD64180 (see Z180)}
12882
12883 \end_inset
12884
12885 )
12886 \end_layout
12887
12888 \begin_layout Standard
12889 The compiler option -
12890 \begin_inset ERT
12891 status collapsed
12892
12893 \begin_layout Standard
12894
12895
12896 \backslash
12897 /
12898 \end_layout
12899
12900 \end_inset
12901
12902 -portmode
12903 \begin_inset LatexCommand \index{Z180!Options!-\/-portmode}
12904
12905 \end_inset
12906
12907 =180 (80) and a compiler #pragma\InsetSpace ~
12908 portmode
12909 \begin_inset LatexCommand \index{Z180!Pragmas!\#pragma portmode}
12910
12911 \end_inset
12912
12913  z180 (z80) is used to turn on (off) the Z180/HD64180 port addressing instructio
12914 ns 
12915 \family typewriter
12916 in0/out0
12917 \family default
12918  instead of 
12919 \family typewriter
12920 in/out
12921 \family default
12922 .
12923  If you include the file z180.h this will be set automatically.
12924 \begin_inset VSpace bigskip
12925 \end_inset
12926
12927
12928 \end_layout
12929
12930 \begin_layout Subsection
12931 HC08 Storage Class
12932 \begin_inset LatexCommand \index{HC08!Storage class}
12933
12934 \end_inset
12935
12936  Language Extensions
12937 \end_layout
12938
12939 \begin_layout Subsubsection
12940 data
12941 \begin_inset LatexCommand \index{data (hc08 storage class)}
12942
12943 \end_inset
12944
12945
12946 \begin_inset LatexCommand \index{\_\_data (hc08 storage class)}
12947
12948 \end_inset
12949
12950  
12951 \end_layout
12952
12953 \begin_layout Standard
12954 The data storage class declares a variable that resides in the first 256
12955  bytes of memory (the direct page).
12956  The HC08
12957 \begin_inset LatexCommand \index{HC08}
12958
12959 \end_inset
12960
12961  is most efficient at accessing variables (especially pointers) stored here.
12962 \end_layout
12963
12964 \begin_layout Subsubsection
12965 xdata
12966 \begin_inset LatexCommand \index{xdata (hc08 storage class)}
12967
12968 \end_inset
12969
12970
12971 \begin_inset LatexCommand \index{\_\_xdata (hc08 storage class)}
12972
12973 \end_inset
12974
12975  
12976 \end_layout
12977
12978 \begin_layout Standard
12979 The xdata storage class declares a variable that can reside anywhere in
12980  memory.
12981  This is the default if no storage class is specified.
12982  
12983 \begin_inset VSpace bigskip
12984 \end_inset
12985
12986
12987 \end_layout
12988
12989 \begin_layout Section
12990 Absolute Addressing
12991 \begin_inset LatexCommand \index{Absolute addressing}
12992
12993 \end_inset
12994
12995
12996 \end_layout
12997
12998 \begin_layout Standard
12999 Data items can be assigned an absolute address with the 
13000 \emph on
13001 at
13002 \begin_inset LatexCommand \index{at}
13003
13004 \end_inset
13005
13006
13007 \begin_inset LatexCommand \index{\_\_at}
13008
13009 \end_inset
13010
13011  <address>
13012 \emph default
13013  keyword, in addition to a storage class, e.g.:
13014 \end_layout
13015
13016 \begin_layout Verse
13017
13018 \family typewriter
13019 xdata
13020 \begin_inset LatexCommand \index{xdata (mcs51, ds390 storage class)}
13021
13022 \end_inset
13023
13024
13025 \begin_inset LatexCommand \index{\_\_xdata (mcs51, ds390 storage class)}
13026
13027 \end_inset
13028
13029  at
13030 \begin_inset LatexCommand \index{at}
13031
13032 \end_inset
13033
13034
13035 \begin_inset LatexCommand \index{\_\_at}
13036
13037 \end_inset
13038
13039  0x7ffe unsigned int chksum;
13040 \end_layout
13041
13042 \begin_layout Standard
13043 or, better conforming to ISO/IEC 9899 C:
13044 \end_layout
13045
13046 \begin_layout Verse
13047
13048 \family typewriter
13049 __xdata __at (0x7ffe) unsigned int chksum;
13050 \end_layout
13051
13052 \begin_layout Standard
13053 In the above example the variable chksum will be located at 0x7ffe and 0x7fff
13054  of the external ram.
13055  The compiler does 
13056 \emph on
13057 not
13058 \emph default
13059  reserve any space for variables declared in this way
13060 \begin_inset Marginal
13061 status collapsed
13062
13063 \begin_layout Standard
13064
13065 \series bold
13066 \InsetSpace ~
13067 !
13068 \end_layout
13069
13070 \end_inset
13071
13072  (they are implemented with an equate in the assembler).
13073  Thus it is left to the programmer to make sure there are no overlaps with
13074  other variables that are declared without the absolute address.
13075  The assembler listing file (.lst
13076 \begin_inset LatexCommand \index{<file>.lst}
13077
13078 \end_inset
13079
13080 ) and the linker output files (.rst
13081 \begin_inset LatexCommand \index{<file>.rst}
13082
13083 \end_inset
13084
13085 ) and (.map
13086 \begin_inset LatexCommand \index{<file>.map}
13087
13088 \end_inset
13089
13090 ) are good places to look for such overlaps.
13091 \end_layout
13092
13093 \begin_layout Standard
13094 If however you provide an initializer
13095 \begin_inset LatexCommand \index{Variable initialization}
13096
13097 \end_inset
13098
13099  actual memory allocation will take place and overlaps will be detected
13100  by the linker.
13101  E.g.:
13102 \end_layout
13103
13104 \begin_layout Verse
13105
13106 \family typewriter
13107 __code __at (0x7ff0) char Id[5] = 
13108 \begin_inset Quotes sld
13109 \end_inset
13110
13111 SDCC
13112 \begin_inset Quotes srd
13113 \end_inset
13114
13115 ;
13116 \end_layout
13117
13118 \begin_layout Standard
13119 In the above example the variable Id will be located from 0x7ff0 to 0x7ff4
13120  in code memory.
13121 \end_layout
13122
13123 \begin_layout Standard
13124 In case of memory mapped I/O devices the keyword 
13125 \emph on
13126 volatile
13127 \emph default
13128  has to be used to tell the compiler that accesses might not be removed:
13129 \end_layout
13130
13131 \begin_layout Verse
13132
13133 \family typewriter
13134 volatile
13135 \begin_inset LatexCommand \index{volatile}
13136
13137 \end_inset
13138
13139  __xdata
13140 \begin_inset LatexCommand \index{xdata (mcs51, ds390 storage class)}
13141
13142 \end_inset
13143
13144  __at
13145 \begin_inset LatexCommand \index{at}
13146
13147 \end_inset
13148
13149  (0x8000) unsigned char PORTA_8255;
13150 \end_layout
13151
13152 \begin_layout Standard
13153 For some architectures (mcs51) array accesses are more efficient if an (xdata/fa
13154 r) array
13155 \family typewriter
13156 \size footnotesize
13157
13158 \begin_inset LatexCommand \index{Aligned array}
13159
13160 \end_inset
13161
13162
13163 \family default
13164 \size default
13165  starts at a block (256 byte) boundary
13166 \begin_inset LatexCommand \index{block boundary}
13167
13168 \end_inset
13169
13170  (section 
13171 \begin_inset LatexCommand \ref{sub:A-Step-by Assembler Introduction}
13172
13173 \end_inset
13174
13175  has an example).
13176 \newline
13177 Absolute addresses can be specified for variables in all
13178  storage classes, e.g.:
13179 \end_layout
13180
13181 \begin_layout Verse
13182
13183 \family typewriter
13184 __bit
13185 \begin_inset LatexCommand \index{bit}
13186
13187 \end_inset
13188
13189  __at
13190 \begin_inset LatexCommand \index{at}
13191
13192 \end_inset
13193
13194  (0x02) bvar;
13195 \end_layout
13196
13197 \begin_layout Standard
13198 The above example will allocate the variable at offset 0x02 in the bit-addressab
13199 le space.
13200  There is no real advantage to assigning absolute addresses to variables
13201  in this manner, unless you want strict control over all the variables allocated.
13202  One possible use would be to write hardware portable code.
13203  For example, if you have a routine that uses one or more of the microcontroller
13204  I/O pins, and such pins are different for two different hardwares, you
13205  can declare the I/O pins in your routine using:
13206 \end_layout
13207
13208 \begin_layout Verse
13209
13210 \family typewriter
13211 extern volatile
13212 \begin_inset LatexCommand \index{volatile}
13213
13214 \end_inset
13215
13216  __bit MOSI;\InsetSpace ~
13217 \InsetSpace ~
13218 \InsetSpace ~
13219 \InsetSpace ~
13220 /* master out, slave in */
13221 \newline
13222 extern volatile __bit MISO;\InsetSpace ~
13223 \InsetSpace ~
13224 \InsetSpace ~
13225 \InsetSpace ~
13226 /* master
13227  in, slave out */
13228 \newline
13229 extern volatile __bit MCLK;\InsetSpace ~
13230 \InsetSpace ~
13231 \InsetSpace ~
13232 \InsetSpace ~
13233 /* master clock */
13234 \newline
13235
13236 \newline
13237 /* Input and
13238  Output of a byte on a 3-wire serial bus.
13239 \newline
13240 \InsetSpace ~
13241 \InsetSpace ~
13242 \InsetSpace ~
13243 If needed adapt polarity of clock,
13244  polarity of data and bit order
13245 \newline
13246 \InsetSpace ~
13247 */
13248 \newline
13249 unsigned char spi_io(unsigned char out_byte)
13250  
13251 \newline
13252
13253 \newline
13254 \InsetSpace ~
13255 \InsetSpace ~
13256 \InsetSpace ~
13257 \InsetSpace ~
13258 unsigned char i=8;
13259 \newline
13260 \InsetSpace ~
13261 \InsetSpace ~
13262 \InsetSpace ~
13263 \InsetSpace ~
13264 do { 
13265 \newline
13266 \InsetSpace ~
13267 \InsetSpace ~
13268 \InsetSpace ~
13269 \InsetSpace ~
13270 \InsetSpace ~
13271 \InsetSpace ~
13272 \InsetSpace ~
13273 \InsetSpace ~
13274 MOSI = out_byte & 0x80; 
13275 \newline
13276 \InsetSpace ~
13277 \InsetSpace ~
13278 \InsetSpace ~
13279 \InsetSpace ~
13280 \InsetSpace ~
13281 \InsetSpace ~
13282 \InsetSpace ~
13283 \InsetSpace ~
13284 out_byte <<= 1;
13285 \newline
13286 \InsetSpace ~
13287 \InsetSpace ~
13288 \InsetSpace ~
13289 \InsetSpace ~
13290 \InsetSpace ~
13291 \InsetSpace ~
13292 \InsetSpace ~
13293 \InsetSpace ~
13294 MCLK =
13295  1; 
13296 \newline
13297 \InsetSpace ~
13298 \InsetSpace ~
13299 \InsetSpace ~
13300 \InsetSpace ~
13301 \InsetSpace ~
13302 \InsetSpace ~
13303 \InsetSpace ~
13304 \InsetSpace ~
13305 /* _asm nop _endasm; */\InsetSpace ~
13306 \InsetSpace ~
13307 \InsetSpace ~
13308 \InsetSpace ~
13309 \InsetSpace ~
13310 \InsetSpace ~
13311 \InsetSpace ~
13312 \InsetSpace ~
13313 /* for slow peripherals */
13314 \newline
13315 \InsetSpace ~
13316 \InsetSpace ~
13317 \InsetSpace ~
13318 \InsetSpace ~
13319 \InsetSpace ~
13320 \InsetSpace ~
13321 \InsetSpace ~
13322 \InsetSpace ~
13323 if(MISO) 
13324 \newline
13325 \InsetSpace ~
13326 \InsetSpace ~
13327 \InsetSpace ~
13328 \InsetSpace ~
13329 \InsetSpace ~
13330 \InsetSpace ~
13331 \InsetSpace ~
13332 \InsetSpace ~
13333 \InsetSpace ~
13334 \InsetSpace ~
13335 \InsetSpace ~
13336 \InsetSpace ~
13337 out_byte +=
13338  1; 
13339 \newline
13340 \InsetSpace ~
13341 \InsetSpace ~
13342 \InsetSpace ~
13343 \InsetSpace ~
13344 \InsetSpace ~
13345 \InsetSpace ~
13346 \InsetSpace ~
13347 \InsetSpace ~
13348 MCLK = 0; 
13349 \newline
13350 \InsetSpace ~
13351 \InsetSpace ~
13352 \InsetSpace ~
13353 \InsetSpace ~
13354 } while(--i);
13355 \newline
13356 \InsetSpace ~
13357 \InsetSpace ~
13358 \InsetSpace ~
13359 \InsetSpace ~
13360 return out_byte; 
13361 \newline
13362 }
13363 \end_layout
13364
13365 \begin_layout Standard
13366 Then, someplace in the code for the first hardware you would use
13367 \end_layout
13368
13369 \begin_layout Verse
13370
13371 \family typewriter
13372 __bit __at
13373 \begin_inset LatexCommand \index{at}
13374
13375 \end_inset
13376
13377
13378 \begin_inset LatexCommand \index{\_\_at}
13379
13380 \end_inset
13381
13382  (0x80) MOSI;\InsetSpace ~
13383 \InsetSpace ~
13384 \InsetSpace ~
13385 \InsetSpace ~
13386 /* I/O port 0, bit 0 */
13387 \newline
13388 __bit __at (0x81) MISO;\InsetSpace ~
13389 \InsetSpace ~
13390 \InsetSpace ~
13391 \InsetSpace ~
13392 /* I/O port 0,
13393  bit 1 */
13394 \newline
13395 __bit __at (0x82) MCLK;\InsetSpace ~
13396 \InsetSpace ~
13397 \InsetSpace ~
13398 \InsetSpace ~
13399 /* I/O port 0, bit 2 */
13400 \end_layout
13401
13402 \begin_layout Standard
13403 Similarly, for the second hardware you would use
13404 \end_layout
13405
13406 \begin_layout Verse
13407
13408 \family typewriter
13409 __bit __at (0x83) MOSI;\InsetSpace ~
13410 \InsetSpace ~
13411 \InsetSpace ~
13412 \InsetSpace ~
13413 /* I/O port 0, bit 3 */
13414 \newline
13415 __bit __at (0x91) MISO;\InsetSpace ~
13416 \InsetSpace ~
13417 \InsetSpace ~
13418 \InsetSpace ~
13419 /*
13420  I/O port 1, bit 1 */
13421 \newline
13422 __bit
13423 \begin_inset LatexCommand \index{bit}
13424
13425 \end_inset
13426
13427  __at (0x92) MCLK;\InsetSpace ~
13428 \InsetSpace ~
13429 \InsetSpace ~
13430 \InsetSpace ~
13431 /* I/O port 1, bit 2 */
13432 \end_layout
13433
13434 \begin_layout Standard
13435 and you can use the same hardware dependent routine without changes, as
13436  for example in a library.
13437  This is somehow similar to sbit, but only one absolute address has to be
13438  specified in the whole project.
13439 \begin_inset VSpace bigskip
13440 \end_inset
13441
13442
13443 \end_layout
13444
13445 \begin_layout Section
13446 Parameters
13447 \begin_inset LatexCommand \index{Parameters}
13448
13449 \end_inset
13450
13451
13452 \begin_inset LatexCommand \index{function parameter}
13453
13454 \end_inset
13455
13456  & Local Variables
13457 \begin_inset LatexCommand \index{local variables}
13458
13459 \end_inset
13460
13461
13462 \begin_inset LatexCommand \label{sec:Parameters-and-Local-Variables}
13463
13464 \end_inset
13465
13466
13467 \end_layout
13468
13469 \begin_layout Standard
13470 Automatic (local) variables and parameters to functions can either be placed
13471  on the stack or in data-space.
13472  The default action of the compiler is to place these variables in the internal
13473  RAM (for small model) or external RAM (for medium or large model).
13474  This in fact makes them similar to 
13475 \emph on
13476 static
13477 \begin_inset LatexCommand \index{static}
13478
13479 \end_inset
13480
13481
13482 \emph default
13483  so by default functions are non-reentrant
13484 \begin_inset LatexCommand \index{reentrant}
13485
13486 \end_inset
13487
13488 .
13489  
13490 \newline
13491
13492 \newline
13493 They can be placed on the stack
13494 \begin_inset LatexCommand \index{stack}
13495
13496 \end_inset
13497
13498  by using the
13499 \emph on
13500  -
13501 \begin_inset ERT
13502 status collapsed
13503
13504 \begin_layout Standard
13505
13506
13507 \backslash
13508 /
13509 \end_layout
13510
13511 \end_inset
13512
13513 -stack-auto
13514 \begin_inset LatexCommand \index{-\/-stack-auto}
13515
13516 \end_inset
13517
13518
13519 \emph default
13520  option, by using 
13521 \emph on
13522 #pragma\InsetSpace ~
13523 stackauto
13524 \emph default
13525
13526 \begin_inset LatexCommand \index{\#pragma stackauto}
13527
13528 \end_inset
13529
13530  or by using the 
13531 \emph on
13532 reentrant
13533 \begin_inset LatexCommand \index{reentrant}
13534
13535 \end_inset
13536
13537
13538 \emph default
13539  keyword in the function declaration, e.g.:
13540 \end_layout
13541
13542 \begin_layout Verse
13543
13544 \family typewriter
13545 unsigned char foo(char i) __reentrant 
13546 \newline
13547
13548 \newline
13549 \InsetSpace ~
13550 \InsetSpace ~
13551 \InsetSpace ~
13552 \InsetSpace ~
13553 ...
13554  
13555 \newline
13556 }
13557 \end_layout
13558
13559 \begin_layout Standard
13560 Since stack space on 8051 is limited, the 
13561 \emph on
13562 reentrant 
13563 \emph default
13564 keyword or the
13565 \emph on
13566  -
13567 \begin_inset ERT
13568 status collapsed
13569
13570 \begin_layout Standard
13571
13572
13573 \backslash
13574 /
13575 \end_layout
13576
13577 \end_inset
13578
13579 -stack-auto
13580 \emph default
13581  option should be used sparingly.
13582  Note that the reentrant keyword just means that the parameters & local
13583  variables will be allocated to the stack, it 
13584 \emph on
13585 does not
13586 \emph default
13587  mean that the function is register bank
13588 \begin_inset LatexCommand \index{register bank (mcs51, ds390)}
13589
13590 \end_inset
13591
13592  independent.
13593 \newline
13594
13595 \newline
13596 Local variables
13597 \begin_inset LatexCommand \index{local variables}
13598
13599 \end_inset
13600
13601  can be assigned storage classes and absolute
13602 \begin_inset LatexCommand \index{Absolute addressing}
13603
13604 \end_inset
13605
13606  addresses, e.g.: 
13607 \end_layout
13608
13609 \begin_layout Verse
13610
13611 \family typewriter
13612 unsigned char foo() 
13613 \newline
13614 {
13615 \newline
13616 \InsetSpace ~
13617 \InsetSpace ~
13618 \InsetSpace ~
13619 \InsetSpace ~
13620 __xdata unsigned char i;
13621 \newline
13622 \InsetSpace ~
13623 \InsetSpace ~
13624 \InsetSpace ~
13625 \InsetSpace ~
13626 __bit bvar;
13627 \newline
13628 \InsetSpace ~
13629 \InsetSpace ~
13630 \InsetSpace ~
13631 \InsetSpace ~
13632 __data __at
13633 \begin_inset LatexCommand \index{at}
13634
13635 \end_inset
13636
13637  (0x31) unsigned char j;
13638 \newline
13639 \InsetSpace ~
13640 \InsetSpace ~
13641 \InsetSpace ~
13642 \InsetSpace ~
13643 ...
13644  
13645 \newline
13646 }
13647 \end_layout
13648
13649 \begin_layout Standard
13650 In the above example the variable 
13651 \emph on
13652 i
13653 \emph default
13654  will be allocated in the external ram, 
13655 \emph on
13656 bvar
13657 \emph default
13658  in bit addressable space and
13659 \emph on
13660  j
13661 \emph default
13662  in internal ram.
13663  When compiled with 
13664 \emph on
13665 -
13666 \begin_inset ERT
13667 status collapsed
13668
13669 \begin_layout Standard
13670
13671
13672 \backslash
13673 /
13674 \end_layout
13675
13676 \end_inset
13677
13678 -stack-auto
13679 \emph default
13680  or when a function is declared as 
13681 \emph on
13682 reentrant
13683 \emph default
13684  this should only be done for static variables.
13685 \end_layout
13686
13687 \begin_layout Standard
13688 Parameters
13689 \begin_inset LatexCommand \index{function parameter}
13690
13691 \end_inset
13692
13693  however are not allowed any storage class
13694 \begin_inset LatexCommand \index{Storage class}
13695
13696 \end_inset
13697
13698 , (storage classes for parameters will be ignored), their allocation is
13699  governed by the memory model in use, and the reentrancy options.
13700 \end_layout
13701
13702 \begin_layout Standard
13703 It is however allowed to use bit parameters in reentrant functions and also
13704  non-static local bit variables are supported.
13705  Efficient use is limited to 8 semi-bitregisters in bit space.
13706  They are pushed and popped to stack
13707 \begin_inset LatexCommand \index{stack}
13708
13709 \end_inset
13710
13711  as a single byte just like the normal registers.
13712 \end_layout
13713
13714 \begin_layout Section
13715 Overlaying
13716 \begin_inset LatexCommand \label{sub:Overlaying}
13717
13718 \end_inset
13719
13720
13721 \begin_inset LatexCommand \index{Overlaying}
13722
13723 \end_inset
13724
13725
13726 \end_layout
13727
13728 \begin_layout Standard
13729 For non-reentrant
13730 \begin_inset LatexCommand \index{reentrant}
13731
13732 \end_inset
13733
13734  functions SDCC will try to reduce internal ram space usage by overlaying
13735  parameters and local variables of a function (if possible).
13736  Parameters and local variables
13737 \begin_inset LatexCommand \index{local variables}
13738
13739 \end_inset
13740
13741  of a function will be allocated to an overlayable segment if the function
13742  has 
13743 \emph on
13744 no other function calls and the function is non-reentrant and the memory
13745  model
13746 \begin_inset LatexCommand \index{Memory model}
13747
13748 \end_inset
13749
13750  is small.
13751
13752 \emph default
13753  If an explicit storage class
13754 \begin_inset LatexCommand \index{Storage class}
13755
13756 \end_inset
13757
13758  is specified for a local variable, it will NOT be overlayed.
13759 \end_layout
13760
13761 \begin_layout Standard
13762 Note that the compiler (not the linkage editor) makes the decision for overlayin
13763 g the data items.
13764  Functions that are called from an interrupt service routine
13765 \begin_inset Marginal
13766 status collapsed
13767
13768 \begin_layout Standard
13769
13770 \series bold
13771 !
13772 \end_layout
13773
13774 \end_inset
13775
13776  should be preceded by a #pragma\InsetSpace ~
13777 nooverlay
13778 \begin_inset LatexCommand \index{\#pragma nooverlay}
13779
13780 \end_inset
13781
13782  if they are not reentrant.
13783 \end_layout
13784
13785 \begin_layout Standard
13786 Also note that the compiler does not do any processing of inline assembler
13787  code, so the compiler might incorrectly assign local variables and parameters
13788  of a function into the overlay segment if the inline assembler code calls
13789  other c-functions that might use the overlay.
13790  In that case the #pragma\InsetSpace ~
13791 nooverlay should be used.
13792 \end_layout
13793
13794 \begin_layout Standard
13795 Parameters and local variables of functions that contain 16 or 32 bit multiplica
13796 tion
13797 \begin_inset LatexCommand \index{Multiplication}
13798
13799 \end_inset
13800
13801  or division
13802 \begin_inset LatexCommand \index{Division}
13803
13804 \end_inset
13805
13806  will NOT be overlayed since these are implemented using external functions,
13807  e.g.:
13808 \end_layout
13809
13810 \begin_layout Verse
13811
13812 \family typewriter
13813 #pragma save 
13814 \newline
13815 #pragma nooverlay
13816 \begin_inset LatexCommand \index{\#pragma nooverlay}
13817
13818 \end_inset
13819
13820  
13821 \newline
13822 void set_error(unsigned char errcd) 
13823 \newline
13824 {
13825 \newline
13826 \InsetSpace ~
13827 \InsetSpace ~
13828 \InsetSpace ~
13829 \InsetSpace ~
13830 P3 = errcd;
13831 \newline
13832
13833 \newline
13834 #pragma restore 
13835 \newline
13836
13837 \newline
13838 void
13839  some_isr () __interrupt
13840 \begin_inset LatexCommand \index{interrupt}
13841
13842 \end_inset
13843
13844  (2)
13845 \newline
13846 {
13847 \newline
13848 \InsetSpace ~
13849 \InsetSpace ~
13850 \InsetSpace ~
13851 \InsetSpace ~
13852 ...
13853 \newline
13854 \InsetSpace ~
13855 \InsetSpace ~
13856 \InsetSpace ~
13857 \InsetSpace ~
13858 set_error(10);
13859 \newline
13860 \InsetSpace ~
13861 \InsetSpace ~
13862 \InsetSpace ~
13863 \InsetSpace ~
13864 ...
13865  
13866 \newline
13867 }
13868 \end_layout
13869
13870 \begin_layout Standard
13871 In the above example the parameter 
13872 \emph on
13873 errcd
13874 \emph default
13875  for the function 
13876 \emph on
13877 set_error
13878 \emph default
13879  would be assigned to the overlayable segment if the #pragma\InsetSpace ~
13880 nooverlay was
13881  not present, this could cause unpredictable runtime behavior when called
13882  from an interrupt service routine.
13883  The #pragma\InsetSpace ~
13884 nooverlay ensures that the parameters and local variables for
13885  the function are NOT overlayed.
13886 \begin_inset VSpace bigskip
13887 \end_inset
13888
13889
13890 \end_layout
13891
13892 \begin_layout Section
13893 Interrupt Service Routines
13894 \begin_inset LatexCommand \label{sub:Interrupt-Service-Routines}
13895
13896 \end_inset
13897
13898
13899 \end_layout
13900
13901 \begin_layout Subsection
13902 General Information
13903 \end_layout
13904
13905 \begin_layout Standard
13906 SDCC allows 
13907 \emph on
13908 i
13909 \emph default
13910 nterrupt 
13911 \emph on
13912 s
13913 \emph default
13914 ervice 
13915 \emph on
13916 r
13917 \emph default
13918 outines to be coded in C, with some extended keywords.
13919 \end_layout
13920
13921 \begin_layout Verse
13922
13923 \family typewriter
13924 void timer_isr (void) __interrupt (1) __using (1) 
13925 \newline
13926
13927 \newline
13928 \InsetSpace ~
13929 \InsetSpace ~
13930 \InsetSpace ~
13931 \InsetSpace ~
13932 ...
13933  
13934 \newline
13935 }
13936 \end_layout
13937
13938 \begin_layout Standard
13939 The optional number following the 
13940 \emph on
13941 interrupt
13942 \begin_inset LatexCommand \index{interrupt}
13943
13944 \end_inset
13945
13946
13947 \begin_inset LatexCommand \index{\_\_interrupt}
13948
13949 \end_inset
13950
13951
13952 \emph default
13953  keyword is the interrupt number this routine will service.
13954  When present, the compiler will insert a call to this routine in the interrupt
13955  vector table
13956 \begin_inset LatexCommand \index{interrupt vector table}
13957
13958 \end_inset
13959
13960  for the interrupt number specified.
13961  If you have multiple source files in your project, interrupt service routines
13962  can be present in any of them, but a prototype of the isr MUST be present
13963  or included in the file that contains the function 
13964 \emph on
13965 main
13966 \emph default
13967 .
13968  The optional (8051 specific) keyword 
13969 \emph on
13970 using
13971 \begin_inset LatexCommand \index{using (mcs51, ds390 register bank)}
13972
13973 \end_inset
13974
13975
13976 \begin_inset LatexCommand \index{\_\_using (mcs51, ds390 register bank)}
13977
13978 \end_inset
13979
13980
13981 \emph default
13982  can be used to tell the compiler to use the specified register bank when
13983  generating code for this function.
13984  
13985 \newline
13986 Interrupt service routines open the door for some very interesting bugs:
13987 \end_layout
13988
13989 \begin_layout Subsubsection
13990 \begin_inset LatexCommand \label{sub:Common-interrupt-pitfall-volatile}
13991
13992 \end_inset
13993
13994 Common interrupt pitfall: variable not declared 
13995 \emph on
13996 volatile
13997 \end_layout
13998
13999 \begin_layout Standard
14000 If an interrupt service routine changes variables which are accessed by
14001  other functions these variables have to be declared 
14002 \emph on
14003 volatile
14004 \emph default
14005
14006 \begin_inset LatexCommand \index{volatile}
14007
14008 \end_inset
14009
14010 .
14011  See 
14012 \begin_inset LatexCommand \url{http://en.wikipedia.org/wiki/Volatile_variable}
14013
14014 \end_inset
14015
14016  .
14017 \end_layout
14018
14019 \begin_layout Subsubsection
14020 \begin_inset LatexCommand \label{sub:Common-interrupt-pitfall-non-atomic}
14021
14022 \end_inset
14023
14024 Common interrupt pitfall: 
14025 \emph on
14026 non-atomic access
14027 \end_layout
14028
14029 \begin_layout Standard
14030 If the access to these variables is not 
14031 \emph on
14032 atomic
14033 \begin_inset LatexCommand \index{atomic}
14034
14035 \end_inset
14036
14037
14038 \emph default
14039  (i.e.
14040  the processor needs more than one instruction for the access and could
14041  be interrupted while accessing the variable) the interrupt must be disabled
14042  during the access to avoid inconsistent data.
14043  
14044 \newline
14045 Access to 16 or 32 bit variables is obviously not atomic on 8 bit CPUs
14046  and should be protected by disabling interrupts.
14047  You're not automatically on the safe side if you use 8 bit variables though.
14048  We need an example here: f.e.
14049  on the 8051 the harmless looking 
14050 \begin_inset Quotes srd
14051 \end_inset
14052
14053
14054 \family typewriter
14055 flags\InsetSpace ~
14056 |=\InsetSpace ~
14057 0x80;
14058 \family default
14059
14060 \begin_inset Quotes sld
14061 \end_inset
14062
14063  is not atomic if 
14064 \family typewriter
14065 flags
14066 \family default
14067  resides in xdata.
14068  Setting 
14069 \begin_inset Quotes srd
14070 \end_inset
14071
14072
14073 \family typewriter
14074 flags\InsetSpace ~
14075 |=\InsetSpace ~
14076 0x40;
14077 \family default
14078
14079 \begin_inset Quotes sld
14080 \end_inset
14081
14082  from within an interrupt routine might get lost if the interrupt occurs
14083  at the wrong time.
14084  
14085 \begin_inset Quotes sld
14086 \end_inset
14087
14088
14089 \family typewriter
14090 counter\InsetSpace ~
14091 +=\InsetSpace ~
14092 8;
14093 \family default
14094
14095 \begin_inset Quotes srd
14096 \end_inset
14097
14098  is not atomic on the 8051 even if 
14099 \family typewriter
14100 counter
14101 \family default
14102  is located in data memory.
14103 \newline
14104 Bugs like these are hard to reproduce and can
14105  cause a lot of trouble.
14106  
14107 \end_layout
14108
14109 \begin_layout Subsubsection
14110 \begin_inset LatexCommand \label{sub:Common-interrupt-pitfall-stack-overflow}
14111
14112 \end_inset
14113
14114 Common interrupt pitfall: 
14115 \emph on
14116 stack overflow
14117 \end_layout
14118
14119 \begin_layout Standard
14120 The return address and the registers used in the interrupt service routine
14121  are saved on the stack
14122 \begin_inset LatexCommand \index{stack}
14123
14124 \end_inset
14125
14126  so there must be sufficient stack space.
14127  If there isn't variables or registers (or even the return address itself)
14128  will be corrupted.
14129  This 
14130 \emph on
14131 stack overflow
14132 \emph default
14133
14134 \begin_inset LatexCommand \index{stack overflow}
14135
14136 \end_inset
14137
14138  is most likely to happen if the interrupt occurs during the 
14139 \begin_inset Quotes sld
14140 \end_inset
14141
14142 deepest
14143 \begin_inset Quotes srd
14144 \end_inset
14145
14146  subroutine when the stack is already in use for f.e.
14147  many return addresses.
14148 \end_layout
14149
14150 \begin_layout Subsubsection
14151 \begin_inset LatexCommand \label{sub:Common-interrupt-pitfall-non-reentrant}
14152
14153 \end_inset
14154
14155 Common interrupt pitfall: 
14156 \emph on
14157 use of non-reentrant functions
14158 \end_layout
14159
14160 \begin_layout Standard
14161 A special note here, int (16 bit) and long (32 bit) integer division
14162 \begin_inset LatexCommand \index{Division}
14163
14164 \end_inset
14165
14166 , multiplication
14167 \begin_inset LatexCommand \index{Multiplication}
14168
14169 \end_inset
14170
14171  & modulus
14172 \begin_inset LatexCommand \index{Modulus}
14173
14174 \end_inset
14175
14176  and floating-point
14177 \begin_inset LatexCommand \index{Floating point support}
14178
14179 \end_inset
14180
14181  operations are implemented using external support routines.
14182  If an interrupt service routine needs to do any of these operations then
14183  the support routines (as mentioned in a following section) will have to
14184  be recompiled using the
14185 \emph on
14186  -
14187 \begin_inset ERT
14188 status collapsed
14189
14190 \begin_layout Standard
14191
14192
14193 \backslash
14194 /
14195 \end_layout
14196
14197 \end_inset
14198
14199 -stack-auto
14200 \begin_inset LatexCommand \index{-\/-stack-auto}
14201
14202 \end_inset
14203
14204
14205 \emph default
14206  option and the source file will need to be compiled using the 
14207 \emph on
14208 -
14209 \begin_inset ERT
14210 status collapsed
14211
14212 \begin_layout Standard
14213
14214
14215 \backslash
14216 /
14217 \end_layout
14218
14219 \end_inset
14220
14221 -int-long-reent
14222 \emph default
14223
14224 \begin_inset LatexCommand \index{-\/-int-long-reent}
14225
14226 \end_inset
14227
14228  compiler option.
14229  
14230 \newline
14231 Note, the type promotion
14232 \begin_inset LatexCommand \index{type promotion}
14233
14234 \end_inset
14235
14236  required by ANSI C can cause 16 bit routines to be used
14237 \begin_inset Marginal
14238 status collapsed
14239
14240 \begin_layout Standard
14241
14242 \series bold
14243 \InsetSpace ~
14244 !
14245 \end_layout
14246
14247 \end_inset
14248
14249  without the programmer being aware of it.
14250  See f.e.
14251  the cast 
14252 \family typewriter
14253 (unsigned char)(tail-1)
14254 \family default
14255  within the if clause in section 
14256 \begin_inset LatexCommand \ref{sub:A-Step-by Assembler Introduction}
14257
14258 \end_inset
14259
14260 .
14261 \end_layout
14262
14263 \begin_layout Standard
14264 Calling other functions from an interrupt service routine is not recommended,
14265  avoid it if possible.
14266  Note that when some function is called from an interrupt service routine
14267  it should be preceded by a #pragma\InsetSpace ~
14268 nooverlay
14269 \begin_inset LatexCommand \index{\#pragma nooverlay}
14270
14271 \end_inset
14272
14273  if it is not reentrant.
14274  Furthermore nonreentrant functions should not be called from the main program
14275  while the interrupt service routine might be active.
14276  They also must not be called from low priority interrupt service routines
14277  while a high priority interrupt service routine might be active.
14278  You could use semaphores or make the function
14279 \emph on
14280  critical
14281 \emph default
14282  if all parameters are passed in registers.
14283 \newline
14284  Also see section 
14285 \begin_inset LatexCommand \ref{sub:Overlaying}
14286
14287 \end_inset
14288
14289 \InsetSpace ~
14290 about Overlaying and section 
14291 \begin_inset LatexCommand \ref{sub:Functions-using-private-banks}
14292
14293 \end_inset
14294
14295 \InsetSpace ~
14296 about Functions using private register banks.
14297 \begin_inset VSpace bigskip
14298 \end_inset
14299
14300
14301 \end_layout
14302
14303 \begin_layout Subsection
14304 MCS51/DS390 Interrupt Service Routines
14305 \end_layout
14306
14307 \begin_layout Standard
14308 Interrupt
14309 \begin_inset LatexCommand \index{interrupt}
14310
14311 \end_inset
14312
14313  numbers and the corresponding address & descriptions for the Standard 8051/8052
14314  are listed below.
14315  SDCC will automatically adjust the 
14316 \begin_inset LatexCommand \index{interrupt vector table}
14317
14318 \end_inset
14319
14320  to the maximum interrupt number specified.
14321 \newline
14322
14323 \end_layout
14324
14325 \begin_layout Standard
14326 \align center
14327 \begin_inset Tabular
14328 <lyxtabular version="3" rows="9" columns="3">
14329 <features>
14330 <column alignment="center" valignment="top" leftline="true" width="0in">
14331 <column alignment="left" valignment="top" leftline="true" width="0in">
14332 <column alignment="left" valignment="top" leftline="true" rightline="true" width="0in">
14333 <row topline="true" bottomline="true">
14334 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14335 \begin_inset Text
14336
14337 \begin_layout Standard
14338 Interrupt #
14339 \end_layout
14340
14341 \end_inset
14342 </cell>
14343 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14344 \begin_inset Text
14345
14346 \begin_layout Standard
14347 Description
14348 \end_layout
14349
14350 \end_inset
14351 </cell>
14352 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
14353 \begin_inset Text
14354
14355 \begin_layout Standard
14356 Vector Address
14357 \end_layout
14358
14359 \end_inset
14360 </cell>
14361 </row>
14362 <row topline="true">
14363 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14364 \begin_inset Text
14365
14366 \begin_layout Standard
14367 0
14368 \end_layout
14369
14370 \end_inset
14371 </cell>
14372 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14373 \begin_inset Text
14374
14375 \begin_layout Standard
14376 External 0
14377 \end_layout
14378
14379 \end_inset
14380 </cell>
14381 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
14382 \begin_inset Text
14383
14384 \begin_layout Standard
14385 0x0003
14386 \end_layout
14387
14388 \end_inset
14389 </cell>
14390 </row>
14391 <row topline="true">
14392 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14393 \begin_inset Text
14394
14395 \begin_layout Standard
14396 1
14397 \end_layout
14398
14399 \end_inset
14400 </cell>
14401 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14402 \begin_inset Text
14403
14404 \begin_layout Standard
14405 Timer 0
14406 \end_layout
14407
14408 \end_inset
14409 </cell>
14410 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
14411 \begin_inset Text
14412
14413 \begin_layout Standard
14414 0x000b
14415 \end_layout
14416
14417 \end_inset
14418 </cell>
14419 </row>
14420 <row topline="true">
14421 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14422 \begin_inset Text
14423
14424 \begin_layout Standard
14425 2
14426 \end_layout
14427
14428 \end_inset
14429 </cell>
14430 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14431 \begin_inset Text
14432
14433 \begin_layout Standard
14434 External 1
14435 \end_layout
14436
14437 \end_inset
14438 </cell>
14439 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
14440 \begin_inset Text
14441
14442 \begin_layout Standard
14443 0x0013
14444 \end_layout
14445
14446 \end_inset
14447 </cell>
14448 </row>
14449 <row topline="true">
14450 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14451 \begin_inset Text
14452
14453 \begin_layout Standard
14454 3
14455 \end_layout
14456
14457 \end_inset
14458 </cell>
14459 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14460 \begin_inset Text
14461
14462 \begin_layout Standard
14463 Timer 1
14464 \end_layout
14465
14466 \end_inset
14467 </cell>
14468 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
14469 \begin_inset Text
14470
14471 \begin_layout Standard
14472 0x001b
14473 \end_layout
14474
14475 \end_inset
14476 </cell>
14477 </row>
14478 <row topline="true">
14479 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14480 \begin_inset Text
14481
14482 \begin_layout Standard
14483 4
14484 \end_layout
14485
14486 \end_inset
14487 </cell>
14488 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14489 \begin_inset Text
14490
14491 \begin_layout Standard
14492 Serial
14493 \end_layout
14494
14495 \end_inset
14496 </cell>
14497 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
14498 \begin_inset Text
14499
14500 \begin_layout Standard
14501 0x0023
14502 \end_layout
14503
14504 \end_inset
14505 </cell>
14506 </row>
14507 <row topline="true">
14508 <cell multicolumn="1" alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14509 \begin_inset Text
14510
14511 \begin_layout Standard
14512 5
14513 \end_layout
14514
14515 \end_inset
14516 </cell>
14517 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14518 \begin_inset Text
14519
14520 \begin_layout Standard
14521 Timer 2 (8052)
14522 \end_layout
14523
14524 \end_inset
14525 </cell>
14526 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
14527 \begin_inset Text
14528
14529 \begin_layout Standard
14530 0x002b
14531 \end_layout
14532
14533 \end_inset
14534 </cell>
14535 </row>
14536 <row topline="true">
14537 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14538 \begin_inset Text
14539
14540 \begin_layout Standard
14541 ...
14542 \end_layout
14543
14544 \end_inset
14545 </cell>
14546 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14547 \begin_inset Text
14548
14549 \begin_layout Standard
14550
14551 \end_layout
14552
14553 \end_inset
14554 </cell>
14555 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
14556 \begin_inset Text
14557
14558 \begin_layout Standard
14559 ...
14560 \end_layout
14561
14562 \end_inset
14563 </cell>
14564 </row>
14565 <row topline="true" bottomline="true">
14566 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14567 \begin_inset Text
14568
14569 \begin_layout Standard
14570 n
14571 \end_layout
14572
14573 \end_inset
14574 </cell>
14575 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14576 \begin_inset Text
14577
14578 \begin_layout Standard
14579
14580 \end_layout
14581
14582 \end_inset
14583 </cell>
14584 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
14585 \begin_inset Text
14586
14587 \begin_layout Standard
14588 0x0003 + 8*n
14589 \end_layout
14590
14591 \end_inset
14592 </cell>
14593 </row>
14594 </lyxtabular>
14595
14596 \end_inset
14597
14598
14599 \newline
14600
14601 \end_layout
14602
14603 \begin_layout Standard
14604 If the interrupt service routine is defined without 
14605 \emph on
14606 using
14607 \begin_inset LatexCommand \index{using (mcs51, ds390 register bank)}
14608
14609 \end_inset
14610
14611
14612 \begin_inset LatexCommand \index{\_\_using (mcs51, ds390 register bank)}
14613
14614 \end_inset
14615
14616
14617 \emph default
14618  a register bank or with register bank 0 (
14619 \emph on
14620 using
14621 \emph default
14622  0), the compiler will save the registers used by itself on the stack upon
14623  entry and restore them at exit, however if such an interrupt service routine
14624  calls another function then the entire register bank will be saved on the
14625  stack.
14626  This scheme may be advantageous for small interrupt service routines which
14627  have low register usage.
14628 \end_layout
14629
14630 \begin_layout Standard
14631 If the interrupt service routine is defined to be using a specific register
14632  bank then only 
14633 \emph on
14634 a, b, dptr
14635 \emph default
14636  & psw are saved and restored, if such an interrupt service routine calls
14637  another function (using another register bank) then the entire register
14638  bank of the called function will be saved on the stack
14639 \begin_inset LatexCommand \index{stack}
14640
14641 \end_inset
14642
14643 .
14644  This scheme is recommended for larger interrupt service routines.
14645 \begin_inset VSpace bigskip
14646 \end_inset
14647
14648
14649 \end_layout
14650
14651 \begin_layout Subsection
14652 HC08
14653 \begin_inset LatexCommand \index{HC08}
14654
14655 \end_inset
14656
14657  Interrupt Service Routines
14658 \end_layout
14659
14660 \begin_layout Standard
14661 Since the number of interrupts
14662 \begin_inset LatexCommand \index{HC08!interrupt}
14663
14664 \end_inset
14665
14666  available is chip specific and the interrupt vector table always ends at
14667  the last byte of memory, the interrupt numbers corresponds to the interrupt
14668  vectors in reverse order of address.
14669  For example, interrupt 1 will use the interrupt vector at 0xfffc, interrupt
14670  2 will use the interrupt vector at 0xfffa, and so on.
14671  However, interrupt 0 (the reset vector at 0xfffe) is not redefinable in
14672  this way; instead see section 
14673 \begin_inset LatexCommand \ref{sub:Startup-Code}
14674
14675 \end_inset
14676
14677  for details on customizing startup.
14678 \begin_inset VSpace bigskip
14679 \end_inset
14680
14681
14682 \end_layout
14683
14684 \begin_layout Subsection
14685 Z80 Interrupt Service Routines
14686 \end_layout
14687
14688 \begin_layout Standard
14689 The Z80
14690 \begin_inset LatexCommand \index{Z80}
14691
14692 \end_inset
14693
14694  uses several different methods for determining the correct interrupt
14695 \begin_inset LatexCommand \index{Z80!interrupt}
14696
14697 \end_inset
14698
14699  vector depending on the hardware implementation.
14700  Therefore, SDCC ignores the optional interrupt number and does not attempt
14701  to generate an interrupt vector table.
14702 \end_layout
14703
14704 \begin_layout Standard
14705 By default, SDCC generates code for a maskable interrupt, which uses a RETI
14706  instruction to return from the interrupt.
14707  To write an interrupt handler for the non-maskable interrupt, which needs
14708  a RETN instruction instead, add the 
14709 \emph on
14710 critical
14711 \emph default
14712  keyword:
14713 \end_layout
14714
14715 \begin_layout Verse
14716
14717 \family typewriter
14718 void nmi_isr (void) critical interrupt
14719 \newline
14720
14721 \newline
14722 \InsetSpace ~
14723 \InsetSpace ~
14724 \InsetSpace ~
14725 \InsetSpace ~
14726 ...
14727  
14728 \newline
14729 }
14730 \end_layout
14731
14732 \begin_layout Standard
14733 However if you need to create a non-interruptable interrupt service routine
14734  you would also require the 
14735 \emph on
14736 critical
14737 \emph default
14738  keyword.
14739  To distinguish between this and an nmi_isr you must provide an interrupt
14740  number.
14741 \begin_inset VSpace bigskip
14742 \end_inset
14743
14744
14745 \end_layout
14746
14747 \begin_layout Section
14748 Enabling and Disabling Interrupts
14749 \end_layout
14750
14751 \begin_layout Subsection
14752 Critical Functions and Critical Statements
14753 \end_layout
14754
14755 \begin_layout Standard
14756 A special keyword may be associated with a block or a function declaring
14757  it as 
14758 \emph on
14759 critical
14760 \emph default
14761 .
14762  SDCC will generate code to disable all interrupts
14763 \begin_inset LatexCommand \index{interrupt}
14764
14765 \end_inset
14766
14767  upon entry to a critical function and restore the interrupt enable to the
14768  previous state before returning.
14769  Nesting critical functions will need one additional byte on the stack
14770 \begin_inset LatexCommand \index{stack}
14771
14772 \end_inset
14773
14774  for each call.
14775 \end_layout
14776
14777 \begin_layout Verse
14778
14779 \family typewriter
14780 int foo () __critical
14781 \begin_inset LatexCommand \index{critical}
14782
14783 \end_inset
14784
14785
14786 \begin_inset LatexCommand \index{\_\_critical}
14787
14788 \end_inset
14789
14790  
14791 \newline
14792
14793 \newline
14794 \InsetSpace ~
14795 \InsetSpace ~
14796 \InsetSpace ~
14797 \InsetSpace ~
14798 ...
14799  
14800 \newline
14801 \InsetSpace ~
14802 \InsetSpace ~
14803 \InsetSpace ~
14804 \InsetSpace ~
14805 ...
14806  
14807 \newline
14808 }
14809 \end_layout
14810
14811 \begin_layout Standard
14812 The critical attribute maybe used with other attributes like 
14813 \emph on
14814 reentrant.
14815 \emph default
14816
14817 \newline
14818 The keyword 
14819 \emph on
14820 critical
14821 \emph default
14822  may also be used to disable interrupts more locally:
14823 \end_layout
14824
14825 \begin_layout Verse
14826
14827 \family typewriter
14828 __critical{ i++; }
14829 \end_layout
14830
14831 \begin_layout Standard
14832 More than one statement could have been included in the block.
14833 \end_layout
14834
14835 \begin_layout Subsection
14836 Enabling and Disabling Interrupts directly
14837 \end_layout
14838
14839 \begin_layout Standard
14840 Interrupts
14841 \begin_inset LatexCommand \index{interrupt}
14842
14843 \end_inset
14844
14845  can also be disabled and enabled directly (8051):
14846 \end_layout
14847
14848 \begin_layout Verse
14849
14850 \family typewriter
14851 EA = 0;\InsetSpace ~
14852 \InsetSpace ~
14853 \InsetSpace ~
14854 \InsetSpace ~
14855 \InsetSpace ~
14856 \InsetSpace ~
14857 \InsetSpace ~
14858 \InsetSpace ~
14859 \InsetSpace ~
14860 \InsetSpace ~
14861 \InsetSpace ~
14862 \InsetSpace ~
14863 or:\InsetSpace ~
14864 \InsetSpace ~
14865 \InsetSpace ~
14866 \InsetSpace ~
14867 \InsetSpace ~
14868 \InsetSpace ~
14869 \InsetSpace ~
14870 \InsetSpace ~
14871 \InsetSpace ~
14872 \InsetSpace ~
14873 \InsetSpace ~
14874 EA_SAVE = EA;
14875 \end_layout
14876
14877 \begin_layout Verse
14878
14879 \family typewriter
14880 ...\InsetSpace ~
14881 \InsetSpace ~
14882 \InsetSpace ~
14883 \InsetSpace ~
14884 \InsetSpace ~
14885 \InsetSpace ~
14886 \InsetSpace ~
14887 \InsetSpace ~
14888 \InsetSpace ~
14889 \InsetSpace ~
14890 \InsetSpace ~
14891 \InsetSpace ~
14892 \InsetSpace ~
14893 \InsetSpace ~
14894 \InsetSpace ~
14895 \InsetSpace ~
14896 \InsetSpace ~
14897 \InsetSpace ~
14898 \InsetSpace ~
14899 \InsetSpace ~
14900 \InsetSpace ~
14901 \InsetSpace ~
14902 \InsetSpace ~
14903 \InsetSpace ~
14904 \InsetSpace ~
14905 \InsetSpace ~
14906 \InsetSpace ~
14907 \InsetSpace ~
14908 \InsetSpace ~
14909 \InsetSpace ~
14910 EA = 0;
14911 \end_layout
14912
14913 \begin_layout Verse
14914
14915 \family typewriter
14916 EA = 1;\InsetSpace ~
14917 \InsetSpace ~
14918 \InsetSpace ~
14919 \InsetSpace ~
14920 \InsetSpace ~
14921 \InsetSpace ~
14922 \InsetSpace ~
14923 \InsetSpace ~
14924 \InsetSpace ~
14925 \InsetSpace ~
14926 \InsetSpace ~
14927 \InsetSpace ~
14928 \InsetSpace ~
14929 \InsetSpace ~
14930 \InsetSpace ~
14931 \InsetSpace ~
14932 \InsetSpace ~
14933 \InsetSpace ~
14934 \InsetSpace ~
14935 \InsetSpace ~
14936 \InsetSpace ~
14937 \InsetSpace ~
14938 \InsetSpace ~
14939 \InsetSpace ~
14940 \InsetSpace ~
14941 \InsetSpace ~
14942 ...
14943 \end_layout
14944
14945 \begin_layout Verse
14946
14947 \family typewriter
14948 \InsetSpace ~
14949 \InsetSpace ~
14950 \InsetSpace ~
14951 \InsetSpace ~
14952 \InsetSpace ~
14953 \InsetSpace ~
14954 \InsetSpace ~
14955 \InsetSpace ~
14956 \InsetSpace ~
14957 \InsetSpace ~
14958 \InsetSpace ~
14959 \InsetSpace ~
14960 \InsetSpace ~
14961 \InsetSpace ~
14962 \InsetSpace ~
14963 \InsetSpace ~
14964 \InsetSpace ~
14965 \InsetSpace ~
14966 \InsetSpace ~
14967 \InsetSpace ~
14968 \InsetSpace ~
14969 \InsetSpace ~
14970 \InsetSpace ~
14971 \InsetSpace ~
14972 \InsetSpace ~
14973 \InsetSpace ~
14974 \InsetSpace ~
14975 \InsetSpace ~
14976 \InsetSpace ~
14977 \InsetSpace ~
14978 \InsetSpace ~
14979 \InsetSpace ~
14980 \InsetSpace ~
14981 EA = EA_SAVE;
14982 \end_layout
14983
14984 \begin_layout Standard
14985 On other architectures which have seperate opcodes for enabling and disabling
14986  interrupts you might want to make use of defines with inline assembly
14987 \begin_inset LatexCommand \index{Assembler routines}
14988
14989 \end_inset
14990
14991  (HC08
14992 \begin_inset LatexCommand \index{HC08!interrupt}
14993
14994 \end_inset
14995
14996 ):
14997 \end_layout
14998
14999 \begin_layout Verse
15000
15001 \family typewriter
15002 #define CLI _asm
15003 \begin_inset LatexCommand \index{\_asm}
15004
15005 \end_inset
15006
15007 \InsetSpace ~
15008 \InsetSpace ~
15009 cli\InsetSpace ~
15010 \InsetSpace ~
15011 _endasm
15012 \begin_inset LatexCommand \index{\_endasm}
15013
15014 \end_inset
15015
15016
15017 \end_layout
15018
15019 \begin_layout Verse
15020
15021 \family typewriter
15022 #define SEI _asm\InsetSpace ~
15023 \InsetSpace ~
15024 sei\InsetSpace ~
15025 \InsetSpace ~
15026 _endasm; 
15027 \end_layout
15028
15029 \begin_layout Verse
15030
15031 \family typewriter
15032 ...
15033 \end_layout
15034
15035 \begin_layout Standard
15036 Note: it is sometimes sufficient to disable only a specific interrupt source
15037  like f.e.
15038  a timer or serial interrupt by manipulating an 
15039 \emph on
15040 interrupt mask
15041 \begin_inset LatexCommand \index{interrupt mask}
15042
15043 \end_inset
15044
15045
15046 \emph default
15047  register.
15048  
15049 \end_layout
15050
15051 \begin_layout Standard
15052 Usually the time during which interrupts are disabled should be kept as
15053  short as possible.
15054  This minimizes both 
15055 \emph on
15056 interrupt latency
15057 \emph default
15058
15059 \begin_inset LatexCommand \index{interrupt latency}
15060
15061 \end_inset
15062
15063  (the time between the occurrence of the interrupt and the execution of
15064  the first code in the interrupt routine) and 
15065 \emph on
15066 interrupt jitter
15067 \emph default
15068
15069 \begin_inset LatexCommand \index{interrupt jitter}
15070
15071 \end_inset
15072
15073  (the difference between the shortest and the longest interrupt latency).
15074  These really are something different, f.e.
15075  a serial interrupt has to be served before its buffer overruns so it cares
15076  for the maximum interrupt latency, whereas it does not care about jitter.
15077  On a loudspeaker driven via a digital to analog converter which is fed
15078  by an interrupt a latency of a few milliseconds might be tolerable, whereas
15079  a much smaller jitter will be very audible.
15080 \end_layout
15081
15082 \begin_layout Standard
15083 You can reenable interrupts within an interrupt routine and on some architecture
15084 s you can make use of two (or more) levels of 
15085 \emph on
15086 interrupt priorities
15087 \emph default
15088
15089 \begin_inset LatexCommand \index{interrupt priority}
15090
15091 \end_inset
15092
15093 .
15094  On some architectures which don't support interrupt priorities these can
15095  be implemented by manipulating the interrupt mask and reenabling interrupts
15096  within the interrupt routine.
15097  Check there is sufficient space on the stack
15098 \begin_inset LatexCommand \index{stack}
15099
15100 \end_inset
15101
15102  and don't add complexity unless you have to.
15103  
15104 \end_layout
15105
15106 \begin_layout Subsection
15107 Semaphore
15108 \begin_inset LatexCommand \index{semaphore}
15109
15110 \end_inset
15111
15112  locking (mcs51/ds390)
15113 \end_layout
15114
15115 \begin_layout Standard
15116 Some architectures (mcs51/ds390) have an atomic
15117 \begin_inset LatexCommand \index{atomic}
15118
15119 \end_inset
15120
15121  bit test and
15122 \emph on
15123  
15124 \emph default
15125 clear
15126 \emph on
15127  
15128 \emph default
15129 instruction.
15130  These type of instructions are typically used in preemptive multitasking
15131  systems, where a routine f.e.
15132  claims the use of a data structure ('acquires a lock
15133 \begin_inset LatexCommand \index{lock}
15134
15135 \end_inset
15136
15137  on it'), makes some modifications and then releases the lock when the data
15138  structure is consistent again.
15139  The instruction may also be used if interrupt and non-interrupt code have
15140  to compete for a resource.
15141  With the atomic bit test and clear instruction interrupts
15142 \begin_inset LatexCommand \index{interrupt}
15143
15144 \end_inset
15145
15146  don't have to be disabled for the locking operation.
15147  
15148 \end_layout
15149
15150 \begin_layout Standard
15151 SDCC generates this instruction if the source follows this pattern:
15152 \end_layout
15153
15154 \begin_layout Verse
15155
15156 \family typewriter
15157 volatile
15158 \begin_inset LatexCommand \index{volatile}
15159
15160 \end_inset
15161
15162  bit resource_is_free; 
15163 \newline
15164
15165 \newline
15166 if (resource_is_free) 
15167 \newline
15168 \InsetSpace ~
15169 \InsetSpace ~
15170
15171 \newline
15172 \InsetSpace ~
15173 \InsetSpace ~
15174 \InsetSpace ~
15175 \InsetSpace ~
15176 resource_is_free=0; 
15177 \newline
15178 \InsetSpace ~
15179 \InsetSpace ~
15180 \InsetSpace ~
15181 \InsetSpace ~
15182 ...
15183  
15184 \newline
15185 \InsetSpace ~
15186 \InsetSpace ~
15187 \InsetSpace ~
15188 \InsetSpace ~
15189 resource_is_free=1;
15190 \newline
15191 \InsetSpace ~
15192 \InsetSpace ~
15193
15194 \end_layout
15195
15196 \begin_layout Standard
15197 Note, mcs51 and ds390 support only an atomic
15198 \begin_inset LatexCommand \index{atomic}
15199
15200 \end_inset
15201
15202  bit test and 
15203 \emph on
15204 clear
15205 \emph default
15206  instruction (as opposed to atomic bit test and 
15207 \emph on
15208 set).
15209 \end_layout
15210
15211 \begin_layout Section
15212 Functions using private register banks
15213 \begin_inset LatexCommand \label{sub:Functions-using-private-banks}
15214
15215 \end_inset
15216
15217  (mcs51/ds390)
15218 \end_layout
15219
15220 \begin_layout Standard
15221 Some architectures have support for quickly changing register sets.
15222  SDCC supports this feature with the 
15223 \emph on
15224 using
15225 \begin_inset LatexCommand \index{using (mcs51, ds390 register bank)}
15226
15227 \end_inset
15228
15229
15230 \begin_inset LatexCommand \index{\_\_using (mcs51, ds390 register bank)}
15231
15232 \end_inset
15233
15234
15235 \emph default
15236  attribute (which tells the compiler to use a register bank
15237 \begin_inset LatexCommand \index{register bank (mcs51, ds390)}
15238
15239 \end_inset
15240
15241  other than the default bank zero).
15242  It should only be applied to 
15243 \emph on
15244 interrupt
15245 \begin_inset LatexCommand \index{interrupt}
15246
15247 \end_inset
15248
15249
15250 \emph default
15251  functions (see footnote below).
15252  This will in most circumstances make the generated ISR code more efficient
15253  since it will not have to save registers on the stack.
15254 \end_layout
15255
15256 \begin_layout Standard
15257 The 
15258 \emph on
15259 using
15260 \emph default
15261  attribute will have no effect on the generated code for a 
15262 \emph on
15263 non-interrupt
15264 \emph default
15265  function (but may occasionally be useful anyway
15266 \begin_inset Foot
15267 status open
15268
15269 \begin_layout Standard
15270 possible exception: if a function is called ONLY from 'interrupt' functions
15271  using a particular bank, it can be declared with the same 'using' attribute
15272  as the calling 'interrupt' functions.
15273  For instance, if you have several ISRs using bank one, and all of them
15274  call memcpy(), it might make sense to create a specialized version of memcpy()
15275  'using 1', since this would prevent the ISR from having to save bank zero
15276  to the stack on entry and switch to bank zero before calling the function
15277 \end_layout
15278
15279 \end_inset
15280
15281 ).
15282 \newline
15283
15284 \emph on
15285 (pending: Note, nowadays the 
15286 \emph default
15287 using
15288 \emph on
15289  attribute has an effect on
15290 \emph default
15291  
15292 \emph on
15293 the generated code for a 
15294 \emph default
15295 non-interrupt
15296 \emph on
15297  function
15298 \emph default
15299 .
15300 \emph on
15301 )
15302 \end_layout
15303
15304 \begin_layout Standard
15305 An 
15306 \emph on
15307 interrupt
15308 \emph default
15309  function using a non-zero bank will assume that it can trash that register
15310  bank, and will not save it.
15311  Since high-priority interrupts
15312 \begin_inset LatexCommand \index{interrupts}
15313
15314 \end_inset
15315
15316
15317 \begin_inset LatexCommand \index{interrupt priority}
15318
15319 \end_inset
15320
15321  can interrupt low-priority ones on the 8051 and friends, this means that
15322  if a high-priority ISR 
15323 \emph on
15324 using
15325 \emph default
15326  a particular bank occurs while processing a low-priority ISR 
15327 \emph on
15328 using
15329 \emph default
15330  the same bank, terrible and bad things can happen.
15331  To prevent this, no single register bank should be 
15332 \emph on
15333 used
15334 \emph default
15335  by both a high priority and a low priority ISR.
15336  This is probably most easily done by having all high priority ISRs use
15337  one bank and all low priority ISRs use another.
15338  If you have an ISR which can change priority at runtime, you're on your
15339  own: I suggest using the default bank zero and taking the small performance
15340  hit.
15341 \end_layout
15342
15343 \begin_layout Standard
15344 It is most efficient if your ISR calls no other functions.
15345  If your ISR must call other functions, it is most efficient if those functions
15346  use the same bank as the ISR (see note 1 below); the next best is if the
15347  called functions use bank zero.
15348  It is very inefficient to call a function using a different, non-zero bank
15349  from an ISR.
15350  
15351 \begin_inset VSpace bigskip
15352 \end_inset
15353
15354
15355 \end_layout
15356
15357 \begin_layout Section
15358 Startup Code
15359 \begin_inset LatexCommand \label{sub:Startup-Code}
15360
15361 \end_inset
15362
15363
15364 \begin_inset LatexCommand \index{Startup code}
15365
15366 \end_inset
15367
15368
15369 \end_layout
15370
15371 \begin_layout Subsection
15372 MCS51/DS390 Startup Code
15373 \end_layout
15374
15375 \begin_layout Standard
15376 The compiler triggers the linker to link certain initialization modules
15377  from the runtime library
15378 \begin_inset LatexCommand \index{Runtime library}
15379
15380 \end_inset
15381
15382  called crt<something>.
15383  Only the necessary ones are linked, for instance crtxstack.asm (GSINIT1,
15384  GSINIT5) is not linked unless the -
15385 \series bold
15386
15387 \begin_inset ERT
15388 status open
15389
15390 \begin_layout Standard
15391
15392
15393 \backslash
15394 /
15395 \end_layout
15396
15397 \end_inset
15398
15399
15400 \series default
15401 -xstack option is used.
15402  These modules are highly entangled by the use of special segments/areas,
15403  but a common layout is shown below:
15404 \end_layout
15405
15406 \begin_layout Verse
15407
15408 \family typewriter
15409 \series bold
15410 \size footnotesize
15411 (main.asm)
15412 \end_layout
15413
15414 \begin_layout Verse
15415
15416 \family typewriter
15417 \size footnotesize
15418 \InsetSpace ~
15419 \InsetSpace ~
15420 \InsetSpace ~
15421 \InsetSpace ~
15422 \InsetSpace ~
15423 \InsetSpace ~
15424 \InsetSpace ~
15425 \InsetSpace ~
15426 .area HOME (CODE)
15427 \newline
15428 __interrupt_vect:
15429 \newline
15430 \InsetSpace ~
15431 \InsetSpace ~
15432 \InsetSpace ~
15433 \InsetSpace ~
15434 \InsetSpace ~
15435 \InsetSpace ~
15436 \InsetSpace ~
15437 \InsetSpace ~
15438 ljmp __sdcc_gsinit_startup
15439 \end_layout
15440
15441 \begin_layout Verse
15442
15443 \family typewriter
15444 \series bold
15445 \size footnotesize
15446 (crtstart.asm)
15447 \end_layout
15448
15449 \begin_layout Verse
15450
15451 \family typewriter
15452 \size footnotesize
15453 \InsetSpace ~
15454 \InsetSpace ~
15455 \InsetSpace ~
15456 \InsetSpace ~
15457 \InsetSpace ~
15458 \InsetSpace ~
15459 \InsetSpace ~
15460 \InsetSpace ~
15461 .area GSINIT0 (CODE)
15462 \newline
15463 __sdcc_gsinit_startup::
15464 \newline
15465 \InsetSpace ~
15466 \InsetSpace ~
15467 \InsetSpace ~
15468 \InsetSpace ~
15469 \InsetSpace ~
15470 \InsetSpace ~
15471 \InsetSpace ~
15472 \InsetSpace ~
15473 mov sp,#__start__stack - 1
15474 \end_layout
15475
15476 \begin_layout Verse
15477
15478 \family typewriter
15479 \series bold
15480 \size footnotesize
15481 (crtxstack.asm)
15482 \end_layout
15483
15484 \begin_layout Verse
15485
15486 \family typewriter
15487 \size footnotesize
15488 \InsetSpace ~
15489 \InsetSpace ~
15490 \InsetSpace ~
15491 \InsetSpace ~
15492 \InsetSpace ~
15493 \InsetSpace ~
15494 \InsetSpace ~
15495 \InsetSpace ~
15496 .area GSINIT1 (CODE)
15497 \newline
15498 __sdcc_init_xstack::
15499 \newline
15500 ; Need to initialize in GSINIT1 in
15501  case the user's __sdcc_external_startup uses the xstack.
15502 \newline
15503 \InsetSpace ~
15504 \InsetSpace ~
15505 \InsetSpace ~
15506 \InsetSpace ~
15507 \InsetSpace ~
15508 \InsetSpace ~
15509 \InsetSpace ~
15510 \InsetSpace ~
15511 mov __XPAGE,#(__start__x
15512 stack >> 8)
15513 \newline
15514 \InsetSpace ~
15515 \InsetSpace ~
15516 \InsetSpace ~
15517 \InsetSpace ~
15518 \InsetSpace ~
15519 \InsetSpace ~
15520 \InsetSpace ~
15521 \InsetSpace ~
15522 mov _spx,#__start__xstack
15523 \end_layout
15524
15525 \begin_layout Verse
15526
15527 \family typewriter
15528 \series bold
15529 \size footnotesize
15530 (crtstart.asm)
15531 \end_layout
15532
15533 \begin_layout Verse
15534
15535 \family typewriter
15536 \size footnotesize
15537 \InsetSpace ~
15538 \InsetSpace ~
15539 \InsetSpace ~
15540 \InsetSpace ~
15541 \InsetSpace ~
15542 \InsetSpace ~
15543 \InsetSpace ~
15544 \InsetSpace ~
15545 .area GSINIT2 (CODE)
15546 \newline
15547 \InsetSpace ~
15548 \InsetSpace ~
15549 \InsetSpace ~
15550 \InsetSpace ~
15551 \InsetSpace ~
15552 \InsetSpace ~
15553 \InsetSpace ~
15554 \InsetSpace ~
15555 lcall __sdcc_external_startup
15556 \newline
15557 \InsetSpace ~
15558 \InsetSpace ~
15559 \InsetSpace ~
15560 \InsetSpace ~
15561 \InsetSpace ~
15562 \InsetSpace ~
15563 \InsetSpace ~
15564 \InsetSpace ~
15565 mov a,dpl
15566 \newline
15567 \InsetSpace ~
15568 \InsetSpace ~
15569 \InsetSpace ~
15570 \InsetSpace ~
15571 \InsetSpace ~
15572 \InsetSpace ~
15573 \InsetSpace ~
15574 \InsetSpace ~
15575 jz __sdcc_init_data
15576 \newline
15577 \InsetSpace ~
15578 \InsetSpace ~
15579 \InsetSpace ~
15580 \InsetSpace ~
15581 \InsetSpace ~
15582 \InsetSpace ~
15583 \InsetSpace ~
15584 \InsetSpace ~
15585 ljmp
15586  __sdcc_program_startup
15587 \newline
15588 __sdcc_init_data:
15589 \end_layout
15590
15591 \begin_layout Verse
15592
15593 \family typewriter
15594 \series bold
15595 \size footnotesize
15596 (crtxinit.asm)
15597 \end_layout
15598
15599 \begin_layout Verse
15600
15601 \family typewriter
15602 \size footnotesize
15603 \InsetSpace ~
15604 \InsetSpace ~
15605 \InsetSpace ~
15606 \InsetSpace ~
15607 \InsetSpace ~
15608 \InsetSpace ~
15609 \InsetSpace ~
15610 \InsetSpace ~
15611 .area GSINIT3 (CODE)
15612 \newline
15613 __mcs51_genXINIT::
15614 \newline
15615 \InsetSpace ~
15616 \InsetSpace ~
15617 \InsetSpace ~
15618 \InsetSpace ~
15619 \InsetSpace ~
15620 \InsetSpace ~
15621 \InsetSpace ~
15622 \InsetSpace ~
15623 mov r1,#l_XINIT
15624 \newline
15625 \InsetSpace ~
15626 \InsetSpace ~
15627 \InsetSpace ~
15628 \InsetSpace ~
15629 \InsetSpace ~
15630 \InsetSpace ~
15631 \InsetSpace ~
15632 \InsetSpace ~
15633 mov a,r1
15634 \newline
15635 \InsetSpace ~
15636 \InsetSpace ~
15637 \InsetSpace ~
15638 \InsetSpace ~
15639 \InsetSpace ~
15640 \InsetSpace ~
15641 \InsetSpace ~
15642 \InsetSpace ~
15643 orl a,#(l_XINIT
15644  >> 8)
15645 \newline
15646 \InsetSpace ~
15647 \InsetSpace ~
15648 \InsetSpace ~
15649 \InsetSpace ~
15650 \InsetSpace ~
15651 \InsetSpace ~
15652 \InsetSpace ~
15653 \InsetSpace ~
15654 jz 00003$
15655 \newline
15656 \InsetSpace ~
15657 \InsetSpace ~
15658 \InsetSpace ~
15659 \InsetSpace ~
15660 \InsetSpace ~
15661 \InsetSpace ~
15662 \InsetSpace ~
15663 \InsetSpace ~
15664 mov r2,#((l_XINIT+255) >> 8)
15665 \newline
15666 \InsetSpace ~
15667 \InsetSpace ~
15668 \InsetSpace ~
15669 \InsetSpace ~
15670 \InsetSpace ~
15671 \InsetSpace ~
15672 \InsetSpace ~
15673 \InsetSpace ~
15674 mov dptr,#s_XINIT
15675 \newline
15676 \InsetSpace ~
15677 \InsetSpace ~
15678 \InsetSpace ~
15679 \InsetSpace ~
15680 \InsetSpace ~
15681 \InsetSpace ~
15682 \InsetSpace ~
15683 \InsetSpace ~
15684 mov r0,#s_XISEG
15685 \newline
15686 \InsetSpace ~
15687 \InsetSpace ~
15688 \InsetSpace ~
15689 \InsetSpace ~
15690 \InsetSpace ~
15691 \InsetSpace ~
15692 \InsetSpace ~
15693 \InsetSpace ~
15694 mov
15695  __XPAGE,#(s_XISEG >> 8)
15696 \newline
15697 00001$:\InsetSpace ~
15698 clr a
15699 \newline
15700 \InsetSpace ~
15701 \InsetSpace ~
15702 \InsetSpace ~
15703 \InsetSpace ~
15704 \InsetSpace ~
15705 \InsetSpace ~
15706 \InsetSpace ~
15707 \InsetSpace ~
15708 movc a,@a+dptr
15709 \newline
15710 \InsetSpace ~
15711 \InsetSpace ~
15712 \InsetSpace ~
15713 \InsetSpace ~
15714 \InsetSpace ~
15715 \InsetSpace ~
15716 \InsetSpace ~
15717 \InsetSpace ~
15718 movx @r0,a
15719 \newline
15720 \InsetSpace ~
15721 \InsetSpace ~
15722 \InsetSpace ~
15723 \InsetSpace ~
15724 \InsetSpace ~
15725 \InsetSpace ~
15726 \InsetSpace ~
15727 \InsetSpace ~
15728 inc dptr
15729 \newline
15730 \InsetSpace ~
15731 \InsetSpace ~
15732 \InsetSpace ~
15733 \InsetSpace ~
15734 \InsetSpace ~
15735 \InsetSpace ~
15736 \InsetSpace ~
15737 \InsetSpace ~
15738 inc
15739  r0
15740 \newline
15741 \InsetSpace ~
15742 \InsetSpace ~
15743 \InsetSpace ~
15744 \InsetSpace ~
15745 \InsetSpace ~
15746 \InsetSpace ~
15747 \InsetSpace ~
15748 \InsetSpace ~
15749 cjne r0,#0,00002$
15750 \newline
15751 \InsetSpace ~
15752 \InsetSpace ~
15753 \InsetSpace ~
15754 \InsetSpace ~
15755 \InsetSpace ~
15756 \InsetSpace ~
15757 \InsetSpace ~
15758 \InsetSpace ~
15759 inc __XPAGE
15760 \newline
15761 00002$:\InsetSpace ~
15762 djnz r1,00001$
15763 \newline
15764 \InsetSpace ~
15765 \InsetSpace ~
15766 \InsetSpace ~
15767 \InsetSpace ~
15768 \InsetSpace ~
15769 \InsetSpace ~
15770 \InsetSpace ~
15771 \InsetSpace ~
15772 djnz r2,00001$
15773 \newline
15774 \InsetSpace ~
15775 \InsetSpace ~
15776 \InsetSpace ~
15777 \InsetSpace ~
15778 \InsetSpace ~
15779 \InsetSpace ~
15780 \InsetSpace ~
15781 \InsetSpace ~
15782 mov __XPAGE,#0
15783 xFF
15784 \newline
15785 00003$:
15786 \end_layout
15787
15788 \begin_layout Verse
15789
15790 \family typewriter
15791 \series bold
15792 \size footnotesize
15793 (crtclear.asm)
15794 \end_layout
15795
15796 \begin_layout Verse
15797
15798 \family typewriter
15799 \size footnotesize
15800 \InsetSpace ~
15801 \InsetSpace ~
15802 \InsetSpace ~
15803 \InsetSpace ~
15804 \InsetSpace ~
15805 \InsetSpace ~
15806 \InsetSpace ~
15807 \InsetSpace ~
15808 .area GSINIT4 (CODE)
15809 \newline
15810 __mcs51_genRAMCLEAR::
15811 \newline
15812 \InsetSpace ~
15813 \InsetSpace ~
15814 \InsetSpace ~
15815 \InsetSpace ~
15816 \InsetSpace ~
15817 \InsetSpace ~
15818 \InsetSpace ~
15819 \InsetSpace ~
15820 clr a
15821 \newline
15822 \InsetSpace ~
15823 \InsetSpace ~
15824 \InsetSpace ~
15825 \InsetSpace ~
15826 \InsetSpace ~
15827 \InsetSpace ~
15828 \InsetSpace ~
15829 \InsetSpace ~
15830 mov r0,#(l_IRAM-1)
15831 \newline
15832 00004$:\InsetSpace ~
15833 mov
15834  @r0,a
15835 \newline
15836 \InsetSpace ~
15837 \InsetSpace ~
15838 \InsetSpace ~
15839 \InsetSpace ~
15840 \InsetSpace ~
15841 \InsetSpace ~
15842 \InsetSpace ~
15843 \InsetSpace ~
15844 djnz r0,00004$
15845 \newline
15846 ; _mcs51_genRAMCLEAR() end
15847 \end_layout
15848
15849 \begin_layout Verse
15850
15851 \family typewriter
15852 \series bold
15853 \size footnotesize
15854 (crtxclear.asm)
15855 \end_layout
15856
15857 \begin_layout Verse
15858
15859 \family typewriter
15860 \size footnotesize
15861 \InsetSpace ~
15862 \InsetSpace ~
15863 \InsetSpace ~
15864 \InsetSpace ~
15865 \InsetSpace ~
15866 \InsetSpace ~
15867 \InsetSpace ~
15868 \InsetSpace ~
15869 .area GSINIT4 (CODE)
15870 \newline
15871 __mcs51_genXRAMCLEAR::
15872 \newline
15873 \InsetSpace ~
15874 \InsetSpace ~
15875 \InsetSpace ~
15876 \InsetSpace ~
15877 \InsetSpace ~
15878 \InsetSpace ~
15879 \InsetSpace ~
15880 \InsetSpace ~
15881 mov r0,#l_PSEG
15882 \newline
15883 \InsetSpace ~
15884 \InsetSpace ~
15885 \InsetSpace ~
15886 \InsetSpace ~
15887 \InsetSpace ~
15888 \InsetSpace ~
15889 \InsetSpace ~
15890 \InsetSpace ~
15891 mov a,r0
15892 \newline
15893 \InsetSpace ~
15894 \InsetSpace ~
15895 \InsetSpace ~
15896 \InsetSpace ~
15897 \InsetSpace ~
15898 \InsetSpace ~
15899 \InsetSpace ~
15900 \InsetSpace ~
15901 orl a,#(l_PSEG
15902  >> 8)
15903 \newline
15904 \InsetSpace ~
15905 \InsetSpace ~
15906 \InsetSpace ~
15907 \InsetSpace ~
15908 \InsetSpace ~
15909 \InsetSpace ~
15910 \InsetSpace ~
15911 \InsetSpace ~
15912 jz 00006$
15913 \newline
15914 \InsetSpace ~
15915 \InsetSpace ~
15916 \InsetSpace ~
15917 \InsetSpace ~
15918 \InsetSpace ~
15919 \InsetSpace ~
15920 \InsetSpace ~
15921 \InsetSpace ~
15922 mov r1,#s_PSEG
15923 \newline
15924 \InsetSpace ~
15925 \InsetSpace ~
15926 \InsetSpace ~
15927 \InsetSpace ~
15928 \InsetSpace ~
15929 \InsetSpace ~
15930 \InsetSpace ~
15931 \InsetSpace ~
15932 mov __XPAGE,#(s_PSEG >> 8)
15933 \newline
15934 \InsetSpace ~
15935 \InsetSpace ~
15936 \InsetSpace ~
15937 \InsetSpace ~
15938 \InsetSpace ~
15939 \InsetSpace ~
15940 \InsetSpace ~
15941 \InsetSpace ~
15942 clr a
15943 \newline
15944 00005$:\InsetSpace ~
15945 movx
15946  @r1,a
15947 \newline
15948 \InsetSpace ~
15949 \InsetSpace ~
15950 \InsetSpace ~
15951 \InsetSpace ~
15952 \InsetSpace ~
15953 \InsetSpace ~
15954 \InsetSpace ~
15955 \InsetSpace ~
15956 inc r1
15957 \newline
15958 \InsetSpace ~
15959 \InsetSpace ~
15960 \InsetSpace ~
15961 \InsetSpace ~
15962 \InsetSpace ~
15963 \InsetSpace ~
15964 \InsetSpace ~
15965 \InsetSpace ~
15966 djnz r0,00005$
15967 \newline
15968 00006$:
15969 \newline
15970 \InsetSpace ~
15971 \InsetSpace ~
15972 \InsetSpace ~
15973 \InsetSpace ~
15974 \InsetSpace ~
15975 \InsetSpace ~
15976 \InsetSpace ~
15977 \InsetSpace ~
15978 mov r0,#l_XSEG
15979 \newline
15980 \InsetSpace ~
15981 \InsetSpace ~
15982 \InsetSpace ~
15983 \InsetSpace ~
15984 \InsetSpace ~
15985 \InsetSpace ~
15986 \InsetSpace ~
15987 \InsetSpace ~
15988 mov a,r0
15989 \newline
15990 \InsetSpace ~
15991 \InsetSpace ~
15992 \InsetSpace ~
15993 \InsetSpace ~
15994 \InsetSpace ~
15995 \InsetSpace ~
15996 \InsetSpace ~
15997 \InsetSpace ~
15998 orl a,#(l_XSEG >>
15999  8)
16000 \newline
16001 \InsetSpace ~
16002 \InsetSpace ~
16003 \InsetSpace ~
16004 \InsetSpace ~
16005 \InsetSpace ~
16006 \InsetSpace ~
16007 \InsetSpace ~
16008 \InsetSpace ~
16009 jz 00008$
16010 \newline
16011 \InsetSpace ~
16012 \InsetSpace ~
16013 \InsetSpace ~
16014 \InsetSpace ~
16015 \InsetSpace ~
16016 \InsetSpace ~
16017 \InsetSpace ~
16018 \InsetSpace ~
16019 mov r1,#((l_XSEG + 255) >> 8)
16020 \newline
16021 \InsetSpace ~
16022 \InsetSpace ~
16023 \InsetSpace ~
16024 \InsetSpace ~
16025 \InsetSpace ~
16026 \InsetSpace ~
16027 \InsetSpace ~
16028 \InsetSpace ~
16029 mov dptr,#s_XSEG
16030 \newline
16031 \InsetSpace ~
16032 \InsetSpace ~
16033 \InsetSpace ~
16034 \InsetSpace ~
16035 \InsetSpace ~
16036 \InsetSpace ~
16037 \InsetSpace ~
16038 \InsetSpace ~
16039 clr a
16040 \newline
16041 00007$:\InsetSpace ~
16042 movx
16043  @dptr,a
16044 \newline
16045 \InsetSpace ~
16046 \InsetSpace ~
16047 \InsetSpace ~
16048 \InsetSpace ~
16049 \InsetSpace ~
16050 \InsetSpace ~
16051 \InsetSpace ~
16052 \InsetSpace ~
16053 inc dptr
16054 \newline
16055 \InsetSpace ~
16056 \InsetSpace ~
16057 \InsetSpace ~
16058 \InsetSpace ~
16059 \InsetSpace ~
16060 \InsetSpace ~
16061 \InsetSpace ~
16062 \InsetSpace ~
16063 djnz r0,00007$
16064 \newline
16065 \InsetSpace ~
16066 \InsetSpace ~
16067 \InsetSpace ~
16068 \InsetSpace ~
16069 \InsetSpace ~
16070 \InsetSpace ~
16071 \InsetSpace ~
16072 \InsetSpace ~
16073 djnz r1,00007$
16074 \newline
16075 00008$:
16076 \end_layout
16077
16078 \begin_layout Verse
16079
16080 \family typewriter
16081 \series bold
16082 \size footnotesize
16083 (crtxstack.asm)
16084 \end_layout
16085
16086 \begin_layout Verse
16087
16088 \family typewriter
16089 \size footnotesize
16090 \InsetSpace ~
16091 \InsetSpace ~
16092 \InsetSpace ~
16093 \InsetSpace ~
16094 \InsetSpace ~
16095 \InsetSpace ~
16096 \InsetSpace ~
16097 \InsetSpace ~
16098 .area GSINIT5 (CODE)
16099 \newline
16100 ; Need to initialize in GSINIT5 because __mcs51_genXINIT
16101  modifies __XPAGE
16102 \newline
16103 ; and __mcs51_genRAMCLEAR modifies _spx.
16104 \newline
16105 \InsetSpace ~
16106 \InsetSpace ~
16107 \InsetSpace ~
16108 \InsetSpace ~
16109 \InsetSpace ~
16110 \InsetSpace ~
16111 \InsetSpace ~
16112 \InsetSpace ~
16113 mov __XPAGE,#(__start__x
16114 stack >> 8)
16115 \newline
16116 \InsetSpace ~
16117 \InsetSpace ~
16118 \InsetSpace ~
16119 \InsetSpace ~
16120 \InsetSpace ~
16121 \InsetSpace ~
16122 \InsetSpace ~
16123 \InsetSpace ~
16124 mov _spx,#__start__xstack
16125 \end_layout
16126
16127 \begin_layout Verse
16128
16129 \family typewriter
16130 \series bold
16131 \size footnotesize
16132 (application modules)
16133 \end_layout
16134
16135 \begin_layout Verse
16136
16137 \family typewriter
16138 \size footnotesize
16139 \InsetSpace ~
16140 \InsetSpace ~
16141 \InsetSpace ~
16142 \InsetSpace ~
16143 \InsetSpace ~
16144 \InsetSpace ~
16145 \InsetSpace ~
16146 \InsetSpace ~
16147 .area GSINIT (CODE)
16148 \end_layout
16149
16150 \begin_layout Verse
16151
16152 \family typewriter
16153 \series bold
16154 \size footnotesize
16155 (main.asm)
16156 \end_layout
16157
16158 \begin_layout Verse
16159
16160 \family typewriter
16161 \size footnotesize
16162 \InsetSpace ~
16163 \InsetSpace ~
16164 \InsetSpace ~
16165 \InsetSpace ~
16166 \InsetSpace ~
16167 \InsetSpace ~
16168 \InsetSpace ~
16169 \InsetSpace ~
16170 .area GSFINAL (CODE)
16171 \newline
16172 \InsetSpace ~
16173 \InsetSpace ~
16174 \InsetSpace ~
16175 \InsetSpace ~
16176 \InsetSpace ~
16177 \InsetSpace ~
16178 \InsetSpace ~
16179 \InsetSpace ~
16180 ljmp __sdcc_program_startup
16181 \newline
16182 ;---------------------------------
16183 -----------------------
16184 \newline
16185 ; Home
16186 \newline
16187 ;--------------------------------------------------
16188 ------
16189 \newline
16190 \InsetSpace ~
16191 \InsetSpace ~
16192 \InsetSpace ~
16193 \InsetSpace ~
16194 \InsetSpace ~
16195 \InsetSpace ~
16196 \InsetSpace ~
16197 \InsetSpace ~
16198 .area HOME (CODE)
16199 \newline
16200 \InsetSpace ~
16201 \InsetSpace ~
16202 \InsetSpace ~
16203 \InsetSpace ~
16204 \InsetSpace ~
16205 \InsetSpace ~
16206 \InsetSpace ~
16207 \InsetSpace ~
16208 .area CSEG (CODE)
16209 \newline
16210 __sdcc_program_startup:
16211 \newline
16212 \InsetSpace ~
16213 \InsetSpace ~
16214 \InsetSpace ~
16215 \InsetSpace ~
16216 \InsetSpace ~
16217 \InsetSpace ~
16218 \InsetSpace ~
16219 \InsetSpace ~
16220 lcall _main
16221 \newline
16222 ;
16223  return from main will lock up
16224 \newline
16225 \InsetSpace ~
16226 \InsetSpace ~
16227 \InsetSpace ~
16228 \InsetSpace ~
16229 \InsetSpace ~
16230 \InsetSpace ~
16231 \InsetSpace ~
16232 \InsetSpace ~
16233 sjmp .
16234 \end_layout
16235
16236 \begin_layout Standard
16237 One of these modules (crtstart.asm) contains a call to the C routine 
16238 \emph on
16239 _sdcc_external_startup()
16240 \begin_inset LatexCommand \index{\_sdcc\_external\_startup()}
16241
16242 \end_inset
16243
16244
16245 \series bold
16246 \emph default
16247  
16248 \series default
16249 at the start of the CODE area.
16250  This routine is also in the runtime library
16251 \begin_inset LatexCommand \index{Runtime library}
16252
16253 \end_inset
16254
16255  and returns 0 by default.
16256  If this routine returns a non-zero value, the static & global variable
16257  initialization will be skipped and the function main will be invoked.
16258  Otherwise static & global variables will be initialized before the function
16259  main is invoked.
16260  You could add an 
16261 \emph on
16262 _sdcc_external_startup()
16263 \emph default
16264  routine to your program to override the default if you need to setup hardware
16265  or perform some other critical operation prior to static & global variable
16266  initialization
16267 \begin_inset LatexCommand \index{Variable initialization}
16268
16269 \end_inset
16270
16271 .
16272  On some mcs51 variants xdata
16273 \begin_inset LatexCommand \index{xdata (mcs51, ds390 storage class)}
16274
16275 \end_inset
16276
16277  memory has to be explicitly enabled before it can be accessed or if the
16278  watchdog
16279 \begin_inset LatexCommand \index{watchdog}
16280
16281 \end_inset
16282
16283  needs to be disabled, this is the place to do it.
16284  The startup code clears all internal data memory, 256 bytes by default,
16285  but from 0 to n-1 if 
16286 \emph on
16287 -
16288 \begin_inset ERT
16289 status collapsed
16290
16291 \begin_layout Standard
16292
16293
16294 \backslash
16295 /
16296 \end_layout
16297
16298 \end_inset
16299
16300 -iram-size
16301 \begin_inset LatexCommand \index{-\/-iram-size <Value>}
16302
16303 \end_inset
16304
16305 n
16306 \emph default
16307  is used.
16308  (recommended for Chipcon CC1010).
16309 \end_layout
16310
16311 \begin_layout Standard
16312 See also the compiler options 
16313 \emph on
16314 -
16315 \begin_inset ERT
16316 status collapsed
16317
16318 \begin_layout Standard
16319
16320
16321 \backslash
16322 /
16323 \end_layout
16324
16325 \end_inset
16326
16327 -no-xinit
16328 \emph default
16329 -
16330 \emph on
16331 opt
16332 \emph default
16333
16334 \begin_inset LatexCommand \index{-\/-no-xinit-opt}
16335
16336 \end_inset
16337
16338
16339 \emph on
16340 -
16341 \begin_inset ERT
16342 status collapsed
16343
16344 \begin_layout Standard
16345
16346
16347 \backslash
16348 /
16349 \end_layout
16350
16351 \end_inset
16352
16353 -main-return
16354 \emph default
16355
16356 \begin_inset LatexCommand \index{-\/-main-return}
16357
16358 \end_inset
16359
16360  and section 
16361 \begin_inset LatexCommand \ref{sub:MCS51-variants}
16362
16363 \end_inset
16364
16365  about MCS51-variants.
16366 \newline
16367
16368 \end_layout
16369
16370 \begin_layout Standard
16371 While these initialization modules are meant as generic startup code there
16372  might be the need for customization.
16373  Let's assume the return value of 
16374 \emph on
16375 _sdcc_external_startup()
16376 \emph default
16377  in 
16378 \emph on
16379 crtstart.asm
16380 \emph default
16381  should not be checked (or 
16382 \emph on
16383 _sdcc_external_startup()
16384 \emph default
16385  should not be called at all).
16386  The recommended way would be to copy 
16387 \emph on
16388 crtstart.asm
16389 \emph default
16390  (f.e.
16391  from 
16392 \begin_inset LatexCommand \url{http://sdcc.svn.sourceforge.net/viewvc/*checkout*/sdcc/trunk/sdcc/device/lib/mcs51/crtstart.asm}
16393
16394 \end_inset
16395
16396 ) into the source directory, adapt it there, then assemble it with 
16397 \emph on
16398 asx8051 -plosgff
16399 \begin_inset Foot
16400 status open
16401
16402 \begin_layout Standard
16403 \begin_inset Quotes sld
16404 \end_inset
16405
16406 -plosgff
16407 \begin_inset Quotes srd
16408 \end_inset
16409
16410  are the assembler options used in 
16411 \begin_inset LatexCommand \url{http://sdcc.svn.sourceforge.net/viewvc/sdcc/trunk/sdcc/device/lib/mcs51/Makefile.in?view=markup }
16412
16413 \end_inset
16414
16415
16416 \end_layout
16417
16418 \end_inset
16419
16420  crtstart.asm
16421 \emph default
16422  and when linking your project explicitely specify 
16423 \emph on
16424 crtstart.rel
16425 \emph default
16426 .
16427  As a bonus a listing of the relocated object file 
16428 \emph on
16429 crtstart.rst
16430 \emph default
16431  is generated.
16432 \end_layout
16433
16434 \begin_layout Standard
16435 \begin_inset VSpace bigskip
16436 \end_inset
16437
16438
16439 \end_layout
16440
16441 \begin_layout Subsection
16442 HC08 Startup Code
16443 \end_layout
16444
16445 \begin_layout Standard
16446 The HC08
16447 \begin_inset LatexCommand \index{HC08}
16448
16449 \end_inset
16450
16451  startup code follows the same scheme as the MCS51 startup code.
16452 \begin_inset VSpace bigskip
16453 \end_inset
16454
16455
16456 \end_layout
16457
16458 \begin_layout Subsection
16459 Z80 Startup Code
16460 \end_layout
16461
16462 \begin_layout Standard
16463 On the Z80
16464 \begin_inset LatexCommand \index{Z80}
16465
16466 \end_inset
16467
16468  the startup code is inserted by linking with crt0.o which is generated from
16469  sdcc/device/lib/z80/crt0.s.
16470  If you need a different startup code you can use the compiler option 
16471 \emph on
16472 -
16473 \series bold
16474 \emph default
16475
16476 \begin_inset ERT
16477 status collapsed
16478
16479 \begin_layout Standard
16480
16481
16482 \backslash
16483 /
16484 \end_layout
16485
16486 \end_inset
16487
16488
16489 \series default
16490 \emph on
16491 -no-std-crt0
16492 \emph default
16493
16494 \begin_inset LatexCommand \index{-\/-no-std-crt0}
16495
16496 \end_inset
16497
16498  and provide your own crt0.o.
16499  
16500 \begin_inset VSpace bigskip
16501 \end_inset
16502
16503
16504 \end_layout
16505
16506 \begin_layout Section
16507 Inline Assembler Code
16508 \begin_inset LatexCommand \index{Assembler routines}
16509
16510 \end_inset
16511
16512
16513 \end_layout
16514
16515 \begin_layout Subsection
16516 A Step by Step Introduction
16517 \begin_inset LatexCommand \label{sub:A-Step-by Assembler Introduction}
16518
16519 \end_inset
16520
16521
16522 \end_layout
16523
16524 \begin_layout Standard
16525 Starting from a small snippet of c-code this example shows for the MCS51
16526  how to use inline assembly, access variables, a function parameter and
16527  an array in xdata memory.
16528  The example uses an MCS51 here but is easily adapted for other architectures.
16529  This is a buffer routine which should be optimized:
16530 \end_layout
16531
16532 \begin_layout Verse
16533
16534 \family typewriter
16535 \size footnotesize
16536 unsigned char __far
16537 \begin_inset LatexCommand \index{far (storage class)}
16538
16539 \end_inset
16540
16541
16542 \begin_inset LatexCommand \index{\_\_far (storage class)}
16543
16544 \end_inset
16545
16546  __at
16547 \begin_inset LatexCommand \index{at}
16548
16549 \end_inset
16550
16551
16552 \begin_inset LatexCommand \index{\_\_at}
16553
16554 \end_inset
16555
16556 (0x7f00) buf[0x100];
16557 \begin_inset LatexCommand \index{Aligned array}
16558
16559 \end_inset
16560
16561
16562 \newline
16563 unsigned char head, tail;\InsetSpace ~
16564 \InsetSpace ~
16565 \InsetSpace ~
16566 \InsetSpace ~
16567 \InsetSpace ~
16568 \InsetSpace ~
16569 \InsetSpace ~
16570 \InsetSpace ~
16571 \InsetSpace ~
16572 \InsetSpace ~
16573 \InsetSpace ~
16574 \InsetSpace ~
16575 \InsetSpace ~
16576 \InsetSpace ~
16577 \InsetSpace ~
16578 \InsetSpace ~
16579 \InsetSpace ~
16580 /* if interrupts
16581 \begin_inset LatexCommand \index{interrupt}
16582
16583 \end_inset
16584
16585  are involved see
16586 \newline
16587 \InsetSpace ~
16588 \InsetSpace ~
16589 \InsetSpace ~
16590 \InsetSpace ~
16591 \InsetSpace ~
16592 \InsetSpace ~
16593 \InsetSpace ~
16594 \InsetSpace ~
16595 \InsetSpace ~
16596 \InsetSpace ~
16597 \InsetSpace ~
16598 \InsetSpace ~
16599 \InsetSpace ~
16600 \InsetSpace ~
16601 \InsetSpace ~
16602 \InsetSpace ~
16603 \InsetSpace ~
16604 \InsetSpace ~
16605 \InsetSpace ~
16606 \InsetSpace ~
16607 \InsetSpace ~
16608 \InsetSpace ~
16609 \InsetSpace ~
16610 \InsetSpace ~
16611 \InsetSpace ~
16612 \InsetSpace ~
16613 \InsetSpace ~
16614 \InsetSpace ~
16615 \InsetSpace ~
16616 \InsetSpace ~
16617 \InsetSpace ~
16618 \InsetSpace ~
16619 \InsetSpace ~
16620 \InsetSpace ~
16621 \InsetSpace ~
16622 \InsetSpace ~
16623 \InsetSpace ~
16624 \InsetSpace ~
16625 \InsetSpace ~
16626 \InsetSpace ~
16627 \InsetSpace ~
16628 \InsetSpace ~
16629 \InsetSpace ~
16630 \InsetSpace ~
16631 \InsetSpace ~
16632 section 
16633 \begin_inset LatexCommand \ref{sub:Common-interrupt-pitfall-volatile}
16634
16635 \end_inset
16636
16637  about
16638 \series bold
16639  volatile
16640 \series default
16641  */
16642 \newline
16643
16644 \newline
16645 void to_buffer( unsigned char c ) 
16646 \newline
16647 {
16648 \newline
16649 \InsetSpace ~
16650 \InsetSpace ~
16651 \InsetSpace ~
16652 \InsetSpace ~
16653 if( head != (unsigned char)(tail-1)
16654  )\InsetSpace ~
16655 /* cast 
16656 \series bold
16657 needed
16658 \series default
16659  to avoid promotion
16660 \begin_inset LatexCommand \index{promotion to signed int}
16661
16662 \end_inset
16663
16664
16665 \begin_inset LatexCommand \index{type promotion}
16666
16667 \end_inset
16668
16669  to integer */
16670 \begin_inset Marginal
16671 status collapsed
16672
16673 \begin_layout Standard
16674
16675 \series bold
16676 \InsetSpace ~
16677 !
16678 \end_layout
16679
16680 \end_inset
16681
16682
16683 \newline
16684 \InsetSpace ~
16685 \InsetSpace ~
16686 \InsetSpace ~
16687 \InsetSpace ~
16688 \InsetSpace ~
16689 \InsetSpace ~
16690 \InsetSpace ~
16691 \InsetSpace ~
16692 buf[ head++ ] = c;\InsetSpace ~
16693 \InsetSpace ~
16694 \InsetSpace ~
16695 \InsetSpace ~
16696 \InsetSpace ~
16697 \InsetSpace ~
16698 \InsetSpace ~
16699 \InsetSpace ~
16700 \InsetSpace ~
16701 \InsetSpace ~
16702 \InsetSpace ~
16703 \InsetSpace ~
16704 \InsetSpace ~
16705 \InsetSpace ~
16706 \InsetSpace ~
16707 \InsetSpace ~
16708 /* access to a 256 byte aligned array */
16709 \newline
16710
16711 \end_layout
16712
16713 \begin_layout Standard
16714 If the code snippet (assume it is saved in buffer.c) is compiled with SDCC
16715  then a corresponding buffer.asm file is generated.
16716  We define a new function 
16717 \family typewriter
16718 to_buffer_asm()
16719 \family default
16720  in file buffer.c in which we cut and paste the generated code, removing
16721  unwanted comments and some ':'.
16722  Then add 
16723 \begin_inset Quotes sld
16724 \end_inset
16725
16726
16727 \series bold
16728 _asm
16729 \series default
16730
16731 \begin_inset Quotes srd
16732 \end_inset
16733
16734  and 
16735 \begin_inset Quotes sld
16736 \end_inset
16737
16738
16739 \series bold
16740 _endasm;
16741 \series default
16742
16743 \begin_inset Quotes srd
16744 \end_inset
16745
16746
16747 \begin_inset Foot
16748 status open
16749
16750 \begin_layout Standard
16751 Note, that the single underscore form (_asm and _endasm) are not C99-compatible,
16752  and for C-99 compatibility, the double-underscore form (__asm and __endasm)
16753  has to be used.
16754  The latter is also used in the library functions.
16755 \end_layout
16756
16757 \end_inset
16758
16759  to the beginning and the end of the function body:
16760 \end_layout
16761
16762 \begin_layout Verse
16763
16764 \family typewriter
16765 \size footnotesize
16766 /* With a cut and paste from the .asm file, we have something to start with.
16767 \newline
16768 \InsetSpace ~
16769 \InsetSpace ~
16770 \InsetSpace ~
16771 The
16772  function is not yet OK! (registers aren't saved) */ 
16773 \newline
16774 void to_buffer_asm(
16775  unsigned char c ) 
16776 \newline
16777
16778 \newline
16779 \InsetSpace ~
16780 \InsetSpace ~
16781 \InsetSpace ~
16782 \InsetSpace ~
16783 _asm
16784 \begin_inset LatexCommand \index{\_asm}
16785
16786 \end_inset
16787
16788
16789 \begin_inset LatexCommand \index{\_\_asm}
16790
16791 \end_inset
16792
16793
16794 \newline
16795 \InsetSpace ~
16796 \InsetSpace ~
16797 \InsetSpace ~
16798 \InsetSpace ~
16799 mov\InsetSpace ~
16800 \InsetSpace ~
16801 r2,dpl 
16802 \newline
16803 ;buffer.c if( head != (unsigned char)(tail-1) ) \InsetSpace ~
16804 /* cast 
16805 \series bold
16806 needed
16807 \series default
16808  to avoid promotion
16809 \begin_inset LatexCommand \index{promotion to signed int}
16810
16811 \end_inset
16812
16813
16814 \begin_inset LatexCommand \index{type promotion}
16815
16816 \end_inset
16817
16818  to integer */
16819 \newline
16820 \InsetSpace ~
16821 \InsetSpace ~
16822 \InsetSpace ~
16823 \InsetSpace ~
16824 mov\InsetSpace ~
16825 \InsetSpace ~
16826 a,_tail 
16827 \newline
16828 \InsetSpace ~
16829 \InsetSpace ~
16830 \InsetSpace ~
16831 \InsetSpace ~
16832 dec\InsetSpace ~
16833 \InsetSpace ~
16834
16835 \newline
16836 \InsetSpace ~
16837 \InsetSpace ~
16838 \InsetSpace ~
16839 \InsetSpace ~
16840 mov\InsetSpace ~
16841 \InsetSpace ~
16842 r3,a 
16843 \newline
16844 \InsetSpace ~
16845 \InsetSpace ~
16846 \InsetSpace ~
16847 \InsetSpace ~
16848 mov\InsetSpace ~
16849 \InsetSpace ~
16850 a,_head 
16851 \newline
16852 \InsetSpace ~
16853 \InsetSpace ~
16854 \InsetSpace ~
16855 \InsetSpace ~
16856 cjne a,ar3,00106$ 
16857 \newline
16858 \InsetSpace ~
16859 \InsetSpace ~
16860 \InsetSpace ~
16861 \InsetSpace ~
16862 ret
16863 \newline
16864 00106$:
16865  
16866 \newline
16867 ;buffer.c buf[ head++ ] = c; /* access to a 256 byte aligned array */
16868 \begin_inset LatexCommand \index{Aligned array}
16869
16870 \end_inset
16871
16872
16873 \newline
16874 \InsetSpace ~
16875 \InsetSpace ~
16876 \InsetSpace ~
16877 \InsetSpace ~
16878 mov\InsetSpace ~
16879 \InsetSpace ~
16880 r3,_head 
16881 \newline
16882 \InsetSpace ~
16883 \InsetSpace ~
16884 \InsetSpace ~
16885 \InsetSpace ~
16886 inc\InsetSpace ~
16887 \InsetSpace ~
16888 _head 
16889 \newline
16890 \InsetSpace ~
16891 \InsetSpace ~
16892 \InsetSpace ~
16893 \InsetSpace ~
16894 mov\InsetSpace ~
16895 \InsetSpace ~
16896 dpl,r3 
16897 \newline
16898 \InsetSpace ~
16899 \InsetSpace ~
16900 \InsetSpace ~
16901 \InsetSpace ~
16902 mov\InsetSpace ~
16903 \InsetSpace ~
16904 dph,#(_buf >> 8) 
16905 \newline
16906 \InsetSpace ~
16907 \InsetSpace ~
16908 \InsetSpace ~
16909 \InsetSpace ~
16910 mov\InsetSpace ~
16911 \InsetSpace ~
16912 a,r2 
16913 \newline
16914 \InsetSpace ~
16915 \InsetSpace ~
16916 \InsetSpace ~
16917 \InsetSpace ~
16918 movx @dptr,a
16919  
16920 \newline
16921 00103$: 
16922 \newline
16923 \InsetSpace ~
16924 \InsetSpace ~
16925 \InsetSpace ~
16926 \InsetSpace ~
16927 ret
16928 \newline
16929 \InsetSpace ~
16930 \InsetSpace ~
16931 \InsetSpace ~
16932 \InsetSpace ~
16933 _endasm
16934 \begin_inset LatexCommand \index{\_endasm}
16935
16936 \end_inset
16937
16938
16939 \begin_inset LatexCommand \index{\_\_endasm}
16940
16941 \end_inset
16942
16943 ;
16944 \newline
16945
16946 \end_layout
16947
16948 \begin_layout Standard
16949 The new file buffer.c should compile with only one warning about the unreferenced
16950  function argument 'c'.
16951  Now we hand-optimize the assembly code and insert an #define USE_ASSEMBLY
16952  (1) and finally have:
16953 \end_layout
16954
16955 \begin_layout Verse
16956
16957 \family typewriter
16958 \size footnotesize
16959 unsigned char __far __at(0x7f00) buf[0x100];
16960 \newline
16961 unsigned char head, tail;
16962 \newline
16963 #define
16964  USE_ASSEMBLY (1)
16965 \newline
16966
16967 \newline
16968 #if !USE_ASSEMBLY
16969 \newline
16970
16971 \newline
16972 void to_buffer( unsigned char c )
16973 \newline
16974 {
16975 \newline
16976 \InsetSpace ~
16977 \InsetSpace ~
16978 \InsetSpace ~
16979 \InsetSpace ~
16980 if(
16981  head != (unsigned char)(tail-1) )
16982 \newline
16983 \InsetSpace ~
16984 \InsetSpace ~
16985 \InsetSpace ~
16986 \InsetSpace ~
16987 \InsetSpace ~
16988 \InsetSpace ~
16989 \InsetSpace ~
16990 \InsetSpace ~
16991 buf[ head++ ] = c;
16992 \newline
16993 }
16994 \newline
16995
16996 \newline
16997 #else
16998 \newline
16999
17000 \newline
17001 void to_buffer(
17002  unsigned char c )
17003 \newline
17004 {
17005 \newline
17006 \InsetSpace ~
17007 \InsetSpace ~
17008 \InsetSpace ~
17009 \InsetSpace ~
17010 c; // to avoid warning: unreferenced function argument
17011 \newline
17012 \InsetSpace ~
17013 \InsetSpace ~
17014 \InsetSpace ~
17015 \InsetSpace ~
17016 _asm
17017 \begin_inset LatexCommand \index{\_asm}
17018
17019 \end_inset
17020
17021
17022 \begin_inset LatexCommand \index{\_\_asm}
17023
17024 \end_inset
17025
17026
17027 \newline
17028 \InsetSpace ~
17029 \InsetSpace ~
17030 \InsetSpace ~
17031 \InsetSpace ~
17032 \InsetSpace ~
17033 \InsetSpace ~
17034 \InsetSpace ~
17035 \InsetSpace ~
17036 ; save used registers here.
17037  
17038 \newline
17039 \InsetSpace ~
17040 \InsetSpace ~
17041 \InsetSpace ~
17042 \InsetSpace ~
17043 \InsetSpace ~
17044 \InsetSpace ~
17045 \InsetSpace ~
17046 \InsetSpace ~
17047 ; If we were still using r2,r3 we would have to push them here.
17048  
17049 \newline
17050 ; if( head != (unsigned char)(tail-1) )
17051 \newline
17052 \InsetSpace ~
17053 \InsetSpace ~
17054 \InsetSpace ~
17055 \InsetSpace ~
17056 \InsetSpace ~
17057 \InsetSpace ~
17058 \InsetSpace ~
17059 \InsetSpace ~
17060 mov\InsetSpace ~
17061  a,_tail
17062 \newline
17063 \InsetSpace ~
17064 \InsetSpace ~
17065 \InsetSpace ~
17066 \InsetSpace ~
17067 \InsetSpace ~
17068 \InsetSpace ~
17069 \InsetSpace ~
17070 \InsetSpace ~
17071 dec\InsetSpace ~
17072  a
17073 \newline
17074 \InsetSpace ~
17075 \InsetSpace ~
17076 \InsetSpace ~
17077 \InsetSpace ~
17078 \InsetSpace ~
17079 \InsetSpace ~
17080 \InsetSpace ~
17081 \InsetSpace ~
17082 xrl\InsetSpace ~
17083  a,_head
17084 \newline
17085 \InsetSpace ~
17086 \InsetSpace ~
17087 \InsetSpace ~
17088 \InsetSpace ~
17089 \InsetSpace ~
17090 \InsetSpace ~
17091 \InsetSpace ~
17092 \InsetSpace ~
17093 ; we
17094  could do an ANL a,#0x0f here to use a smaller buffer (see below)
17095 \newline
17096 \InsetSpace ~
17097 \InsetSpace ~
17098 \InsetSpace ~
17099 \InsetSpace ~
17100 \InsetSpace ~
17101 \InsetSpace ~
17102 \InsetSpace ~
17103 \InsetSpace ~
17104 jz\InsetSpace ~
17105 \InsetSpace ~
17106  t_b_end$
17107 \newline
17108 \InsetSpace ~
17109 \InsetSpace ~
17110 \InsetSpace ~
17111 \InsetSpace ~
17112 \InsetSpace ~
17113 \InsetSpace ~
17114 \InsetSpace ~
17115 \InsetSpace ~
17116 ;
17117 \newline
17118 ;
17119  buf[ head++ ] = c;
17120 \newline
17121 \InsetSpace ~
17122 \InsetSpace ~
17123 \InsetSpace ~
17124 \InsetSpace ~
17125 \InsetSpace ~
17126 \InsetSpace ~
17127 \InsetSpace ~
17128 \InsetSpace ~
17129 mov\InsetSpace ~
17130  a,dpl \InsetSpace ~
17131 \InsetSpace ~
17132 \InsetSpace ~
17133 \InsetSpace ~
17134 \InsetSpace ~
17135 \InsetSpace ~
17136 \InsetSpace ~
17137 ; dpl holds lower byte of function argument
17138 \newline
17139 \InsetSpace ~
17140 \InsetSpace ~
17141 \InsetSpace ~
17142 \InsetSpace ~
17143 \InsetSpace ~
17144 \InsetSpace ~
17145 \InsetSpace ~
17146 \InsetSpace ~
17147 mov\InsetSpace ~
17148
17149  dpl,_head \InsetSpace ~
17150 \InsetSpace ~
17151 \InsetSpace ~
17152 ; buf is 0x100 byte aligned so head can be used directly
17153 \newline
17154 \InsetSpace ~
17155 \InsetSpace ~
17156 \InsetSpace ~
17157 \InsetSpace ~
17158 \InsetSpace ~
17159 \InsetSpace ~
17160 \InsetSpace ~
17161 \InsetSpace ~
17162 mov\InsetSpace ~
17163  dph,#(_bu
17164 f>>8)
17165 \newline
17166 \InsetSpace ~
17167 \InsetSpace ~
17168 \InsetSpace ~
17169 \InsetSpace ~
17170 \InsetSpace ~
17171 \InsetSpace ~
17172 \InsetSpace ~
17173 \InsetSpace ~
17174 movx @dptr,a
17175 \newline
17176 \InsetSpace ~
17177 \InsetSpace ~
17178 \InsetSpace ~
17179 \InsetSpace ~
17180 \InsetSpace ~
17181 \InsetSpace ~
17182 \InsetSpace ~
17183 \InsetSpace ~
17184 inc \InsetSpace ~
17185 _head
17186 \newline
17187 \InsetSpace ~
17188 \InsetSpace ~
17189 \InsetSpace ~
17190 \InsetSpace ~
17191 \InsetSpace ~
17192 \InsetSpace ~
17193 \InsetSpace ~
17194 \InsetSpace ~
17195 ; we could do an ANL _head,#0x0f here to use a
17196  smaller buffer (see above)
17197 \newline
17198 t_b_end$:
17199 \newline
17200 \InsetSpace ~
17201 \InsetSpace ~
17202 \InsetSpace ~
17203 \InsetSpace ~
17204 \InsetSpace ~
17205 \InsetSpace ~
17206 \InsetSpace ~
17207 \InsetSpace ~
17208 ; restore used registers here 
17209 \newline
17210 \InsetSpace ~
17211 \InsetSpace ~
17212 \InsetSpace ~
17213 \InsetSpace ~
17214 _endasm
17215 \begin_inset LatexCommand \index{\_endasm}
17216
17217 \end_inset
17218
17219
17220 \begin_inset LatexCommand \index{\_\_endasm}
17221
17222 \end_inset
17223
17224 ;
17225 \newline
17226 }
17227 \newline
17228 #endif
17229 \end_layout
17230
17231 \begin_layout Standard
17232 The inline assembler code can contain any valid code understood by the assembler
17233 , this includes any assembler directives and comment lines.
17234  The assembler does not like some characters like ':' or ''' in comments.
17235  You'll find an 100+ pages assembler manual in sdcc/as/doc/asxhtm.html
17236 \begin_inset LatexCommand \index{asXXXX (as-gbz80, as-hc08, asx8051, as-z80)}
17237
17238 \end_inset
17239
17240
17241 \begin_inset LatexCommand \index{Assembler documentation}
17242
17243 \end_inset
17244
17245  or online at 
17246 \begin_inset LatexCommand \url{http://sdcc.svn.sourceforge.net/viewvc/*checkout*/sdcc/trunk/sdcc/as/doc/asxhtm.html}
17247
17248 \end_inset
17249
17250 \InsetSpace ~
17251 .
17252 \end_layout
17253
17254 \begin_layout Standard
17255 The compiler does not do any validation of the code within the 
17256 \family typewriter
17257 _asm
17258 \begin_inset LatexCommand \index{\_asm}
17259
17260 \end_inset
17261
17262
17263 \begin_inset LatexCommand \index{\_\_asm}
17264
17265 \end_inset
17266
17267  ...
17268  _endasm
17269 \size footnotesize
17270
17271 \begin_inset LatexCommand \index{\_endasm}
17272
17273 \end_inset
17274
17275
17276 \begin_inset LatexCommand \index{\_\_endasm}
17277
17278 \end_inset
17279
17280
17281 \size default
17282 ;
17283 \family default
17284  keyword pair.
17285  Specifically it will not know which registers are used and thus register
17286  pushing/popping
17287 \begin_inset LatexCommand \index{push/pop}
17288
17289 \end_inset
17290
17291  has to be done manually.
17292  
17293 \end_layout
17294
17295 \begin_layout Standard
17296 It is recommended that each assembly instruction (including labels) be placed
17297  in a separate line (as the example shows).
17298  When the -
17299 \begin_inset ERT
17300 status collapsed
17301
17302 \begin_layout Standard
17303
17304
17305 \backslash
17306 /
17307 \end_layout
17308
17309 \end_inset
17310
17311 -
17312 \emph on
17313 peep-asm
17314 \begin_inset LatexCommand \index{-\/-peep-asm}
17315
17316 \end_inset
17317
17318
17319 \emph default
17320  command line option is used, the inline assembler code will be passed through
17321  the peephole optimizer
17322 \begin_inset LatexCommand \index{Peephole optimizer}
17323
17324 \end_inset
17325
17326 .
17327  There are only a few (if any) cases where this option makes sense, it might
17328  cause some unexpected changes in the inline assembler code.
17329  Please go through the peephole optimizer rules defined in file 
17330 \emph on
17331 SDCCpeeph.def
17332 \emph default
17333  before using this option.
17334 \end_layout
17335
17336 \begin_layout Subsection
17337 Naked Functions
17338 \begin_inset LatexCommand \label{sub:Naked-Functions}
17339
17340 \end_inset
17341
17342
17343 \begin_inset LatexCommand \index{Naked functions}
17344
17345 \end_inset
17346
17347
17348 \end_layout
17349
17350 \begin_layout Standard
17351 A special keyword may be associated with a function declaring it as 
17352 \emph on
17353 _naked
17354 \begin_inset LatexCommand \index{\_naked}
17355
17356 \end_inset
17357
17358
17359 \begin_inset LatexCommand \index{\_\_naked}
17360
17361 \end_inset
17362
17363 .
17364  
17365 \emph default
17366 The 
17367 \emph on
17368 _naked
17369 \emph default
17370  function modifier attribute prevents the compiler from generating prologue
17371 \begin_inset LatexCommand \index{function prologue}
17372
17373 \end_inset
17374
17375  and epilogue
17376 \begin_inset LatexCommand \index{function epilogue}
17377
17378 \end_inset
17379
17380  code for that function.
17381  This means that the user is entirely responsible for such things as saving
17382  any registers that may need to be preserved, selecting the proper register
17383  bank, generating the 
17384 \emph on
17385 return
17386 \emph default
17387  instruction at the end, etc.
17388  Practically, this means that the contents of the function must be written
17389  in inline assembler.
17390  This is particularly useful for interrupt functions, which can have a large
17391  (and often unnecessary) prologue/epilogue.
17392  For example, compare the code generated by these two functions:
17393 \end_layout
17394
17395 \begin_layout Verse
17396
17397 \family typewriter
17398 volatile
17399 \begin_inset LatexCommand \index{volatile}
17400
17401 \end_inset
17402
17403  data unsigned char counter;
17404 \newline
17405
17406 \newline
17407 void simpleInterrupt(void) __interrupt
17408 \begin_inset LatexCommand \index{interrupt}
17409
17410 \end_inset
17411
17412
17413 \begin_inset LatexCommand \index{\_\_interrupt}
17414
17415 \end_inset
17416
17417  (1)
17418 \newline
17419 {
17420 \newline
17421 \InsetSpace ~
17422 \InsetSpace ~
17423 \InsetSpace ~
17424 \InsetSpace ~
17425 counter++;
17426 \newline
17427 }
17428 \newline
17429
17430 \newline
17431 void nakedInterrupt(void) __interrupt (2) __naked
17432 \newline
17433 {
17434 \newline
17435 \InsetSpace ~
17436 \InsetSpace ~
17437 \InsetSpace ~
17438 \InsetSpace ~
17439 _asm
17440 \begin_inset LatexCommand \index{\_asm}
17441
17442 \end_inset
17443
17444
17445 \begin_inset LatexCommand \index{\_\_asm}
17446
17447 \end_inset
17448
17449
17450 \newline
17451 \InsetSpace ~
17452 \InsetSpace ~
17453 \InsetSpace ~
17454 \InsetSpace ~
17455 \InsetSpace ~
17456 \InsetSpace ~
17457 inc\InsetSpace ~
17458 \InsetSpace ~
17459 \InsetSpace ~
17460 \InsetSpace ~
17461 \InsetSpace ~
17462 _counter ; does not change flags, no need to save psw
17463 \newline
17464 \InsetSpace ~
17465 \InsetSpace ~
17466 \InsetSpace ~
17467 \InsetSpace ~
17468 \InsetSpace ~
17469 \InsetSpace ~
17470 reti\InsetSpace ~
17471 \InsetSpace ~
17472 \InsetSpace ~
17473 \InsetSpace ~
17474 ; MUST explicitly
17475  include ret or reti in _naked function.
17476 \newline
17477 \InsetSpace ~
17478 \InsetSpace ~
17479 \InsetSpace ~
17480 \InsetSpace ~
17481 _endasm
17482 \begin_inset LatexCommand \index{\_endasm}
17483
17484 \end_inset
17485
17486
17487 \begin_inset LatexCommand \index{\_\_endasm}
17488
17489 \end_inset
17490
17491 ;
17492 \newline
17493 }
17494 \end_layout
17495
17496 \begin_layout Standard
17497 For an 8051 target, the generated simpleInterrupt looks like:
17498 \end_layout
17499
17500 \begin_layout Verse
17501
17502 \family typewriter
17503 Note, this is an 
17504 \emph on
17505 outdated
17506 \emph default
17507  example, recent versions of SDCC generate
17508 \newline
17509 the 
17510 \emph on
17511 same
17512 \emph default
17513  code for simpleInterrupt() and nakedInterrupt()!
17514 \newline
17515
17516 \newline
17517 _simpleInterrupt:
17518 \newline
17519 \InsetSpace ~
17520 \InsetSpace ~
17521 \InsetSpace ~
17522 \InsetSpace ~
17523 push\InsetSpace ~
17524 \InsetSpace ~
17525 \InsetSpace ~
17526 \InsetSpace ~
17527 acc
17528 \newline
17529 \InsetSpace ~
17530 \InsetSpace ~
17531 \InsetSpace ~
17532 \InsetSpace ~
17533 push\InsetSpace ~
17534 \InsetSpace ~
17535 \InsetSpace ~
17536 \InsetSpace ~
17537 b
17538 \newline
17539 \InsetSpace ~
17540 \InsetSpace ~
17541 \InsetSpace ~
17542 \InsetSpace ~
17543 pu
17544 sh\InsetSpace ~
17545 \InsetSpace ~
17546 \InsetSpace ~
17547 \InsetSpace ~
17548 dpl
17549 \newline
17550 \InsetSpace ~
17551 \InsetSpace ~
17552 \InsetSpace ~
17553 \InsetSpace ~
17554 push\InsetSpace ~
17555 \InsetSpace ~
17556 \InsetSpace ~
17557 \InsetSpace ~
17558 dph
17559 \newline
17560 \InsetSpace ~
17561 \InsetSpace ~
17562 \InsetSpace ~
17563 \InsetSpace ~
17564 push\InsetSpace ~
17565 \InsetSpace ~
17566 \InsetSpace ~
17567 \InsetSpace ~
17568 psw
17569 \newline
17570 \InsetSpace ~
17571 \InsetSpace ~
17572 \InsetSpace ~
17573 \InsetSpace ~
17574 mov\InsetSpace ~
17575 \InsetSpace ~
17576 \InsetSpace ~
17577 \InsetSpace ~
17578 \InsetSpace ~
17579 psw,#0x00
17580 \newline
17581 \InsetSpace ~
17582 \InsetSpace ~
17583 \InsetSpace ~
17584 \InsetSpace ~
17585 inc\InsetSpace ~
17586 \InsetSpace ~
17587 \InsetSpace ~
17588 \InsetSpace ~
17589 \InsetSpace ~
17590 _counter
17591 \newline
17592 \InsetSpace ~
17593 \InsetSpace ~
17594 \InsetSpace ~
17595 \InsetSpace ~
17596 pop\InsetSpace ~
17597 \InsetSpace ~
17598 \InsetSpace ~
17599 \InsetSpace ~
17600 \InsetSpace ~
17601 psw
17602 \newline
17603 \InsetSpace ~
17604 \InsetSpace ~
17605 \InsetSpace ~
17606 \InsetSpace ~
17607 pop\InsetSpace ~
17608 \InsetSpace ~
17609 \InsetSpace ~
17610 \InsetSpace ~
17611 \InsetSpace ~
17612 dph
17613 \newline
17614 \InsetSpace ~
17615 \InsetSpace ~
17616 \InsetSpace ~
17617 \InsetSpace ~
17618 pop\InsetSpace ~
17619 \InsetSpace ~
17620 \InsetSpace ~
17621 \InsetSpace ~
17622 \InsetSpace ~
17623 dpl
17624 \newline
17625 \InsetSpace ~
17626 \InsetSpace ~
17627 \InsetSpace ~
17628 \InsetSpace ~
17629 pop\InsetSpace ~
17630 \InsetSpace ~
17631 \InsetSpace ~
17632 \InsetSpace ~
17633 \InsetSpace ~
17634 b
17635 \newline
17636 \InsetSpace ~
17637 \InsetSpace ~
17638 \InsetSpace ~
17639 \InsetSpace ~
17640 pop\InsetSpace ~
17641 \InsetSpace ~
17642 \InsetSpace ~
17643 \InsetSpace ~
17644 \InsetSpace ~
17645 acc
17646 \newline
17647 \InsetSpace ~
17648 \InsetSpace ~
17649 \InsetSpace ~
17650 \InsetSpace ~
17651 reti
17652 \end_layout
17653
17654 \begin_layout Standard
17655 whereas nakedInterrupt looks like:
17656 \end_layout
17657
17658 \begin_layout Verse
17659
17660 \family typewriter
17661 _nakedInterrupt:
17662 \newline
17663 \InsetSpace ~
17664 \InsetSpace ~
17665 \InsetSpace ~
17666 \InsetSpace ~
17667 inc\InsetSpace ~
17668 \InsetSpace ~
17669 \InsetSpace ~
17670 \InsetSpace ~
17671 _counter ; does not change flags, no need to save psw
17672 \newline
17673 \InsetSpace ~
17674 \InsetSpace ~
17675 \InsetSpace ~
17676 \InsetSpace ~
17677 reti\InsetSpace ~
17678 \InsetSpace ~
17679 \InsetSpace ~
17680 \InsetSpace ~
17681 \InsetSpace ~
17682 \InsetSpace ~
17683 \InsetSpace ~
17684 \InsetSpace ~
17685 \InsetSpace ~
17686 \InsetSpace ~
17687 \InsetSpace ~
17688 \InsetSpace ~
17689 ;
17690  MUST explicitly include ret or reti in _naked function
17691 \end_layout
17692
17693 \begin_layout Standard
17694 The related directive #pragma exclude
17695 \begin_inset LatexCommand \index{\#pragma exclude}
17696
17697 \end_inset
17698
17699  allows a more fine grained control over pushing & popping
17700 \begin_inset LatexCommand \index{push/pop}
17701
17702 \end_inset
17703
17704  the registers.
17705 \end_layout
17706
17707 \begin_layout Standard
17708 While there is nothing preventing you from writing C code inside a 
17709 \family typewriter
17710 _naked
17711 \family default
17712  function, there are many ways to shoot yourself in the foot doing this,
17713  and it is recommended that you stick to inline assembler.
17714 \end_layout
17715
17716 \begin_layout Subsection
17717 Use of Labels within Inline Assembler
17718 \end_layout
17719
17720 \begin_layout Standard
17721 SDCC allows the use of in-line assembler with a few restrictions regarding
17722  labels.
17723  All labels defined within inline assembler code have to be of the form
17724  
17725 \emph on
17726 nnnnn$
17727 \emph default
17728  where nnnnn is a number less than 100 (which implies a limit of utmost
17729  100 inline assembler labels 
17730 \emph on
17731 per function
17732 \emph default
17733 \noun on
17734 )
17735 \noun default
17736 .
17737 \begin_inset Foot
17738 status open
17739
17740 \begin_layout Standard
17741 This is a slightly more stringent rule than absolutely necessary, but stays
17742  always on the safe side.
17743  Labels in the form of nnnnn$ are local labels in the assembler, locality
17744  of which is confined within two labels of the standard form.
17745  The compiler uses the same form for labels within a function (but starting
17746  from nnnnn=00100); and places always a standard label at the beginning
17747  of a function, thus limiting the locality of labels within the scope of
17748  the function.
17749  So, if the inline assembler part would be embedded into C-code, an improperly
17750  placed non-local label in the assembler would break up the reference space
17751  for labels created by the compiler for the C-code, leading to an assembling
17752  error.
17753 \end_layout
17754
17755 \begin_layout Standard
17756 The numeric part of local labels does not need to have 5 digits (although
17757  this is the form of labels output by the compiler), any valid integer will
17758  do.
17759  Please refer to the assemblers documentation for further details.
17760 \end_layout
17761
17762 \end_inset
17763
17764  
17765 \end_layout
17766
17767 \begin_layout Verse
17768
17769 \family typewriter
17770 _asm
17771 \begin_inset LatexCommand \index{\_asm}
17772
17773 \end_inset
17774
17775
17776 \begin_inset LatexCommand \index{\_\_asm}
17777
17778 \end_inset
17779
17780  
17781 \newline
17782 \InsetSpace ~
17783 \InsetSpace ~
17784 \InsetSpace ~
17785 \InsetSpace ~
17786 mov\InsetSpace ~
17787 \InsetSpace ~
17788 \InsetSpace ~
17789 \InsetSpace ~
17790 \InsetSpace ~
17791 b,#10 
17792 \newline
17793 00001$: 
17794 \newline
17795 \InsetSpace ~
17796 \InsetSpace ~
17797 \InsetSpace ~
17798 \InsetSpace ~
17799 djnz\InsetSpace ~
17800 \InsetSpace ~
17801 \InsetSpace ~
17802 \InsetSpace ~
17803 b,00001$ 
17804 \newline
17805 _endasm
17806 \begin_inset LatexCommand \index{\_endasm}
17807
17808 \end_inset
17809
17810
17811 \begin_inset LatexCommand \index{\_\_endasm}
17812
17813 \end_inset
17814
17815  ;
17816 \end_layout
17817
17818 \begin_layout Standard
17819 Inline assembler code cannot reference any C-labels, however it can reference
17820  labels
17821 \begin_inset LatexCommand \index{Labels}
17822
17823 \end_inset
17824
17825  defined by the inline assembler, e.g.:
17826 \end_layout
17827
17828 \begin_layout Verse
17829
17830 \family typewriter
17831 foo() { 
17832 \newline
17833 \InsetSpace ~
17834 \InsetSpace ~
17835 \InsetSpace ~
17836 \InsetSpace ~
17837 /* some c code */ 
17838 \newline
17839 \InsetSpace ~
17840 \InsetSpace ~
17841 \InsetSpace ~
17842 \InsetSpace ~
17843 _asm 
17844 \newline
17845 \InsetSpace ~
17846 \InsetSpace ~
17847 \InsetSpace ~
17848 \InsetSpace ~
17849 \InsetSpace ~
17850 \InsetSpace ~
17851 ; some assembler code 
17852 \newline
17853 \InsetSpace ~
17854 \InsetSpace ~
17855 \InsetSpace ~
17856 \InsetSpace ~
17857 \InsetSpace ~
17858 \InsetSpace ~
17859 ljmp 0003$ 
17860 \newline
17861 \InsetSpace ~
17862 \InsetSpace ~
17863 \InsetSpace ~
17864 \InsetSpace ~
17865 _endasm;
17866  
17867 \newline
17868 \InsetSpace ~
17869 \InsetSpace ~
17870 \InsetSpace ~
17871 \InsetSpace ~
17872 /* some more c code */ 
17873 \newline
17874 clabel:\InsetSpace ~
17875 \InsetSpace ~
17876 /* inline assembler cannot reference this
17877  label */ 
17878 \begin_inset Foot
17879 status open
17880
17881 \begin_layout Standard
17882 Here, the C-label 
17883 \family typewriter
17884 clabel
17885 \family default
17886  is translated by the compiler into a local label, so the locality of labels
17887  within the function is not broken.
17888 \end_layout
17889
17890 \end_inset
17891
17892
17893 \newline
17894 \InsetSpace ~
17895 \InsetSpace ~
17896 \InsetSpace ~
17897 \InsetSpace ~
17898 _asm
17899 \newline
17900 \InsetSpace ~
17901 \InsetSpace ~
17902 \InsetSpace ~
17903 \InsetSpace ~
17904 0003$: ;label (can be referenced by inline assembler only) 
17905 \newline
17906 \InsetSpace ~
17907 \InsetSpace ~
17908 \InsetSpace ~
17909 \InsetSpace ~
17910 _endasm
17911 \begin_inset LatexCommand \index{\_endasm}
17912
17913 \end_inset
17914
17915
17916 \begin_inset LatexCommand \index{\_\_endasm}
17917
17918 \end_inset
17919
17920  ; 
17921 \newline
17922 \InsetSpace ~
17923 \InsetSpace ~
17924 \InsetSpace ~
17925 \InsetSpace ~
17926 /* some more c code */
17927 \newline
17928 }
17929 \end_layout
17930
17931 \begin_layout Standard
17932 In other words inline assembly code can access labels defined in inline
17933  assembly within the scope of the function.
17934  The same goes the other way, i.e.
17935  labels defines in inline assembly can not be accessed by C statements.
17936 \end_layout
17937
17938 \begin_layout Section
17939 Interfacing with Assembler Code
17940 \begin_inset LatexCommand \index{Assembler routines}
17941
17942 \end_inset
17943
17944
17945 \end_layout
17946
17947 \begin_layout Subsection
17948 Global Registers used for Parameter Passing
17949 \begin_inset LatexCommand \index{Parameter passing}
17950
17951 \end_inset
17952
17953
17954 \end_layout
17955
17956 \begin_layout Standard
17957 The compiler always uses the global registers 
17958 \emph on
17959 DPL, DPH
17960 \begin_inset LatexCommand \index{DPTR, DPH, DPL}
17961
17962 \end_inset
17963
17964
17965 \begin_inset LatexCommand \index{DPTR}
17966
17967 \end_inset
17968
17969 , B
17970 \begin_inset LatexCommand \index{B (mcs51, ds390 register)}
17971
17972 \end_inset
17973
17974  
17975 \emph default
17976 and
17977 \emph on
17978  ACC
17979 \begin_inset LatexCommand \index{ACC (mcs51, ds390 register)}
17980
17981 \end_inset
17982
17983
17984 \emph default
17985  to pass the first (non-bit) parameter to a function, and also to pass the
17986  return value 
17987 \begin_inset LatexCommand \index{return value}
17988
17989 \end_inset
17990
17991 of function; according to the following scheme: one byte return value in
17992  
17993 \emph on
17994 DPL
17995 \emph default
17996 , two byte value in 
17997 \emph on
17998 DPL
17999 \emph default
18000  (LSB) and 
18001 \emph on
18002 DPH
18003 \emph default
18004  (MSB).
18005  three byte values (generic pointers) in 
18006 \emph on
18007 DPH
18008 \emph default
18009
18010 \emph on
18011 DPL
18012 \emph default
18013  and 
18014 \emph on
18015 B
18016 \emph default
18017 , and four byte values in 
18018 \emph on
18019 DPH
18020 \emph default
18021
18022 \emph on
18023 DPL
18024 \emph default
18025 ,
18026 \emph on
18027  B
18028 \emph default
18029  and 
18030 \emph on
18031 ACC
18032 \emph default
18033 .
18034  Generic pointers
18035 \begin_inset LatexCommand \index{generic pointer}
18036
18037 \end_inset
18038
18039  contain type of accessed memory in 
18040 \emph on
18041 B
18042 \emph default
18043
18044 \series bold
18045 0x00
18046 \series default
18047  -- xdata/far, 
18048 \series bold
18049 0x40
18050 \series default
18051  -- idata/near -- , 
18052 \series bold
18053 0x60
18054 \series default
18055  -- pdata, 
18056 \series bold
18057 0x80
18058 \series default
18059  -- code
18060 \begin_inset Note Note
18061 status collapsed
18062
18063 \begin_layout Standard
18064 This might not be the case of certain memory models (medium???)
18065 \end_layout
18066
18067 \end_inset
18068
18069 .
18070 \end_layout
18071
18072 \begin_layout Standard
18073 The second parameter onwards is either allocated on the stack (for reentrant
18074  routines or if -
18075 \begin_inset ERT
18076 status collapsed
18077
18078 \begin_layout Standard
18079
18080
18081 \backslash
18082 /
18083 \end_layout
18084
18085 \end_inset
18086
18087 -stack-auto is used) or in data/xdata memory (depending on the memory model).
18088 \end_layout
18089
18090 \begin_layout Standard
18091 Bit parameters are passed in a virtual register called 'bits' in bit-addressable
18092  space for reentrant functions or allocated directly in bit memory otherwise.
18093 \end_layout
18094
18095 \begin_layout Standard
18096 Functions (with two or more parameters or bit parameters) that are called
18097  through function pointers
18098 \begin_inset LatexCommand \index{function pointers}
18099
18100 \end_inset
18101
18102  must therefor be reentrant so the compiler knows how to pass the parameters.
18103 \end_layout
18104
18105 \begin_layout Subsection
18106 Registers usage
18107 \end_layout
18108
18109 \begin_layout Standard
18110 Unless the called function is declared as 
18111 \family typewriter
18112 _naked
18113 \family default
18114
18115 \begin_inset LatexCommand \index{naked}
18116
18117 \end_inset
18118
18119 , or the -
18120 \begin_inset ERT
18121 status collapsed
18122
18123 \begin_layout Standard
18124
18125
18126 \backslash
18127 /
18128 \end_layout
18129
18130 \end_inset
18131
18132 -callee-saves
18133 \begin_inset LatexCommand \index{-\/-callee-saves}
18134
18135 \end_inset
18136
18137 /-
18138 \begin_inset ERT
18139 status collapsed
18140
18141 \begin_layout Standard
18142
18143
18144 \backslash
18145 /
18146 \end_layout
18147
18148 \end_inset
18149
18150 -all-callee-saves command line option or the corresponding callee_saves
18151  pragma are used, the caller will save the registers (
18152 \emph on
18153 R0-R7
18154 \emph default
18155 ) around the call, so the called function can destroy they content freely.
18156 \end_layout
18157
18158 \begin_layout Standard
18159 If the called function is not declared as 
18160 \family typewriter
18161 _naked
18162 \family default
18163 , the caller will swap register banks around the call, if caller and callee
18164  use different register banks (having them defined by the 
18165 \family typewriter
18166 _using
18167 \family default
18168  modifier).
18169  
18170 \end_layout
18171
18172 \begin_layout Standard
18173 The called function can also use 
18174 \emph on
18175 DPL
18176 \emph default
18177
18178 \emph on
18179 DPH
18180 \emph default
18181
18182 \emph on
18183 B
18184 \emph default
18185  and 
18186 \emph on
18187 ACC
18188 \emph default
18189  observing that they are used for parameter/return value passing.
18190 \end_layout
18191
18192 \begin_layout Subsection
18193 Assembler Routine (non-reentrant)
18194 \end_layout
18195
18196 \begin_layout Standard
18197 In the following example
18198 \begin_inset LatexCommand \index{reentrant}
18199
18200 \end_inset
18201
18202
18203 \begin_inset LatexCommand \index{Assembler routines (non-reentrant)}
18204
18205 \end_inset
18206
18207  the function c_func calls an assembler routine asm_func, which takes two
18208  parameters
18209 \begin_inset LatexCommand \index{function parameter}
18210
18211 \end_inset
18212
18213 .
18214 \end_layout
18215
18216 \begin_layout Verse
18217
18218 \family typewriter
18219 extern int asm_func(unsigned char, unsigned char);
18220 \newline
18221
18222 \newline
18223 int c_func (unsigned char
18224  i, unsigned char j)
18225 \newline
18226 {
18227 \newline
18228 \InsetSpace ~
18229 \InsetSpace ~
18230 \InsetSpace ~
18231 \InsetSpace ~
18232 return asm_func(i,j);
18233 \newline
18234 }
18235 \newline
18236
18237 \newline
18238 int main()
18239 \newline
18240 {
18241 \newline
18242 \InsetSpace ~
18243 \InsetSpace ~
18244 \InsetSpace ~
18245 \InsetSpace ~
18246 return c_func(10,9);
18247 \newline
18248 }
18249 \end_layout
18250
18251 \begin_layout Standard
18252 The corresponding assembler function is:
18253 \end_layout
18254
18255 \begin_layout Verse
18256
18257 \family typewriter
18258 .globl _asm_func_PARM_2 
18259 \newline
18260 \InsetSpace ~
18261 \InsetSpace ~
18262 \InsetSpace ~
18263 \InsetSpace ~
18264 \InsetSpace ~
18265 \InsetSpace ~
18266 \InsetSpace ~
18267 \InsetSpace ~
18268 .globl _asm_func 
18269 \newline
18270 \InsetSpace ~
18271 \InsetSpace ~
18272 \InsetSpace ~
18273 \InsetSpace ~
18274 \InsetSpace ~
18275 \InsetSpace ~
18276 \InsetSpace ~
18277 \InsetSpace ~
18278 .area OSEG 
18279 \newline
18280 _asm_func_PARM_2:
18281 \newline
18282 \InsetSpace ~
18283 \InsetSpace ~
18284 \InsetSpace ~
18285 \InsetSpace ~
18286 \InsetSpace ~
18287 \InsetSpace ~
18288 \InsetSpace ~
18289 \InsetSpace ~
18290 .ds   
18291  1 
18292 \newline
18293 \InsetSpace ~
18294 \InsetSpace ~
18295 \InsetSpace ~
18296 \InsetSpace ~
18297 \InsetSpace ~
18298 \InsetSpace ~
18299 \InsetSpace ~
18300 \InsetSpace ~
18301 .area CSEG 
18302 \newline
18303 _asm_func: 
18304 \newline
18305 \InsetSpace ~
18306 \InsetSpace ~
18307 \InsetSpace ~
18308 \InsetSpace ~
18309 \InsetSpace ~
18310 \InsetSpace ~
18311 \InsetSpace ~
18312 \InsetSpace ~
18313 mov\InsetSpace ~
18314 \InsetSpace ~
18315 \InsetSpace ~
18316 \InsetSpace ~
18317 a,dpl 
18318 \newline
18319 \InsetSpace ~
18320 \InsetSpace ~
18321 \InsetSpace ~
18322 \InsetSpace ~
18323 \InsetSpace ~
18324 \InsetSpace ~
18325 \InsetSpace ~
18326 \InsetSpace ~
18327 add\InsetSpace ~
18328 \InsetSpace ~
18329 \InsetSpace ~
18330 \InsetSpace ~
18331 a,_asm_func_PARM_2 
18332 \newline
18333 \InsetSpace ~
18334 \InsetSpace ~
18335 \InsetSpace ~
18336 \InsetSpace ~
18337 \InsetSpace ~
18338 \InsetSpace ~
18339 \InsetSpace ~
18340 \InsetSpace ~
18341 mov\InsetSpace ~
18342 \InsetSpace ~
18343 \InsetSpace ~
18344 \InsetSpace ~
18345 dpl,a 
18346 \newline
18347 \InsetSpace ~
18348 \InsetSpace ~
18349 \InsetSpace ~
18350 \InsetSpace ~
18351 \InsetSpace ~
18352 \InsetSpace ~
18353 \InsetSpace ~
18354 \InsetSpace ~
18355 mov\InsetSpace ~
18356 \InsetSpace ~
18357 \InsetSpace ~
18358 \InsetSpace ~
18359 dph
18360 \begin_inset LatexCommand \index{DPTR, DPH, DPL}
18361
18362 \end_inset
18363
18364 ,#0x00 
18365 \newline
18366 \InsetSpace ~
18367 \InsetSpace ~
18368 \InsetSpace ~
18369 \InsetSpace ~
18370 \InsetSpace ~
18371 \InsetSpace ~
18372 \InsetSpace ~
18373 \InsetSpace ~
18374 ret
18375 \end_layout
18376
18377 \begin_layout Standard
18378 The parameter naming convention is _<function_name>_PARM_<n>, where n is
18379  the parameter number starting from 1, and counting from the left.
18380  The first parameter is passed in 
18381 \emph on
18382 DPH
18383 \emph default
18384
18385 \emph on
18386 DPL
18387 \emph default
18388
18389 \emph on
18390 B
18391 \emph default
18392  and 
18393 \emph on
18394 ACC
18395 \emph default
18396  according to the description above.
18397  The variable name for the second parameter will be _<function_name>_PARM_2.
18398 \newline
18399
18400 \newline
18401 Assem
18402 ble the assembler routine with the following command:
18403 \newline
18404
18405 \newline
18406
18407 \family sans
18408 \series bold
18409 asx8051 -losg asmfunc.asm
18410 \newline
18411
18412 \newline
18413
18414 \family default
18415 \series default
18416 Then compile and link the assembler routine to the C source file with the
18417  following command:
18418 \newline
18419
18420 \newline
18421
18422 \family sans
18423 \series bold
18424 sdcc cfunc.c asmfunc.rel
18425 \end_layout
18426
18427 \begin_layout Subsection
18428 Assembler Routine (reentrant)
18429 \end_layout
18430
18431 \begin_layout Standard
18432 In this case
18433 \begin_inset LatexCommand \index{reentrant}
18434
18435 \end_inset
18436
18437
18438 \begin_inset LatexCommand \index{Assembler routines (reentrant)}
18439
18440 \end_inset
18441
18442  the second parameter
18443 \begin_inset LatexCommand \index{function parameter}
18444
18445 \end_inset
18446
18447  onwards will be passed on the stack, the parameters are pushed from right
18448  to left i.e.
18449  before the call the second leftmost parameter will be on the top of the
18450  stack (the leftmost parameter is passed in registers).
18451  Here is an example:
18452 \end_layout
18453
18454 \begin_layout Verse
18455
18456 \family typewriter
18457 extern int asm_func(unsigned char, unsigned char, unsigned char) reentrant;
18458 \newline
18459
18460 \newline
18461 int
18462  c_func (unsigned char i, unsigned char j, unsigned char k) reentrant 
18463 \newline
18464 {
18465  
18466 \newline
18467 \InsetSpace ~
18468 \InsetSpace ~
18469 \InsetSpace ~
18470 \InsetSpace ~
18471 return asm_func(i,j,k); 
18472 \newline
18473
18474 \newline
18475
18476 \newline
18477 int main() 
18478 \newline
18479
18480 \newline
18481 \InsetSpace ~
18482 \InsetSpace ~
18483 \InsetSpace ~
18484 \InsetSpace ~
18485 return c_func(10,9,8); 
18486 \newline
18487 }
18488 \end_layout
18489
18490 \begin_layout Standard
18491 The corresponding (unoptimized) assembler routine is:
18492 \end_layout
18493
18494 \begin_layout Verse
18495
18496 \family typewriter
18497 .globl _asm_func 
18498 \newline
18499 _asm_func: 
18500 \newline
18501 \InsetSpace ~
18502 \InsetSpace ~
18503 \InsetSpace ~
18504 \InsetSpace ~
18505 push\InsetSpace ~
18506 _bp 
18507 \newline
18508 \InsetSpace ~
18509 \InsetSpace ~
18510 \InsetSpace ~
18511 \InsetSpace ~
18512 mov\InsetSpace ~
18513 \InsetSpace ~
18514 _bp,sp\InsetSpace ~
18515 \InsetSpace ~
18516 \InsetSpace ~
18517 \InsetSpace ~
18518 \InsetSpace ~
18519 \InsetSpace ~
18520 ;stack contains: _bp, return
18521  address, second parameter, third parameter
18522 \newline
18523 \InsetSpace ~
18524 \InsetSpace ~
18525 \InsetSpace ~
18526 \InsetSpace ~
18527 mov\InsetSpace ~
18528 \InsetSpace ~
18529 r2,dpl
18530 \newline
18531 \InsetSpace ~
18532 \InsetSpace ~
18533 \InsetSpace ~
18534 \InsetSpace ~
18535 mov\InsetSpace ~
18536 \InsetSpace ~
18537 a,_bp
18538 \newline
18539 \InsetSpace ~
18540 \InsetSpace ~
18541 \InsetSpace ~
18542 \InsetSpace ~
18543 add\InsetSpace ~
18544 \InsetSpace ~
18545 a,#0xfd\InsetSpace ~
18546 \InsetSpace ~
18547 \InsetSpace ~
18548 \InsetSpace ~
18549 \InsetSpace ~
18550 ;calculate
18551  pointer to the second parameter
18552 \newline
18553 \InsetSpace ~
18554 \InsetSpace ~
18555 \InsetSpace ~
18556 \InsetSpace ~
18557 mov\InsetSpace ~
18558 \InsetSpace ~
18559 r0,a 
18560 \newline
18561 \InsetSpace ~
18562 \InsetSpace ~
18563 \InsetSpace ~
18564 \InsetSpace ~
18565 mov\InsetSpace ~
18566 \InsetSpace ~
18567 a,_bp 
18568 \newline
18569 \InsetSpace ~
18570 \InsetSpace ~
18571 \InsetSpace ~
18572 \InsetSpace ~
18573 add\InsetSpace ~
18574 \InsetSpace ~
18575 a,#0xfc\InsetSpace ~
18576 \InsetSpace ~
18577 \InsetSpace ~
18578 \InsetSpace ~
18579 \InsetSpace ~
18580 ;calculate pointer
18581  to the rightmost parameter
18582 \newline
18583 \InsetSpace ~
18584 \InsetSpace ~
18585 \InsetSpace ~
18586 \InsetSpace ~
18587 mov\InsetSpace ~
18588 \InsetSpace ~
18589 r1,a 
18590 \newline
18591 \InsetSpace ~
18592 \InsetSpace ~
18593 \InsetSpace ~
18594 \InsetSpace ~
18595 mov\InsetSpace ~
18596 \InsetSpace ~
18597 a,@r0
18598 \newline
18599 \InsetSpace ~
18600 \InsetSpace ~
18601 \InsetSpace ~
18602 \InsetSpace ~
18603 add\InsetSpace ~
18604 \InsetSpace ~
18605 a,@r1
18606 \newline
18607 \InsetSpace ~
18608 \InsetSpace ~
18609 \InsetSpace ~
18610 \InsetSpace ~
18611 add\InsetSpace ~
18612 \InsetSpace ~
18613 a,r2\InsetSpace ~
18614 \InsetSpace ~
18615 \InsetSpace ~
18616 \InsetSpace ~
18617 \InsetSpace ~
18618 \InsetSpace ~
18619 \InsetSpace ~
18620 \InsetSpace ~
18621 ;calculate the
18622  result (= sum of all three parameters)
18623 \newline
18624 \InsetSpace ~
18625 \InsetSpace ~
18626 \InsetSpace ~
18627 \InsetSpace ~
18628 mov\InsetSpace ~
18629 \InsetSpace ~
18630 dpl,a\InsetSpace ~
18631 \InsetSpace ~
18632 \InsetSpace ~
18633 \InsetSpace ~
18634 \InsetSpace ~
18635 \InsetSpace ~
18636 \InsetSpace ~
18637 ;return value goes into dptr
18638  (cast into int)
18639 \newline
18640 \InsetSpace ~
18641 \InsetSpace ~
18642 \InsetSpace ~
18643 \InsetSpace ~
18644 mov\InsetSpace ~
18645 \InsetSpace ~
18646 dph,#0x00 
18647 \newline
18648 \InsetSpace ~
18649 \InsetSpace ~
18650 \InsetSpace ~
18651 \InsetSpace ~
18652 mov\InsetSpace ~
18653 \InsetSpace ~
18654 sp,_bp 
18655 \newline
18656 \InsetSpace ~
18657 \InsetSpace ~
18658 \InsetSpace ~
18659 \InsetSpace ~
18660 pop\InsetSpace ~
18661 \InsetSpace ~
18662 _bp 
18663 \newline
18664 \InsetSpace ~
18665 \InsetSpace ~
18666 \InsetSpace ~
18667 \InsetSpace ~
18668 ret
18669 \end_layout
18670
18671 \begin_layout Standard
18672 The compiling and linking procedure remains the same, however note the extra
18673  entry & exit linkage required for the assembler code, _bp is the stack
18674  frame pointer and is used to compute the offset into the stack for parameters
18675  and local variables.
18676 \begin_inset VSpace bigskip
18677 \end_inset
18678
18679
18680 \end_layout
18681
18682 \begin_layout Section
18683 int (16 bit)
18684 \begin_inset LatexCommand \index{int (16 bit)}
18685
18686 \end_inset
18687
18688  and long (32 bit)
18689 \begin_inset LatexCommand \index{long (32 bit)}
18690
18691 \end_inset
18692
18693  Support
18694 \end_layout
18695
18696 \begin_layout Standard
18697 For signed & unsigned int (16 bit) and long (32 bit) variables, division,
18698  multiplication and modulus operations are implemented by support routines.
18699  These support routines are all developed in ANSI-C to facilitate porting
18700  to other MCUs, although some model specific assembler optimizations are
18701  used.
18702  The following files contain the described routines, all of them can be
18703  found in <installdir>/share/sdcc/lib.
18704 \newline
18705
18706 \end_layout
18707
18708 \begin_layout Standard
18709 \align center
18710 \begin_inset Tabular
18711 <lyxtabular version="3" rows="11" columns="2">
18712 <features>
18713 <column alignment="left" valignment="top" leftline="true" width="0">
18714 <column alignment="left" valignment="top" leftline="true" rightline="true" width="0">
18715 <row topline="true" bottomline="true">
18716 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
18717 \begin_inset Text
18718
18719 \begin_layout Standard
18720
18721 \series bold
18722 Function
18723 \end_layout
18724
18725 \end_inset
18726 </cell>
18727 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
18728 \begin_inset Text
18729
18730 \begin_layout Standard
18731
18732 \series bold
18733 Description
18734 \end_layout
18735
18736 \end_inset
18737 </cell>
18738 </row>
18739 <row topline="true">
18740 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
18741 \begin_inset Text
18742
18743 \begin_layout Standard
18744 _mulint.c 
18745 \end_layout
18746
18747 \end_inset
18748 </cell>
18749 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
18750 \begin_inset Text
18751
18752 \begin_layout Standard
18753 16 bit multiplication
18754 \end_layout
18755
18756 \end_inset
18757 </cell>
18758 </row>
18759 <row topline="true">
18760 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
18761 \begin_inset Text
18762
18763 \begin_layout Standard
18764 _divsint.c 
18765 \end_layout
18766
18767 \end_inset
18768 </cell>
18769 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
18770 \begin_inset Text
18771
18772 \begin_layout Standard
18773  signed 16 bit division (calls _divuint)
18774 \end_layout
18775
18776 \end_inset
18777 </cell>
18778 </row>
18779 <row topline="true">
18780 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
18781 \begin_inset Text
18782
18783 \begin_layout Standard
18784 _divuint.c 
18785 \end_layout
18786
18787 \end_inset
18788 </cell>
18789 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
18790 \begin_inset Text
18791
18792 \begin_layout Standard
18793  unsigned 16 bit division
18794 \end_layout
18795
18796 \end_inset
18797 </cell>
18798 </row>
18799 <row topline="true">
18800 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
18801 \begin_inset Text
18802
18803 \begin_layout Standard
18804 _modsint.c
18805 \end_layout
18806
18807 \end_inset
18808 </cell>
18809 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
18810 \begin_inset Text
18811
18812 \begin_layout Standard
18813 signed 16 bit modulus (calls _moduint)
18814 \end_layout
18815
18816 \end_inset
18817 </cell>
18818 </row>
18819 <row topline="true">
18820 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
18821 \begin_inset Text
18822
18823 \begin_layout Standard
18824 _moduint.c
18825 \end_layout
18826
18827 \end_inset
18828 </cell>
18829 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
18830 \begin_inset Text
18831
18832 \begin_layout Standard
18833 unsigned 16 bit modulus
18834 \end_layout
18835
18836 \end_inset
18837 </cell>
18838 </row>
18839 <row topline="true">
18840 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
18841 \begin_inset Text
18842
18843 \begin_layout Standard
18844 _mullong.c
18845 \end_layout
18846
18847 \end_inset
18848 </cell>
18849 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
18850 \begin_inset Text
18851
18852 \begin_layout Standard
18853 32 bit multiplication
18854 \end_layout
18855
18856 \end_inset
18857 </cell>
18858 </row>
18859 <row topline="true">
18860 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
18861 \begin_inset Text
18862
18863 \begin_layout Standard
18864 _divslong.c 
18865 \end_layout
18866
18867 \end_inset
18868 </cell>
18869 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
18870 \begin_inset Text
18871
18872 \begin_layout Standard
18873  signed 32 division (calls _divulong)
18874 \end_layout
18875
18876 \end_inset
18877 </cell>
18878 </row>
18879 <row topline="true">
18880 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
18881 \begin_inset Text
18882
18883 \begin_layout Standard
18884 _divulong.c 
18885 \end_layout
18886
18887 \end_inset
18888 </cell>
18889 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
18890 \begin_inset Text
18891
18892 \begin_layout Standard
18893 unsigned 32 division
18894 \end_layout
18895
18896 \end_inset
18897 </cell>
18898 </row>
18899 <row topline="true">
18900 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
18901 \begin_inset Text
18902
18903 \begin_layout Standard
18904 _modslong.c
18905 \end_layout
18906
18907 \end_inset
18908 </cell>
18909 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
18910 \begin_inset Text
18911
18912 \begin_layout Standard
18913  signed 32 bit modulus (calls _modulong)
18914 \end_layout
18915
18916 \end_inset
18917 </cell>
18918 </row>
18919 <row topline="true" bottomline="true">
18920 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
18921 \begin_inset Text
18922
18923 \begin_layout Standard
18924 _modulong.c
18925 \end_layout
18926
18927 \end_inset
18928 </cell>
18929 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
18930 \begin_inset Text
18931
18932 \begin_layout Standard
18933 unsigned 32 bit modulus
18934 \end_layout
18935
18936 \end_inset
18937 </cell>
18938 </row>
18939 </lyxtabular>
18940
18941 \end_inset
18942
18943
18944 \newline
18945
18946 \end_layout
18947
18948 \begin_layout Standard
18949 Since they are compiled as 
18950 \emph on
18951 non-reentrant
18952 \emph default
18953
18954 \begin_inset LatexCommand \index{reentrant}
18955
18956 \end_inset
18957
18958 , interrupt
18959 \begin_inset LatexCommand \index{interrupt}
18960
18961 \end_inset
18962
18963  service routines should not do any of the above operations.
18964  If this is unavoidable then the above routines will need to be compiled
18965  with the 
18966 \emph on
18967 -
18968 \begin_inset ERT
18969 status collapsed
18970
18971 \begin_layout Standard
18972
18973
18974 \backslash
18975 /
18976 \end_layout
18977
18978 \end_inset
18979
18980 -stack-auto
18981 \begin_inset LatexCommand \index{-\/-stack-auto}
18982
18983 \end_inset
18984
18985
18986 \emph default
18987  option, after which the source program will have to be compiled with 
18988 \emph on
18989 -
18990 \begin_inset ERT
18991 status collapsed
18992
18993 \begin_layout Standard
18994
18995
18996 \backslash
18997 /
18998 \end_layout
18999
19000 \end_inset
19001
19002 -int-long-reent
19003 \begin_inset LatexCommand \index{-\/-int-long-reent}
19004
19005 \end_inset
19006
19007
19008 \emph default
19009  option.
19010  Notice that you don't have to call these routines directly.
19011  The compiler will use them automatically every time an integer operation
19012  is required.
19013 \end_layout
19014
19015 \begin_layout Section
19016 Floating Point Support
19017 \begin_inset LatexCommand \index{Floating point support}
19018
19019 \end_inset
19020
19021
19022 \end_layout
19023
19024 \begin_layout Standard
19025 SDCC supports IEEE (single precision 4 bytes) floating point numbers.
19026  The floating point support routines are derived from gcc's floatlib.c and
19027  consist of the following routines:
19028 \newline
19029
19030 \end_layout
19031
19032 \begin_layout Standard
19033 \align center
19034
19035 \size footnotesize
19036 \begin_inset Tabular
19037 <lyxtabular version="3" rows="17" columns="2">
19038 <features>
19039 <column alignment="left" valignment="top" leftline="true" width="0">
19040 <column alignment="left" valignment="top" leftline="true" rightline="true" width="0">
19041 <row topline="true" bottomline="true">
19042 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19043 \begin_inset Text
19044
19045 \begin_layout Standard
19046
19047 \family roman
19048 \series medium
19049 \shape up
19050 \size normal
19051 \emph off
19052 \bar no
19053 \noun off
19054 \color none
19055 Function 
19056 \end_layout
19057
19058 \end_inset
19059 </cell>
19060 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19061 \begin_inset Text
19062
19063 \begin_layout Standard
19064 Description
19065 \end_layout
19066
19067 \end_inset
19068 </cell>
19069 </row>
19070 <row topline="true">
19071 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19072 \begin_inset Text
19073
19074 \begin_layout Standard
19075
19076 \family roman
19077 \series medium
19078 \shape up
19079 \size normal
19080 \emph off
19081 \bar no
19082 \noun off
19083 \color none
19084 _fsadd.c
19085 \end_layout
19086
19087 \end_inset
19088 </cell>
19089 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19090 \begin_inset Text
19091
19092 \begin_layout Standard
19093
19094 \family roman
19095 \series medium
19096 \shape up
19097 \size normal
19098 \emph off
19099 \bar no
19100 \noun off
19101 \color none
19102 add floating point numbers
19103 \end_layout
19104
19105 \end_inset
19106 </cell>
19107 </row>
19108 <row topline="true">
19109 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19110 \begin_inset Text
19111
19112 \begin_layout Standard
19113
19114 \family roman
19115 \series medium
19116 \shape up
19117 \size normal
19118 \emph off
19119 \bar no
19120 \noun off
19121 \color none
19122 _fssub.c 
19123 \end_layout
19124
19125 \end_inset
19126 </cell>
19127 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19128 \begin_inset Text
19129
19130 \begin_layout Standard
19131
19132 \family roman
19133 \series medium
19134 \shape up
19135 \size normal
19136 \emph off
19137 \bar no
19138 \noun off
19139 \color none
19140 subtract floating point numbers 
19141 \end_layout
19142
19143 \end_inset
19144 </cell>
19145 </row>
19146 <row topline="true">
19147 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19148 \begin_inset Text
19149
19150 \begin_layout Standard
19151
19152 \family roman
19153 \series medium
19154 \shape up
19155 \size normal
19156 \emph off
19157 \bar no
19158 \noun off
19159 \color none
19160 _fsdiv.c 
19161 \end_layout
19162
19163 \end_inset
19164 </cell>
19165 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19166 \begin_inset Text
19167
19168 \begin_layout Standard
19169
19170 \family roman
19171 \series medium
19172 \shape up
19173 \size normal
19174 \emph off
19175 \bar no
19176 \noun off
19177 \color none
19178 divide floating point numbers 
19179 \end_layout
19180
19181 \end_inset
19182 </cell>
19183 </row>
19184 <row topline="true">
19185 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19186 \begin_inset Text
19187
19188 \begin_layout Standard
19189
19190 \family roman
19191 \series medium
19192 \shape up
19193 \size normal
19194 \emph off
19195 \bar no
19196 \noun off
19197 \color none
19198 _fsmul.c 
19199 \end_layout
19200
19201 \end_inset
19202 </cell>
19203 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19204 \begin_inset Text
19205
19206 \begin_layout Standard
19207
19208 \family roman
19209 \series medium
19210 \shape up
19211 \size normal
19212 \emph off
19213 \bar no
19214 \noun off
19215 \color none
19216 multiply floating point numbers 
19217 \end_layout
19218
19219 \end_inset
19220 </cell>
19221 </row>
19222 <row topline="true">
19223 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19224 \begin_inset Text
19225
19226 \begin_layout Standard
19227
19228 \family roman
19229 \series medium
19230 \shape up
19231 \size normal
19232 \emph off
19233 \bar no
19234 \noun off
19235 \color none
19236 _fs2uchar.c
19237 \end_layout
19238
19239 \end_inset
19240 </cell>
19241 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19242 \begin_inset Text
19243
19244 \begin_layout Standard
19245
19246 \family roman
19247 \series medium
19248 \shape up
19249 \size normal
19250 \emph off
19251 \bar no
19252 \noun off
19253 \color none
19254 convert floating point to unsigned char
19255 \end_layout
19256
19257 \end_inset
19258 </cell>
19259 </row>
19260 <row topline="true">
19261 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19262 \begin_inset Text
19263
19264 \begin_layout Standard
19265
19266 \family roman
19267 \series medium
19268 \shape up
19269 \size normal
19270 \emph off
19271 \bar no
19272 \noun off
19273 \color none
19274 _fs2char.c
19275 \end_layout
19276
19277 \end_inset
19278 </cell>
19279 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19280 \begin_inset Text
19281
19282 \begin_layout Standard
19283
19284 \family roman
19285 \series medium
19286 \shape up
19287 \size normal
19288 \emph off
19289 \bar no
19290 \noun off
19291 \color none
19292 convert floating point to signed char
19293 \end_layout
19294
19295 \end_inset
19296 </cell>
19297 </row>
19298 <row topline="true">
19299 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19300 \begin_inset Text
19301
19302 \begin_layout Standard
19303
19304 \family roman
19305 \series medium
19306 \shape up
19307 \size normal
19308 \emph off
19309 \bar no
19310 \noun off
19311 \color none
19312 _fs2uint.c
19313 \end_layout
19314
19315 \end_inset
19316 </cell>
19317 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19318 \begin_inset Text
19319
19320 \begin_layout Standard
19321
19322 \family roman
19323 \series medium
19324 \shape up
19325 \size normal
19326 \emph off
19327 \bar no
19328 \noun off
19329 \color none
19330 convert floating point to unsigned int
19331 \end_layout
19332
19333 \end_inset
19334 </cell>
19335 </row>
19336 <row topline="true">
19337 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19338 \begin_inset Text
19339
19340 \begin_layout Standard
19341
19342 \family roman
19343 \series medium
19344 \shape up
19345 \size normal
19346 \emph off
19347 \bar no
19348 \noun off
19349 \color none
19350 _fs2int.c
19351 \end_layout
19352
19353 \end_inset
19354 </cell>
19355 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19356 \begin_inset Text
19357
19358 \begin_layout Standard
19359
19360 \family roman
19361 \series medium
19362 \shape up
19363 \size normal
19364 \emph off
19365 \bar no
19366 \noun off
19367 \color none
19368 convert floating point to signed int
19369 \end_layout
19370
19371 \end_inset
19372 </cell>
19373 </row>
19374 <row topline="true">
19375 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19376 \begin_inset Text
19377
19378 \begin_layout Standard
19379
19380 \family roman
19381 \series medium
19382 \shape up
19383 \size normal
19384 \emph off
19385 \bar no
19386 \noun off
19387 \color none
19388 _fs2ulong.
19389 \family default
19390 \series default
19391 \shape default
19392 \size default
19393 \emph default
19394 \bar default
19395 \noun default
19396 c
19397 \end_layout
19398
19399 \end_inset
19400 </cell>
19401 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19402 \begin_inset Text
19403
19404 \begin_layout Standard
19405
19406 \family roman
19407 \series medium
19408 \shape up
19409 \size normal
19410 \emph off
19411 \bar no
19412 \noun off
19413 \color none
19414 convert floating point to unsigned long
19415 \end_layout
19416
19417 \end_inset
19418 </cell>
19419 </row>
19420 <row topline="true">
19421 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19422 \begin_inset Text
19423
19424 \begin_layout Standard
19425
19426 \family roman
19427 \series medium
19428 \shape up
19429 \size normal
19430 \emph off
19431 \bar no
19432 \noun off
19433 \color none
19434 _fs2long.c
19435 \end_layout
19436
19437 \end_inset
19438 </cell>
19439 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19440 \begin_inset Text
19441
19442 \begin_layout Standard
19443
19444 \family roman
19445 \series medium
19446 \shape up
19447 \size normal
19448 \emph off
19449 \bar no
19450 \noun off
19451 \color none
19452 convert floating point to signed long
19453 \end_layout
19454
19455 \end_inset
19456 </cell>
19457 </row>
19458 <row topline="true">
19459 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19460 \begin_inset Text
19461
19462 \begin_layout Standard
19463
19464 \family roman
19465 \series medium
19466 \shape up
19467 \size normal
19468 \emph off
19469 \bar no
19470 \noun off
19471 \color none
19472 _uchar2fs.c
19473 \end_layout
19474
19475 \end_inset
19476 </cell>
19477 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19478 \begin_inset Text
19479
19480 \begin_layout Standard
19481
19482 \family roman
19483 \series medium
19484 \shape up
19485 \size normal
19486 \emph off
19487 \bar no
19488 \noun off
19489 \color none
19490 convert unsigned char to floating point
19491 \end_layout
19492
19493 \end_inset
19494 </cell>
19495 </row>
19496 <row topline="true">
19497 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19498 \begin_inset Text
19499
19500 \begin_layout Standard
19501
19502 \family roman
19503 \series medium
19504 \shape up
19505 \size normal
19506 \emph off
19507 \bar no
19508 \noun off
19509 \color none
19510 _char2fs.c
19511 \end_layout
19512
19513 \end_inset
19514 </cell>
19515 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19516 \begin_inset Text
19517
19518 \begin_layout Standard
19519
19520 \family roman
19521 \series medium
19522 \shape up
19523 \size normal
19524 \emph off
19525 \bar no
19526 \noun off
19527 \color none
19528 convert char to floating point number
19529 \end_layout
19530
19531 \end_inset
19532 </cell>
19533 </row>
19534 <row topline="true">
19535 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19536 \begin_inset Text
19537
19538 \begin_layout Standard
19539
19540 \family roman
19541 \series medium
19542 \shape up
19543 \size normal
19544 \emph off
19545 \bar no
19546 \noun off
19547 \color none
19548 _uint2fs.c
19549 \end_layout
19550
19551 \end_inset
19552 </cell>
19553 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19554 \begin_inset Text
19555
19556 \begin_layout Standard
19557
19558 \family roman
19559 \series medium
19560 \shape up
19561 \size normal
19562 \emph off
19563 \bar no
19564 \noun off
19565 \color none
19566 convert unsigned int to floating point
19567 \end_layout
19568
19569 \end_inset
19570 </cell>
19571 </row>
19572 <row topline="true">
19573 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19574 \begin_inset Text
19575
19576 \begin_layout Standard
19577
19578 \family roman
19579 \series medium
19580 \shape up
19581 \size normal
19582 \emph off
19583 \bar no
19584 \noun off
19585 \color none
19586 _int2fs.c
19587 \end_layout
19588
19589 \end_inset
19590 </cell>
19591 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19592 \begin_inset Text
19593
19594 \begin_layout Standard
19595
19596 \family roman
19597 \series medium
19598 \shape up
19599 \size normal
19600 \emph off
19601 \bar no
19602 \noun off
19603 \color none
19604 convert int to floating point numbers
19605 \end_layout
19606
19607 \end_inset
19608 </cell>
19609 </row>
19610 <row topline="true">
19611 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19612 \begin_inset Text
19613
19614 \begin_layout Standard
19615
19616 \family roman
19617 \series medium
19618 \shape up
19619 \size normal
19620 \emph off
19621 \bar no
19622 \noun off
19623 \color none
19624 _ulong2fs.c
19625 \end_layout
19626
19627 \end_inset
19628 </cell>
19629 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19630 \begin_inset Text
19631
19632 \begin_layout Standard
19633
19634 \family roman
19635 \series medium
19636 \shape up
19637 \size normal
19638 \emph off
19639 \bar no
19640 \noun off
19641 \color none
19642 convert unsigned long to floating point number
19643 \end_layout
19644
19645 \end_inset
19646 </cell>
19647 </row>
19648 <row topline="true" bottomline="true">
19649 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19650 \begin_inset Text
19651
19652 \begin_layout Standard
19653
19654 \family roman
19655 \series medium
19656 \shape up
19657 \size normal
19658 \emph off
19659 \bar no
19660 \noun off
19661 \color none
19662 _long2fs.c
19663 \end_layout
19664
19665 \end_inset
19666 </cell>
19667 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19668 \begin_inset Text
19669
19670 \begin_layout Standard
19671
19672 \family roman
19673 \series medium
19674 \shape up
19675 \size normal
19676 \emph off
19677 \bar no
19678 \noun off
19679 \color none
19680 convert long to floating point number
19681 \end_layout
19682
19683 \end_inset
19684 </cell>
19685 </row>
19686 </lyxtabular>
19687
19688 \end_inset
19689
19690
19691 \newline
19692
19693 \end_layout
19694
19695 \begin_layout Standard
19696 These support routines are developed in ANSI-C so there is room for space
19697  and speed improvement
19698 \begin_inset Foot
19699 status open
19700
19701 \begin_layout Standard
19702 These floating point routines (
19703 \emph on
19704 not
19705 \emph default
19706  sinf(), cosf(), ...) for the mcs51 are implemented in assembler.
19707  
19708 \end_layout
19709
19710 \end_inset
19711
19712 .
19713  Note if all these routines are used simultaneously the data space might
19714  overflow.
19715  For serious floating point usage the large model might be needed.
19716  Also notice that you don't have to call this routines directly.
19717  The compiler will use them automatically every time a floating point operation
19718  is required.
19719 \begin_inset VSpace bigskip
19720 \end_inset
19721
19722
19723 \end_layout
19724
19725 \begin_layout Section
19726 Library Routines
19727 \begin_inset LatexCommand \index{Libraries}
19728
19729 \end_inset
19730
19731
19732 \end_layout
19733
19734 \begin_layout Standard
19735
19736 \emph on
19737 <pending: this is messy and incomplete - a little more information is in
19738  sdcc/doc/libdoc.txt
19739 \emph default
19740  >
19741 \end_layout
19742
19743 \begin_layout Subsection
19744 Compiler support routines (_gptrget, _mulint etc.)
19745 \end_layout
19746
19747 \begin_layout Subsection
19748 Stdclib functions (puts, printf, strcat etc.)
19749 \end_layout
19750
19751 \begin_layout Subsubsection
19752 <stdio.h>
19753 \end_layout
19754
19755 \begin_layout Paragraph
19756 getchar(), putchar()
19757 \end_layout
19758
19759 \begin_layout Standard
19760 \begin_inset LatexCommand \index{<stdio.h>}
19761
19762 \end_inset
19763
19764 As usual on embedded systems you have to provide your own 
19765 \family typewriter
19766 getchar()
19767 \begin_inset LatexCommand \index{getchar()}
19768
19769 \end_inset
19770
19771  
19772 \family default
19773 and 
19774 \family typewriter
19775 putchar()
19776 \begin_inset LatexCommand \index{putchar()}
19777
19778 \end_inset
19779
19780
19781 \family default
19782  routines.
19783  SDCC does not know whether the system connects to a serial line with or
19784  without handshake, LCD, keyboard or other device.
19785  And whether a 
19786 \family typewriter
19787 lf
19788 \family default
19789  to 
19790 \family typewriter
19791 crlf
19792 \family default
19793  conversion within 
19794 \family typewriter
19795 putchar()
19796 \family default
19797  is intended.
19798  You'll find examples for serial routines f.e.
19799  in sdcc/device/lib.
19800  For the mcs51 this minimalistic polling 
19801 \family typewriter
19802 putchar()
19803 \family default
19804  routine might be a start:
19805 \end_layout
19806
19807 \begin_layout Verse
19808
19809 \family typewriter
19810 void putchar (char c) { 
19811 \newline
19812 \InsetSpace ~
19813 \InsetSpace ~
19814 \InsetSpace ~
19815 \InsetSpace ~
19816 while (!TI)\InsetSpace ~
19817 \InsetSpace ~
19818 \InsetSpace ~
19819  /* assumes UART is initialized */
19820 \newline
19821 \InsetSpace ~
19822 \InsetSpace ~
19823 \InsetSpace ~
19824 \InsetSpace ~
19825 \InsetSpace ~
19826 \InsetSpace ~
19827 \InsetSpace ~
19828 \InsetSpace ~
19829 ;
19830 \newline
19831 \InsetSpace ~
19832 \InsetSpace ~
19833 \InsetSpace ~
19834 \InsetSpace ~
19835 TI
19836  = 0;
19837 \newline
19838 \InsetSpace ~
19839 \InsetSpace ~
19840 \InsetSpace ~
19841 \InsetSpace ~
19842 SBUF = c;
19843 \newline
19844 }
19845 \end_layout
19846
19847 \begin_layout Paragraph
19848 printf()
19849 \end_layout
19850
19851 \begin_layout Standard
19852 The default
19853 \family typewriter
19854  printf()
19855 \begin_inset LatexCommand \index{printf()}
19856
19857 \end_inset
19858
19859
19860 \family default
19861  implementation in
19862 \family typewriter
19863  printf_large.c
19864 \family default
19865  does not support float (except on ds390).
19866  To enable this recompile it with the option 
19867 \emph on
19868 -
19869 \begin_inset ERT
19870 status collapsed
19871
19872 \begin_layout Standard
19873
19874
19875 \backslash
19876 /
19877 \end_layout
19878
19879 \end_inset
19880
19881 DUSE_FLOATS=1
19882 \begin_inset LatexCommand \index{USE\_FLOATS}
19883
19884 \end_inset
19885
19886
19887 \emph default
19888  on the command line.
19889  Use
19890 \emph on
19891  -
19892 \begin_inset ERT
19893 status collapsed
19894
19895 \begin_layout Standard
19896
19897
19898 \backslash
19899 /
19900 \end_layout
19901
19902 \end_inset
19903
19904 -model-large
19905 \begin_inset LatexCommand \index{-\/-model-large}
19906
19907 \end_inset
19908
19909
19910 \emph default
19911  for the mcs51 port, since this uses a lot of memory.
19912 \end_layout
19913
19914 \begin_layout Standard
19915 If you're short on code memory you might want to use 
19916 \family typewriter
19917 printf_small()
19918 \begin_inset LatexCommand \index{printf\_small()}
19919
19920 \end_inset
19921
19922
19923 \family default
19924  
19925 \emph on
19926 instead
19927 \emph default
19928  of
19929 \family typewriter
19930  printf().
19931
19932 \family default
19933  For the mcs51 there additionally are assembly versions 
19934 \family typewriter
19935 printf_tiny()
19936 \begin_inset LatexCommand \index{printf\_tiny() (mcs51)}
19937
19938 \end_inset
19939
19940
19941 \family default
19942  (subset of printf using less than 270 bytes) and 
19943 \family typewriter
19944 printf_fast()
19945 \begin_inset LatexCommand \index{printf\_fast() (mcs51)}
19946
19947 \end_inset
19948
19949  
19950 \family default
19951 and
19952 \family typewriter
19953  printf_fast_f()
19954 \begin_inset LatexCommand \index{printf\_fast\_f() (mcs51)}
19955
19956 \end_inset
19957
19958
19959 \family default
19960  (floating-point aware version of printf_fast) which should fit the requirements
19961  of many embedded systems (printf_fast() can be customized by unsetting
19962  #defines to 
19963 \emph on
19964 not
19965 \emph default
19966  support long variables and field widths).
19967  Be sure to use only one of these printf options within a project.
19968 \newline
19969
19970 \end_layout
19971
19972 \begin_layout Standard
19973 Feature matrix of different 
19974 \emph on
19975 printf
19976 \emph default
19977  options on mcs51.
19978 \end_layout
19979
19980 \begin_layout Standard
19981 \begin_inset Tabular
19982 <lyxtabular version="3" rows="14" columns="7">
19983 <features islongtable="true">
19984 <column alignment="left" valignment="middle" leftline="true" width="14col%">
19985 <column alignment="center" valignment="top" leftline="true" width="0">
19986 <column alignment="center" valignment="top" leftline="true" width="12col%">
19987 <column alignment="center" valignment="top" leftline="true" width="10col%">
19988 <column alignment="center" valignment="top" leftline="true" width="0">
19989 <column alignment="center" valignment="top" leftline="true" rightline="true" width="12col%">
19990 <column alignment="center" valignment="top" rightline="true" width="0">
19991 <row topline="true" bottomline="true" endhead="true">
19992 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19993 \begin_inset Text
19994
19995 \begin_layout Standard
19996
19997 \series bold
19998 \size large
19999 mcs51
20000 \end_layout
20001
20002 \end_inset
20003 </cell>
20004 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20005 \begin_inset Text
20006
20007 \begin_layout Standard
20008 printf
20009 \begin_inset LatexCommand \index{printf}
20010
20011 \end_inset
20012
20013
20014 \end_layout
20015
20016 \end_inset
20017 </cell>
20018 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20019 \begin_inset Text
20020
20021 \begin_layout Standard
20022 printf 
20023 \size scriptsize
20024 USE_FLOATS=1
20025 \end_layout
20026
20027 \end_inset
20028 </cell>
20029 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20030 \begin_inset Text
20031
20032 \begin_layout Standard
20033 printf_small
20034 \end_layout
20035
20036 \end_inset
20037 </cell>
20038 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20039 \begin_inset Text
20040
20041 \begin_layout Standard
20042 printf_fast
20043 \end_layout
20044
20045 \end_inset
20046 </cell>
20047 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20048 \begin_inset Text
20049
20050 \begin_layout Standard
20051 printf_fast_f
20052 \end_layout
20053
20054 \end_inset
20055 </cell>
20056 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20057 \begin_inset Text
20058
20059 \begin_layout Standard
20060 printf_tiny
20061 \end_layout
20062
20063 \end_inset
20064 </cell>
20065 </row>
20066 <row topline="true" endhead="true">
20067 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20068 \begin_inset Text
20069
20070 \begin_layout Standard
20071 filename
20072 \end_layout
20073
20074 \end_inset
20075 </cell>
20076 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20077 \begin_inset Text
20078
20079 \begin_layout Standard
20080
20081 \size scriptsize
20082 printf_large.c
20083 \end_layout
20084
20085 \end_inset
20086 </cell>
20087 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20088 \begin_inset Text
20089
20090 \begin_layout Standard
20091
20092 \size scriptsize
20093 printf_large.c
20094 \end_layout
20095
20096 \end_inset
20097 </cell>
20098 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20099 \begin_inset Text
20100
20101 \begin_layout Standard
20102
20103 \size scriptsize
20104 printfl.c
20105 \end_layout
20106
20107 \end_inset
20108 </cell>
20109 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20110 \begin_inset Text
20111
20112 \begin_layout Standard
20113
20114 \size scriptsize
20115 printf_fast.c
20116 \end_layout
20117
20118 \end_inset
20119 </cell>
20120 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20121 \begin_inset Text
20122
20123 \begin_layout Standard
20124
20125 \size scriptsize
20126 printf_fast_f.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
20136 \size scriptsize
20137 printf_tiny.c
20138 \end_layout
20139
20140 \end_inset
20141 </cell>
20142 </row>
20143 <row topline="true" endhead="true">
20144 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20145 \begin_inset Text
20146
20147 \begin_layout Standard
20148 \begin_inset Quotes sld
20149 \end_inset
20150
20151 Hello World
20152 \begin_inset Quotes srd
20153 \end_inset
20154
20155  size
20156 \end_layout
20157
20158 \begin_layout Standard
20159 small / large
20160 \end_layout
20161
20162 \end_inset
20163 </cell>
20164 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20165 \begin_inset Text
20166
20167 \begin_layout Standard
20168 1.7k / 2.4k
20169 \end_layout
20170
20171 \end_inset
20172 </cell>
20173 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20174 \begin_inset Text
20175
20176 \begin_layout Standard
20177 4.3k / 5.6k
20178 \end_layout
20179
20180 \end_inset
20181 </cell>
20182 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20183 \begin_inset Text
20184
20185 \begin_layout Standard
20186 1.2k / 1.8k
20187 \end_layout
20188
20189 \end_inset
20190 </cell>
20191 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20192 \begin_inset Text
20193
20194 \begin_layout Standard
20195 1.3k / 1.3k
20196 \end_layout
20197
20198 \end_inset
20199 </cell>
20200 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20201 \begin_inset Text
20202
20203 \begin_layout Standard
20204 1.9k / 1.9k
20205 \end_layout
20206
20207 \end_inset
20208 </cell>
20209 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20210 \begin_inset Text
20211
20212 \begin_layout Standard
20213 0.44k / 0.44k
20214 \end_layout
20215
20216 \end_inset
20217 </cell>
20218 </row>
20219 <row topline="true" endhead="true">
20220 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20221 \begin_inset Text
20222
20223 \begin_layout Standard
20224 code size
20225 \end_layout
20226
20227 \begin_layout Standard
20228 small / large
20229 \end_layout
20230
20231 \end_inset
20232 </cell>
20233 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20234 \begin_inset Text
20235
20236 \begin_layout Standard
20237 1.4k / 2.0k
20238 \end_layout
20239
20240 \end_inset
20241 </cell>
20242 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20243 \begin_inset Text
20244
20245 \begin_layout Standard
20246 2.8k / 3.7k
20247 \end_layout
20248
20249 \end_inset
20250 </cell>
20251 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20252 \begin_inset Text
20253
20254 \begin_layout Standard
20255 0.45k / 0.47k (+ _ltoa)
20256 \end_layout
20257
20258 \end_inset
20259 </cell>
20260 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20261 \begin_inset Text
20262
20263 \begin_layout Standard
20264 1.2k / 1.2k
20265 \end_layout
20266
20267 \end_inset
20268 </cell>
20269 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20270 \begin_inset Text
20271
20272 \begin_layout Standard
20273 1.6k / 1.6k
20274 \end_layout
20275
20276 \end_inset
20277 </cell>
20278 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20279 \begin_inset Text
20280
20281 \begin_layout Standard
20282 0.26k / 0.26k
20283 \end_layout
20284
20285 \end_inset
20286 </cell>
20287 </row>
20288 <row topline="true">
20289 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20290 \begin_inset Text
20291
20292 \begin_layout Standard
20293 formats
20294 \end_layout
20295
20296 \end_inset
20297 </cell>
20298 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20299 \begin_inset Text
20300
20301 \begin_layout Standard
20302 cdi
20303 \emph on
20304 o
20305 \emph default
20306 psux
20307 \end_layout
20308
20309 \end_inset
20310 </cell>
20311 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20312 \begin_inset Text
20313
20314 \begin_layout Standard
20315
20316 \family roman
20317 \series medium
20318 \shape up
20319 \size normal
20320 \emph off
20321 \bar no
20322 \noun off
20323 \color none
20324 cd
20325 \family default
20326 \series default
20327 \shape default
20328 \size default
20329 \emph default
20330 \bar default
20331 \noun default
20332 f
20333 \family roman
20334 \series medium
20335 \shape up
20336 \size normal
20337 \emph off
20338 \bar no
20339 \noun off
20340 i
20341 \family default
20342 \series default
20343 \shape default
20344 \size default
20345 \emph on
20346 \bar default
20347 \noun default
20348 o
20349 \family roman
20350 \series medium
20351 \shape up
20352 \size normal
20353 \emph off
20354 \bar no
20355 \noun off
20356 psux
20357 \end_layout
20358
20359 \end_inset
20360 </cell>
20361 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20362 \begin_inset Text
20363
20364 \begin_layout Standard
20365 c
20366 \family roman
20367 \series medium
20368 \shape up
20369 \size normal
20370 \emph off
20371 \bar no
20372 \noun off
20373 \color none
20374 d
20375 \family default
20376 \series default
20377 \shape default
20378 \size default
20379 \emph on
20380 \bar default
20381 \noun default
20382 o
20383 \family roman
20384 \series medium
20385 \shape up
20386 \size normal
20387 \emph off
20388 \bar no
20389 \noun off
20390 s
20391 \family default
20392 \series default
20393 \shape default
20394 \size default
20395 \emph default
20396 \bar default
20397 \noun default
20398 x
20399 \end_layout
20400
20401 \end_inset
20402 </cell>
20403 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20404 \begin_inset Text
20405
20406 \begin_layout Standard
20407 cdsux
20408 \end_layout
20409
20410 \end_inset
20411 </cell>
20412 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20413 \begin_inset Text
20414
20415 \begin_layout Standard
20416 cdfsux
20417 \end_layout
20418
20419 \end_inset
20420 </cell>
20421 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20422 \begin_inset Text
20423
20424 \begin_layout Standard
20425 cdsux
20426 \end_layout
20427
20428 \end_inset
20429 </cell>
20430 </row>
20431 <row topline="true">
20432 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20433 \begin_inset Text
20434
20435 \begin_layout Standard
20436 long (32 bit) support
20437 \end_layout
20438
20439 \end_inset
20440 </cell>
20441 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20442 \begin_inset Text
20443
20444 \begin_layout Standard
20445 x
20446 \end_layout
20447
20448 \end_inset
20449 </cell>
20450 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20451 \begin_inset Text
20452
20453 \begin_layout Standard
20454 x
20455 \end_layout
20456
20457 \end_inset
20458 </cell>
20459 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20460 \begin_inset Text
20461
20462 \begin_layout Standard
20463 x
20464 \end_layout
20465
20466 \end_inset
20467 </cell>
20468 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20469 \begin_inset Text
20470
20471 \begin_layout Standard
20472 x
20473 \end_layout
20474
20475 \end_inset
20476 </cell>
20477 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20478 \begin_inset Text
20479
20480 \begin_layout Standard
20481
20482 \family roman
20483 \series medium
20484 \shape up
20485 \size normal
20486 \emph off
20487 \bar no
20488 \noun off
20489 \color none
20490 x
20491 \end_layout
20492
20493 \end_inset
20494 </cell>
20495 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20496 \begin_inset Text
20497
20498 \begin_layout Standard
20499 -
20500 \end_layout
20501
20502 \end_inset
20503 </cell>
20504 </row>
20505 <row topline="true">
20506 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20507 \begin_inset Text
20508
20509 \begin_layout Standard
20510 byte arguments on stack
20511 \end_layout
20512
20513 \end_inset
20514 </cell>
20515 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20516 \begin_inset Text
20517
20518 \begin_layout Standard
20519 b
20520 \end_layout
20521
20522 \end_inset
20523 </cell>
20524 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20525 \begin_inset Text
20526
20527 \begin_layout Standard
20528 b
20529 \end_layout
20530
20531 \end_inset
20532 </cell>
20533 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20534 \begin_inset Text
20535
20536 \begin_layout Standard
20537 -
20538 \end_layout
20539
20540 \end_inset
20541 </cell>
20542 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20543 \begin_inset Text
20544
20545 \begin_layout Standard
20546 -
20547 \end_layout
20548
20549 \end_inset
20550 </cell>
20551 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20552 \begin_inset Text
20553
20554 \begin_layout Standard
20555 -
20556 \end_layout
20557
20558 \end_inset
20559 </cell>
20560 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20561 \begin_inset Text
20562
20563 \begin_layout Standard
20564 -
20565 \end_layout
20566
20567 \end_inset
20568 </cell>
20569 </row>
20570 <row topline="true">
20571 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20572 \begin_inset Text
20573
20574 \begin_layout Standard
20575 float format
20576 \begin_inset LatexCommand \index{Floating point support}
20577
20578 \end_inset
20579
20580
20581 \end_layout
20582
20583 \end_inset
20584 </cell>
20585 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20586 \begin_inset Text
20587
20588 \begin_layout Standard
20589 -
20590 \end_layout
20591
20592 \end_inset
20593 </cell>
20594 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20595 \begin_inset Text
20596
20597 \begin_layout Standard
20598 %f
20599 \end_layout
20600
20601 \end_inset
20602 </cell>
20603 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20604 \begin_inset Text
20605
20606 \begin_layout Standard
20607 -
20608 \end_layout
20609
20610 \end_inset
20611 </cell>
20612 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20613 \begin_inset Text
20614
20615 \begin_layout Standard
20616 -
20617 \end_layout
20618
20619 \end_inset
20620 </cell>
20621 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20622 \begin_inset Text
20623
20624 \begin_layout Standard
20625 %f
20626 \begin_inset Foot
20627 status collapsed
20628
20629 \begin_layout Standard
20630 Range limited to +/- 4294967040, precision limited to 8 digits past decimal
20631 \end_layout
20632
20633 \end_inset
20634
20635
20636 \end_layout
20637
20638 \end_inset
20639 </cell>
20640 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20641 \begin_inset Text
20642
20643 \begin_layout Standard
20644 -
20645 \end_layout
20646
20647 \end_inset
20648 </cell>
20649 </row>
20650 <row topline="true">
20651 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20652 \begin_inset Text
20653
20654 \begin_layout Standard
20655 float formats %e %g
20656 \end_layout
20657
20658 \end_inset
20659 </cell>
20660 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20661 \begin_inset Text
20662
20663 \begin_layout Standard
20664 -
20665 \end_layout
20666
20667 \end_inset
20668 </cell>
20669 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20670 \begin_inset Text
20671
20672 \begin_layout Standard
20673 -
20674 \end_layout
20675
20676 \end_inset
20677 </cell>
20678 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20679 \begin_inset Text
20680
20681 \begin_layout Standard
20682 -
20683 \end_layout
20684
20685 \end_inset
20686 </cell>
20687 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20688 \begin_inset Text
20689
20690 \begin_layout Standard
20691 -
20692 \end_layout
20693
20694 \end_inset
20695 </cell>
20696 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20697 \begin_inset Text
20698
20699 \begin_layout Standard
20700 -
20701 \end_layout
20702
20703 \end_inset
20704 </cell>
20705 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20706 \begin_inset Text
20707
20708 \begin_layout Standard
20709 -
20710 \end_layout
20711
20712 \end_inset
20713 </cell>
20714 </row>
20715 <row topline="true" bottomline="true">
20716 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20717 \begin_inset Text
20718
20719 \begin_layout Standard
20720 field width
20721 \end_layout
20722
20723 \end_inset
20724 </cell>
20725 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20726 \begin_inset Text
20727
20728 \begin_layout Standard
20729 x
20730 \end_layout
20731
20732 \end_inset
20733 </cell>
20734 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20735 \begin_inset Text
20736
20737 \begin_layout Standard
20738 x
20739 \end_layout
20740
20741 \end_inset
20742 </cell>
20743 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20744 \begin_inset Text
20745
20746 \begin_layout Standard
20747 -
20748 \end_layout
20749
20750 \end_inset
20751 </cell>
20752 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20753 \begin_inset Text
20754
20755 \begin_layout Standard
20756 x
20757 \end_layout
20758
20759 \end_inset
20760 </cell>
20761 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20762 \begin_inset Text
20763
20764 \begin_layout Standard
20765 x
20766 \end_layout
20767
20768 \end_inset
20769 </cell>
20770 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20771 \begin_inset Text
20772
20773 \begin_layout Standard
20774 -
20775 \end_layout
20776
20777 \end_inset
20778 </cell>
20779 </row>
20780 <row bottomline="true">
20781 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20782 \begin_inset Text
20783
20784 \begin_layout Standard
20785 string speed
20786 \begin_inset Foot
20787 status collapsed
20788
20789 \begin_layout Standard
20790 Execution time of printf("%s%c%s%c%c%c", "Hello", ' ', "World", '!', '
20791 \backslash
20792 r', '
20793 \backslash
20794 n'); standard 8051 @ 22.1184 MHz, empty putchar()
20795 \end_layout
20796
20797 \end_inset
20798
20799 ,
20800 \end_layout
20801
20802 \begin_layout Standard
20803 small / large
20804 \end_layout
20805
20806 \end_inset
20807 </cell>
20808 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20809 \begin_inset Text
20810
20811 \begin_layout Standard
20812 1.52 / 2.59 ms
20813 \end_layout
20814
20815 \end_inset
20816 </cell>
20817 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20818 \begin_inset Text
20819
20820 \begin_layout Standard
20821 1.53 / 2.62 ms
20822 \end_layout
20823
20824 \end_inset
20825 </cell>
20826 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20827 \begin_inset Text
20828
20829 \begin_layout Standard
20830 0.92 / 0.93 ms
20831 \end_layout
20832
20833 \end_inset
20834 </cell>
20835 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20836 \begin_inset Text
20837
20838 \begin_layout Standard
20839 0.45 / 0.45 ms
20840 \end_layout
20841
20842 \end_inset
20843 </cell>
20844 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20845 \begin_inset Text
20846
20847 \begin_layout Standard
20848 0.46 / 0.46 ms
20849 \end_layout
20850
20851 \end_inset
20852 </cell>
20853 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20854 \begin_inset Text
20855
20856 \begin_layout Standard
20857 0.45 / 0.45 ms
20858 \end_layout
20859
20860 \end_inset
20861 </cell>
20862 </row>
20863 <row bottomline="true">
20864 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20865 \begin_inset Text
20866
20867 \begin_layout Standard
20868 int speed
20869 \begin_inset Foot
20870 status collapsed
20871
20872 \begin_layout Standard
20873 Execution time of printf("%d", -12345); standard 8051 @ 22.1184 MHz, empty
20874  putchar()
20875 \end_layout
20876
20877 \end_inset
20878
20879 ,
20880 \end_layout
20881
20882 \begin_layout Standard
20883 small / large
20884 \end_layout
20885
20886 \end_inset
20887 </cell>
20888 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20889 \begin_inset Text
20890
20891 \begin_layout Standard
20892 3.01 / 3.61 ms
20893 \end_layout
20894
20895 \end_inset
20896 </cell>
20897 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20898 \begin_inset Text
20899
20900 \begin_layout Standard
20901 3.01 / 3.61 ms
20902 \end_layout
20903
20904 \end_inset
20905 </cell>
20906 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20907 \begin_inset Text
20908
20909 \begin_layout Standard
20910 3.51 / 18.13 ms
20911 \end_layout
20912
20913 \end_inset
20914 </cell>
20915 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20916 \begin_inset Text
20917
20918 \begin_layout Standard
20919 0.22 / 0.22 ms
20920 \end_layout
20921
20922 \end_inset
20923 </cell>
20924 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20925 \begin_inset Text
20926
20927 \begin_layout Standard
20928 0.23 / 0.23 ms
20929 \end_layout
20930
20931 \end_inset
20932 </cell>
20933 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20934 \begin_inset Text
20935
20936 \begin_layout Standard
20937 0.25 / 0.25 ms
20938 \begin_inset Foot
20939 status collapsed
20940
20941 \begin_layout Standard
20942 printf_tiny integer speed is data dependent, worst case is 0.33 ms
20943 \end_layout
20944
20945 \end_inset
20946
20947
20948 \end_layout
20949
20950 \end_inset
20951 </cell>
20952 </row>
20953 <row bottomline="true">
20954 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20955 \begin_inset Text
20956
20957 \begin_layout Standard
20958 long speed
20959 \begin_inset Foot
20960 status collapsed
20961
20962 \begin_layout Standard
20963 Execution time of printf("%ld", -123456789); standard 8051 @ 22.1184 MHz,
20964  empty putchar()
20965 \end_layout
20966
20967 \end_inset
20968
20969 ,
20970 \end_layout
20971
20972 \begin_layout Standard
20973 small / large
20974 \end_layout
20975
20976 \end_inset
20977 </cell>
20978 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20979 \begin_inset Text
20980
20981 \begin_layout Standard
20982 5.37 / 6.31 ms
20983 \end_layout
20984
20985 \end_inset
20986 </cell>
20987 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20988 \begin_inset Text
20989
20990 \begin_layout Standard
20991 5.37 / 6.31 ms
20992 \end_layout
20993
20994 \end_inset
20995 </cell>
20996 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20997 \begin_inset Text
20998
20999 \begin_layout Standard
21000 8.71 / 40.65 ms
21001 \end_layout
21002
21003 \end_inset
21004 </cell>
21005 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21006 \begin_inset Text
21007
21008 \begin_layout Standard
21009 0.40 / 0.40 ms
21010 \end_layout
21011
21012 \end_inset
21013 </cell>
21014 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21015 \begin_inset Text
21016
21017 \begin_layout Standard
21018 0.40 / 0.40 ms
21019 \end_layout
21020
21021 \end_inset
21022 </cell>
21023 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
21024 \begin_inset Text
21025
21026 \begin_layout Standard
21027 -
21028 \end_layout
21029
21030 \end_inset
21031 </cell>
21032 </row>
21033 <row bottomline="true">
21034 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21035 \begin_inset Text
21036
21037 \begin_layout Standard
21038 float speed
21039 \begin_inset Foot
21040 status collapsed
21041
21042 \begin_layout Standard
21043 Execution time of printf("%.3f", -12345.678); standard 8051 @ 22.1184 MHz,
21044  empty putchar()
21045 \end_layout
21046
21047 \end_inset
21048
21049 ,
21050 \end_layout
21051
21052 \begin_layout Standard
21053 small / large
21054 \end_layout
21055
21056 \end_inset
21057 </cell>
21058 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21059 \begin_inset Text
21060
21061 \begin_layout Standard
21062 -
21063 \end_layout
21064
21065 \end_inset
21066 </cell>
21067 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21068 \begin_inset Text
21069
21070 \begin_layout Standard
21071 7.49 / 22.47 ms
21072 \end_layout
21073
21074 \end_inset
21075 </cell>
21076 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21077 \begin_inset Text
21078
21079 \begin_layout Standard
21080 -
21081 \end_layout
21082
21083 \end_inset
21084 </cell>
21085 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21086 \begin_inset Text
21087
21088 \begin_layout Standard
21089 -
21090 \end_layout
21091
21092 \end_inset
21093 </cell>
21094 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21095 \begin_inset Text
21096
21097 \begin_layout Standard
21098 1.04 / 1.04 ms
21099 \end_layout
21100
21101 \end_inset
21102 </cell>
21103 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
21104 \begin_inset Text
21105
21106 \begin_layout Standard
21107 -
21108 \end_layout
21109
21110 \end_inset
21111 </cell>
21112 </row>
21113 </lyxtabular>
21114
21115 \end_inset
21116
21117
21118 \end_layout
21119
21120 \begin_layout Subsubsection
21121 <malloc.h>
21122 \begin_inset LatexCommand \index{malloc.h}
21123
21124 \end_inset
21125
21126
21127 \end_layout
21128
21129 \begin_layout Standard
21130 As of SDCC 2.6.2 you no longer need to call an initialization routine before
21131  using dynamic memory allocation
21132 \begin_inset LatexCommand \index{dynamic memory allocation (malloc)}
21133
21134 \end_inset
21135
21136  and a default heap
21137 \begin_inset LatexCommand \index{heap (malloc)}
21138
21139 \end_inset
21140
21141  space of 1024 bytes is provided for malloc to allocate memory from.
21142  If you need a different heap size you need to recompile _heap.c with the
21143  required size defined in HEAP_SIZE.
21144  It is recommended to make a copy of this file into your project directory
21145  and compile it there with:
21146 \end_layout
21147
21148 \begin_layout Verse
21149
21150 \family typewriter
21151 sdcc -c _heap.c -D HEAD_SIZE=2048
21152 \end_layout
21153
21154 \begin_layout Standard
21155 And then link it with:
21156 \end_layout
21157
21158 \begin_layout Verse
21159
21160 \family typewriter
21161 sdcc main.rel _heap.rel
21162 \end_layout
21163
21164 \begin_layout Subsection
21165 Math functions (sinf, powf, sqrtf etc.)
21166 \end_layout
21167
21168 \begin_layout Subsubsection
21169 <math.h>
21170 \end_layout
21171
21172 \begin_layout Standard
21173 See definitions in file <math.h>.
21174 \end_layout
21175
21176 \begin_layout Subsection
21177 Other libraries
21178 \end_layout
21179
21180 \begin_layout Standard
21181 Libraries
21182 \begin_inset LatexCommand \index{Libraries}
21183
21184 \end_inset
21185
21186  included in SDCC should have a license at least as liberal as the GNU Lesser
21187  General Public License
21188 \begin_inset LatexCommand \index{GNU Lesser General Public License, LGPL}
21189
21190 \end_inset
21191
21192  
21193 \emph on
21194 LGPL
21195 \emph default
21196 .
21197 \end_layout
21198
21199 \begin_layout Standard
21200 \begin_inset Note Note
21201 status collapsed
21202
21203 \begin_layout Standard
21204 license statements for the libraries are missing.
21205  sdcc/device/lib/ser_ir.c
21206 \end_layout
21207
21208 \begin_layout Standard
21209 or _decdptr f.e.
21210  come with a GPL (as opposed to LGPL) License - this will not be liberal
21211  enough for many embedded programmers.
21212 \end_layout
21213
21214 \end_inset
21215
21216
21217 \end_layout
21218
21219 \begin_layout Standard
21220 If you have ported some library or want to share experience about some code
21221  which f.e.
21222  falls into any of these categories Busses (I
21223 \begin_inset Formula $^{\textrm{2}}$
21224 \end_inset
21225
21226 C, CAN, Ethernet, Profibus, Modbus, USB, SPI, JTAG ...), Media (IDE, Memory
21227  cards, eeprom, flash...), En-/Decryption, Remote debugging, Realtime kernel,
21228  Keyboard, LCD, RTC, FPGA, PID then the sdcc-user mailing list 
21229 \begin_inset LatexCommand \url{http://sourceforge.net/mail/?group_id=599}
21230
21231 \end_inset
21232
21233 \InsetSpace ~
21234 would certainly like to hear about it.
21235 \end_layout
21236
21237 \begin_layout Standard
21238 Programmers coding for embedded systems are not especially famous for being
21239  enthusiastic, so don't expect a big hurray but as the mailing list is searchabl
21240 e these references are very valuable.
21241  Let's help to create a climate where information is shared.
21242 \begin_inset VSpace bigskip
21243 \end_inset
21244
21245
21246 \end_layout
21247
21248 \begin_layout Section
21249 Memory Models
21250 \end_layout
21251
21252 \begin_layout Subsection
21253 MCS51 Memory Models
21254 \begin_inset LatexCommand \index{Memory model}
21255
21256 \end_inset
21257
21258
21259 \begin_inset LatexCommand \index{MCS51 memory model}
21260
21261 \end_inset
21262
21263
21264 \end_layout
21265
21266 \begin_layout Subsubsection
21267 Small, Medium and Large
21268 \end_layout
21269
21270 \begin_layout Standard
21271 SDCC allows three memory models for MCS51 code, 
21272 \shape slanted
21273 small, medium
21274 \shape default
21275  and 
21276 \shape slanted
21277 large
21278 \shape default
21279 .
21280  Modules compiled with different memory models should 
21281 \emph on
21282 never
21283 \emph default
21284  be combined together or the results would be unpredictable.
21285  The library routines supplied with the compiler are compiled as small,
21286  medium and large.
21287  The compiled library modules are contained in separate directories as small,
21288  medium and large so that you can link to the appropriate set.
21289 \end_layout
21290
21291 \begin_layout Standard
21292 When the medium or large model is used all variables declared without a
21293  storage class will be allocated into the external ram, this includes all
21294  parameters and local variables (for non-reentrant
21295 \begin_inset LatexCommand \index{reentrant}
21296
21297 \end_inset
21298
21299  functions).
21300  When the small model is used variables without storage class are allocated
21301  in the internal ram.
21302 \end_layout
21303
21304 \begin_layout Standard
21305 Judicious usage of the processor specific storage classes
21306 \begin_inset LatexCommand \index{Storage class}
21307
21308 \end_inset
21309
21310  and the 'reentrant' function type will yield much more efficient code,
21311  than using the large model.
21312  Several optimizations are disabled when the program is compiled using the
21313  large model, it is therefore recommended that the small model be used unless
21314  absolutely required.
21315 \end_layout
21316
21317 \begin_layout Subsubsection
21318 External Stack
21319 \begin_inset LatexCommand \label{sub:External-Stack}
21320
21321 \end_inset
21322
21323
21324 \begin_inset LatexCommand \index{stack}
21325
21326 \end_inset
21327
21328
21329 \begin_inset LatexCommand \index{External stack (mcs51)}
21330
21331 \end_inset
21332
21333
21334 \end_layout
21335
21336 \begin_layout Standard
21337 The external stack (-
21338 \begin_inset ERT
21339 status collapsed
21340
21341 \begin_layout Standard
21342
21343
21344 \backslash
21345 /
21346 \end_layout
21347
21348 \end_inset
21349
21350 -xstack option
21351 \begin_inset LatexCommand \index{-\/-xstack}
21352
21353 \end_inset
21354
21355 ) is located in pdata
21356 \begin_inset LatexCommand \index{pdata (mcs51, ds390 storage class)}
21357
21358 \end_inset
21359
21360  memory (usually at the start of the external ram segment) and uses all
21361  unused space in pdata (max.
21362  256 bytes).
21363  When -
21364 \begin_inset ERT
21365 status collapsed
21366
21367 \begin_layout Standard
21368
21369
21370 \backslash
21371 /
21372 \end_layout
21373
21374 \end_inset
21375
21376 -xstack option is used to compile the program, the parameters and local
21377  variables
21378 \begin_inset LatexCommand \index{local variables}
21379
21380 \end_inset
21381
21382  of all reentrant functions are allocated in this area.
21383  This option is provided for programs with large stack space requirements.
21384  When used with the -
21385 \begin_inset ERT
21386 status collapsed
21387
21388 \begin_layout Standard
21389
21390
21391 \backslash
21392 /
21393 \end_layout
21394
21395 \end_inset
21396
21397 -stack-auto
21398 \begin_inset LatexCommand \index{-\/-stack-auto}
21399
21400 \end_inset
21401
21402  option, all parameters and local variables are allocated on the external
21403  stack (note: support libraries will need to be recompiled with the same
21404  options.
21405  There is a predefined target in the library makefile).
21406 \end_layout
21407
21408 \begin_layout Standard
21409 The compiler outputs the higher order address byte of the external ram segment
21410  into port P2
21411 \begin_inset LatexCommand \index{P2 (mcs51 sfr)}
21412
21413 \end_inset
21414
21415  (see also section 
21416 \begin_inset LatexCommand \ref{sub:MCS51-variants}
21417
21418 \end_inset
21419
21420 ), therefore when using the External Stack option, this port 
21421 \emph on
21422 may not
21423 \emph default
21424  be used by the application program.
21425 \end_layout
21426
21427 \begin_layout Subsection
21428 DS390 Memory Model
21429 \begin_inset LatexCommand \index{Memory model}
21430
21431 \end_inset
21432
21433
21434 \begin_inset LatexCommand \index{DS390 memory model}
21435
21436 \end_inset
21437
21438
21439 \end_layout
21440
21441 \begin_layout Standard
21442 The only model supported is Flat 24
21443 \begin_inset LatexCommand \index{Flat 24 (DS390 memory model)}
21444
21445 \end_inset
21446
21447 .
21448  This generates code for the 24 bit contiguous addressing mode of the Dallas
21449  DS80C390 part.
21450  In this mode, up to four meg of external RAM or code space can be directly
21451  addressed.
21452  See the data sheets at www.dalsemi.com for further information on this part.
21453 \newline
21454
21455 \newline
21456 Note
21457  that the compiler does not generate any code to place the processor into
21458  24 bitmode (although 
21459 \emph on
21460 tinibios
21461 \emph default
21462  in the ds390 libraries will do that for you).
21463  If you don't use 
21464 \emph on
21465 tinibios
21466 \emph default
21467
21468 \begin_inset LatexCommand \index{Tinibios (DS390)}
21469
21470 \end_inset
21471
21472 , the boot loader or similar code must ensure that the processor is in 24
21473  bit contiguous addressing mode before calling the SDCC startup code.
21474 \newline
21475
21476 \newline
21477 Like
21478  the 
21479 \emph on
21480 -
21481 \begin_inset ERT
21482 status collapsed
21483
21484 \begin_layout Standard
21485
21486
21487 \backslash
21488 /
21489 \end_layout
21490
21491 \end_inset
21492
21493 -model-large
21494 \emph default
21495  option, variables will by default be placed into the XDATA segment.
21496  
21497 \newline
21498
21499 \newline
21500 Segments may be placed anywhere in the 4 meg address space using the usual
21501  -
21502 \begin_inset ERT
21503 status collapsed
21504
21505 \begin_layout Standard
21506
21507
21508 \backslash
21509 /
21510 \end_layout
21511
21512 \end_inset
21513
21514 -*-loc options.
21515  Note that if any segments are located above 64K, the -r flag must be passed
21516  to the linker to generate the proper segment relocations, and the Intel
21517  HEX output format must be used.
21518  The -r flag can be passed to the linker by using the option 
21519 \emph on
21520 -Wl-r
21521 \emph default
21522  on the SDCC command line.
21523  However, currently the linker can not handle code segments > 64k.
21524 \end_layout
21525
21526 \begin_layout Section
21527 Pragmas
21528 \begin_inset LatexCommand \label{sec:Pragmas}
21529
21530 \end_inset
21531
21532
21533 \begin_inset LatexCommand \index{Pragmas}
21534
21535 \end_inset
21536
21537
21538 \end_layout
21539
21540 \begin_layout Standard
21541 Pragmas are used to turn on and/or off certain compiler options.
21542  Some of them are closely related to corresponding command-line options
21543  (see section 
21544 \begin_inset LatexCommand \vref{sec:Command-Line-Options}
21545
21546 \end_inset
21547
21548 ).
21549 \newline
21550 Pragmas should be placed before and/or after a function, placing pragmas
21551  inside a function body could have unpredictable results.
21552 \newline
21553
21554 \newline
21555 SDCC supports the
21556  following #pragma directives:
21557 \end_layout
21558
21559 \begin_layout Itemize
21560
21561 \series bold
21562 save
21563 \series default
21564
21565 \begin_inset LatexCommand \index{\#pragma save}
21566
21567 \end_inset
21568
21569  - this will save most current options to the save/restore stack.
21570  See #pragma\InsetSpace ~
21571 restore.
21572 \end_layout
21573
21574 \begin_layout Itemize
21575
21576 \series bold
21577 restore
21578 \series default
21579
21580 \begin_inset LatexCommand \index{\#pragma restore}
21581
21582 \end_inset
21583
21584  - will restore saved options from the last save.
21585  saves & restores can be nested.
21586  SDCC uses a save/restore stack: save pushes current options to the stack,
21587  restore pulls current options from the stack.
21588  See #pragma\InsetSpace ~
21589 save.
21590 \newline
21591
21592 \end_layout
21593
21594 \begin_layout Itemize
21595
21596 \series bold
21597 callee_saves
21598 \series default
21599
21600 \begin_inset LatexCommand \index{\#pragma callee\_saves}
21601
21602 \end_inset
21603
21604
21605 \begin_inset LatexCommand \index{function prologue}
21606
21607 \end_inset
21608
21609  function1[,function2[,function3...]] 
21610 \begin_inset LatexCommand \label{ite:callee_saves-function1[,function2[,function3...]]--}
21611
21612 \end_inset
21613
21614 - The compiler by default uses a caller saves convention for register saving
21615  across function calls, however this can cause unnecessary register pushing
21616  and popping
21617 \begin_inset LatexCommand \index{push/pop}
21618
21619 \end_inset
21620
21621  when calling small functions from larger functions.
21622  This option can be used to switch off the register saving convention for
21623  the function names specified.
21624  The compiler will not save registers when calling these functions, extra
21625  code need to be manually inserted at the entry and exit for these functions
21626  to save and restore the registers used by these functions, this can SUBSTANTIAL
21627 LY reduce code and improve run time performance of the generated code.
21628  In the future the compiler (with inter procedural analysis) may be able
21629  to determine the appropriate scheme to use for each function call.
21630  If -
21631 \begin_inset ERT
21632 status collapsed
21633
21634 \begin_layout Standard
21635
21636
21637 \backslash
21638 /
21639 \end_layout
21640
21641 \end_inset
21642
21643 -callee-saves command line option is used (see page 
21644 \begin_inset LatexCommand \vpageref{lyx:--callee-saves-function1[,function2][,function3]...}
21645
21646 \end_inset
21647
21648 ), the function names specified in #pragma\InsetSpace ~
21649 callee_saves
21650 \begin_inset LatexCommand \index{\#pragma callee\_saves}
21651
21652 \end_inset
21653
21654  is appended to the list of functions specified in the command line.
21655 \end_layout
21656
21657 \begin_layout Itemize
21658
21659 \series bold
21660 exclude
21661 \series default
21662
21663 \begin_inset LatexCommand \index{\#pragma exclude}
21664
21665 \end_inset
21666
21667  none | {acc[,b[,dpl[,dph]]] - The exclude pragma disables the generation
21668  of pairs of push/pop
21669 \begin_inset LatexCommand \index{push/pop}
21670
21671 \end_inset
21672
21673  instructions in 
21674 \emph on
21675 I
21676 \emph default
21677 nterrupt
21678 \begin_inset LatexCommand \index{interrupt}
21679
21680 \end_inset
21681
21682  
21683 \emph on
21684 S
21685 \emph default
21686 ervice 
21687 \emph on
21688 R
21689 \emph default
21690 outines.
21691  The directive should be placed immediately before the ISR function definition
21692  and it affects ALL ISR functions following it.
21693  To enable the normal register saving for ISR functions use #pragma\InsetSpace ~
21694 exclude\InsetSpace ~
21695 none
21696 \begin_inset LatexCommand \index{\#pragma exclude}
21697
21698 \end_inset
21699
21700 .
21701  See also the related keyword _naked
21702 \begin_inset LatexCommand \index{\_naked}
21703
21704 \end_inset
21705
21706
21707 \begin_inset LatexCommand \index{\_\_naked}
21708
21709 \end_inset
21710
21711 .
21712 \end_layout
21713
21714 \begin_layout Itemize
21715
21716 \series bold
21717 less_pedantic
21718 \series default
21719
21720 \begin_inset LatexCommand \index{pedantic}
21721
21722 \end_inset
21723
21724
21725 \begin_inset LatexCommand \index{\#pragma less\_pedantic}
21726
21727 \end_inset
21728
21729  
21730 \begin_inset LatexCommand \label{ite:less_pedantic}
21731
21732 \end_inset
21733
21734 - the compiler will not warn you anymore for obvious mistakes, you're on
21735  your own now ;-( .
21736  See also the command line option -
21737 \begin_inset ERT
21738 status collapsed
21739
21740 \begin_layout Standard
21741
21742
21743 \backslash
21744 /
21745 \end_layout
21746
21747 \end_inset
21748
21749 -less-pedantic 
21750 \begin_inset LatexCommand \vpageref{lyx:--less-pedantic}
21751
21752 \end_inset
21753
21754 .
21755  
21756 \newline
21757 More specifically, the following warnings will be disabled: 
21758 \shape italic
21759 comparison is always [true/false] due to limited range of data type
21760 \shape default
21761  (94); 
21762 \shape italic
21763 overflow in implicit constant conversion
21764 \shape default
21765  (158); [the (in)famous] 
21766 \shape italic
21767 conditional flow changed by optimizer: so said EVELYN the modified DOG
21768 \shape default
21769  (110); 
21770 \shape italic
21771 function '[function name]' must return value
21772 \shape default
21773  (59).
21774  
21775 \newline
21776 Furthermore, warnings of less importance (of PEDANTIC and INFO warning
21777  level) are disabled, too, namely: 
21778 \shape italic
21779 constant value '[
21780 \begin_inset Note Note
21781 status collapsed
21782
21783 \begin_layout Standard
21784 dunno what comes here - this warning appears to be unused altogether
21785 \end_layout
21786
21787 \end_inset
21788
21789 ]', out of range
21790 \shape default
21791  (81); 
21792 \shape italic
21793 [left/right] shifting more than size of object changed to zero
21794 \shape default
21795  (116); 
21796 \shape italic
21797 unreachable code
21798 \shape default
21799  (126); 
21800 \shape italic
21801 integer overflow in expression
21802 \shape default
21803  (165); 
21804 \shape italic
21805 unmatched #pragma save and #pragma restore
21806 \shape default
21807  (170); 
21808 \shape italic
21809 comparison of 'signed char' with 'unsigned char' requires promotion to int
21810 \shape default
21811  (185); 
21812 \shape italic
21813 ISO C90 does not support flexible array members
21814 \shape default
21815  (187); 
21816 \shape italic
21817 extended stack by [number] bytes for compiler temp(s) :in function '[function\InsetSpace ~
21818 nam
21819 e]':\InsetSpace ~
21820 [
21821 \begin_inset Note Note
21822 status collapsed
21823
21824 \begin_layout Standard
21825 appears to be always blank - what was supposed to be here?
21826 \end_layout
21827
21828 \end_inset
21829
21830 ]
21831 \shape default
21832  (114); 
21833 \shape italic
21834 function '[function name]', # edges [number] , # nodes [number] , cyclomatic
21835  complexity [number]
21836 \shape default
21837  (121).
21838 \end_layout
21839
21840 \begin_layout Itemize
21841
21842 \series bold
21843 disable_warning
21844 \series default
21845  <nnnn>
21846 \begin_inset LatexCommand \index{\#pragma disable\_warning}
21847
21848 \end_inset
21849
21850  - the compiler will not warn you anymore about warning number <nnnn>.
21851 \end_layout
21852
21853 \begin_layout Itemize
21854
21855 \series bold
21856 nogcse
21857 \series default
21858
21859 \begin_inset LatexCommand \index{\#pragma nogcse}
21860
21861 \end_inset
21862
21863  - will stop global common subexpression elimination.
21864 \end_layout
21865
21866 \begin_layout Itemize
21867
21868 \series bold
21869 noinduction
21870 \series default
21871
21872 \begin_inset LatexCommand \index{\#pragma noinduction}
21873
21874 \end_inset
21875
21876  - will stop loop induction optimizations.
21877 \end_layout
21878
21879 \begin_layout Itemize
21880
21881 \series bold
21882 noinvariant
21883 \series default
21884
21885 \begin_inset LatexCommand \index{\#pragma noinvariant}
21886
21887 \end_inset
21888
21889  - will not do loop invariant optimizations.
21890  For more details see Loop Invariants in section
21891 \begin_inset LatexCommand \ref{sub:Loop-Optimizations}
21892
21893 \end_inset
21894
21895 .
21896 \end_layout
21897
21898 \begin_layout Itemize
21899
21900 \series bold
21901 noiv
21902 \series default
21903
21904 \begin_inset LatexCommand \index{\#pragma noiv}
21905
21906 \end_inset
21907
21908  - Do not generate interrupt
21909 \begin_inset LatexCommand \index{interrupt}
21910
21911 \end_inset
21912
21913  vector table
21914 \begin_inset LatexCommand \index{interrupt vector table}
21915
21916 \end_inset
21917
21918  entries for all ISR functions defined after the pragma.
21919  This is useful in cases where the interrupt vector table must be defined
21920  manually, or when there is a secondary, manually defined interrupt vector
21921  table (e.g.
21922  for the autovector feature of the Cypress EZ-USB FX2).
21923  More elegantly this can be achieved by obmitting the optional interrupt
21924  number after the interrupt keyword, see section 
21925 \begin_inset LatexCommand \ref{sub:Interrupt-Service-Routines}
21926
21927 \end_inset
21928
21929 \InsetSpace ~
21930 about interrupts.
21931 \end_layout
21932
21933 \begin_layout Itemize
21934
21935 \series bold
21936 nojtbound
21937 \series default
21938
21939 \begin_inset LatexCommand \index{\#pragma nojtbound}
21940
21941 \end_inset
21942
21943  - will not generate code for boundary value checking, when switch statements
21944  are turned into jump-tables (dangerous).
21945  For more details see section 
21946 \begin_inset LatexCommand \ref{sub:'switch'-Statements}
21947
21948 \end_inset
21949
21950 .
21951 \end_layout
21952
21953 \begin_layout Itemize
21954
21955 \series bold
21956 noloopreverse
21957 \series default
21958
21959 \begin_inset LatexCommand \index{\#pragma noloopreverse}
21960
21961 \end_inset
21962
21963  - Will not do loop reversal optimization
21964 \end_layout
21965
21966 \begin_layout Itemize
21967
21968 \series bold
21969 nooverlay
21970 \series default
21971
21972 \begin_inset LatexCommand \index{\#pragma nooverlay}
21973
21974 \end_inset
21975
21976  - the compiler will not overlay the parameters and local variables of a
21977  function.
21978 \end_layout
21979
21980 \begin_layout Itemize
21981
21982 \series bold
21983 stackauto
21984 \series default
21985
21986 \begin_inset LatexCommand \index{\#pragma stackauto}
21987
21988 \end_inset
21989
21990 - See option -
21991 \begin_inset ERT
21992 status collapsed
21993
21994 \begin_layout Standard
21995
21996
21997 \backslash
21998 /
21999 \end_layout
22000
22001 \end_inset
22002
22003 -stack-auto
22004 \begin_inset LatexCommand \index{-\/-stack-auto}
22005
22006 \end_inset
22007
22008  and section 
22009 \begin_inset LatexCommand \ref{sec:Parameters-and-Local-Variables}
22010
22011 \end_inset
22012
22013  Parameters and Local Variables.
22014 \end_layout
22015
22016 \begin_layout Itemize
22017
22018 \series bold
22019 opt_code_speed
22020 \series default
22021  
22022 \begin_inset LatexCommand \index{\#pragma opt\_code\_speed}
22023
22024 \end_inset
22025
22026 - The compiler will optimize code generation towards fast code, possibly
22027  at the expense of code size.
22028  Currently this has little effect.
22029 \end_layout
22030
22031 \begin_layout Itemize
22032
22033 \series bold
22034 opt_code_size
22035 \series default
22036  
22037 \begin_inset LatexCommand \index{\#pragma opt\_code\_size}
22038
22039 \end_inset
22040
22041 - The compiler will optimize code generation towards compact code, possibly
22042  at the expense of code speed.
22043  Currently this has little effect.
22044 \end_layout
22045
22046 \begin_layout Itemize
22047
22048 \series bold
22049 opt_code_balanced
22050 \series default
22051  
22052 \begin_inset LatexCommand \index{\#pragma opt\_code\_balanced}
22053
22054 \end_inset
22055
22056 - The compiler will attempt to generate code that is both compact and fast,
22057  as long as meeting one goal is not a detriment to the other (this is the
22058  default).
22059  
22060 \end_layout
22061
22062 \begin_layout Itemize
22063
22064 \series bold
22065 std_sdcc89
22066 \series default
22067  
22068 \begin_inset LatexCommand \index{\#pragma std\_sdcc89}
22069
22070 \end_inset
22071
22072 - Generally follow the C89 standard, but allow SDCC features that conflict
22073  with the standard (default).
22074 \end_layout
22075
22076 \begin_layout Itemize
22077
22078 \series bold
22079 std_c89
22080 \series default
22081  
22082 \begin_inset LatexCommand \index{\#pragma std\_c89}
22083
22084 \end_inset
22085
22086 - Follow the C89 standard and disable SDCC features that conflict with the
22087  standard.
22088 \end_layout
22089
22090 \begin_layout Itemize
22091
22092 \series bold
22093 std_sdcc99
22094 \series default
22095  
22096 \begin_inset LatexCommand \index{\#pragma std\_sdcc99}
22097
22098 \end_inset
22099
22100 - Generally follow the C99 standard, but allow SDCC features that conflict
22101  with the standard (incomplete support).
22102 \end_layout
22103
22104 \begin_layout Itemize
22105
22106 \series bold
22107 std_c99
22108 \series default
22109  
22110 \begin_inset LatexCommand \index{\#pragma std\_c99}
22111
22112 \end_inset
22113
22114 - Follow the C99 standard and disable SDCC features that conflict with the
22115  standard (incomplete support).
22116 \end_layout
22117
22118 \begin_layout Itemize
22119
22120 \series bold
22121 codeseg
22122 \series default
22123  <name>
22124 \begin_inset LatexCommand \index{\#pragma codeseg}
22125
22126 \end_inset
22127
22128 - Use this name (max.
22129  8 characters) for the code segment.
22130  See option -
22131 \begin_inset ERT
22132 status collapsed
22133
22134 \begin_layout Standard
22135
22136
22137 \backslash
22138 /
22139 \end_layout
22140
22141 \end_inset
22142
22143 -codeseg.
22144 \end_layout
22145
22146 \begin_layout Itemize
22147
22148 \series bold
22149 constseg
22150 \series default
22151  <name>
22152 \begin_inset LatexCommand \index{\#pragma constseg}
22153
22154 \end_inset
22155
22156 - Use this name (max.
22157  8 characters) for the const segment.
22158  See option -
22159 \begin_inset ERT
22160 status collapsed
22161
22162 \begin_layout Standard
22163
22164
22165 \backslash
22166 /
22167 \end_layout
22168
22169 \end_inset
22170
22171 -constseg.
22172 \end_layout
22173
22174 \begin_layout Standard
22175 The preprocessor SDCPP
22176 \begin_inset LatexCommand \index{sdcpp (preprocessor)}
22177
22178 \end_inset
22179
22180  supports the following #pragma directives:
22181 \end_layout
22182
22183 \begin_layout Itemize
22184
22185 \series bold
22186 pedantic_parse_number
22187 \series default
22188
22189 \begin_inset LatexCommand \index{pedantic}
22190
22191 \end_inset
22192
22193
22194 \begin_inset LatexCommand \index{\#pragma pedantic\_parse\_number}
22195
22196 \end_inset
22197
22198  (+ | -) 
22199 \begin_inset LatexCommand \label{ite:pedantic_parse_number}
22200
22201 \end_inset
22202
22203 - Pedantic parse numbers so that situations like 0xfe-LO_B(3) are parsed
22204  properly and the macro LO_B(3) gets expanded.
22205  Default is off.
22206  See also the -
22207 \begin_inset ERT
22208 status collapsed
22209
22210 \begin_layout Standard
22211
22212
22213 \backslash
22214 /
22215 \end_layout
22216
22217 \end_inset
22218
22219 -pedantic-parse-number command line option 
22220 \begin_inset LatexCommand \vpageref{lyx:-pedantic-parse-number}
22221
22222 \end_inset
22223
22224 .
22225  
22226 \newline
22227 Below is an example on how to use this pragma.
22228
22229 \emph on
22230  Note: this functionality is not in conformance with standard!
22231 \end_layout
22232
22233 \begin_layout Verse
22234
22235 \family typewriter
22236 #pragma pedantic_parse_number +
22237 \begin_inset LatexCommand \index{\#pragma pedantic\_parse\_number}
22238
22239 \end_inset
22240
22241
22242 \newline
22243
22244 \newline
22245 #define LO_B(x) ((x) & 0xff)
22246 \newline
22247
22248 \newline
22249 unsigned char foo(void)
22250 \newline
22251 {
22252 \newline
22253 \InsetSpace ~
22254 \InsetSpace ~
22255 \InsetSpace ~
22256 unsigned char c=0xfe-LO_B(3)
22257 ;
22258 \newline
22259
22260 \newline
22261 \InsetSpace ~
22262 \InsetSpace ~
22263 \InsetSpace ~
22264 return c;
22265 \newline
22266 }
22267 \newline
22268
22269 \end_layout
22270
22271 \begin_layout Itemize
22272
22273 \series bold
22274 preproc_asm
22275 \series default
22276
22277 \begin_inset LatexCommand \index{\#pragma preproc\_asm}
22278
22279 \end_inset
22280
22281  (+ | -) - switch _asm _endasm block preprocessing on / off.
22282  Default is on.
22283  You use this prama to define multilines of assembly code.
22284  This will prevent the preprocessor from changing the formating required
22285  by assembly code.
22286  Below is an example on how to use this pragma.
22287 \end_layout
22288
22289 \begin_layout Verse
22290
22291 \family typewriter
22292 #pragma preproc_asm -
22293 \begin_inset LatexCommand \index{\#pragma preproc\_asm}
22294
22295 \end_inset
22296
22297
22298 \newline
22299 #define MYDELAY _asm
22300 \newline
22301 \InsetSpace ~
22302 \InsetSpace ~
22303 \InsetSpace ~
22304 nop ;my assembly comment...
22305 \newline
22306 \InsetSpace ~
22307 \InsetSpace ~
22308 \InsetSpace ~
22309 nop
22310 \newline
22311 \InsetSpace ~
22312 \InsetSpace ~
22313 \InsetSpace ~
22314 nop
22315 \newline
22316 _endasm
22317 \newline
22318 #pragma preproc_asm
22319  +
22320 \newline
22321
22322 \newline
22323 void foo (void) 
22324 \newline
22325
22326 \newline
22327 \InsetSpace ~
22328 \InsetSpace ~
22329 \InsetSpace ~
22330  ...
22331  
22332 \newline
22333 \InsetSpace ~
22334 \InsetSpace ~
22335 \InsetSpace ~
22336  MYDELAY;
22337 \newline
22338 \InsetSpace ~
22339 \InsetSpace ~
22340 \InsetSpace ~
22341  ...
22342  
22343 \newline
22344
22345 \newline
22346
22347 \end_layout
22348
22349 \begin_layout Itemize
22350
22351 \series bold
22352 sdcc_hash
22353 \series default
22354
22355 \begin_inset LatexCommand \index{\#pragma sdcc\_hash}
22356
22357 \end_inset
22358
22359  (+ | -) - Allow "naked" hash in macro definition, for example:
22360 \newline
22361
22362 \family typewriter
22363 #define DIR_LO(x) #(x & 0xff)
22364 \family default
22365
22366 \newline
22367 Default is off.
22368  Below is an example on how to use this pragma.
22369 \end_layout
22370
22371 \begin_layout Verse
22372
22373 \family typewriter
22374 #pragma preproc_asm +
22375 \newline
22376 #pragma sdcc_hash +
22377 \begin_inset LatexCommand \index{\#pragma sdcc\_hash}
22378
22379 \end_inset
22380
22381
22382 \newline
22383
22384 \newline
22385 #define ROMCALL(x) 
22386 \backslash
22387
22388 \newline
22389 \InsetSpace ~
22390 \InsetSpace ~
22391 \InsetSpace ~
22392 mov R6_B3, #(x & 0xff) 
22393 \backslash
22394
22395 \newline
22396 \InsetSpace ~
22397 \InsetSpace ~
22398 \InsetSpace ~
22399 mov R7_B3, #((x >> 8) & 0xff) 
22400 \backslash
22401
22402 \newline
22403 \InsetSpace ~
22404 \InsetSpace ~
22405 \InsetSpace ~
22406 lcall __romcall
22407 \newline
22408
22409 \newline
22410 ...
22411 \newline
22412 _asm
22413 \newline
22414 ROMCALL(72)
22415 \newline
22416 _endasm;
22417 \newline
22418 ...
22419 \newline
22420
22421 \end_layout
22422
22423 \begin_layout Standard
22424 Some of the pragmas are intended to be used to turn-on or off certain optimizati
22425 ons which might cause the compiler to generate extra stack and/or data space
22426  to store compiler generated temporary variables.
22427  This usually happens in large functions.
22428  Pragma directives should be used as shown in the following example, they
22429  are used to control options and optimizations for a given function.
22430  
22431 \end_layout
22432
22433 \begin_layout Verse
22434
22435 \family typewriter
22436 #pragma save
22437 \begin_inset LatexCommand \index{\#pragma save}
22438
22439 \end_inset
22440
22441  \InsetSpace ~
22442 \InsetSpace ~
22443 \InsetSpace ~
22444 \InsetSpace ~
22445 \InsetSpace ~
22446 \InsetSpace ~
22447 \InsetSpace ~
22448 /* save the current settings */ 
22449 \newline
22450 #pragma nogcse
22451 \begin_inset LatexCommand \index{\#pragma nogcse}
22452
22453 \end_inset
22454
22455  \InsetSpace ~
22456 \InsetSpace ~
22457 \InsetSpace ~
22458 \InsetSpace ~
22459 \InsetSpace ~
22460 /* turnoff global subexpression elimination */ 
22461 \newline
22462 #pragma noinduction
22463 \begin_inset LatexCommand \index{\#pragma noinduction}
22464
22465 \end_inset
22466
22467  /* turn off induction optimizations */ 
22468 \newline
22469 int foo () 
22470 \newline
22471
22472 \newline
22473 \InsetSpace ~
22474  \InsetSpace ~
22475  ...
22476  
22477 \newline
22478 \InsetSpace ~
22479  \InsetSpace ~
22480  /* large code */ 
22481 \newline
22482 \InsetSpace ~
22483  \InsetSpace ~
22484  ...
22485  
22486 \newline
22487
22488 \newline
22489 #pragma restore
22490 \begin_inset LatexCommand \index{\#pragma restore}
22491
22492 \end_inset
22493
22494  /* turn the optimizations back on */
22495 \end_layout
22496
22497 \begin_layout Standard
22498 The compiler will generate a warning message when extra space is allocated.
22499  It is strongly recommended that the save and restore pragmas be used when
22500  changing options for a function.
22501 \newline
22502
22503 \newline
22504
22505 \newline
22506
22507 \end_layout
22508
22509 \begin_layout Section
22510 Defines Created by the Compiler
22511 \end_layout
22512
22513 \begin_layout Standard
22514 The compiler creates the following #defines
22515 \begin_inset LatexCommand \index{\#defines}
22516
22517 \end_inset
22518
22519
22520 \begin_inset LatexCommand \index{Defines created by the compiler}
22521
22522 \end_inset
22523
22524 :
22525 \newline
22526
22527 \end_layout
22528
22529 \begin_layout Standard
22530 \begin_inset Tabular
22531 <lyxtabular version="3" rows="11" columns="2">
22532 <features>
22533 <column alignment="left" valignment="top" leftline="true" width="3in">
22534 <column alignment="left" valignment="top" leftline="true" rightline="true" width="3in">
22535 <row topline="true" bottomline="true">
22536 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
22537 \begin_inset Text
22538
22539 \begin_layout Standard
22540
22541 \series bold
22542 #define
22543 \end_layout
22544
22545 \end_inset
22546 </cell>
22547 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
22548 \begin_inset Text
22549
22550 \begin_layout Standard
22551
22552 \series bold
22553 Description
22554 \end_layout
22555
22556 \end_inset
22557 </cell>
22558 </row>
22559 <row topline="true">
22560 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
22561 \begin_inset Text
22562
22563 \begin_layout Standard
22564 SDCC
22565 \begin_inset LatexCommand \index{SDCC}
22566
22567 \end_inset
22568
22569  
22570 \end_layout
22571
22572 \end_inset
22573 </cell>
22574 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
22575 \begin_inset Text
22576
22577 \begin_layout Standard
22578 Always defined.
22579  Since version 2.5.6 the version number as an int (ex.
22580  256)
22581 \end_layout
22582
22583 \end_inset
22584 </cell>
22585 </row>
22586 <row topline="true">
22587 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
22588 \begin_inset Text
22589
22590 \begin_layout Standard
22591 SDCC_mcs51
22592 \begin_inset LatexCommand \index{SDCC\_mcs51}
22593
22594 \end_inset
22595
22596  or SDCC_ds390
22597 \begin_inset LatexCommand \index{SDCC\_ds390}
22598
22599 \end_inset
22600
22601  or SDCC_z80
22602 \begin_inset LatexCommand \index{SDCC\_z80}
22603
22604 \end_inset
22605
22606 , etc.
22607 \end_layout
22608
22609 \end_inset
22610 </cell>
22611 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
22612 \begin_inset Text
22613
22614 \begin_layout Standard
22615 depending on the model used (e.g.: -mds390)
22616 \end_layout
22617
22618 \end_inset
22619 </cell>
22620 </row>
22621 <row topline="true">
22622 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
22623 \begin_inset Text
22624
22625 \begin_layout Standard
22626 __mcs51
22627 \begin_inset LatexCommand \index{\_\_mcs51}
22628
22629 \end_inset
22630
22631 , __ds390
22632 \begin_inset LatexCommand \index{\_\_ds390}
22633
22634 \end_inset
22635
22636 , __hc08
22637 \begin_inset LatexCommand \index{\_\_hc08}
22638
22639 \end_inset
22640
22641 , __z80
22642 \begin_inset LatexCommand \index{\_\_z80}
22643
22644 \end_inset
22645
22646 , etc
22647 \end_layout
22648
22649 \end_inset
22650 </cell>
22651 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
22652 \begin_inset Text
22653
22654 \begin_layout Standard
22655 depending on the model used (e.g.
22656  -mz80)
22657 \end_layout
22658
22659 \end_inset
22660 </cell>
22661 </row>
22662 <row topline="true">
22663 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
22664 \begin_inset Text
22665
22666 \begin_layout Standard
22667 SDCC_STACK_AUTO
22668 \begin_inset LatexCommand \index{SDCC\_STACK\_AUTO}
22669
22670 \end_inset
22671
22672
22673 \end_layout
22674
22675 \end_inset
22676 </cell>
22677 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
22678 \begin_inset Text
22679
22680 \begin_layout Standard
22681 when 
22682 \emph on
22683 -
22684 \begin_inset ERT
22685 status collapsed
22686
22687 \begin_layout Standard
22688
22689
22690 \backslash
22691 /
22692 \end_layout
22693
22694 \end_inset
22695
22696 -stack-auto
22697 \emph default
22698  option is used
22699 \end_layout
22700
22701 \end_inset
22702 </cell>
22703 </row>
22704 <row topline="true">
22705 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
22706 \begin_inset Text
22707
22708 \begin_layout Standard
22709 SDCC_MODEL_SMALL
22710 \begin_inset LatexCommand \index{SDCC\_MODEL\_SMALL}
22711
22712 \end_inset
22713
22714
22715 \end_layout
22716
22717 \end_inset
22718 </cell>
22719 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
22720 \begin_inset Text
22721
22722 \begin_layout Standard
22723 when 
22724 \emph on
22725 -
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 -model-small
22739 \emph default
22740  is used
22741 \end_layout
22742
22743 \end_inset
22744 </cell>
22745 </row>
22746 <row topline="true">
22747 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
22748 \begin_inset Text
22749
22750 \begin_layout Standard
22751 SDCC_MODEL_MEDIUM
22752 \begin_inset LatexCommand \index{SDCC\_MODEL\_MEDIUM}
22753
22754 \end_inset
22755
22756
22757 \end_layout
22758
22759 \end_inset
22760 </cell>
22761 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
22762 \begin_inset Text
22763
22764 \begin_layout Standard
22765 when 
22766 \emph on
22767 -
22768 \begin_inset ERT
22769 status collapsed
22770
22771 \begin_layout Standard
22772
22773
22774 \backslash
22775 /
22776 \end_layout
22777
22778 \end_inset
22779
22780 -model-medium
22781 \emph default
22782  is used
22783 \end_layout
22784
22785 \end_inset
22786 </cell>
22787 </row>
22788 <row topline="true">
22789 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
22790 \begin_inset Text
22791
22792 \begin_layout Standard
22793 SDCC_MODEL_LARGE
22794 \begin_inset LatexCommand \index{SDCC\_MODEL\_LARGE}
22795
22796 \end_inset
22797
22798
22799 \end_layout
22800
22801 \end_inset
22802 </cell>
22803 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
22804 \begin_inset Text
22805
22806 \begin_layout Standard
22807 when 
22808 \emph on
22809 -
22810 \begin_inset ERT
22811 status collapsed
22812
22813 \begin_layout Standard
22814
22815
22816 \backslash
22817 /
22818 \end_layout
22819
22820 \end_inset
22821
22822 -model-large
22823 \emph default
22824  is used
22825 \end_layout
22826
22827 \end_inset
22828 </cell>
22829 </row>
22830 <row topline="true">
22831 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
22832 \begin_inset Text
22833
22834 \begin_layout Standard
22835 SDCC_USE_XSTACK
22836 \begin_inset LatexCommand \index{SDCC\_USE\_XSTACK}
22837
22838 \end_inset
22839
22840
22841 \end_layout
22842
22843 \end_inset
22844 </cell>
22845 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
22846 \begin_inset Text
22847
22848 \begin_layout Standard
22849 when 
22850 \emph on
22851 -
22852 \begin_inset ERT
22853 status collapsed
22854
22855 \begin_layout Standard
22856
22857
22858 \backslash
22859 /
22860 \end_layout
22861
22862 \end_inset
22863
22864 -xstack
22865 \emph default
22866  option is used
22867 \end_layout
22868
22869 \end_inset
22870 </cell>
22871 </row>
22872 <row topline="true">
22873 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
22874 \begin_inset Text
22875
22876 \begin_layout Standard
22877 SDCC_STACK_TENBIT
22878 \begin_inset LatexCommand \index{SDCC\_STACK\_TENBIT}
22879
22880 \end_inset
22881
22882  
22883 \end_layout
22884
22885 \end_inset
22886 </cell>
22887 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
22888 \begin_inset Text
22889
22890 \begin_layout Standard
22891 when 
22892 \emph on
22893 -mds390
22894 \emph default
22895  is used
22896 \end_layout
22897
22898 \end_inset
22899 </cell>
22900 </row>
22901 <row topline="true" bottomline="true">
22902 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
22903 \begin_inset Text
22904
22905 \begin_layout Standard
22906 SDCC_MODEL_FLAT24
22907 \begin_inset LatexCommand \index{SDCC\_MODEL\_FLAT24}
22908
22909 \end_inset
22910
22911
22912 \end_layout
22913
22914 \end_inset
22915 </cell>
22916 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
22917 \begin_inset Text
22918
22919 \begin_layout Standard
22920 when 
22921 \emph on
22922 -mds390
22923 \emph default
22924  is used
22925 \end_layout
22926
22927 \end_inset
22928 </cell>
22929 </row>
22930 </lyxtabular>
22931
22932 \end_inset
22933
22934
22935 \end_layout
22936
22937 \begin_layout Chapter
22938 Notes on supported Processors
22939 \end_layout
22940
22941 \begin_layout Section
22942 MCS51 variants
22943 \begin_inset LatexCommand \label{sub:MCS51-variants}
22944
22945 \end_inset
22946
22947
22948 \begin_inset LatexCommand \index{MCS51 variants}
22949
22950 \end_inset
22951
22952
22953 \end_layout
22954
22955 \begin_layout Standard
22956 MCS51 processors are available from many vendors and come in many different
22957  flavours.
22958  While they might differ considerably in respect to Special Function Registers
22959  the core MCS51 is usually not modified or is kept compatible.
22960  
22961 \end_layout
22962
22963 \begin_layout Subsection
22964 pdata access by SFR 
22965 \end_layout
22966
22967 \begin_layout Standard
22968 With the upcome of devices with internal xdata and flash memory devices
22969  using port P2
22970 \begin_inset LatexCommand \index{P2 (mcs51 sfr)}
22971
22972 \end_inset
22973
22974  as dedicated I/O port is becoming more popular.
22975  Switching the high byte for pdata
22976 \begin_inset LatexCommand \index{pdata (mcs51, ds390 storage class)}
22977
22978 \end_inset
22979
22980  access which was formerly done by port P2 is then achieved by a Special
22981  Function Register
22982 \begin_inset LatexCommand \index{sfr}
22983
22984 \end_inset
22985
22986 .
22987  In well-established MCS51 tradition the address of this 
22988 \emph on
22989 sfr
22990 \emph default
22991  is where the chip designers decided to put it.
22992  Needless to say that they didn't agree on a common name either.
22993  So that the startup code can correctly initialize xdata variables, you
22994  should define an sfr with the name _XPAGE
22995 \family typewriter
22996
22997 \begin_inset LatexCommand \index{\_XPAGE (mcs51)}
22998
22999 \end_inset
23000
23001
23002 \family default
23003  at the appropriate location if the default, port P2, is not used for this.
23004  Some examples are:
23005 \end_layout
23006
23007 \begin_layout Verse
23008
23009 \family typewriter
23010 __sfr __at (0x85) _XPAGE; /* Ramtron VRS51 family a.k.a.
23011  MPAGE */
23012 \end_layout
23013
23014 \begin_layout Verse
23015
23016 \family typewriter
23017 __sfr __at (0x92) _XPAGE; /* Cypress EZ-USB family, Texas Instruments (Chipcon)
23018  a.k.a.
23019  MPAGE */
23020 \end_layout
23021
23022 \begin_layout Verse
23023
23024 \family typewriter
23025 __sfr __at (0x91) _XPAGE; /* Infineon (Siemens) C500 family a.k.a.
23026  XPAGE */
23027 \end_layout
23028
23029 \begin_layout Verse
23030
23031 \family typewriter
23032 __sfr __at (0xaf) _XPAGE; /* some Silicon Labs (Cygnal) chips a.k.a.
23033  EMI0CN */
23034 \end_layout
23035
23036 \begin_layout Verse
23037
23038 \family typewriter
23039 __sfr __at (0xaa) _XPAGE; /* some Silicon Labs (Cygnal) chips a.k.a.
23040  EMI0CN */
23041 \end_layout
23042
23043 \begin_layout Standard
23044 For more exotic implementations further customizations may be needed.
23045  See section 
23046 \begin_inset LatexCommand \ref{sub:Startup-Code}
23047
23048 \end_inset
23049
23050  for other possibilities.
23051 \end_layout
23052
23053 \begin_layout Subsection
23054 Other Features available by SFR
23055 \end_layout
23056
23057 \begin_layout Standard
23058 Some MCS51 variants offer features like Double DPTR
23059 \begin_inset LatexCommand \index{DPTR}
23060
23061 \end_inset
23062
23063 , multiple DPTR, decrementing DPTR, 16x16 Multiply.
23064  These are currently not used for the MCS51 port.
23065  If you absolutely need them you can fall back to inline assembly or submit
23066  a patch to SDCC.
23067 \begin_inset VSpace bigskip
23068 \end_inset
23069
23070
23071 \end_layout
23072
23073 \begin_layout Section
23074 DS400 port
23075 \end_layout
23076
23077 \begin_layout Standard
23078 The DS80C400
23079 \begin_inset LatexCommand \index{DS80C400}
23080
23081 \end_inset
23082
23083
23084 \begin_inset LatexCommand \index{DS400}
23085
23086 \end_inset
23087
23088  microcontroller has a rich set of peripherals.
23089  In its built-in ROM library it includes functions to access some of the
23090  features, among them is a TCP stack with IP4 and IP6 support.
23091  Library headers (currently in beta status) and other files are provided
23092  at 
23093 \size footnotesize
23094
23095 \begin_inset LatexCommand \url{ftp://ftp.dalsemi.com/pub/tini/ds80c400/c_libraries/sdcc/index.html}
23096
23097 \end_inset
23098
23099 .
23100  
23101 \begin_inset VSpace bigskip
23102 \end_inset
23103
23104
23105 \end_layout
23106
23107 \begin_layout Section
23108 The Z80 and gbz80 port
23109 \end_layout
23110
23111 \begin_layout Standard
23112 SDCC can target both the Zilog Z80
23113 \begin_inset LatexCommand \index{Z80}
23114
23115 \end_inset
23116
23117  and the Nintendo Gameboy's Z80-like gbz80
23118 \begin_inset LatexCommand \index{gbz80 (GameBoy Z80)}
23119
23120 \end_inset
23121
23122 .
23123  The Z80 port is passed through the same 
23124 \emph on
23125 regressions tests
23126 \begin_inset LatexCommand \index{Regression test}
23127
23128 \end_inset
23129
23130
23131 \emph default
23132  (see section 
23133 \begin_inset LatexCommand \ref{sec:Quality-control}
23134
23135 \end_inset
23136
23137 ) as the MCS51 and DS390 ports, so floating point support, support for long
23138  variables and bitfield support is fine.
23139  See mailing lists and forums about interrupt routines.
23140 \end_layout
23141
23142 \begin_layout Standard
23143 As always, the code is the authoritative reference - see z80/ralloc.c and
23144  z80/gen.c.
23145  The stack
23146 \begin_inset LatexCommand \index{Z80!stack}
23147
23148 \end_inset
23149
23150  frame is similar to that generated by the IAR Z80 compiler.
23151  IX is used as the base pointer, HL and IY are used as a temporary registers,
23152  and BC and DE are available for holding variables.
23153  Return values
23154 \begin_inset LatexCommand \index{Z80!return value}
23155
23156 \end_inset
23157
23158  for the Z80 port are stored in L (one byte), HL (two bytes), or DEHL (four
23159  bytes).
23160  The gbz80 port use the same set of registers for the return values, but
23161  in a different order of significance: E (one byte), DE (two bytes), or
23162  HLDE (four bytes).
23163 \begin_inset VSpace bigskip
23164 \end_inset
23165
23166
23167 \end_layout
23168
23169 \begin_layout Section
23170 The HC08 port
23171 \end_layout
23172
23173 \begin_layout Standard
23174 The port to the Freescale/Motorola HC08
23175 \begin_inset LatexCommand \index{HC08}
23176
23177 \end_inset
23178
23179  family has been added in October 2003, and is still undergoing some basic
23180  development.
23181  The code generator is complete, but the register allocation is still quite
23182  unoptimized.
23183  Some of the SDCC's standard C library functions have embedded non-HC08
23184  inline assembly and so are not yet usable.
23185 \end_layout
23186
23187 \begin_layout Standard
23188 The HC08 port passes the regression test suite (see section 
23189 \begin_inset LatexCommand \ref{sec:Quality-control}
23190
23191 \end_inset
23192
23193 ).
23194 \begin_inset VSpace bigskip
23195 \end_inset
23196
23197
23198 \newpage
23199
23200 \end_layout
23201
23202 \begin_layout Section
23203 The PIC14
23204 \begin_inset LatexCommand \index{PIC14}
23205
23206 \end_inset
23207
23208  port
23209 \end_layout
23210
23211 \begin_layout Standard
23212 The PIC14 port adds support for Microchip
23213 \begin_inset LatexCommand \index{Microchip}
23214
23215 \end_inset
23216
23217
23218 \begin_inset Formula $^{\text{TM}}$
23219 \end_inset
23220
23221  PIC
23222 \begin_inset LatexCommand \index{PIC14}
23223
23224 \end_inset
23225
23226
23227 \begin_inset Formula $^{\text{TM}}$
23228 \end_inset
23229
23230  MCUs with 14 bit wide instructions.
23231  This port is not yet mature and still lacks many features.
23232  However, it can work for simple code.
23233 \end_layout
23234
23235 \begin_layout Standard
23236 Currently supported devices include:
23237 \end_layout
23238
23239 \begin_layout Standard
23240 12F: 629, 635, 675, 683
23241 \end_layout
23242
23243 \begin_layout Standard
23244 16C: 432, 433
23245 \end_layout
23246
23247 \begin_layout Standard
23248 16C: 554, 557, 558
23249 \end_layout
23250
23251 \begin_layout Standard
23252 16C: 62, 620, 620a, 621, 621a, 622, 622a, 63a, 65b
23253 \end_layout
23254
23255 \begin_layout Standard
23256 16C: 71, 710, 711, 715, 717, 72, 73b, 745, 74b, 765, 770, 771, 773, 774,
23257  781, 782
23258 \end_layout
23259
23260 \begin_layout Standard
23261 16C: 925, 926
23262 \end_layout
23263
23264 \begin_layout Standard
23265 16F: 627, 627a, 628, 628a, 630, 636, 639, 648a, 676, 684, 685, 687, 688,
23266  689, 690
23267 \end_layout
23268
23269 \begin_layout Standard
23270 16F: 716, 72, 73, 737, 74, 76, 767, 77, 777, 785
23271 \end_layout
23272
23273 \begin_layout Standard
23274 16F: 818, 819, 84, 84a, 87, 870, 871, 872, 873, 873a, 874, 874a, 876, 876a,
23275  877, 877a, 88
23276 \end_layout
23277
23278 \begin_layout Standard
23279 16F: 913, 914, 916, 917
23280 \end_layout
23281
23282 \begin_layout Standard
23283 An up-to-date list of currently supported devices can be obtained via 
23284 \family typewriter
23285 sdcc -mpic14 -phelp foo.c
23286 \family default
23287  (foo.c must exist...).
23288 \end_layout
23289
23290 \begin_layout Subsection
23291 PIC Code Pages
23292 \begin_inset LatexCommand \index{code page (pic14)}
23293
23294 \end_inset
23295
23296  and Memory Banks
23297 \begin_inset LatexCommand \index{Memory bank (pic14)}
23298
23299 \end_inset
23300
23301
23302 \end_layout
23303
23304 \begin_layout Standard
23305 The linker organizes allocation for the code page and RAM banks.
23306  It does not have intimate knowledge of the code flow.
23307  It will put all the code section of a single .asm file into a single code
23308  page.
23309  In order to make use of multiple code pages, separate asm files must be
23310  used.
23311  The compiler assigns all 
23312 \emph on
23313 static
23314 \emph default
23315  functions of a single .c file into the same code page.
23316 \newline
23317
23318 \newline
23319 To get the best results,
23320  follow these guidelines:
23321 \end_layout
23322
23323 \begin_layout Enumerate
23324 Make local functions static, as non static functions require code page selection
23325  overhead.
23326 \newline
23327 Due to the way sdcc handles functions, place called functions prior
23328  to calling functions in the file wherever possible: Otherwise sdcc will
23329  insert unneccessary pagesel directives around the call, believing that
23330  the called function is externally defined.
23331 \end_layout
23332
23333 \begin_layout Enumerate
23334 For devices that have multiple code pages it is more efficient to use the
23335  same number of files as pages: Use up to 4 separate .c files for the 16F877,
23336  but only 2 files for the 16F874.
23337  This way the linker can put the code for each file into different code
23338  pages and there will be less page selection overhead.
23339 \end_layout
23340
23341 \begin_layout Enumerate
23342 And as for any 8 bit micro (especially for PIC14 as they have a very simple
23343  instruction set), use `unsigned char' wherever possible instead of `int'.
23344 \end_layout
23345
23346 \begin_layout Subsection
23347 Adding New Devices to the Port 
23348 \end_layout
23349
23350 \begin_layout Standard
23351 Adding support for a new 14
23352 \begin_inset ERT
23353 status open
23354
23355 \begin_layout Standard
23356
23357
23358 \backslash
23359 ,
23360 \end_layout
23361
23362 \end_inset
23363
23364 bit PIC MCU requires the following steps:
23365 \end_layout
23366
23367 \begin_layout Enumerate
23368 Create a new device description.
23369 \newline
23370 Each device is described in two files: pic16f*.h
23371  and pic16f*.c.
23372  These files primarily define SFRs, structs to access their bits, and symbolic
23373  configuration options.
23374  Both files can be generated from gputils' .inc files using the perl script
23375  
23376 \family typewriter
23377 support/scripts/inc2h.pl
23378 \family default
23379 .
23380  This file also contains further instructions on how to proceed.
23381 \end_layout
23382
23383 \begin_layout Enumerate
23384 Copy the .h file into SDCC's include path and either add the .c file to your
23385  project or copy it to 
23386 \family typewriter
23387 device/lib/pic/libdev
23388 \family default
23389 .
23390  Afterwards, rebuild and install the libraries.
23391 \end_layout
23392
23393 \begin_layout Enumerate
23394 Edit pic14devices.txt in SDCC's include path (
23395 \family typewriter
23396 device/include/pic/
23397 \family default
23398  in the source tree or 
23399 \family typewriter
23400 /usr/local/share/sdcc/include/pic
23401 \family default
23402  after installation).
23403 \newline
23404 You need to add a device specification here to make
23405  the memory layout (code banks, RAM, aliased memory regions, ...) known to
23406  the compiler.
23407  Probably you can copy and modify an existing entry.
23408  The file format is documented at the top of the file.
23409 \end_layout
23410
23411 \begin_layout Subsection
23412 Interrupt Code
23413 \end_layout
23414
23415 \begin_layout Standard
23416 For the interrupt function, use the keyword `__interrupt'
23417 \begin_inset LatexCommand \index{PIC14!interrupt}
23418
23419 \end_inset
23420
23421  with level number of 0 (PIC14 only has 1 interrupt so this number is only
23422  there to avoid a syntax error - it ought to be fixed).
23423  E.g.:
23424 \end_layout
23425
23426 \begin_layout Verse
23427
23428 \family typewriter
23429 void Intr(void) __interrupt 0
23430 \newline
23431 {
23432 \newline
23433 \InsetSpace ~
23434 \InsetSpace ~
23435 T0IF = 0; /* Clear timer interrupt */
23436 \newline
23437 }
23438 \end_layout
23439
23440 \begin_layout Subsection
23441 Linking and Assembling
23442 \end_layout
23443
23444 \begin_layout Standard
23445 For assembling you can use either GPUTILS'
23446 \begin_inset LatexCommand \index{gputils (pic tools)}
23447
23448 \end_inset
23449
23450  gpasm.exe or MPLAB's mpasmwin.exe.
23451  GPUTILS are available from 
23452 \begin_inset LatexCommand \url{http://sourceforge.net/projects/gputils}
23453
23454 \end_inset
23455
23456 .
23457  For linking you can use either GPUTILS' gplink or MPLAB's mplink.exe.
23458  If you use MPLAB and an interrupt function then the linker script file
23459  vectors section will need to be enlarged to link with mplink.
23460 \newline
23461
23462 \newline
23463 Here is a 
23464 \family typewriter
23465 Makefile
23466 \family default
23467  using GPUTILS:
23468 \end_layout
23469
23470 \begin_layout Verse
23471
23472 \family typewriter
23473 .c.o:
23474 \newline
23475 \InsetSpace ~
23476 \InsetSpace ~
23477 \InsetSpace ~
23478 \InsetSpace ~
23479 \InsetSpace ~
23480 \InsetSpace ~
23481 \InsetSpace ~
23482 \InsetSpace ~
23483 sdcc -V -mpic14 -p16f877 -c $< 
23484 \newline
23485
23486 \newline
23487 $(PRJ).hex: $(OBJS) 
23488 \newline
23489 \InsetSpace ~
23490 \InsetSpace ~
23491 \InsetSpace ~
23492 \InsetSpace ~
23493 \InsetSpace ~
23494 \InsetSpace ~
23495 \InsetSpace ~
23496 \InsetSpace ~
23497 gplink -m -s $(PRJ).lkr
23498  -o $(PRJ).hex $(OBJS) libsdcc.lib
23499 \end_layout
23500
23501 \begin_layout Standard
23502 Here is a 
23503 \family typewriter
23504 Makefile
23505 \family default
23506  using MPLAB:
23507 \end_layout
23508
23509 \begin_layout Verse
23510
23511 \family typewriter
23512 .c.o: 
23513 \newline
23514 \InsetSpace ~
23515 \InsetSpace ~
23516 \InsetSpace ~
23517 \InsetSpace ~
23518 \InsetSpace ~
23519 \InsetSpace ~
23520 \InsetSpace ~
23521 \InsetSpace ~
23522 sdcc -S -V -mpic14 -p16f877 $< 
23523 \newline
23524 \InsetSpace ~
23525 \InsetSpace ~
23526 \InsetSpace ~
23527 \InsetSpace ~
23528 \InsetSpace ~
23529 \InsetSpace ~
23530 \InsetSpace ~
23531 \InsetSpace ~
23532 mpasmwin /q /o $*.asm
23533 \newline
23534
23535 \newline
23536 $(PRJ).hex: $(OBJS)
23537  
23538 \newline
23539 \InsetSpace ~
23540 \InsetSpace ~
23541 \InsetSpace ~
23542 \InsetSpace ~
23543 \InsetSpace ~
23544 \InsetSpace ~
23545 \InsetSpace ~
23546 \InsetSpace ~
23547 mplink /v $(PRJ).lkr /m $(PRJ).map /o $(PRJ).hex $(OBJS) libsdcc.lib
23548 \end_layout
23549
23550 \begin_layout Standard
23551 Please note that indentations within a
23552 \family typewriter
23553  Makefile
23554 \family default
23555  have to be done with a tabulator character.
23556 \end_layout
23557
23558 \begin_layout Subsection
23559 Command-Line Options
23560 \end_layout
23561
23562 \begin_layout Standard
23563 Besides the switches common to all SDCC backends, the PIC14 port accepts
23564  the following options (for an updated list see sdcc -
23565 \begin_inset ERT
23566 status collapsed
23567
23568 \begin_layout Standard
23569
23570
23571 \backslash
23572 /
23573 \end_layout
23574
23575 \end_inset
23576
23577 -help):
23578 \end_layout
23579
23580 \begin_layout Description
23581 -
23582 \begin_inset ERT
23583 status collapsed
23584
23585 \begin_layout Standard
23586
23587
23588 \backslash
23589 /
23590 \end_layout
23591
23592 \end_inset
23593
23594 -debug-xtra
23595 \begin_inset LatexCommand \index{PIC14!Options!-\/-debug-extra}
23596
23597 \end_inset
23598
23599  emit debug info in assembly output
23600 \end_layout
23601
23602 \begin_layout Description
23603 -
23604 \begin_inset ERT
23605 status collapsed
23606
23607 \begin_layout Standard
23608
23609
23610 \backslash
23611 /
23612 \end_layout
23613
23614 \end_inset
23615
23616 -no-pcode-opt
23617 \begin_inset LatexCommand \index{PIC14!Options!-\/-no-pcode-opt}
23618
23619 \end_inset
23620
23621  disable (slightly faulty) optimization on pCode
23622 \end_layout
23623
23624 \begin_layout Description
23625 -
23626 \begin_inset ERT
23627 status collapsed
23628
23629 \begin_layout Standard
23630
23631
23632 \backslash
23633 /
23634 \end_layout
23635
23636 \end_inset
23637
23638 -stack-loc
23639 \begin_inset LatexCommand \index{PIC14!Options!-\/-stack-loc}
23640
23641 \end_inset
23642
23643  sets the lowest address of the argument passing stack (defaults to a suitably
23644  large shared databank to reduce BANKSEL overhead)
23645 \end_layout
23646
23647 \begin_layout Description
23648 -
23649 \begin_inset ERT
23650 status collapsed
23651
23652 \begin_layout Standard
23653
23654
23655 \backslash
23656 /
23657 \end_layout
23658
23659 \end_inset
23660
23661 -stack-size
23662 \begin_inset LatexCommand \index{PIC14!Options!-\/-stack-size}
23663
23664 \end_inset
23665
23666  sets the size if the argument passing stack (default: 16, minimum: 4)
23667 \end_layout
23668
23669 \begin_layout Subsection
23670 Environment Variables
23671 \end_layout
23672
23673 \begin_layout Standard
23674 The PIC14 port recognizes the following environment variables:
23675 \end_layout
23676
23677 \begin_layout Description
23678 SDCC_PIC14_SPLIT_LOCALS If set and not empty, sdcc will allocate each temporary
23679  register (the ones called r0xNNNN) in a section of its own.
23680  By default (if this variable is unset), sdcc tries to cluster registers
23681  in sections in order to reduce the BANKSEL overhead when accessing them.
23682 \end_layout
23683
23684 \begin_layout Subsection
23685 The Library
23686 \end_layout
23687
23688 \begin_layout Standard
23689 The PIC14 library currently only contains support routines required by the
23690  compiler to implement multiplication, division, and floating point support.
23691  No libc-like replacement is available at the moment, though many of the
23692  common sdcc library sources (in 
23693 \family typewriter
23694 device/lib
23695 \family default
23696 ) should also compile with the PIC14 port.
23697 \end_layout
23698
23699 \begin_layout Subsubsection
23700 error: missing definition for symbol ``__gptrget1''
23701 \end_layout
23702
23703 \begin_layout Standard
23704 The PIC14 port uses library routines to provide more complex operations
23705  like multiplication, division/modulus and (generic) pointer dereferencing.
23706  In order to add these routines to your project, you must link with PIC14's
23707  
23708 \family typewriter
23709 libsdcc.lib
23710 \family default
23711 .
23712  For single source file projects this is done automatically, more complex
23713  projects must add 
23714 \family typewriter
23715 libsdcc.lib
23716 \family default
23717  to the linker's arguments.
23718  Make sure you also add an include path for the library (using the -I switch
23719  to the linker)!
23720 \end_layout
23721
23722 \begin_layout Subsubsection
23723 Processor mismatch in file ``XXX''.
23724 \end_layout
23725
23726 \begin_layout Standard
23727 This warning can usually be ignored due to the very good compatibility amongst
23728  14
23729 \begin_inset ERT
23730 status open
23731
23732 \begin_layout Standard
23733
23734
23735 \backslash
23736 ,
23737 \end_layout
23738
23739 \end_inset
23740
23741 bit PIC
23742 \begin_inset LatexCommand \index{PIC14}
23743
23744 \end_inset
23745
23746  devices.
23747 \end_layout
23748
23749 \begin_layout Standard
23750 You might also consider recompiling the library for your specific device
23751  by changing the ARCH=p16f877 (default target) entry in 
23752 \family typewriter
23753 device/lib/pic/Makefile.in
23754 \family default
23755  and 
23756 \family typewriter
23757 device/lib/pic/Makefile
23758 \family default
23759  to reflect your device.
23760  This might even improve performance for smaller devices as unneccesary
23761  BANKSELs might be removed.
23762 \end_layout
23763
23764 \begin_layout Subsection
23765 Known Bugs
23766 \end_layout
23767
23768 \begin_layout Subsubsection
23769 Function arguments
23770 \end_layout
23771
23772 \begin_layout Standard
23773 Functions with variable argument lists (like printf) are not yet supported.
23774  Similarly, taking the argument of the first argument passed into a function
23775  does not work: It is currently passed in WREG and has no address...
23776 \end_layout
23777
23778 \begin_layout Subsubsection
23779 Regression tests fail
23780 \end_layout
23781
23782 \begin_layout Standard
23783 Though the small subset of regression tests in src/regression passes, SDCC
23784  regression test suite does not, indicating that there are still major bugs
23785  in the port.
23786  However, many smaller projects have successfully used SDCC in the past...
23787 \end_layout
23788
23789 \begin_layout Standard
23790
23791 \size footnotesize
23792
23793 \newpage
23794
23795 \end_layout
23796
23797 \begin_layout Section
23798 The PIC16
23799 \begin_inset LatexCommand \index{PIC16}
23800
23801 \end_inset
23802
23803  port
23804 \end_layout
23805
23806 \begin_layout Standard
23807 The PIC16 port adds support for Microchip
23808 \begin_inset LatexCommand \index{Microchip}
23809
23810 \end_inset
23811
23812
23813 \begin_inset Formula $^{\text{TM}}$
23814 \end_inset
23815
23816  PIC
23817 \begin_inset LatexCommand \index{PIC}
23818
23819 \end_inset
23820
23821
23822 \begin_inset Formula $^{\text{TM}}$
23823 \end_inset
23824
23825  MCUs with 16 bit wide instructions.
23826  Currently this family of microcontrollers contains the PIC18Fxxx and PIC18Fxxxx
23827 ; devices supported by the port include:
23828 \end_layout
23829
23830 \begin_layout Standard
23831 18F: 242, 248, 252, 258, 442, 448, 452, 458
23832 \end_layout
23833
23834 \begin_layout Standard
23835 18F: 1220, 1320
23836 \end_layout
23837
23838 \begin_layout Standard
23839 18F: 2220, 2221, 2320, 2321, 2331, 2431, 2455, 24j10, 2525, 2550, 25j10,
23840  2620
23841 \end_layout
23842
23843 \begin_layout Standard
23844 18F: 4220, 4221, 4320, 4321, 4331, 4431, 4455, 44j10, 4520, 4525, 4550,
23845  45j10, 4620
23846 \end_layout
23847
23848 \begin_layout Standard
23849 18F: 6520, 6620, 6680, 6720
23850 \end_layout
23851
23852 \begin_layout Standard
23853 18F: 8520, 8620, 8680, 8720
23854 \end_layout
23855
23856 \begin_layout Subsection
23857 Global Options
23858 \end_layout
23859
23860 \begin_layout Standard
23861 PIC16 port supports the standard command line arguments as supposed, with
23862  the exception of certain cases that will be mentioned in the following
23863  list:
23864 \end_layout
23865
23866 \begin_layout Description
23867 -
23868 \begin_inset ERT
23869 status collapsed
23870
23871 \begin_layout Standard
23872
23873
23874 \backslash
23875 /
23876 \end_layout
23877
23878 \end_inset
23879
23880 -callee-saves
23881 \begin_inset LatexCommand \index{PIC16!Options!-\/-callee-saves}
23882
23883 \end_inset
23884
23885  See -
23886 \begin_inset ERT
23887 status collapsed
23888
23889 \begin_layout Standard
23890
23891
23892 \backslash
23893 /
23894 \end_layout
23895
23896 \end_inset
23897
23898 -all-callee-saves
23899 \end_layout
23900
23901 \begin_layout Description
23902 -
23903 \begin_inset ERT
23904 status collapsed
23905
23906 \begin_layout Standard
23907
23908
23909 \backslash
23910 /
23911 \end_layout
23912
23913 \end_inset
23914
23915 -fommit-frame-pointer
23916 \begin_inset LatexCommand \index{PIC16!Options!-\/-fommit-frame-pointer}
23917
23918 \end_inset
23919
23920  Frame pointer will be omitted when the function uses no local variables.
23921 \end_layout
23922
23923 \begin_layout Subsection
23924 Port Specific Options
23925 \begin_inset LatexCommand \index{Options PIC16}
23926
23927 \end_inset
23928
23929
23930 \end_layout
23931
23932 \begin_layout Standard
23933 The port specific options appear after the global options in the sdcc -
23934 \begin_inset ERT
23935 status collapsed
23936
23937 \begin_layout Standard
23938
23939
23940 \backslash
23941 /
23942 \end_layout
23943
23944 \end_inset
23945
23946 -help output.
23947 \end_layout
23948
23949 \begin_layout Subsubsection
23950 Code Generation Options
23951 \end_layout
23952
23953 \begin_layout Standard
23954 These options influence the generated assembler code.
23955 \end_layout
23956
23957 \begin_layout Description
23958 -
23959 \begin_inset ERT
23960 status collapsed
23961
23962 \begin_layout Standard
23963
23964
23965 \backslash
23966 /
23967 \end_layout
23968
23969 \end_inset
23970
23971 -pstack-model=[model] Used in conjuction with the command above.
23972  Defines the stack model to be used, valid stack models are:
23973 \end_layout
23974
23975 \begin_deeper
23976 \begin_layout List
23977 \labelwidthstring 00.00.0000
23978
23979 \emph on
23980 small
23981 \emph default
23982  Selects small stack model.
23983  8 bit stack and frame pointers.
23984  Supports 256 bytes stack size.
23985 \end_layout
23986
23987 \begin_layout List
23988 \labelwidthstring 00.00.0000
23989
23990 \emph on
23991 large
23992 \emph default
23993  Selects large stack model.
23994  16 bit stack and frame pointers.
23995  Supports 65536 bytes stack size.
23996 \end_layout
23997
23998 \end_deeper
23999 \begin_layout Description
24000 -
24001 \begin_inset ERT
24002 status collapsed
24003
24004 \begin_layout Standard
24005
24006
24007 \backslash
24008 /
24009 \end_layout
24010
24011 \end_inset
24012
24013 -pno-banksel Do not generate BANKSEL assembler directives.
24014 \end_layout
24015
24016 \begin_layout Description
24017 -
24018 \begin_inset ERT
24019 status collapsed
24020
24021 \begin_layout Standard
24022
24023
24024 \backslash
24025 /
24026 \end_layout
24027
24028 \end_inset
24029
24030 -extended Enable extended instruction set/literal offset addressing mode.
24031  Use with care!
24032 \end_layout
24033
24034 \begin_layout Subsubsection
24035 Optimization Options
24036 \end_layout
24037
24038 \begin_layout Description
24039 -
24040 \begin_inset ERT
24041 status collapsed
24042
24043 \begin_layout Standard
24044
24045
24046 \backslash
24047 /
24048 \end_layout
24049
24050 \end_inset
24051
24052 -obanksel=n Set optimization level for inserting BANKSELs.
24053 \newline
24054
24055 \end_layout
24056
24057 \begin_deeper
24058 \begin_layout List
24059 \labelwidthstring 00.00.0000
24060 0 no optimization
24061 \end_layout
24062
24063 \begin_layout List
24064 \labelwidthstring 00.00.0000
24065 1 checks previous used register and if it is the same then does not emit
24066  BANKSEL, accounts only for labels.
24067 \end_layout
24068
24069 \begin_layout List
24070 \labelwidthstring 00.00.0000
24071 2 tries to check the location of (even different) symbols and removes BANKSELs
24072  if they are in the same bank.
24073  
24074 \newline
24075
24076 \emph on
24077 Important: There might be problems if the linker script has data sections
24078  across bank borders!
24079 \end_layout
24080
24081 \end_deeper
24082 \begin_layout Description
24083 -
24084 \begin_inset ERT
24085 status collapsed
24086
24087 \begin_layout Standard
24088
24089
24090 \backslash
24091 /
24092 \end_layout
24093
24094 \end_inset
24095
24096 -denable-peeps Force the usage of peepholes.
24097  Use with care.
24098 \end_layout
24099
24100 \begin_layout Description
24101 -
24102 \begin_inset ERT
24103 status collapsed
24104
24105 \begin_layout Standard
24106
24107
24108 \backslash
24109 /
24110 \end_layout
24111
24112 \end_inset
24113
24114 -optimize-goto Try to use (conditional) BRA instead of GOTO.
24115 \end_layout
24116
24117 \begin_layout Description
24118 -
24119 \begin_inset ERT
24120 status collapsed
24121
24122 \begin_layout Standard
24123
24124
24125 \backslash
24126 /
24127 \end_layout
24128
24129 \end_inset
24130
24131 -optimize-cmp Try to optimize some compares.
24132 \end_layout
24133
24134 \begin_layout Description
24135 -
24136 \begin_inset ERT
24137 status collapsed
24138
24139 \begin_layout Standard
24140
24141
24142 \backslash
24143 /
24144 \end_layout
24145
24146 \end_inset
24147
24148 -optimize-df Analyze the dataflow of the generated code and improve it.
24149 \end_layout
24150
24151 \begin_layout Subsubsection
24152 Assembling Options
24153 \end_layout
24154
24155 \begin_layout Description
24156 -
24157 \begin_inset ERT
24158 status collapsed
24159
24160 \begin_layout Standard
24161
24162
24163 \backslash
24164 /
24165 \end_layout
24166
24167 \end_inset
24168
24169 -asm= Sets the full path and name of an external assembler to call.
24170 \end_layout
24171
24172 \begin_layout Description
24173 -
24174 \begin_inset ERT
24175 status collapsed
24176
24177 \begin_layout Standard
24178
24179
24180 \backslash
24181 /
24182 \end_layout
24183
24184 \end_inset
24185
24186 -mplab-comp MPLAB
24187 \begin_inset LatexCommand \index{PIC16!MPLAB}
24188
24189 \end_inset
24190
24191  compatibility option.
24192  Currently only suppresses special gpasm directives.
24193 \end_layout
24194
24195 \begin_layout Subsubsection
24196 Linking Options
24197 \end_layout
24198
24199 \begin_layout Description
24200 -
24201 \begin_inset ERT
24202 status collapsed
24203
24204 \begin_layout Standard
24205
24206
24207 \backslash
24208 /
24209 \end_layout
24210
24211 \end_inset
24212
24213 -link= Sets the full path and name of an external linker to call.
24214 \end_layout
24215
24216 \begin_layout Description
24217 -
24218 \begin_inset ERT
24219 status collapsed
24220
24221 \begin_layout Standard
24222
24223
24224 \backslash
24225 /
24226 \end_layout
24227
24228 \end_inset
24229
24230 -preplace-udata-with=[kword] Replaces the default udata keyword for allocating
24231  unitialized data variables with [kword].
24232  Valid keywords are: "udata_acs", "udata_shr", "udata_ovr".
24233 \end_layout
24234
24235 \begin_layout Description
24236 -
24237 \begin_inset ERT
24238 status collapsed
24239
24240 \begin_layout Standard
24241
24242
24243 \backslash
24244 /
24245 \end_layout
24246
24247 \end_inset
24248
24249 -ivt-loc=n Place the interrupt vector table at address 
24250 \emph on
24251 n
24252 \emph default
24253 .
24254  Useful for bootloaders.
24255 \end_layout
24256
24257 \begin_layout Description
24258 -
24259 \begin_inset ERT
24260 status collapsed
24261
24262 \begin_layout Standard
24263
24264
24265 \backslash
24266 /
24267 \end_layout
24268
24269 \end_inset
24270
24271 -nodefaultlibs Do not link default libraries when linking.
24272 \end_layout
24273
24274 \begin_layout Description
24275 -
24276 \begin_inset ERT
24277 status collapsed
24278
24279 \begin_layout Standard
24280
24281
24282 \backslash
24283 /
24284 \end_layout
24285
24286 \end_inset
24287
24288 -use-crt= Use a custom run-time module instead of the defaults.
24289 \end_layout
24290
24291 \begin_layout Description
24292 -
24293 \begin_inset ERT
24294 status collapsed
24295
24296 \begin_layout Standard
24297
24298
24299 \backslash
24300 /
24301 \end_layout
24302
24303 \end_inset
24304
24305 -no-crt Don't link the default run-time modules
24306 \end_layout
24307
24308 \begin_layout Subsubsection
24309 Debugging Options
24310 \end_layout
24311
24312 \begin_layout Standard
24313 Debugging options enable extra debugging information in the output files.
24314 \end_layout
24315
24316 \begin_layout Description
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 -debug-xtra Similar to -
24331 \begin_inset ERT
24332 status collapsed
24333
24334 \begin_layout Standard
24335
24336
24337 \backslash
24338 /
24339 \end_layout
24340
24341 \end_inset
24342
24343 -debug
24344 \begin_inset LatexCommand \index{-\/-debug}
24345
24346 \end_inset
24347
24348 , but dumps more information.
24349 \end_layout
24350
24351 \begin_layout Description
24352 -
24353 \begin_inset ERT
24354 status collapsed
24355
24356 \begin_layout Standard
24357
24358
24359 \backslash
24360 /
24361 \end_layout
24362
24363 \end_inset
24364
24365 -debug-ralloc Force register allocator to dump <source>.d file with debugging
24366  information.
24367  <source> is the name of the file being compiled.
24368 \end_layout
24369
24370 \begin_layout Description
24371 -
24372 \begin_inset ERT
24373 status collapsed
24374
24375 \begin_layout Standard
24376
24377
24378 \backslash
24379 /
24380 \end_layout
24381
24382 \end_inset
24383
24384 -pcode-verbose Enable pcode debugging information in translation.
24385 \end_layout
24386
24387 \begin_layout Description
24388 -
24389 \begin_inset ERT
24390 status collapsed
24391
24392 \begin_layout Standard
24393
24394
24395 \backslash
24396 /
24397 \end_layout
24398
24399 \end_inset
24400
24401 -calltree Dump call tree in .calltree file.
24402 \end_layout
24403
24404 \begin_layout Description
24405 -
24406 \begin_inset ERT
24407 status collapsed
24408
24409 \begin_layout Standard
24410
24411
24412 \backslash
24413 /
24414 \end_layout
24415
24416 \end_inset
24417
24418 -gstack Trace push/pops for stack pointer overflow.
24419 \end_layout
24420
24421 \begin_layout Subsection
24422 Enviroment Variables
24423 \end_layout
24424
24425 \begin_layout Standard
24426 There is a number of enviromental variables that can be used when running
24427  SDCC to enable certain optimizations or force a specific program behaviour.
24428  these variables are primarily for debugging purposes so they can be enabled/dis
24429 abled at will.
24430 \end_layout
24431
24432 \begin_layout Standard
24433 Currently there is only two such variables available:
24434 \end_layout
24435
24436 \begin_layout Description
24437 OPTIMIZE_BITFIELD_POINTER_GET When this variable exists, reading of structure
24438  bitfields is optimized by directly loading FSR0 with the address of the
24439  bitfield structure.
24440  Normally SDCC will cast the bitfield structure to a bitfield pointer and
24441  then load FSR0.
24442  This step saves data ram and code space for functions that make heavy use
24443  of bitfields.
24444  (i.e., 80 bytes of code space are saved when compiling malloc.c with this
24445  option).
24446  
24447 \end_layout
24448
24449 \begin_layout Description
24450 NO_REG_OPT Do not perform pCode registers optimization.
24451  This should be used for debugging purposes.
24452  If bugs in the pcode optimizer are found, users can benefit from temporarily
24453  disabling the optimizer until the bug is fixed.
24454 \end_layout
24455
24456 \begin_layout Subsection
24457 Preprocessor Macros
24458 \end_layout
24459
24460 \begin_layout Standard
24461 PIC16
24462 \begin_inset LatexCommand \index{PIC16}
24463
24464 \end_inset
24465
24466  port defines the following preprocessor macros while translating a source.
24467 \end_layout
24468
24469 \begin_layout Standard
24470 \align center
24471 \begin_inset Tabular
24472 <lyxtabular version="3" rows="6" columns="2">
24473 <features>
24474 <column alignment="center" valignment="top" leftline="true" width="0">
24475 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
24476 <row topline="true" bottomline="true">
24477 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
24478 \begin_inset Text
24479
24480 \begin_layout Standard
24481 Macro
24482 \end_layout
24483
24484 \end_inset
24485 </cell>
24486 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
24487 \begin_inset Text
24488
24489 \begin_layout Standard
24490 Description
24491 \end_layout
24492
24493 \end_inset
24494 </cell>
24495 </row>
24496 <row topline="true">
24497 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
24498 \begin_inset Text
24499
24500 \begin_layout Standard
24501 SDCC_pic16
24502 \end_layout
24503
24504 \end_inset
24505 </cell>
24506 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
24507 \begin_inset Text
24508
24509 \begin_layout Standard
24510 Port identification
24511 \end_layout
24512
24513 \end_inset
24514 </cell>
24515 </row>
24516 <row topline="true">
24517 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
24518 \begin_inset Text
24519
24520 \begin_layout Standard
24521 _
24522 \begin_inset ERT
24523 status collapsed
24524
24525 \begin_layout Standard
24526
24527
24528 \backslash
24529 /
24530 \end_layout
24531
24532 \end_inset
24533
24534 _pic16
24535 \end_layout
24536
24537 \end_inset
24538 </cell>
24539 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
24540 \begin_inset Text
24541
24542 \begin_layout Standard
24543 Port identification (same as above)
24544 \end_layout
24545
24546 \end_inset
24547 </cell>
24548 </row>
24549 <row topline="true">
24550 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
24551 \begin_inset Text
24552
24553 \begin_layout Standard
24554 pic18fxxxx
24555 \end_layout
24556
24557 \end_inset
24558 </cell>
24559 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
24560 \begin_inset Text
24561
24562 \begin_layout Standard
24563 MCU Identification.
24564  
24565 \emph on
24566 xxxx
24567 \emph default
24568  is the microcontrol identification number, i.e.
24569  452, 6620, etc
24570 \end_layout
24571
24572 \end_inset
24573 </cell>
24574 </row>
24575 <row topline="true">
24576 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
24577 \begin_inset Text
24578
24579 \begin_layout Standard
24580 _
24581 \begin_inset ERT
24582 status collapsed
24583
24584 \begin_layout Standard
24585
24586
24587 \backslash
24588 /
24589 \end_layout
24590
24591 \end_inset
24592
24593 _18Fxxxx
24594 \end_layout
24595
24596 \end_inset
24597 </cell>
24598 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
24599 \begin_inset Text
24600
24601 \begin_layout Standard
24602 MCU Identification (same as above)
24603 \end_layout
24604
24605 \end_inset
24606 </cell>
24607 </row>
24608 <row topline="true" bottomline="true">
24609 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
24610 \begin_inset Text
24611
24612 \begin_layout Standard
24613 STACK_MODEL_nnn
24614 \end_layout
24615
24616 \end_inset
24617 </cell>
24618 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
24619 \begin_inset Text
24620
24621 \begin_layout Standard
24622 nnn = SMALL or LARGE respectively according to the stack model used
24623 \end_layout
24624
24625 \end_inset
24626 </cell>
24627 </row>
24628 </lyxtabular>
24629
24630 \end_inset
24631
24632
24633 \end_layout
24634
24635 \begin_layout Standard
24636 In addition the following macros are defined when calling assembler:
24637 \end_layout
24638
24639 \begin_layout Standard
24640 \align center
24641 \begin_inset Tabular
24642 <lyxtabular version="3" rows="4" columns="2">
24643 <features>
24644 <column alignment="center" valignment="top" leftline="true" width="0">
24645 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
24646 <row topline="true" bottomline="true">
24647 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
24648 \begin_inset Text
24649
24650 \begin_layout Standard
24651 Macro
24652 \end_layout
24653
24654 \end_inset
24655 </cell>
24656 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
24657 \begin_inset Text
24658
24659 \begin_layout Standard
24660 Description
24661 \end_layout
24662
24663 \end_inset
24664 </cell>
24665 </row>
24666 <row topline="true">
24667 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
24668 \begin_inset Text
24669
24670 \begin_layout Standard
24671 __18Fxxxx
24672 \end_layout
24673
24674 \end_inset
24675 </cell>
24676 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
24677 \begin_inset Text
24678
24679 \begin_layout Standard
24680 MCU Identification.
24681  
24682 \emph on
24683 xxxx
24684 \emph default
24685  is the microcontrol identification number, i.e.
24686  452, 6620, etc
24687 \end_layout
24688
24689 \end_inset
24690 </cell>
24691 </row>
24692 <row topline="true">
24693 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
24694 \begin_inset Text
24695
24696 \begin_layout Standard
24697 SDCC_MODEL_nnn
24698 \end_layout
24699
24700 \end_inset
24701 </cell>
24702 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
24703 \begin_inset Text
24704
24705 \begin_layout Standard
24706 nnn = SMALL or LARGE respectively according to the memory model used for
24707  SDCC
24708 \end_layout
24709
24710 \end_inset
24711 </cell>
24712 </row>
24713 <row topline="true" bottomline="true">
24714 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
24715 \begin_inset Text
24716
24717 \begin_layout Standard
24718 STACK_MODEL_nnn
24719 \end_layout
24720
24721 \end_inset
24722 </cell>
24723 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
24724 \begin_inset Text
24725
24726 \begin_layout Standard
24727 nnn = SMALL or LARGE respectively according to the stack model used
24728 \end_layout
24729
24730 \end_inset
24731 </cell>
24732 </row>
24733 </lyxtabular>
24734
24735 \end_inset
24736
24737
24738 \end_layout
24739
24740 \begin_layout Subsection
24741 Directories
24742 \end_layout
24743
24744 \begin_layout Standard
24745 PIC16
24746 \begin_inset LatexCommand \index{PIC16}
24747
24748 \end_inset
24749
24750  port uses the following directories for searching header files and libraries.
24751 \end_layout
24752
24753 \begin_layout Standard
24754 \align center
24755 \begin_inset Tabular
24756 <lyxtabular version="3" rows="3" columns="4">
24757 <features>
24758 <column alignment="center" valignment="top" leftline="true" width="0">
24759 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
24760 <column alignment="center" valignment="top" width="0">
24761 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
24762 <row topline="true" bottomline="true">
24763 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
24764 \begin_inset Text
24765
24766 \begin_layout Standard
24767 Directory
24768 \end_layout
24769
24770 \end_inset
24771 </cell>
24772 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
24773 \begin_inset Text
24774
24775 \begin_layout Standard
24776 Description
24777 \end_layout
24778
24779 \end_inset
24780 </cell>
24781 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
24782 \begin_inset Text
24783
24784 \begin_layout Standard
24785 Target
24786 \end_layout
24787
24788 \end_inset
24789 </cell>
24790 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
24791 \begin_inset Text
24792
24793 \begin_layout Standard
24794 Command prefix
24795 \end_layout
24796
24797 \end_inset
24798 </cell>
24799 </row>
24800 <row topline="true">
24801 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
24802 \begin_inset Text
24803
24804 \begin_layout Standard
24805 PREFIX/sdcc/include/pic16
24806 \end_layout
24807
24808 \end_inset
24809 </cell>
24810 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
24811 \begin_inset Text
24812
24813 \begin_layout Standard
24814 PIC16 specific headers
24815 \end_layout
24816
24817 \end_inset
24818 </cell>
24819 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
24820 \begin_inset Text
24821
24822 \begin_layout Standard
24823 Compiler
24824 \end_layout
24825
24826 \end_inset
24827 </cell>
24828 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
24829 \begin_inset Text
24830
24831 \begin_layout Standard
24832 -I
24833 \end_layout
24834
24835 \end_inset
24836 </cell>
24837 </row>
24838 <row topline="true" bottomline="true">
24839 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
24840 \begin_inset Text
24841
24842 \begin_layout Standard
24843 PREFIX/sdcc/lib/pic16
24844 \end_layout
24845
24846 \end_inset
24847 </cell>
24848 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
24849 \begin_inset Text
24850
24851 \begin_layout Standard
24852 PIC16 specific libraries
24853 \end_layout
24854
24855 \end_inset
24856 </cell>
24857 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
24858 \begin_inset Text
24859
24860 \begin_layout Standard
24861 Linker
24862 \end_layout
24863
24864 \end_inset
24865 </cell>
24866 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
24867 \begin_inset Text
24868
24869 \begin_layout Standard
24870 -L
24871 \end_layout
24872
24873 \end_inset
24874 </cell>
24875 </row>
24876 </lyxtabular>
24877
24878 \end_inset
24879
24880
24881 \end_layout
24882
24883 \begin_layout Subsection
24884 Pragmas
24885 \begin_inset LatexCommand \label{sub:PIC16_Pragmas}
24886
24887 \end_inset
24888
24889
24890 \end_layout
24891
24892 \begin_layout Standard
24893 The PIC16
24894 \begin_inset LatexCommand \index{PIC16}
24895
24896 \end_inset
24897
24898  port currently supports the following pragmas:
24899 \end_layout
24900
24901 \begin_layout Description
24902 stack
24903 \begin_inset LatexCommand \index{PIC16!Pragmas!\#pragma stack}
24904
24905 \end_inset
24906
24907  This forces the code generator to initialize the stack & frame pointers
24908  at a specific address.
24909  This is an ad hoc solution for cases where no STACK directive is available
24910  in the linker script or gplink is not instructed to create a stack section.
24911 \newline
24912 The
24913  stack pragma should be used only once in a project.
24914  Multiple pragmas may result in indeterminate behaviour of the program.
24915 \begin_inset Foot
24916 status open
24917
24918 \begin_layout Standard
24919 The old format (ie.
24920  #pragma stack 0x5ff) is deprecated and will cause the stack pointer to
24921  cross page boundaries (or even exceed the available data RAM) and crash
24922  the program.
24923  Make sure that stack does not cross page boundaries when using the SMALL
24924  stack model.
24925 \end_layout
24926
24927 \end_inset
24928
24929
24930 \newline
24931 The format is as follows:
24932 \newline
24933
24934 \end_layout
24935
24936 \begin_layout LyX-Code
24937 #pragma stack bottom_address [stack_size]
24938 \newline
24939
24940 \end_layout
24941
24942 \begin_layout Standard
24943
24944 \emph on
24945 bottom_address
24946 \emph default
24947  is the lower bound of the stack section.
24948  The stack pointer initially will point at address (bottom_address+stack_size-1).
24949 \end_layout
24950
24951 \begin_layout LyX-Code
24952 Example:
24953 \end_layout
24954
24955 \begin_layout LyX-Code
24956
24957 \end_layout
24958
24959 \begin_layout LyX-Code
24960 /* initializes stack of 100 bytes at RAM address 0x200 */
24961 \end_layout
24962
24963 \begin_layout LyX-Code
24964 #pragma stack 0x200 100
24965 \end_layout
24966
24967 \begin_layout Standard
24968 If the stack_size field is omitted then a stack is created with the default
24969  size of 64.
24970  This size might be enough for most programs, but its not enough for operations
24971  with deep function nesting or excessive stack usage.
24972 \end_layout
24973
24974 \begin_layout Description
24975 code
24976 \begin_inset LatexCommand \index{PIC16!Pragmas!\#pragma code}
24977
24978 \end_inset
24979
24980  Force a function to a static FLASH address.
24981 \end_layout
24982
24983 \begin_layout LyX-Code
24984 Example:
24985 \end_layout
24986
24987 \begin_layout LyX-Code
24988
24989 \end_layout
24990
24991 \begin_layout LyX-Code
24992 /* place function test_func at 0x4000 */
24993 \end_layout
24994
24995 \begin_layout LyX-Code
24996 #pragma code test_func 0x4000
24997 \end_layout
24998
24999 \begin_layout LyX-Code
25000
25001 \end_layout
25002
25003 \begin_layout Description
25004 library instructs the linker to use a library module.
25005 \newline
25006 Usage:
25007 \end_layout
25008
25009 \begin_layout LyX-Code
25010 #pragma library module_name
25011 \end_layout
25012
25013 \begin_layout Standard
25014
25015 \emph on
25016 module_name
25017 \emph default
25018  can be any library or object file (including its path).
25019  Note that there are four reserved keywords which have special meaning.
25020  These are:
25021 \end_layout
25022
25023 \begin_layout Standard
25024 \align center
25025 \begin_inset Tabular
25026 <lyxtabular version="3" rows="6" columns="3">
25027 <features>
25028 <column alignment="center" valignment="top" leftline="true" width="0">
25029 <column alignment="block" valignment="top" leftline="true" width="20page%">
25030 <column alignment="left" valignment="top" leftline="true" rightline="true" width="0">
25031 <row topline="true" bottomline="true">
25032 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25033 \begin_inset Text
25034
25035 \begin_layout Standard
25036 Keyword
25037 \end_layout
25038
25039 \end_inset
25040 </cell>
25041 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25042 \begin_inset Text
25043
25044 \begin_layout Standard
25045 Description
25046 \end_layout
25047
25048 \end_inset
25049 </cell>
25050 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
25051 \begin_inset Text
25052
25053 \begin_layout Standard
25054 Module to link
25055 \end_layout
25056
25057 \end_inset
25058 </cell>
25059 </row>
25060 <row topline="true">
25061 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25062 \begin_inset Text
25063
25064 \begin_layout Standard
25065
25066 \series bold
25067 ignore
25068 \end_layout
25069
25070 \end_inset
25071 </cell>
25072 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25073 \begin_inset Text
25074
25075 \begin_layout Standard
25076 ignore all library pragmas
25077 \end_layout
25078
25079 \end_inset
25080 </cell>
25081 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
25082 \begin_inset Text
25083
25084 \begin_layout Standard
25085
25086 \emph on
25087 (none)
25088 \end_layout
25089
25090 \end_inset
25091 </cell>
25092 </row>
25093 <row topline="true">
25094 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25095 \begin_inset Text
25096
25097 \begin_layout Standard
25098
25099 \series bold
25100 c
25101 \end_layout
25102
25103 \end_inset
25104 </cell>
25105 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25106 \begin_inset Text
25107
25108 \begin_layout Standard
25109 link the C library
25110 \end_layout
25111
25112 \end_inset
25113 </cell>
25114 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
25115 \begin_inset Text
25116
25117 \begin_layout Standard
25118
25119 \emph on
25120 libc18f
25121 \emph default
25122 .lib
25123 \end_layout
25124
25125 \end_inset
25126 </cell>
25127 </row>
25128 <row topline="true">
25129 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25130 \begin_inset Text
25131
25132 \begin_layout Standard
25133
25134 \series bold
25135 math
25136 \end_layout
25137
25138 \end_inset
25139 </cell>
25140 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25141 \begin_inset Text
25142
25143 \begin_layout Standard
25144 link the Math libarary
25145 \end_layout
25146
25147 \end_inset
25148 </cell>
25149 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
25150 \begin_inset Text
25151
25152 \begin_layout Standard
25153
25154 \emph on
25155 libm18f
25156 \emph default
25157 .lib
25158 \end_layout
25159
25160 \end_inset
25161 </cell>
25162 </row>
25163 <row topline="true">
25164 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25165 \begin_inset Text
25166
25167 \begin_layout Standard
25168
25169 \series bold
25170 io
25171 \end_layout
25172
25173 \end_inset
25174 </cell>
25175 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25176 \begin_inset Text
25177
25178 \begin_layout Standard
25179 link the I/O library
25180 \end_layout
25181
25182 \end_inset
25183 </cell>
25184 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
25185 \begin_inset Text
25186
25187 \begin_layout Standard
25188
25189 \emph on
25190 libio18f*
25191 \emph default
25192 .lib
25193 \end_layout
25194
25195 \end_inset
25196 </cell>
25197 </row>
25198 <row topline="true" bottomline="true">
25199 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25200 \begin_inset Text
25201
25202 \begin_layout Standard
25203
25204 \series bold
25205 debug
25206 \end_layout
25207
25208 \end_inset
25209 </cell>
25210 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25211 \begin_inset Text
25212
25213 \begin_layout Standard
25214 link the debug library
25215 \end_layout
25216
25217 \end_inset
25218 </cell>
25219 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
25220 \begin_inset Text
25221
25222 \begin_layout Standard
25223
25224 \emph on
25225 libdebug
25226 \emph default
25227 .lib
25228 \end_layout
25229
25230 \end_inset
25231 </cell>
25232 </row>
25233 </lyxtabular>
25234
25235 \end_inset
25236
25237
25238 \newline
25239 * is the device number, i.e.
25240  452 for PIC18F452 MCU.
25241 \end_layout
25242
25243 \begin_layout Standard
25244 This feature allows for linking with specific libraries withoug having to
25245  explicit name them in the command line.
25246  Note that the 
25247 \noun on
25248 ignore
25249 \noun default
25250  keyword will reject all modules specified by the library pragma.
25251 \end_layout
25252
25253 \begin_layout Description
25254 udata The pragma udata instructs the compiler to emit code so that linker
25255  will place a variable at a specific memory bank.
25256 \end_layout
25257
25258 \begin_layout LyX-Code
25259 Example:
25260 \end_layout
25261
25262 \begin_layout LyX-Code
25263
25264 \end_layout
25265
25266 \begin_layout LyX-Code
25267 /* places variable foo at bank2 */
25268 \end_layout
25269
25270 \begin_layout LyX-Code
25271 #pragma udata bank2 foo
25272 \end_layout
25273
25274 \begin_layout LyX-Code
25275 char foo;
25276 \end_layout
25277
25278 \begin_layout Standard
25279 In order for this pragma to work extra SECTION directives should be added
25280  in the .lkr script.
25281  In the following example a sample .lkr file is shown:
25282 \end_layout
25283
25284 \begin_layout LyX-Code
25285
25286 \end_layout
25287
25288 \begin_layout LyX-Code
25289 // Sample linker script for the PIC18F452 processor
25290 \end_layout
25291
25292 \begin_layout LyX-Code
25293 LIBPATH .
25294 \end_layout
25295
25296 \begin_layout LyX-Code
25297 CODEPAGE   NAME=vectors    START=0x0            END=0x29           PROTECTED
25298 \end_layout
25299
25300 \begin_layout LyX-Code
25301 CODEPAGE   NAME=page       START=0x2A           END=0x7FFF
25302 \end_layout
25303
25304 \begin_layout LyX-Code
25305 CODEPAGE   NAME=idlocs     START=0x200000       END=0x200007       PROTECTED
25306 \end_layout
25307
25308 \begin_layout LyX-Code
25309 CODEPAGE   NAME=config     START=0x300000       END=0x30000D       PROTECTED
25310 \end_layout
25311
25312 \begin_layout LyX-Code
25313 CODEPAGE   NAME=devid      START=0x3FFFFE       END=0x3FFFFF       PROTECTED
25314 \end_layout
25315
25316 \begin_layout LyX-Code
25317 CODEPAGE   NAME=eedata     START=0xF00000       END=0xF000FF       PROTECTED
25318 \end_layout
25319
25320 \begin_layout LyX-Code
25321 ACCESSBANK NAME=accessram  START=0x0            END=0x7F
25322 \end_layout
25323
25324 \begin_layout LyX-Code
25325
25326 \end_layout
25327
25328 \begin_layout LyX-Code
25329 DATABANK   NAME=gpr0       START=0x80           END=0xFF
25330 \end_layout
25331
25332 \begin_layout LyX-Code
25333 DATABANK   NAME=gpr1       START=0x100          END=0x1FF
25334 \end_layout
25335
25336 \begin_layout LyX-Code
25337 DATABANK   NAME=gpr2       START=0x200          END=0x2FF
25338 \end_layout
25339
25340 \begin_layout LyX-Code
25341 DATABANK   NAME=gpr3       START=0x300          END=0x3FF
25342 \end_layout
25343
25344 \begin_layout LyX-Code
25345 DATABANK   NAME=gpr4       START=0x400          END=0x4FF
25346 \end_layout
25347
25348 \begin_layout LyX-Code
25349 DATABANK   NAME=gpr5       START=0x500          END=0x5FF
25350 \end_layout
25351
25352 \begin_layout LyX-Code
25353 ACCESSBANK NAME=accesssfr  START=0xF80          END=0xFFF          PROTECTED
25354 \end_layout
25355
25356 \begin_layout LyX-Code
25357
25358 \end_layout
25359
25360 \begin_layout LyX-Code
25361 SECTION    NAME=CONFIG     ROM=config
25362 \end_layout
25363
25364 \begin_layout LyX-Code
25365
25366 \end_layout
25367
25368 \begin_layout LyX-Code
25369 SECTION    NAME=bank0      RAM=gpr0       # these SECTION directives
25370 \end_layout
25371
25372 \begin_layout LyX-Code
25373 SECTION    NAME=bank1      RAM=gpr1       # should be added to link
25374 \end_layout
25375
25376 \begin_layout LyX-Code
25377 SECTION    NAME=bank2      RAM=gpr2       # section name 'bank?' with
25378 \end_layout
25379
25380 \begin_layout LyX-Code
25381 SECTION    NAME=bank3      RAM=gpr3       # a specific DATABANK name
25382 \end_layout
25383
25384 \begin_layout LyX-Code
25385 SECTION    NAME=bank4      RAM=gpr4
25386 \end_layout
25387
25388 \begin_layout LyX-Code
25389 SECTION    NAME=bank5      RAM=gpr5
25390 \end_layout
25391
25392 \begin_layout Standard
25393 The linker will recognise the section name set in the pragma statement and
25394  will position the variable at the memory bank set with the RAM field at
25395  the SECTION line in the linker script file.
25396 \end_layout
25397
25398 \begin_layout Subsection
25399 Header Files
25400 \begin_inset LatexCommand \label{sub:PIC16_Header-Files}
25401
25402 \end_inset
25403
25404
25405 \end_layout
25406
25407 \begin_layout Standard
25408 There is one main header file
25409 \begin_inset LatexCommand \index{PIC16!Header files}
25410
25411 \end_inset
25412
25413  that can be included to the source files using the pic16
25414 \begin_inset LatexCommand \index{PIC16}
25415
25416 \end_inset
25417
25418  port.
25419  That file is the 
25420 \series bold
25421 pic18fregs.h
25422 \series default
25423 .
25424  This header file contains the definitions for the processor special registers,
25425  so it is necessary if the source accesses them.
25426  It can be included by adding the following line in the beginning of the
25427  file:
25428 \end_layout
25429
25430 \begin_layout LyX-Code
25431 #include <pic18fregs.h>
25432 \end_layout
25433
25434 \begin_layout Standard
25435 The specific microcontroller is selected within the pic18fregs.h automatically,
25436  so the same source can be used with a variety of devices.
25437 \end_layout
25438
25439 \begin_layout Subsection
25440 Libraries
25441 \end_layout
25442
25443 \begin_layout Standard
25444 The libraries
25445 \begin_inset LatexCommand \index{PIC16!Libraries}
25446
25447 \end_inset
25448
25449  that PIC16
25450 \begin_inset LatexCommand \index{PIC16}
25451
25452 \end_inset
25453
25454  port depends on are the microcontroller device libraries which contain
25455  the symbol definitions for the microcontroller special function registers.
25456  These libraries have the format pic18fxxxx.lib, where 
25457 \emph on
25458 xxxx
25459 \emph default
25460  is the microcontroller identification number.
25461  The specific library is selected automatically by the compiler at link
25462  stage according to the selected device.
25463 \end_layout
25464
25465 \begin_layout Standard
25466 Libraries are created with gplib which is part of the gputils package 
25467 \begin_inset LatexCommand \url{http://sourceforge.net/projects/gputils}
25468
25469 \end_inset
25470
25471 .
25472 \end_layout
25473
25474 \begin_layout Subsubsection*
25475 Building the libraries
25476 \end_layout
25477
25478 \begin_layout Standard
25479 Before using SDCC/pic16 there are some libraries that need to be compiled.
25480  This process is not done automatically by SDCC since not all users use
25481  SDCC for pic16 projects.
25482  So each user should compile the libraries separately.
25483 \end_layout
25484
25485 \begin_layout Standard
25486 The steps to compile the pic16 libraries under Linux and Mac OS X are:
25487 \end_layout
25488
25489 \begin_layout LyX-Code
25490 cd device/lib/pic16
25491 \end_layout
25492
25493 \begin_layout LyX-Code
25494 ./configure
25495 \end_layout
25496
25497 \begin_layout LyX-Code
25498 make
25499 \end_layout
25500
25501 \begin_layout LyX-Code
25502 cd ..
25503 \end_layout
25504
25505 \begin_layout LyX-Code
25506 make model-pic16
25507 \end_layout
25508
25509 \begin_layout LyX-Code
25510 su -c 'make install'     # install the libraries, you need the root password
25511 \end_layout
25512
25513 \begin_layout Standard
25514 If you need to install the headers too, do:
25515 \end_layout
25516
25517 \begin_layout LyX-Code
25518 cd device/include
25519 \end_layout
25520
25521 \begin_layout LyX-Code
25522 su -c 'make install'     # install the headers, you need the root password
25523 \end_layout
25524
25525 \begin_layout Standard
25526 There exist a special target to build the I/O libraries.
25527  This target is not automatically build because it will build the I/O library
25528  for 
25529 \emph on
25530 every
25531 \emph default
25532  supported device.
25533  This way building will take quite a lot of time.
25534  Users are advised to edit the 
25535 \series bold
25536 device/lib/pic16/pics.build
25537 \series default
25538  file and then execute:
25539 \end_layout
25540
25541 \begin_layout LyX-Code
25542 make lib-io
25543 \end_layout
25544
25545 \begin_layout Subsection
25546 Adding New Devices to the Port
25547 \end_layout
25548
25549 \begin_layout Standard
25550 Adding support for a new 16
25551 \begin_inset ERT
25552 status open
25553
25554 \begin_layout Standard
25555
25556
25557 \backslash
25558 ,
25559 \end_layout
25560
25561 \end_inset
25562
25563 bit PIC MCU requires the following steps:
25564 \end_layout
25565
25566 \begin_layout Enumerate
25567 Create picDEVICE.c and picDEVICE.h from pDEVICE.inc using
25568 \newline
25569
25570 \family typewriter
25571 perl /path/to/sdcc/support/scripts/inc2h-pic16.pl /path/to/gputils/header/pDEVICE.
25572 inc
25573 \end_layout
25574
25575 \begin_layout Enumerate
25576
25577 \family typewriter
25578 mv picDEVICE.h /path/to/sdcc/device/include/pic16
25579 \end_layout
25580
25581 \begin_layout Enumerate
25582
25583 \family typewriter
25584 mv picDEVICE.c /path/to/sdcc/device/lib/pic16/libdev
25585 \end_layout
25586
25587 \begin_layout Enumerate
25588 Add DEVICE to 
25589 \family typewriter
25590 /path/to/sdcc/device/lib/pics.all
25591 \family default
25592  (and 
25593 \family typewriter
25594 .build
25595 \family default
25596 ).
25597 \newline
25598 Note: No 18f prefix here!
25599 \end_layout
25600
25601 \begin_layout Enumerate
25602 Adjust 
25603 \family typewriter
25604 /path/to/sdcc/device/lib/pic16/libio/*.ignore
25605 \family default
25606
25607 \newline
25608 Add your DEVICE if it does not compile in 
25609 \family typewriter
25610 adc
25611 \family default
25612
25613 \family typewriter
25614 i2c
25615 \family default
25616 , or 
25617 \family typewriter
25618 usart
25619 \family default
25620 .
25621 \end_layout
25622
25623 \begin_layout Enumerate
25624 Edit 
25625 \family typewriter
25626 /path/to/sdcc/device/include/pic16/pic18fregs.h
25627 \family default
25628 .
25629  The file format is self-explanatory, just add
25630 \newline
25631
25632 \family typewriter
25633 #elif defined(picDEVICE)
25634 \newline
25635 # include <picDEVICE.h>
25636 \family default
25637
25638 \newline
25639 at the right place (keep it sorted).
25640 \end_layout
25641
25642 \begin_layout Enumerate
25643 Edit 
25644 \family typewriter
25645 /path/to/sdcc/src/pic16/devices.inc
25646 \family default
25647 .
25648  Copy and modify an existing entry and insert it at the correct place (keep
25649  the file sorted).
25650  The file is hardly documented, look at the entries for the 18f2221...
25651 \end_layout
25652
25653 \begin_layout Enumerate
25654 Recompile SDCC, including the pic16 libraries.
25655 \end_layout
25656
25657 \begin_layout Subsection
25658 Memory Models
25659 \end_layout
25660
25661 \begin_layout Standard
25662 The following memory models are supported by the PIC16 port:
25663 \end_layout
25664
25665 \begin_layout Itemize
25666 small model
25667 \end_layout
25668
25669 \begin_layout Itemize
25670 large model
25671 \end_layout
25672
25673 \begin_layout Standard
25674 Memory model affects the default size of pointers within the source.
25675  The sizes are shown in the next table:
25676 \end_layout
25677
25678 \begin_layout Standard
25679 \align center
25680 \begin_inset Tabular
25681 <lyxtabular version="3" rows="3" columns="3">
25682 <features>
25683 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
25684 <column alignment="center" valignment="top" leftline="true" width="0">
25685 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
25686 <row topline="true" bottomline="true">
25687 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25688 \begin_inset Text
25689
25690 \begin_layout Standard
25691 Pointer sizes according to memory model
25692 \end_layout
25693
25694 \end_inset
25695 </cell>
25696 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25697 \begin_inset Text
25698
25699 \begin_layout Standard
25700 small model
25701 \end_layout
25702
25703 \end_inset
25704 </cell>
25705 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
25706 \begin_inset Text
25707
25708 \begin_layout Standard
25709 large model
25710 \end_layout
25711
25712 \end_inset
25713 </cell>
25714 </row>
25715 <row topline="true" bottomline="true">
25716 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25717 \begin_inset Text
25718
25719 \begin_layout Standard
25720 code pointers
25721 \end_layout
25722
25723 \end_inset
25724 </cell>
25725 <cell multicolumn="1" alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25726 \begin_inset Text
25727
25728 \begin_layout Standard
25729 16-bits
25730 \end_layout
25731
25732 \end_inset
25733 </cell>
25734 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
25735 \begin_inset Text
25736
25737 \begin_layout Standard
25738 24-bits
25739 \end_layout
25740
25741 \end_inset
25742 </cell>
25743 </row>
25744 <row topline="true" bottomline="true">
25745 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25746 \begin_inset Text
25747
25748 \begin_layout Standard
25749 data pointers
25750 \end_layout
25751
25752 \end_inset
25753 </cell>
25754 <cell multicolumn="1" alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
25755 \begin_inset Text
25756
25757 \begin_layout Standard
25758 16-bits
25759 \end_layout
25760
25761 \end_inset
25762 </cell>
25763 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
25764 \begin_inset Text
25765
25766 \begin_layout Standard
25767 16-bits
25768 \end_layout
25769
25770 \end_inset
25771 </cell>
25772 </row>
25773 </lyxtabular>
25774
25775 \end_inset
25776
25777
25778 \end_layout
25779
25780 \begin_layout Standard
25781 It is advisable that all sources within a project are compiled with the
25782  same memory model.
25783  If one wants to override the default memory model, this can be done by
25784  declaring a pointer as 
25785 \series bold
25786 far
25787 \series default
25788  or 
25789 \series bold
25790 near
25791 \series default
25792 .
25793  Far selects large memory model's pointers, while near selects small memory
25794  model's pointers.
25795 \end_layout
25796
25797 \begin_layout Standard
25798 The standard device libraries (see 
25799 \begin_inset LatexCommand \ref{sub:PIC16_Header-Files}
25800
25801 \end_inset
25802
25803 ) contain no reference to pointers, so they can be used with both memory
25804  models.
25805 \end_layout
25806
25807 \begin_layout Subsection
25808 Stack
25809 \end_layout
25810
25811 \begin_layout Standard
25812 The stack
25813 \begin_inset LatexCommand \index{PIC16!stack}
25814
25815 \end_inset
25816
25817  implementation for the PIC16 port uses two indirect registers, FSR1 and
25818  FSR2.
25819 \end_layout
25820
25821 \begin_layout Description
25822 FSR1 is assigned as stack pointer
25823 \end_layout
25824
25825 \begin_layout Description
25826 FSR2 is assigned as frame pointer
25827 \end_layout
25828
25829 \begin_layout Standard
25830 The following stack models are supported by the PIC16 port
25831 \end_layout
25832
25833 \begin_layout Itemize
25834
25835 \noun on
25836 small
25837 \noun default
25838  model
25839 \end_layout
25840
25841 \begin_layout Itemize
25842
25843 \noun on
25844 large
25845 \noun default
25846  model
25847 \end_layout
25848
25849 \begin_layout Standard
25850
25851 \noun on
25852 Small
25853 \noun default
25854  model means that only the FSRxL byte is used to access stack and frame,
25855  while 
25856 \emph on
25857 \noun on
25858 large
25859 \emph default
25860 \noun default
25861  uses both FSRxL and FSRxH registers.
25862  The following table shows the stack/frame pointers sizes according to stack
25863  model and the maximum space they can address:
25864 \end_layout
25865
25866 \begin_layout Standard
25867 \align center
25868 \begin_inset Tabular
25869 <lyxtabular version="3" rows="3" columns="3">
25870 <features>
25871 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
25872 <column alignment="center" valignment="top" leftline="true" width="0">
25873 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
25874 <row topline="true" bottomline="true">
25875 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25876 \begin_inset Text
25877
25878 \begin_layout Standard
25879 Stack & Frame pointer sizes according to stack model
25880 \end_layout
25881
25882 \end_inset
25883 </cell>
25884 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25885 \begin_inset Text
25886
25887 \begin_layout Standard
25888 small
25889 \end_layout
25890
25891 \end_inset
25892 </cell>
25893 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25894 \begin_inset Text
25895
25896 \begin_layout Standard
25897 large
25898 \end_layout
25899
25900 \end_inset
25901 </cell>
25902 </row>
25903 <row topline="true">
25904 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25905 \begin_inset Text
25906
25907 \begin_layout Standard
25908 Stack pointer FSR1
25909 \end_layout
25910
25911 \end_inset
25912 </cell>
25913 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25914 \begin_inset Text
25915
25916 \begin_layout Standard
25917 8-bits
25918 \end_layout
25919
25920 \end_inset
25921 </cell>
25922 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25923 \begin_inset Text
25924
25925 \begin_layout Standard
25926 16-bits
25927 \end_layout
25928
25929 \end_inset
25930 </cell>
25931 </row>
25932 <row topline="true" bottomline="true">
25933 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25934 \begin_inset Text
25935
25936 \begin_layout Standard
25937 Frame pointer FSR2
25938 \end_layout
25939
25940 \end_inset
25941 </cell>
25942 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25943 \begin_inset Text
25944
25945 \begin_layout Standard
25946 8-bits
25947 \end_layout
25948
25949 \end_inset
25950 </cell>
25951 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25952 \begin_inset Text
25953
25954 \begin_layout Standard
25955 16-bits
25956 \end_layout
25957
25958 \end_inset
25959 </cell>
25960 </row>
25961 </lyxtabular>
25962
25963 \end_inset
25964
25965
25966 \end_layout
25967
25968 \begin_layout Standard
25969
25970 \noun on
25971 Large 
25972 \noun default
25973 stack model is currently not working properly throughout the code generator.
25974  So its use is not advised.
25975  Also there are some other points that need special care:
25976 \newline
25977
25978 \end_layout
25979
25980 \begin_layout Enumerate
25981 Do not create stack sections with size more than one physical bank (that
25982  is 256 bytes)
25983 \end_layout
25984
25985 \begin_layout Enumerate
25986 Stack sections should no cross physical bank limits (i.e.
25987  #pragma stack 0x50 0x100)
25988 \end_layout
25989
25990 \begin_layout Standard
25991 These limitations are caused by the fact that only FSRxL is modified when
25992  using SMALL stack model, so no more than 256 bytes of stack can be used.
25993  This problem will disappear after LARGE model is fully implemented.
25994 \end_layout
25995
25996 \begin_layout Subsection
25997 Functions
25998 \end_layout
25999
26000 \begin_layout Standard
26001 In addition to the standard SDCC function keywords, PIC16
26002 \begin_inset LatexCommand \index{PIC16}
26003
26004 \end_inset
26005
26006  port makes available two more:
26007 \end_layout
26008
26009 \begin_layout Description
26010 wparam
26011 \begin_inset LatexCommand \index{PIC16!wparam}
26012
26013 \end_inset
26014
26015  Use the WREG to pass one byte of the first function argument.
26016  This improves speed but you may not use this for functions with arguments
26017  that are called via function pointers, otherwise the first byte of the
26018  first parameter will get lost.
26019  Usage:
26020 \end_layout
26021
26022 \begin_layout LyX-Code
26023 void func_wparam(int a) wparam
26024 \end_layout
26025
26026 \begin_layout LyX-Code
26027 {
26028 \end_layout
26029
26030 \begin_layout LyX-Code
26031     /* WREG hold the lower part of a */
26032 \end_layout
26033
26034 \begin_layout LyX-Code
26035     /* the high part of a is stored in FSR2+2 (or +3 for large stack model)
26036  */
26037 \end_layout
26038
26039 \begin_layout LyX-Code
26040 ...
26041 \end_layout
26042
26043 \begin_layout LyX-Code
26044 }
26045 \end_layout
26046
26047 \begin_layout Description
26048 shadowregs
26049 \begin_inset LatexCommand \index{PIC16!shadowregs}
26050
26051 \end_inset
26052
26053  When entering/exiting an ISR, it is possible to take advantage of the PIC18F
26054  hardware shadow registers which hold the values of WREG, STATUS and BSR
26055  registers.
26056  This can be done by adding the keyword 
26057 \emph on
26058 shadowregs
26059 \emph default
26060  before the 
26061 \emph on
26062 interrupt
26063 \emph default
26064  keyword in the function's header.
26065 \end_layout
26066
26067 \begin_layout LyX-Code
26068 void isr_shadow(void) shadowregs interrupt 1
26069 \end_layout
26070
26071 \begin_layout LyX-Code
26072 {
26073 \end_layout
26074
26075 \begin_layout LyX-Code
26076 ...
26077 \end_layout
26078
26079 \begin_layout LyX-Code
26080 }
26081 \end_layout
26082
26083 \begin_layout Standard
26084
26085 \emph on
26086 shadowregs
26087 \emph default
26088  instructs the code generator not to store/restore WREG, STATUS, BSR when
26089  entering/exiting the ISR.
26090 \end_layout
26091
26092 \begin_layout Subsection
26093 Function return values
26094 \end_layout
26095
26096 \begin_layout Standard
26097 Return values from functions are placed to the appropriate registers following
26098  a modified Microchip policy optimized for SDCC.
26099  The following table shows these registers:
26100 \end_layout
26101
26102 \begin_layout Standard
26103 \align center
26104 \begin_inset Tabular
26105 <lyxtabular version="3" rows="6" columns="2">
26106 <features>
26107 <column alignment="center" valignment="top" leftline="true" width="0">
26108 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
26109 <row topline="true" bottomline="true">
26110 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26111 \begin_inset Text
26112
26113 \begin_layout Standard
26114 size
26115 \end_layout
26116
26117 \end_inset
26118 </cell>
26119 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26120 \begin_inset Text
26121
26122 \begin_layout Standard
26123 destination register
26124 \end_layout
26125
26126 \end_inset
26127 </cell>
26128 </row>
26129 <row topline="true">
26130 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26131 \begin_inset Text
26132
26133 \begin_layout Standard
26134 8 bits
26135 \end_layout
26136
26137 \end_inset
26138 </cell>
26139 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26140 \begin_inset Text
26141
26142 \begin_layout Standard
26143 WREG
26144 \end_layout
26145
26146 \end_inset
26147 </cell>
26148 </row>
26149 <row topline="true">
26150 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26151 \begin_inset Text
26152
26153 \begin_layout Standard
26154 16 bits
26155 \end_layout
26156
26157 \end_inset
26158 </cell>
26159 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26160 \begin_inset Text
26161
26162 \begin_layout Standard
26163 PRODL:WREG
26164 \end_layout
26165
26166 \end_inset
26167 </cell>
26168 </row>
26169 <row topline="true">
26170 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26171 \begin_inset Text
26172
26173 \begin_layout Standard
26174 24 bits
26175 \end_layout
26176
26177 \end_inset
26178 </cell>
26179 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26180 \begin_inset Text
26181
26182 \begin_layout Standard
26183 PRODH:PRODL:WREG
26184 \end_layout
26185
26186 \end_inset
26187 </cell>
26188 </row>
26189 <row topline="true">
26190 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26191 \begin_inset Text
26192
26193 \begin_layout Standard
26194 32 bits
26195 \end_layout
26196
26197 \end_inset
26198 </cell>
26199 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26200 \begin_inset Text
26201
26202 \begin_layout Standard
26203 FSR0L:PRODH:PRODL:WREG
26204 \end_layout
26205
26206 \end_inset
26207 </cell>
26208 </row>
26209 <row topline="true" bottomline="true">
26210 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26211 \begin_inset Text
26212
26213 \begin_layout Standard
26214 >32 bits
26215 \end_layout
26216
26217 \end_inset
26218 </cell>
26219 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26220 \begin_inset Text
26221
26222 \begin_layout Standard
26223 on stack, FSR0 points to the beginning
26224 \end_layout
26225
26226 \end_inset
26227 </cell>
26228 </row>
26229 </lyxtabular>
26230
26231 \end_inset
26232
26233
26234 \end_layout
26235
26236 \begin_layout Subsection
26237 Interrupts
26238 \end_layout
26239
26240 \begin_layout Standard
26241 An interrupt
26242 \begin_inset LatexCommand \index{PIC16!interrupt}
26243
26244 \end_inset
26245
26246  service routine (ISR) is declared using the 
26247 \emph on
26248 interrupt
26249 \emph default
26250  keyword.
26251 \end_layout
26252
26253 \begin_layout LyX-Code
26254 void isr(void) interrupt 
26255 \emph on
26256 n
26257 \end_layout
26258
26259 \begin_layout LyX-Code
26260 {
26261 \end_layout
26262
26263 \begin_layout LyX-Code
26264 ...
26265 \end_layout
26266
26267 \begin_layout LyX-Code
26268 }
26269 \end_layout
26270
26271 \begin_layout Standard
26272
26273 \emph on
26274 n
26275 \emph default
26276  is the interrupt number, which for PIC18F devices can be:
26277 \end_layout
26278
26279 \begin_layout Standard
26280 \align center
26281 \begin_inset Tabular
26282 <lyxtabular version="3" rows="4" columns="3">
26283 <features>
26284 <column alignment="center" valignment="top" leftline="true" width="0">
26285 <column alignment="center" valignment="top" leftline="true" width="0">
26286 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
26287 <row topline="true" bottomline="true">
26288 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26289 \begin_inset Text
26290
26291 \begin_layout Standard
26292
26293 \emph on
26294 n
26295 \end_layout
26296
26297 \end_inset
26298 </cell>
26299 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26300 \begin_inset Text
26301
26302 \begin_layout Standard
26303 Interrupt Vector
26304 \end_layout
26305
26306 \end_inset
26307 </cell>
26308 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26309 \begin_inset Text
26310
26311 \begin_layout Standard
26312 Interrupt Vector Address
26313 \end_layout
26314
26315 \end_inset
26316 </cell>
26317 </row>
26318 <row topline="true">
26319 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26320 \begin_inset Text
26321
26322 \begin_layout Standard
26323 0
26324 \end_layout
26325
26326 \end_inset
26327 </cell>
26328 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26329 \begin_inset Text
26330
26331 \begin_layout Standard
26332 RESET vector
26333 \end_layout
26334
26335 \end_inset
26336 </cell>
26337 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26338 \begin_inset Text
26339
26340 \begin_layout Standard
26341 0x000000
26342 \end_layout
26343
26344 \end_inset
26345 </cell>
26346 </row>
26347 <row topline="true">
26348 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26349 \begin_inset Text
26350
26351 \begin_layout Standard
26352
26353 \family roman
26354 \series medium
26355 \shape up
26356 \size normal
26357 \emph off
26358 \bar no
26359 \noun off
26360 \color none
26361 1
26362 \end_layout
26363
26364 \end_inset
26365 </cell>
26366 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26367 \begin_inset Text
26368
26369 \begin_layout Standard
26370
26371 \family roman
26372 \series medium
26373 \shape up
26374 \size normal
26375 \emph off
26376 \bar no
26377 \noun off
26378 \color none
26379 HIGH priority interrupts
26380 \end_layout
26381
26382 \end_inset
26383 </cell>
26384 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26385 \begin_inset Text
26386
26387 \begin_layout Standard
26388 0x000008
26389 \end_layout
26390
26391 \end_inset
26392 </cell>
26393 </row>
26394 <row topline="true" bottomline="true">
26395 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26396 \begin_inset Text
26397
26398 \begin_layout Standard
26399 2
26400 \end_layout
26401
26402 \end_inset
26403 </cell>
26404 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26405 \begin_inset Text
26406
26407 \begin_layout Standard
26408 LOW priority interrupts
26409 \end_layout
26410
26411 \end_inset
26412 </cell>
26413 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26414 \begin_inset Text
26415
26416 \begin_layout Standard
26417 0x000018
26418 \end_layout
26419
26420 \end_inset
26421 </cell>
26422 </row>
26423 </lyxtabular>
26424
26425 \end_inset
26426
26427
26428 \end_layout
26429
26430 \begin_layout Standard
26431 When generating assembly code for ISR the code generator places a 
26432 \noun on
26433 goto 
26434 \noun default
26435 instruction at the 
26436 \emph on
26437 Interrupt Vector Address
26438 \emph default
26439  which points at the genetated ISR.
26440  This single GOTO instruction is part of an automatically generated 
26441 \emph on
26442 interrupt entry point
26443 \emph default
26444  function.
26445  The actuall ISR code is placed as normally would in the code space.
26446  Upon interrupt request, the GOTO instruction is executed which jumps to
26447  the ISR code.
26448  When declaring interrupt functions as _naked this GOTO instruction is 
26449 \series bold
26450 not
26451 \series default
26452  generated.
26453  The whole interrupt functions is therefore placed at the Interrupt Vector
26454  Address of the specific interrupt.
26455  This is not a problem for the LOW priority interrupts, but it is a problem
26456  for the RESET and the HIGH priority interrupts because code may be written
26457  at the next interrupt's vector address and cause undeterminate program
26458  behaviour if that interrupt is raised.
26459 \begin_inset Foot
26460 status open
26461
26462 \begin_layout Standard
26463 This is not a problem when
26464 \end_layout
26465
26466 \begin_layout Enumerate
26467 this is a HIGH interrupt ISR and LOW interrupts are 
26468 \emph on
26469 disabled
26470 \emph default
26471  or not used.
26472 \end_layout
26473
26474 \begin_layout Enumerate
26475 when the ISR is small enough not to reach the next interrupt's vector address.
26476 \end_layout
26477
26478 \end_inset
26479
26480
26481 \end_layout
26482
26483 \begin_layout Standard
26484
26485 \emph on
26486 n
26487 \emph default
26488  may be omitted.
26489  This way a function is generated similar to an ISR, but it is not assigned
26490  to any interrupt.
26491 \end_layout
26492
26493 \begin_layout Standard
26494 When entering an interrupt, currently the PIC16
26495 \begin_inset LatexCommand \index{PIC16}
26496
26497 \end_inset
26498
26499  port automatically saves the following registers:
26500 \end_layout
26501
26502 \begin_layout Itemize
26503 WREG
26504 \end_layout
26505
26506 \begin_layout Itemize
26507 STATUS
26508 \end_layout
26509
26510 \begin_layout Itemize
26511 BSR
26512 \end_layout
26513
26514 \begin_layout Itemize
26515 PROD (PRODL and PRODH)
26516 \end_layout
26517
26518 \begin_layout Itemize
26519 FSR0 (FSR0L and FSR0H)
26520 \end_layout
26521
26522 \begin_layout Standard
26523 These registers are restored upon return from the interrupt routine.
26524 \begin_inset Foot
26525 status open
26526
26527 \begin_layout Standard
26528 NOTE that when the _naked attribute is specified for an interrupt routine,
26529  then NO registers are stored or restored.
26530 \end_layout
26531
26532 \end_inset
26533
26534
26535 \end_layout
26536
26537 \begin_layout Subsection
26538 Generic Pointers
26539 \end_layout
26540
26541 \begin_layout Standard
26542 Generic pointers are implemented in PIC16 port as 3-byte (24-bit) types.
26543  There are 3 types of generic pointers currently implemented data, code
26544  and eeprom pointers.
26545  They are differentiated by the value of the 7th and 6th bits of the upper
26546  byte:
26547 \end_layout
26548
26549 \begin_layout Standard
26550 \align center
26551 \begin_inset Tabular
26552 <lyxtabular version="3" rows="5" columns="5">
26553 <features>
26554 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
26555 <column alignment="center" valignment="top" width="0">
26556 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
26557 <column alignment="center" valignment="top" width="0">
26558 <column alignment="left" valignment="top" rightline="true" width="0">
26559 <row topline="true" bottomline="true">
26560 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26561 \begin_inset Text
26562
26563 \begin_layout Standard
26564 pointer type
26565 \end_layout
26566
26567 \end_inset
26568 </cell>
26569 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26570 \begin_inset Text
26571
26572 \begin_layout Standard
26573 7th bit
26574 \end_layout
26575
26576 \end_inset
26577 </cell>
26578 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26579 \begin_inset Text
26580
26581 \begin_layout Standard
26582 6th bit
26583 \end_layout
26584
26585 \end_inset
26586 </cell>
26587 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26588 \begin_inset Text
26589
26590 \begin_layout Standard
26591 rest of the pointer
26592 \end_layout
26593
26594 \end_inset
26595 </cell>
26596 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26597 \begin_inset Text
26598
26599 \begin_layout Standard
26600 description
26601 \end_layout
26602
26603 \end_inset
26604 </cell>
26605 </row>
26606 <row topline="true" bottomline="true">
26607 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26608 \begin_inset Text
26609
26610 \begin_layout Standard
26611 data 
26612 \end_layout
26613
26614 \end_inset
26615 </cell>
26616 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26617 \begin_inset Text
26618
26619 \begin_layout Standard
26620 1
26621 \end_layout
26622
26623 \end_inset
26624 </cell>
26625 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26626 \begin_inset Text
26627
26628 \begin_layout Standard
26629 0
26630 \end_layout
26631
26632 \end_inset
26633 </cell>
26634 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26635 \begin_inset Text
26636
26637 \begin_layout Standard
26638
26639 \family typewriter
26640 \shape slanted
26641 \emph on
26642 uuuuuu uuuuxxxx xxxxxxxx
26643 \end_layout
26644
26645 \end_inset
26646 </cell>
26647 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26648 \begin_inset Text
26649
26650 \begin_layout Standard
26651 a 12-bit data pointer in data RAM memory
26652 \end_layout
26653
26654 \end_inset
26655 </cell>
26656 </row>
26657 <row bottomline="true">
26658 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26659 \begin_inset Text
26660
26661 \begin_layout Standard
26662 code
26663 \end_layout
26664
26665 \end_inset
26666 </cell>
26667 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26668 \begin_inset Text
26669
26670 \begin_layout Standard
26671 0
26672 \end_layout
26673
26674 \end_inset
26675 </cell>
26676 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26677 \begin_inset Text
26678
26679 \begin_layout Standard
26680 0
26681 \end_layout
26682
26683 \end_inset
26684 </cell>
26685 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26686 \begin_inset Text
26687
26688 \begin_layout Standard
26689
26690 \family typewriter
26691 \shape slanted
26692 \emph on
26693 uxxxxx xxxxxxxx xxxxxxxx
26694 \end_layout
26695
26696 \end_inset
26697 </cell>
26698 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26699 \begin_inset Text
26700
26701 \begin_layout Standard
26702 a 21-bit code pointer in FLASH memory
26703 \end_layout
26704
26705 \end_inset
26706 </cell>
26707 </row>
26708 <row bottomline="true">
26709 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26710 \begin_inset Text
26711
26712 \begin_layout Standard
26713 eeprom
26714 \end_layout
26715
26716 \end_inset
26717 </cell>
26718 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26719 \begin_inset Text
26720
26721 \begin_layout Standard
26722 0
26723 \end_layout
26724
26725 \end_inset
26726 </cell>
26727 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26728 \begin_inset Text
26729
26730 \begin_layout Standard
26731 1
26732 \end_layout
26733
26734 \end_inset
26735 </cell>
26736 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26737 \begin_inset Text
26738
26739 \begin_layout Standard
26740
26741 \family typewriter
26742 \shape slanted
26743 \emph on
26744 uuuuuu uuuuuuxx xxxxxxxx
26745 \end_layout
26746
26747 \end_inset
26748 </cell>
26749 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26750 \begin_inset Text
26751
26752 \begin_layout Standard
26753 a 10-bit eeprom pointer in EEPROM memory
26754 \end_layout
26755
26756 \end_inset
26757 </cell>
26758 </row>
26759 <row bottomline="true">
26760 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26761 \begin_inset Text
26762
26763 \begin_layout Standard
26764 (unimplemented)
26765 \end_layout
26766
26767 \end_inset
26768 </cell>
26769 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26770 \begin_inset Text
26771
26772 \begin_layout Standard
26773 1
26774 \end_layout
26775
26776 \end_inset
26777 </cell>
26778 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26779 \begin_inset Text
26780
26781 \begin_layout Standard
26782 1
26783 \end_layout
26784
26785 \end_inset
26786 </cell>
26787 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26788 \begin_inset Text
26789
26790 \begin_layout Standard
26791
26792 \family typewriter
26793 \shape slanted
26794 \emph on
26795 xxxxxx xxxxxxxx xxxxxxxx
26796 \end_layout
26797
26798 \end_inset
26799 </cell>
26800 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26801 \begin_inset Text
26802
26803 \begin_layout Standard
26804 unimplemented pointer type
26805 \end_layout
26806
26807 \end_inset
26808 </cell>
26809 </row>
26810 </lyxtabular>
26811
26812 \end_inset
26813
26814
26815 \end_layout
26816
26817 \begin_layout Standard
26818 Generic pointer are read and written with a set of library functions which
26819  read/write 1, 2, 3, 4 bytes.
26820 \end_layout
26821
26822 \begin_layout Subsection
26823 PIC16 C Libraries
26824 \end_layout
26825
26826 \begin_layout Subsubsection
26827 Standard I/O Streams
26828 \end_layout
26829
26830 \begin_layout Standard
26831 In the 
26832 \emph on
26833 stdio.h
26834 \emph default
26835  the type FILE is defined as:
26836 \end_layout
26837
26838 \begin_layout LyX-Code
26839 typedef char * FILE;
26840 \end_layout
26841
26842 \begin_layout Standard
26843 This type is the stream type implemented I/O in the PIC18F devices.
26844  Also the standard input and output streams are declared in stdio.h:
26845 \end_layout
26846
26847 \begin_layout LyX-Code
26848 extern FILE * stdin;
26849 \end_layout
26850
26851 \begin_layout LyX-Code
26852 extern FILE * stdout;
26853 \end_layout
26854
26855 \begin_layout Standard
26856 The FILE type is actually a generic pointer which defines one more type
26857  of generic pointers, the 
26858 \emph on
26859 stream 
26860 \emph default
26861 pointer.
26862  This new type has the format:
26863 \end_layout
26864
26865 \begin_layout Standard
26866 \align center
26867 \begin_inset Tabular
26868 <lyxtabular version="3" rows="2" columns="7">
26869 <features>
26870 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
26871 <column alignment="center" valignment="top" width="0">
26872 <column alignment="center" valignment="top" leftline="true" width="0">
26873 <column alignment="center" valignment="top" leftline="true" width="0">
26874 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
26875 <column alignment="center" valignment="top" width="0">
26876 <column alignment="left" valignment="top" rightline="true" width="0">
26877 <row topline="true" bottomline="true">
26878 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26879 \begin_inset Text
26880
26881 \begin_layout Standard
26882 pointer type
26883 \end_layout
26884
26885 \end_inset
26886 </cell>
26887 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26888 \begin_inset Text
26889
26890 \begin_layout Standard
26891 <7:6>
26892 \end_layout
26893
26894 \end_inset
26895 </cell>
26896 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26897 \begin_inset Text
26898
26899 \begin_layout Standard
26900 <5>
26901 \end_layout
26902
26903 \end_inset
26904 </cell>
26905 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26906 \begin_inset Text
26907
26908 \begin_layout Standard
26909 <4>
26910 \end_layout
26911
26912 \end_inset
26913 </cell>
26914 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26915 \begin_inset Text
26916
26917 \begin_layout Standard
26918 <3:0>
26919 \end_layout
26920
26921 \end_inset
26922 </cell>
26923 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26924 \begin_inset Text
26925
26926 \begin_layout Standard
26927 rest of the pointer
26928 \end_layout
26929
26930 \end_inset
26931 </cell>
26932 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26933 \begin_inset Text
26934
26935 \begin_layout Standard
26936 descrption
26937 \end_layout
26938
26939 \end_inset
26940 </cell>
26941 </row>
26942 <row topline="true" bottomline="true">
26943 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26944 \begin_inset Text
26945
26946 \begin_layout Standard
26947 stream
26948 \end_layout
26949
26950 \end_inset
26951 </cell>
26952 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26953 \begin_inset Text
26954
26955 \begin_layout Standard
26956 00
26957 \end_layout
26958
26959 \end_inset
26960 </cell>
26961 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26962 \begin_inset Text
26963
26964 \begin_layout Standard
26965 1
26966 \end_layout
26967
26968 \end_inset
26969 </cell>
26970 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26971 \begin_inset Text
26972
26973 \begin_layout Standard
26974 0
26975 \end_layout
26976
26977 \end_inset
26978 </cell>
26979 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26980 \begin_inset Text
26981
26982 \begin_layout Standard
26983 nnnn
26984 \end_layout
26985
26986 \end_inset
26987 </cell>
26988 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26989 \begin_inset Text
26990
26991 \begin_layout Standard
26992
26993 \family typewriter
26994 \shape slanted
26995 \emph on
26996 uuuuuuuu uuuuuuuu
26997 \end_layout
26998
26999 \end_inset
27000 </cell>
27001 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27002 \begin_inset Text
27003
27004 \begin_layout Standard
27005 upper byte high nubble is 0x2n, the rest are zeroes
27006 \end_layout
27007
27008 \end_inset
27009 </cell>
27010 </row>
27011 </lyxtabular>
27012
27013 \end_inset
27014
27015
27016 \end_layout
27017
27018 \begin_layout Standard
27019 Currently implemented there are 3 types of streams defined:
27020 \end_layout
27021
27022 \begin_layout Standard
27023 \align center
27024 \begin_inset Tabular
27025 <lyxtabular version="3" rows="4" columns="4">
27026 <features>
27027 <column alignment="center" valignment="top" leftline="true" width="0">
27028 <column alignment="center" valignment="top" leftline="true" width="0">
27029 <column alignment="center" valignment="top" leftline="true" width="0">
27030 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
27031 <row topline="true" bottomline="true">
27032 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27033 \begin_inset Text
27034
27035 \begin_layout Standard
27036 stream type
27037 \end_layout
27038
27039 \end_inset
27040 </cell>
27041 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27042 \begin_inset Text
27043
27044 \begin_layout Standard
27045 value
27046 \end_layout
27047
27048 \end_inset
27049 </cell>
27050 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27051 \begin_inset Text
27052
27053 \begin_layout Standard
27054 module
27055 \end_layout
27056
27057 \end_inset
27058 </cell>
27059 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27060 \begin_inset Text
27061
27062 \begin_layout Standard
27063 description
27064 \end_layout
27065
27066 \end_inset
27067 </cell>
27068 </row>
27069 <row topline="true">
27070 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27071 \begin_inset Text
27072
27073 \begin_layout Standard
27074 STREAM_USART
27075 \end_layout
27076
27077 \end_inset
27078 </cell>
27079 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27080 \begin_inset Text
27081
27082 \begin_layout Standard
27083
27084 \family typewriter
27085 0x200000UL
27086 \end_layout
27087
27088 \end_inset
27089 </cell>
27090 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27091 \begin_inset Text
27092
27093 \begin_layout Standard
27094 USART
27095 \end_layout
27096
27097 \end_inset
27098 </cell>
27099 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27100 \begin_inset Text
27101
27102 \begin_layout Standard
27103 Writes/Reads characters via the USART peripheral
27104 \end_layout
27105
27106 \end_inset
27107 </cell>
27108 </row>
27109 <row topline="true">
27110 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27111 \begin_inset Text
27112
27113 \begin_layout Standard
27114 STREAM_MSSP
27115 \end_layout
27116
27117 \end_inset
27118 </cell>
27119 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27120 \begin_inset Text
27121
27122 \begin_layout Standard
27123
27124 \family typewriter
27125 0x210000UL
27126 \end_layout
27127
27128 \end_inset
27129 </cell>
27130 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27131 \begin_inset Text
27132
27133 \begin_layout Standard
27134 MSSP
27135 \end_layout
27136
27137 \end_inset
27138 </cell>
27139 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27140 \begin_inset Text
27141
27142 \begin_layout Standard
27143 Writes/Reads characters via the MSSP peripheral
27144 \end_layout
27145
27146 \end_inset
27147 </cell>
27148 </row>
27149 <row topline="true" bottomline="true">
27150 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27151 \begin_inset Text
27152
27153 \begin_layout Standard
27154 STREAM_USER
27155 \end_layout
27156
27157 \end_inset
27158 </cell>
27159 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27160 \begin_inset Text
27161
27162 \begin_layout Standard
27163
27164 \family typewriter
27165 0x2f0000UL
27166 \end_layout
27167
27168 \end_inset
27169 </cell>
27170 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27171 \begin_inset Text
27172
27173 \begin_layout Standard
27174 (none)
27175 \end_layout
27176
27177 \end_inset
27178 </cell>
27179 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27180 \begin_inset Text
27181
27182 \begin_layout Standard
27183 Writes/Reads characters via used defined functions
27184 \end_layout
27185
27186 \end_inset
27187 </cell>
27188 </row>
27189 </lyxtabular>
27190
27191 \end_inset
27192
27193
27194 \end_layout
27195
27196 \begin_layout Standard
27197 The stream identifiers are declared as macros in the stdio.h header.
27198 \end_layout
27199
27200 \begin_layout Standard
27201 In the libc library there exist the functions that are used to write to
27202  each of the above streams.
27203  These are
27204 \end_layout
27205
27206 \begin_layout Description
27207 _
27208 \begin_inset ERT
27209 status collapsed
27210
27211 \begin_layout Standard
27212
27213
27214 \backslash
27215 /
27216 \end_layout
27217
27218 \end_inset
27219
27220 _stream_usart_putchar writes a character at the USART stream
27221 \end_layout
27222
27223 \begin_layout Description
27224 _
27225 \begin_inset ERT
27226 status collapsed
27227
27228 \begin_layout Standard
27229
27230
27231 \backslash
27232 /
27233 \end_layout
27234
27235 \end_inset
27236
27237 _stream_mssp_putchar writes a character at the MSSP stream
27238 \end_layout
27239
27240 \begin_layout Description
27241 putchar dummy function.
27242  This writes a character to a user specified manner.
27243 \end_layout
27244
27245 \begin_layout Standard
27246 In order to increase performance 
27247 \emph on
27248 putchar 
27249 \emph default
27250 is declared in stdio.h as having its parameter in WREG (it has the wparam
27251  keyword).
27252  In stdio.h exists the macro PUTCHAR(arg) that defines the putchar function
27253  in a user-friendly way.
27254  
27255 \emph on
27256 arg
27257 \emph default
27258  is the name of the variable that holds the character to print.
27259  An example follows:
27260 \end_layout
27261
27262 \begin_layout LyX-Code
27263 #include <pic18fregs.h>
27264 \newline
27265 #include <stdio.h>
27266 \newline
27267
27268 \newline
27269 PUTCHAR( c )
27270 \end_layout
27271
27272 \begin_layout LyX-Code
27273 {
27274 \end_layout
27275
27276 \begin_layout LyX-Code
27277     PORTA = c;    /* dump character c to PORTA */
27278 \end_layout
27279
27280 \begin_layout LyX-Code
27281
27282 \newline
27283
27284 \newline
27285 void main(void)
27286 \end_layout
27287
27288 \begin_layout LyX-Code
27289 {
27290 \end_layout
27291
27292 \begin_layout LyX-Code
27293     stdout = STREAM_USER;    /* this is not necessary, since stdout points
27294 \end_layout
27295
27296 \begin_layout LyX-Code
27297                               * by default to STREAM_USER */
27298 \end_layout
27299
27300 \begin_layout LyX-Code
27301     printf (
27302 \begin_inset Quotes sld
27303 \end_inset
27304
27305 This is a printf test
27306 \backslash
27307 n
27308 \begin_inset Quotes srd
27309 \end_inset
27310
27311 );
27312 \end_layout
27313
27314 \begin_layout LyX-Code
27315 }
27316 \end_layout
27317
27318 \begin_layout LyX-Code
27319
27320 \end_layout
27321
27322 \begin_layout Subsubsection
27323 Printing functions
27324 \end_layout
27325
27326 \begin_layout Standard
27327 PIC16 contains an implementation of the printf-family of functions.
27328  There exist the following functions:
27329 \end_layout
27330
27331 \begin_layout LyX-Code
27332 extern unsigned int sprintf(char *buf, char *fmt, ...);
27333 \end_layout
27334
27335 \begin_layout LyX-Code
27336 extern unsigned int vsprintf(char *buf, char *fmt, va_list ap);
27337 \end_layout
27338
27339 \begin_layout LyX-Code
27340
27341 \end_layout
27342
27343 \begin_layout LyX-Code
27344 extern unsigned int printf(char *fmt, ...);
27345 \end_layout
27346
27347 \begin_layout LyX-Code
27348 extern unsigned int vprintf(char *fmt, va_lista ap);
27349 \end_layout
27350
27351 \begin_layout LyX-Code
27352
27353 \end_layout
27354
27355 \begin_layout LyX-Code
27356 extern unsigned int fprintf(FILE *fp, char *fmt, ...);
27357 \end_layout
27358
27359 \begin_layout LyX-Code
27360 extern unsigned int vfprintf(FILE *fp, char *fmt, va_list ap);
27361 \end_layout
27362
27363 \begin_layout Standard
27364 For sprintf and vsprintf 
27365 \emph on
27366 buf 
27367 \emph default
27368 should normally be a data pointer where the resulting string will be placed.
27369  No range checking is done so the user should allocate the necessery buffer.
27370  For fprintf and vfprintf 
27371 \emph on
27372 fp
27373 \emph default
27374  should be a stream pointer (i.e.
27375  stdout, STREAM_MSSP, etc...).
27376 \end_layout
27377
27378 \begin_layout Subsubsection
27379 Signals
27380 \end_layout
27381
27382 \begin_layout Standard
27383 The PIC18F family of microcontrollers supports a number of interrupt sources.
27384  A list of these interrupts is shown in the following table:
27385 \end_layout
27386
27387 \begin_layout Standard
27388 \align center
27389 \begin_inset Tabular
27390 <lyxtabular version="3" rows="11" columns="4">
27391 <features>
27392 <column alignment="left" valignment="top" leftline="true" width="0">
27393 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
27394 <column alignment="left" valignment="top" leftline="true" width="0">
27395 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
27396 <row topline="true" bottomline="true">
27397 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27398 \begin_inset Text
27399
27400 \begin_layout Standard
27401 signal name
27402 \end_layout
27403
27404 \end_inset
27405 </cell>
27406 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27407 \begin_inset Text
27408
27409 \begin_layout Standard
27410 description
27411 \end_layout
27412
27413 \end_inset
27414 </cell>
27415 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27416 \begin_inset Text
27417
27418 \begin_layout Standard
27419 signal name
27420 \end_layout
27421
27422 \end_inset
27423 </cell>
27424 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27425 \begin_inset Text
27426
27427 \begin_layout Standard
27428 descritpion
27429 \end_layout
27430
27431 \end_inset
27432 </cell>
27433 </row>
27434 <row topline="true">
27435 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27436 \begin_inset Text
27437
27438 \begin_layout Standard
27439 SIG_RB
27440 \end_layout
27441
27442 \end_inset
27443 </cell>
27444 <cell multicolumn="1" alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27445 \begin_inset Text
27446
27447 \begin_layout Standard
27448 PORTB change interrupt
27449 \end_layout
27450
27451 \end_inset
27452 </cell>
27453 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27454 \begin_inset Text
27455
27456 \begin_layout Standard
27457 SIG_EE
27458 \end_layout
27459
27460 \end_inset
27461 </cell>
27462 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27463 \begin_inset Text
27464
27465 \begin_layout Standard
27466 EEPROM/FLASH write complete interrupt
27467 \end_layout
27468
27469 \end_inset
27470 </cell>
27471 </row>
27472 <row topline="true">
27473 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27474 \begin_inset Text
27475
27476 \begin_layout Standard
27477 SIG_INT0
27478 \end_layout
27479
27480 \end_inset
27481 </cell>
27482 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27483 \begin_inset Text
27484
27485 \begin_layout Standard
27486 INT0 external interrupt
27487 \end_layout
27488
27489 \end_inset
27490 </cell>
27491 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27492 \begin_inset Text
27493
27494 \begin_layout Standard
27495 SIG_BCOL
27496 \end_layout
27497
27498 \end_inset
27499 </cell>
27500 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27501 \begin_inset Text
27502
27503 \begin_layout Standard
27504 Bus collision interrupt
27505 \end_layout
27506
27507 \end_inset
27508 </cell>
27509 </row>
27510 <row topline="true">
27511 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27512 \begin_inset Text
27513
27514 \begin_layout Standard
27515 SIG_INT1
27516 \end_layout
27517
27518 \end_inset
27519 </cell>
27520 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27521 \begin_inset Text
27522
27523 \begin_layout Standard
27524 INT1 external interrupt
27525 \end_layout
27526
27527 \end_inset
27528 </cell>
27529 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27530 \begin_inset Text
27531
27532 \begin_layout Standard
27533 SIG_LVD
27534 \end_layout
27535
27536 \end_inset
27537 </cell>
27538 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27539 \begin_inset Text
27540
27541 \begin_layout Standard
27542 Low voltage detect interrupt
27543 \end_layout
27544
27545 \end_inset
27546 </cell>
27547 </row>
27548 <row topline="true">
27549 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27550 \begin_inset Text
27551
27552 \begin_layout Standard
27553 SIG_INT2
27554 \end_layout
27555
27556 \end_inset
27557 </cell>
27558 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27559 \begin_inset Text
27560
27561 \begin_layout Standard
27562 INT2 external interrupt
27563 \end_layout
27564
27565 \end_inset
27566 </cell>
27567 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27568 \begin_inset Text
27569
27570 \begin_layout Standard
27571 SIG_PSP
27572 \end_layout
27573
27574 \end_inset
27575 </cell>
27576 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27577 \begin_inset Text
27578
27579 \begin_layout Standard
27580 Parallel slave port interrupt
27581 \end_layout
27582
27583 \end_inset
27584 </cell>
27585 </row>
27586 <row topline="true">
27587 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27588 \begin_inset Text
27589
27590 \begin_layout Standard
27591 SIG_CCP1
27592 \end_layout
27593
27594 \end_inset
27595 </cell>
27596 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27597 \begin_inset Text
27598
27599 \begin_layout Standard
27600 CCP1 module interrupt
27601 \end_layout
27602
27603 \end_inset
27604 </cell>
27605 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27606 \begin_inset Text
27607
27608 \begin_layout Standard
27609 SIG_AD
27610 \end_layout
27611
27612 \end_inset
27613 </cell>
27614 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27615 \begin_inset Text
27616
27617 \begin_layout Standard
27618 AD convertion complete interrupt
27619 \end_layout
27620
27621 \end_inset
27622 </cell>
27623 </row>
27624 <row topline="true">
27625 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27626 \begin_inset Text
27627
27628 \begin_layout Standard
27629 SIG_CCP2
27630 \end_layout
27631
27632 \end_inset
27633 </cell>
27634 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27635 \begin_inset Text
27636
27637 \begin_layout Standard
27638 CCP2 module interrupt
27639 \end_layout
27640
27641 \end_inset
27642 </cell>
27643 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27644 \begin_inset Text
27645
27646 \begin_layout Standard
27647 SIG_RC
27648 \end_layout
27649
27650 \end_inset
27651 </cell>
27652 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27653 \begin_inset Text
27654
27655 \begin_layout Standard
27656 USART receive interrupt
27657 \end_layout
27658
27659 \end_inset
27660 </cell>
27661 </row>
27662 <row topline="true">
27663 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27664 \begin_inset Text
27665
27666 \begin_layout Standard
27667 SIG_TMR0
27668 \end_layout
27669
27670 \end_inset
27671 </cell>
27672 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27673 \begin_inset Text
27674
27675 \begin_layout Standard
27676 TMR0 overflow interrupt
27677 \end_layout
27678
27679 \end_inset
27680 </cell>
27681 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27682 \begin_inset Text
27683
27684 \begin_layout Standard
27685 SIG_TX
27686 \end_layout
27687
27688 \end_inset
27689 </cell>
27690 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27691 \begin_inset Text
27692
27693 \begin_layout Standard
27694 USART transmit interrupt
27695 \end_layout
27696
27697 \end_inset
27698 </cell>
27699 </row>
27700 <row topline="true">
27701 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27702 \begin_inset Text
27703
27704 \begin_layout Standard
27705 SIG_TMR1
27706 \end_layout
27707
27708 \end_inset
27709 </cell>
27710 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27711 \begin_inset Text
27712
27713 \begin_layout Standard
27714 TMR1 overflow interrupt
27715 \end_layout
27716
27717 \end_inset
27718 </cell>
27719 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27720 \begin_inset Text
27721
27722 \begin_layout Standard
27723 SIG_MSSP
27724 \end_layout
27725
27726 \end_inset
27727 </cell>
27728 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27729 \begin_inset Text
27730
27731 \begin_layout Standard
27732 SSP receive/transmit interrupt
27733 \end_layout
27734
27735 \end_inset
27736 </cell>
27737 </row>
27738 <row topline="true">
27739 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27740 \begin_inset Text
27741
27742 \begin_layout Standard
27743 SIG_TMR2
27744 \end_layout
27745
27746 \end_inset
27747 </cell>
27748 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27749 \begin_inset Text
27750
27751 \begin_layout Standard
27752 TMR2 matches PR2 interrupt
27753 \end_layout
27754
27755 \end_inset
27756 </cell>
27757 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27758 \begin_inset Text
27759
27760 \begin_layout Standard
27761
27762 \end_layout
27763
27764 \end_inset
27765 </cell>
27766 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27767 \begin_inset Text
27768
27769 \begin_layout Standard
27770
27771 \end_layout
27772
27773 \end_inset
27774 </cell>
27775 </row>
27776 <row topline="true" bottomline="true">
27777 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27778 \begin_inset Text
27779
27780 \begin_layout Standard
27781 SIG_TMR3
27782 \end_layout
27783
27784 \end_inset
27785 </cell>
27786 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27787 \begin_inset Text
27788
27789 \begin_layout Standard
27790 TMR3 overflow interrupt
27791 \end_layout
27792
27793 \end_inset
27794 </cell>
27795 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27796 \begin_inset Text
27797
27798 \begin_layout Standard
27799
27800 \end_layout
27801
27802 \end_inset
27803 </cell>
27804 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27805 \begin_inset Text
27806
27807 \begin_layout Standard
27808
27809 \end_layout
27810
27811 \end_inset
27812 </cell>
27813 </row>
27814 </lyxtabular>
27815
27816 \end_inset
27817
27818
27819 \end_layout
27820
27821 \begin_layout Standard
27822 The prototypes for these names are defined in the header file 
27823 \emph on
27824 signal.h
27825 \emph default
27826  .
27827 \end_layout
27828
27829 \begin_layout Standard
27830 In order to simplify signal handling, a number of macros is provided:
27831 \end_layout
27832
27833 \begin_layout List
27834 \labelwidthstring 00.00.0000
27835 DEF_INTHIGH(name) begin the definition of the interrupt dispatch table for
27836  high priority interrupts.
27837  
27838 \emph on
27839 name
27840 \emph default
27841  is the function name to use.
27842 \end_layout
27843
27844 \begin_layout List
27845 \labelwidthstring 00.00.0000
27846 DEF_INTLOW(name) begin the definition of the interrupt dispatch table fo
27847  low priority interrupt.
27848  
27849 \emph on
27850 name
27851 \emph default
27852  is the function name to use.
27853 \end_layout
27854
27855 \begin_layout List
27856 \labelwidthstring 00.00.0000
27857 DEF_HANDLER(sig,handler) define a handler for signal 
27858 \emph on
27859 sig.
27860 \end_layout
27861
27862 \begin_layout List
27863 \labelwidthstring 00.00.0000
27864 END_DEF end the declaration of the dispatch table.
27865 \end_layout
27866
27867 \begin_layout Standard
27868 Additionally there are two more macros to simplify the declaration of the
27869  signal handler:
27870 \end_layout
27871
27872 \begin_layout List
27873 \labelwidthstring 00.00.0000
27874
27875 \series medium
27876 SIGHANDLER(handler) 
27877 \series default
27878 this declares the function prototype for the 
27879 \emph on
27880 handler
27881 \emph default
27882  function.
27883 \end_layout
27884
27885 \begin_layout List
27886 \labelwidthstring 00.00.0000
27887 SIGHANDLERNAKED(handler) same as SIGHANDLER() but declares a naked function.
27888 \end_layout
27889
27890 \begin_layout Standard
27891 An example of using the macros above is shown below:
27892 \end_layout
27893
27894 \begin_layout LyX-Code
27895 #include <pic18fregs.h>
27896 \end_layout
27897
27898 \begin_layout LyX-Code
27899 #include <signal.h>
27900 \newline
27901
27902 \newline
27903 DEF_INTHIGH(high_int)
27904 \end_layout
27905
27906 \begin_layout LyX-Code
27907 DEF_HANDLER(SIG_TMR0, _tmr0_handler)
27908 \end_layout
27909
27910 \begin_layout LyX-Code
27911 DEF_HANDLER(SIG_BCOL, _bcol_handler)
27912 \end_layout
27913
27914 \begin_layout LyX-Code
27915 END_DEF
27916 \newline
27917
27918 \newline
27919 SIGHANDLER(_tmr0_handler)
27920 \end_layout
27921
27922 \begin_layout LyX-Code
27923 {
27924 \end_layout
27925
27926 \begin_layout LyX-Code
27927   /* action to be taken when timer 0 overflows */
27928 \end_layout
27929
27930 \begin_layout LyX-Code
27931 }
27932 \newline
27933
27934 \newline
27935 SIGHANDLERNAKED(_bcol_handler)
27936 \end_layout
27937
27938 \begin_layout LyX-Code
27939 {
27940 \end_layout
27941
27942 \begin_layout LyX-Code
27943   _asm
27944 \end_layout
27945
27946 \begin_layout LyX-Code
27947     /* action to be taken when bus collision occurs */
27948 \end_layout
27949
27950 \begin_layout LyX-Code
27951     retfie
27952 \end_layout
27953
27954 \begin_layout LyX-Code
27955  _endasm;
27956 \end_layout
27957
27958 \begin_layout LyX-Code
27959 }
27960 \end_layout
27961
27962 \begin_layout Standard
27963
27964 \series bold
27965 NOTES:
27966 \series default
27967  Special care should be taken when using the above scheme:
27968 \end_layout
27969
27970 \begin_layout Itemize
27971 do not place a colon (;) at the end of the DEF_* and END_DEF macros.
27972 \end_layout
27973
27974 \begin_layout Itemize
27975 when declaring SIGHANDLERNAKED handler never forget to use 
27976 \emph on
27977 retfie
27978 \emph default
27979  for proper returning.
27980 \end_layout
27981
27982 \begin_layout Subsection
27983 PIC16 Port -- Tips
27984 \end_layout
27985
27986 \begin_layout Standard
27987 Here you can find some general tips for compiling programs with SDCC/pic16.
27988 \end_layout
27989
27990 \begin_layout Subsubsection
27991 Stack size
27992 \end_layout
27993
27994 \begin_layout Standard
27995 The default stack
27996 \begin_inset LatexCommand \index{PIC16!stack}
27997
27998 \end_inset
27999
28000  size (that is 64 bytes) probably is enough for many programs.
28001  One must take care that when there are many levels of function nesting,
28002  or there is excessive usage of stack, its size should be extended.
28003  An example of such a case is the printf/sprintf family of functions.
28004  If you encounter problems like not being able to print integers, then you
28005  need to set the stack size around the maximum (256 for small stack model).
28006  The following diagram shows what happens when calling printf to print an
28007  integer:
28008 \end_layout
28009
28010 \begin_layout LyX-Code
28011 printf () --> ltoa () --> ultoa () --> divschar ()
28012 \end_layout
28013
28014 \begin_layout Standard
28015 It is should be understood that stack is easily consumed when calling complicate
28016 d functions.
28017  Using command line arguments like -
28018 \begin_inset ERT
28019 status collapsed
28020
28021 \begin_layout Standard
28022
28023
28024 \backslash
28025 /
28026 \end_layout
28027
28028 \end_inset
28029
28030 -fommit-frame-pointer might reduce stack usage by not creating unnecessery
28031  stack frames.
28032  Other ways to reduce stack usage may exist.
28033 \end_layout
28034
28035 \begin_layout Subsection
28036 Known Bugs
28037 \end_layout
28038
28039 \begin_layout Standard
28040 The PIC16 Port currently does not pass SDCC's regression test
28041 \begin_inset LatexCommand \index{Regression test (PIC16)}
28042
28043 \end_inset
28044
28045  suite (see section 
28046 \begin_inset LatexCommand \ref{sec:Quality-control}
28047
28048 \end_inset
28049
28050 ) and thus the snapshot build regression tests for the PIC16 target are
28051  currently disabled for all hosts
28052 \emph on
28053 .
28054 \end_layout
28055
28056 \begin_layout Chapter
28057 Debugging
28058 \end_layout
28059
28060 \begin_layout Standard
28061 There are several approaches to debugging your code.
28062  This chapter is meant to show your options and to give detail on some of
28063  them:
28064 \newline
28065
28066 \newline
28067 When writing your code:
28068 \end_layout
28069
28070 \begin_layout Itemize
28071 write your code with debugging in mind (avoid duplicating code, put conceptually
28072  similar variables into structs, use structured code, have strategic points
28073  within your code where all variables are consistent, ...)
28074 \end_layout
28075
28076 \begin_layout Itemize
28077 run a syntax-checking tool like splint
28078 \begin_inset LatexCommand \index{splint (syntax checking tool)}
28079
28080 \end_inset
28081
28082
28083 \begin_inset LatexCommand \index{lint (syntax checking tool)}
28084
28085 \end_inset
28086
28087  (see -
28088 \begin_inset ERT
28089 status collapsed
28090
28091 \begin_layout Standard
28092
28093
28094 \backslash
28095 /
28096 \end_layout
28097
28098 \end_inset
28099
28100 -more-pedantic 
28101 \begin_inset LatexCommand \ref{lyx:more-pedantic-SPLINT}
28102
28103 \end_inset
28104
28105 ) over the code.
28106 \end_layout
28107
28108 \begin_layout Itemize
28109 for the high level code use a C-compiler (like f.e.
28110  GCC) to compile run and debug the code on your host.
28111  See (see -
28112 \begin_inset ERT
28113 status collapsed
28114
28115 \begin_layout Standard
28116
28117
28118 \backslash
28119 /
28120 \end_layout
28121
28122 \end_inset
28123
28124 -more-pedantic 
28125 \begin_inset LatexCommand \ref{lyx:more-pedantic-SPLINT}
28126
28127 \end_inset
28128
28129 ) on how to handle syntax extensions like __xdata, __at(), ...
28130  
28131 \end_layout
28132
28133 \begin_layout Itemize
28134 use another C-compiler to compile code for your target.
28135  Always an option but not recommended:) And not very likely to help you.
28136  If you seriously consider walking this path you should at least occasionally
28137  check portability of your code.
28138  Most commercial compiler vendors will offer an evaluation version so you
28139  can test compile your code or snippets of your code.
28140 \end_layout
28141
28142 \begin_layout Standard
28143 Debugging on a simulator:
28144 \end_layout
28145
28146 \begin_layout Itemize
28147 there is a separate section about SDCDB (section 
28148 \begin_inset LatexCommand \ref{cha:Debugging-with-SDCDB}
28149
28150 \end_inset
28151
28152 ) below.
28153 \end_layout
28154
28155 \begin_layout Itemize
28156 or (8051 specific) use a freeware/commercial simulator which interfaces
28157  to the AOMF
28158 \begin_inset LatexCommand \index{AOMF, AOMF51}
28159
28160 \end_inset
28161
28162  file (see 
28163 \begin_inset LatexCommand \ref{OMF file}
28164
28165 \end_inset
28166
28167 ) optionally generated by SDCC.
28168 \end_layout
28169
28170 \begin_layout Standard
28171 Debugging On-target: 
28172 \end_layout
28173
28174 \begin_layout Itemize
28175 use a MCU port pin to serially output debug data to the RS232 port of your
28176  host.
28177  You'll probably want some level shifting device typically involving a MAX232
28178  or similar IC.
28179  If the hardware serial port of the MCU is not available search for 'Software
28180  UART' in your favourite search machine.
28181 \end_layout
28182
28183 \begin_layout Itemize
28184 use an on-target monitor.
28185  In this context a monitor is a small program which usually accepts commands
28186  via a serial line and allows to set program counter, to single step through
28187  a program and read/write memory locations.
28188  For the 8051 good examples of monitors are paulmon and cmon51 (see section
28189  
28190 \begin_inset LatexCommand \ref{sec:Related-open-source-tools}
28191
28192 \end_inset
28193
28194 ).
28195 \end_layout
28196
28197 \begin_layout Itemize
28198 toggle MCU port pins at strategic points within your code and use an oscilloscop
28199 e.
28200  A 
28201 \emph on
28202 digital oscilloscope
28203 \emph default
28204
28205 \begin_inset LatexCommand \index{Oscilloscope}
28206
28207 \end_inset
28208
28209  with deep trace memory is really helpful especially if you have to debug
28210  a realtime application.
28211  If you need to monitor more pins than your oscilloscope provides you can
28212  sometimes get away with a small R-2R network.
28213  On a single channel oscilloscope you could f.e.
28214  monitor 2 push-pull driven pins by connecting one via a 10\InsetSpace ~
28215 k
28216 \begin_inset Formula $\Omega$
28217 \end_inset
28218
28219  resistor and the other one by a 5\InsetSpace ~
28220 k
28221 \begin_inset Formula $\Omega$
28222 \end_inset
28223
28224  resistor to the oscilloscope probe (check output drive capability of the
28225  pins you want to monitor).
28226  If you need to monitor many more pins a 
28227 \emph on
28228 logic analyzer
28229 \emph default
28230  will be handy.
28231 \end_layout
28232
28233 \begin_layout Itemize
28234 use an ICE (
28235 \emph on
28236 i
28237 \emph default
28238
28239 \emph on
28240 c
28241 \emph default
28242 ircuit 
28243 \emph on
28244 e
28245 \emph default
28246 mulator
28247 \begin_inset LatexCommand \index{ICE (in circuit emulator)}
28248
28249 \end_inset
28250
28251 ).
28252  Usually very expensive.
28253  And very nice to have too.
28254  And usually locks you (for years...) to the devices the ICE can emulate.
28255  
28256 \end_layout
28257
28258 \begin_layout Itemize
28259 use a remote debugger.
28260  In most 8-bit systems the symbol information is not available on the target,
28261  and a complete debugger is too bulky for the target system.
28262  Therefore usually a debugger on the host system connects to an on-target
28263  debugging stub which accepts only primitive commands.
28264  
28265 \newline
28266 Terms to enter into your favourite search engine could be 'remote debugging',
28267  'gdb stub' or 'inferior debugger'.
28268  (is there one?)
28269 \end_layout
28270
28271 \begin_layout Itemize
28272 use an on target hardware debugger.
28273  Some of the more modern MCUs include hardware support for setting break
28274  points and monitoring/changing variables by using dedicated hardware pins.
28275  This facility doesn't require additional code to run on the target and
28276  
28277 \emph on
28278 usually
28279 \emph default
28280  doesn't affect runtime behaviour until a breakpoint is hit.
28281  For the mcs51 most hardware debuggers use the AOMF
28282 \begin_inset LatexCommand \index{AOMF, AOMF51}
28283
28284 \end_inset
28285
28286  file (see 
28287 \begin_inset LatexCommand \ref{OMF file}
28288
28289 \end_inset
28290
28291 ) as input file.
28292  
28293 \end_layout
28294
28295 \begin_layout Standard
28296 Last not least:
28297 \end_layout
28298
28299 \begin_layout Itemize
28300 if you are not familiar with any of the following terms you're likely to
28301  run into problems rather sooner than later: 
28302 \emph on
28303 volatile
28304 \emph default
28305
28306 \emph on
28307 atomic
28308 \emph default
28309
28310 \emph on
28311 memory map
28312 \emph default
28313
28314 \emph on
28315 overlay
28316 \emph default
28317 .
28318  As an embedded programmer you 
28319 \emph on
28320 have
28321 \emph default
28322  to know them so why not look them up 
28323 \emph on
28324 before
28325 \emph default
28326  you have problems?)
28327 \end_layout
28328
28329 \begin_layout Itemize
28330 tell someone else about your problem (actually this is a surprisingly effective
28331  means to hunt down the bug even if the listener is not familiar with your
28332  environment).
28333  As 'failure to communicate' is probably one of the job-induced deformations
28334  of an embedded programmer this is highly encouraged.
28335 \end_layout
28336
28337 \begin_layout Section
28338 Debugging with SDCDB
28339 \begin_inset LatexCommand \label{cha:Debugging-with-SDCDB}
28340
28341 \end_inset
28342
28343
28344 \begin_inset LatexCommand \index{SDCDB (debugger)}
28345
28346 \end_inset
28347
28348  
28349 \end_layout
28350
28351 \begin_layout Standard
28352 SDCC is distributed with a source level debugger
28353 \begin_inset LatexCommand \index{Debugger}
28354
28355 \end_inset
28356
28357 .
28358  The debugger uses a command line interface, the command repertoire of the
28359  debugger has been kept as close to gdb
28360 \begin_inset LatexCommand \index{gdb}
28361
28362 \end_inset
28363
28364  (the GNU debugger) as possible.
28365  The configuration and build process is part of the standard compiler installati
28366 on, which also builds and installs the debugger in the target directory
28367  specified during configuration.
28368  The debugger allows you debug BOTH at the C source and at the ASM source
28369  level.
28370 \end_layout
28371
28372 \begin_layout Subsection
28373 Compiling for Debugging
28374 \end_layout
28375
28376 \begin_layout Standard
28377 The -
28378 \begin_inset ERT
28379 status collapsed
28380
28381 \begin_layout Standard
28382
28383
28384 \backslash
28385 /
28386 \end_layout
28387
28388 \end_inset
28389
28390 -debug
28391 \begin_inset LatexCommand \index{-\/-debug}
28392
28393 \end_inset
28394
28395  option must be specified for all files for which debug information is to
28396  be generated.
28397  The compiler generates a .adb file for each of these files.
28398  The linker creates the .cdb
28399 \begin_inset LatexCommand \index{<file>.cdb}
28400
28401 \end_inset
28402
28403  file from the .adb
28404 \begin_inset LatexCommand \index{<file>.adb}
28405
28406 \end_inset
28407
28408  files and the address information.
28409  This .cdb is used by the debugger.
28410 \end_layout
28411
28412 \begin_layout Subsection
28413 How the Debugger Works
28414 \end_layout
28415
28416 \begin_layout Standard
28417 When the -
28418 \begin_inset ERT
28419 status collapsed
28420
28421 \begin_layout Standard
28422
28423
28424 \backslash
28425 /
28426 \end_layout
28427
28428 \end_inset
28429
28430 -debug option is specified the compiler generates extra symbol information
28431  some of which are put into the assembler source and some are put into the
28432  .adb file.
28433  Then the linker creates the .cdb file from the individual .adb files with
28434  the address information for the symbols.
28435  The debugger reads the symbolic information generated by the compiler &
28436  the address information generated by the linker.
28437  It uses the SIMULATOR (Daniel's S51) to execute the program, the program
28438  execution is controlled by the debugger.
28439  When a command is issued for the debugger, it translates it into appropriate
28440  commands for the simulator.
28441  (Currently SDCDM only connects to the simulator but 
28442 \emph on
28443 newcdb
28444 \emph default
28445  at 
28446 \begin_inset LatexCommand \url{http://ec2drv.sf.net/}
28447
28448 \end_inset
28449
28450  is an effort to connect directly to the hardware.) 
28451 \end_layout
28452
28453 \begin_layout Subsection
28454 Starting the Debugger SDCDB
28455 \end_layout
28456
28457 \begin_layout Standard
28458 The debugger can be started using the following command line.
28459  (Assume the file you are debugging has the file name foo).
28460 \newline
28461
28462 \newline
28463
28464 \family sans
28465 \series bold
28466 sdcdb foo
28467 \newline
28468
28469 \family default
28470 \series default
28471
28472 \newline
28473 The debugger will look for the following files.
28474 \end_layout
28475
28476 \begin_layout Itemize
28477 foo.c - the source file.
28478 \end_layout
28479
28480 \begin_layout Itemize
28481 foo.cdb - the debugger symbol information file.
28482 \end_layout
28483
28484 \begin_layout Itemize
28485 foo.ihx - the Intel hex format
28486 \begin_inset LatexCommand \index{Intel hex format}
28487
28488 \end_inset
28489
28490  object file.
28491 \end_layout
28492
28493 \begin_layout Subsection
28494 SDCDB Command Line Options
28495 \end_layout
28496
28497 \begin_layout Itemize
28498 -
28499 \begin_inset ERT
28500 status collapsed
28501
28502 \begin_layout Standard
28503
28504
28505 \backslash
28506 /
28507 \end_layout
28508
28509 \end_inset
28510
28511 -directory=<source file directory> this option can used to specify the directory
28512  search list.
28513  The debugger will look into the directory list specified for source, cdb
28514  & ihx files.
28515  The items in the directory list must be separated by ':', e.g.
28516  if the source files can be in the directories /home/src1 and /home/src2,
28517  the -
28518 \begin_inset ERT
28519 status collapsed
28520
28521 \begin_layout Standard
28522
28523
28524 \backslash
28525 /
28526 \end_layout
28527
28528 \end_inset
28529
28530 -directory option should be -
28531 \begin_inset ERT
28532 status collapsed
28533
28534 \begin_layout Standard
28535
28536
28537 \backslash
28538 /
28539 \end_layout
28540
28541 \end_inset
28542
28543 -directory=/home/src1:/home/src2.
28544  Note there can be no spaces in the option.
28545  
28546 \end_layout
28547
28548 \begin_layout Itemize
28549 -cd <directory> - change to the <directory>.
28550 \end_layout
28551
28552 \begin_layout Itemize
28553 -fullname - used by GUI front ends.
28554 \end_layout
28555
28556 \begin_layout Itemize
28557 -cpu <cpu-type> - this argument is passed to the simulator please see the
28558  simulator docs for details.
28559 \end_layout
28560
28561 \begin_layout Itemize
28562 -X <Clock frequency > this options is passed to the simulator please see
28563  the simulator docs for details.
28564 \end_layout
28565
28566 \begin_layout Itemize
28567 -s <serial port file> passed to simulator see the simulator docs for details.
28568 \end_layout
28569
28570 \begin_layout Itemize
28571 -S <serial in,out> passed to simulator see the simulator docs for details.
28572 \end_layout
28573
28574 \begin_layout Itemize
28575 -k <port number> passed to simulator see the simulator docs for details.
28576 \end_layout
28577
28578 \begin_layout Subsection
28579 SDCDB Debugger Commands
28580 \end_layout
28581
28582 \begin_layout Standard
28583 As mentioned earlier the command interface for the debugger has been deliberatel
28584 y kept as close the GNU debugger gdb, as possible.
28585  This will help the integration with existing graphical user interfaces
28586  (like ddd, xxgdb or xemacs) existing for the GNU debugger.
28587  If you use a graphical user interface for the debugger you can skip this
28588  section.
28589 \end_layout
28590
28591 \begin_layout Subsubsection*
28592 break [line | file:line | function | file:function]
28593 \end_layout
28594
28595 \begin_layout Standard
28596 Set breakpoint at specified line or function:
28597 \newline
28598
28599 \newline
28600
28601 \family sans
28602 \series bold
28603 sdcdb>break 100 
28604 \newline
28605 sdcdb>break foo.c:100
28606 \newline
28607 sdcdb>break funcfoo
28608 \newline
28609 sdcdb>break foo.c:funcfoo
28610 \end_layout
28611
28612 \begin_layout Subsubsection*
28613 clear [line | file:line | function | file:function ]
28614 \end_layout
28615
28616 \begin_layout Standard
28617 Clear breakpoint at specified line or function:
28618 \newline
28619
28620 \newline
28621
28622 \family sans
28623 \series bold
28624 sdcdb>clear 100
28625 \newline
28626 sdcdb>clear foo.c:100
28627 \newline
28628 sdcdb>clear funcfoo
28629 \newline
28630 sdcdb>clear foo.c:funcfoo
28631 \end_layout
28632
28633 \begin_layout Subsubsection*
28634 continue
28635 \end_layout
28636
28637 \begin_layout Standard
28638 Continue program being debugged, after breakpoint.
28639 \end_layout
28640
28641 \begin_layout Subsubsection*
28642 finish
28643 \end_layout
28644
28645 \begin_layout Standard
28646 Execute till the end of the current function.
28647 \end_layout
28648
28649 \begin_layout Subsubsection*
28650 delete [n]
28651 \end_layout
28652
28653 \begin_layout Standard
28654 Delete breakpoint number 'n'.
28655  If used without any option clear ALL user defined break points.
28656 \end_layout
28657
28658 \begin_layout Subsubsection*
28659 info [break | stack | frame | registers ]
28660 \end_layout
28661
28662 \begin_layout Itemize
28663 info break - list all breakpoints
28664 \end_layout
28665
28666 \begin_layout Itemize
28667 info stack - show the function call stack.
28668 \end_layout
28669
28670 \begin_layout Itemize
28671 info frame - show information about the current execution frame.
28672 \end_layout
28673
28674 \begin_layout Itemize
28675 info registers - show content of all registers.
28676 \end_layout
28677
28678 \begin_layout Subsubsection*
28679 step
28680 \end_layout
28681
28682 \begin_layout Standard
28683 Step program until it reaches a different source line.
28684  Note: pressing <return> repeats the last command.
28685 \end_layout
28686
28687 \begin_layout Subsubsection*
28688 next
28689 \end_layout
28690
28691 \begin_layout Standard
28692 Step program, proceeding through subroutine calls.
28693 \end_layout
28694
28695 \begin_layout Subsubsection*
28696 run
28697 \end_layout
28698
28699 \begin_layout Standard
28700 Start debugged program.
28701 \end_layout
28702
28703 \begin_layout Subsubsection*
28704 ptype variable 
28705 \end_layout
28706
28707 \begin_layout Standard
28708 Print type information of the variable.
28709 \end_layout
28710
28711 \begin_layout Subsubsection*
28712 print variable
28713 \end_layout
28714
28715 \begin_layout Standard
28716 print value of variable.
28717 \end_layout
28718
28719 \begin_layout Subsubsection*
28720 file filename
28721 \end_layout
28722
28723 \begin_layout Standard
28724 load the given file name.
28725  Note this is an alternate method of loading file for debugging.
28726 \end_layout
28727
28728 \begin_layout Subsubsection*
28729 frame
28730 \end_layout
28731
28732 \begin_layout Standard
28733 print information about current frame.
28734 \end_layout
28735
28736 \begin_layout Subsubsection*
28737 set srcmode
28738 \end_layout
28739
28740 \begin_layout Standard
28741 Toggle between C source & assembly source.
28742 \end_layout
28743
28744 \begin_layout Subsubsection*
28745 ! simulator command
28746 \end_layout
28747
28748 \begin_layout Standard
28749 Send the string following '!' to the simulator, the simulator response is
28750  displayed.
28751  Note the debugger does not interpret the command being sent to the simulator,
28752  so if a command like 'go' is sent the debugger can loose its execution
28753  context and may display incorrect values.
28754 \end_layout
28755
28756 \begin_layout Subsubsection*
28757 quit
28758 \end_layout
28759
28760 \begin_layout Standard
28761 "Watch me now.
28762  Iam going Down.
28763  My name is Bobby Brown"
28764 \end_layout
28765
28766 \begin_layout Subsection
28767 Interfacing SDCDB with DDD
28768 \end_layout
28769
28770 \begin_layout Standard
28771 \begin_inset Note Note
28772 status collapsed
28773
28774 \begin_layout Standard
28775 The screenshot was converted from png to eps with: 
28776 \begin_inset Quotes sld
28777 \end_inset
28778
28779 bmeps -c -e8f -p3 ddd_example.png >ddd_example.eps
28780 \begin_inset Quotes srd
28781 \end_inset
28782
28783  which produces a pretty compact eps file which is free from compression
28784  artifacts.
28785 \end_layout
28786
28787 \begin_layout Standard
28788 The screenshot was included in sdccman.lyx cvs version 1.120 but later removed
28789  as this broke the build system on Sourceforge (pdf-file was broken.
28790  pdflatex does not accept eps files).
28791 \end_layout
28792
28793 \end_inset
28794
28795
28796 \end_layout
28797
28798 \begin_layout Standard
28799 The 
28800 \emph on
28801 p
28802 \emph default
28803 ortable 
28804 \emph on
28805 n
28806 \emph default
28807 etwork 
28808 \emph on
28809 g
28810 \emph default
28811 raphics File 
28812 \size footnotesize
28813
28814 \begin_inset LatexCommand \url{http://sdcc.svn.sourceforge.net/viewvc/*checkout*/sdcc/trunk/sdcc/doc/figures/ddd_example.png}
28815
28816 \end_inset
28817
28818
28819 \size default
28820  shows a screenshot of a debugging session with DDD
28821 \begin_inset LatexCommand \index{DDD (debugger)}
28822
28823 \end_inset
28824
28825  (Unix only) on a simulated 8032.
28826  The debugging session might not run as smoothly as the screenshot suggests.
28827  The debugger allows setting of breakpoints, displaying and changing variables,
28828  single stepping through C and assembler code.
28829  
28830 \newline
28831 The source was compiled with 
28832 \family sans
28833 \series bold
28834
28835 \newline
28836
28837 \newline
28838 sdcc -
28839 \family default
28840 \series default
28841
28842 \begin_inset ERT
28843 status collapsed
28844
28845 \begin_layout Standard
28846
28847
28848 \backslash
28849 /
28850 \end_layout
28851
28852 \end_inset
28853
28854
28855 \family sans
28856 \series bold
28857 -debug ddd_example.c
28858 \family default
28859 \series default
28860  
28861 \family sans
28862 \series bold
28863
28864 \newline
28865
28866 \family default
28867 \series default
28868
28869 \newline
28870 and DDD was invoked with 
28871 \family sans
28872 \series bold
28873
28874 \newline
28875
28876 \newline
28877 ddd -debugger "sdcdb -cpu 8032 ddd_example"
28878 \end_layout
28879
28880 \begin_layout Standard
28881 \begin_inset Note Note
28882 status open
28883
28884 \begin_layout Standard
28885 Check that the double quotes or an apostroph within the command line survive
28886  the LyX tool chain.
28887  Previously the apostrophs got slanted in the PDF output so a cut and paste
28888  did not work.
28889 \end_layout
28890
28891 \end_inset
28892
28893
28894 \end_layout
28895
28896 \begin_layout Subsection
28897 Interfacing SDCDB with XEmacs
28898 \begin_inset LatexCommand \index{XEmacs}
28899
28900 \end_inset
28901
28902
28903 \begin_inset LatexCommand \index{Emacs}
28904
28905 \end_inset
28906
28907
28908 \end_layout
28909
28910 \begin_layout Standard
28911 Two files (in emacs lisp) are provided for the interfacing with XEmacs,
28912  sdcdb.el and sdcdbsrc.el.
28913  These two files can be found in the $(prefix)/bin directory after the installat
28914 ion is complete.
28915  These files need to be loaded into XEmacs for the interface to work.
28916  This can be done at XEmacs startup time by inserting the following into
28917  your '.xemacs' file (which can be found in your HOME directory): 
28918 \newline
28919
28920 \newline
28921
28922 \family typewriter
28923 (load-file sdcdbsrc.el) 
28924 \family default
28925
28926 \newline
28927
28928 \newline
28929 .xemacs is a lisp file so the () around the command is REQUIRED.
28930  The files can also be loaded dynamically while XEmacs is running, set the
28931  environment variable 'EMACSLOADPATH' to the installation bin directory
28932  (<installdir>/bin), then enter the following command ESC-x load-file sdcdbsrc.
28933  To start the interface enter the following command: 
28934 \newline
28935
28936 \newline
28937
28938 \family sans
28939 \series bold
28940 ESC-x sdcdbsrc
28941 \family default
28942 \series default
28943
28944 \newline
28945
28946 \newline
28947 You will prompted to enter the file name to be debugged.
28948  
28949 \newline
28950
28951 \newline
28952 The command line options that are passed to the simulator directly are
28953  bound to default values in the file sdcdbsrc.el.
28954  The variables are listed below, these values maybe changed as required.
28955 \end_layout
28956
28957 \begin_layout Itemize
28958 sdcdbsrc-cpu-type '51
28959 \end_layout
28960
28961 \begin_layout Itemize
28962 sdcdbsrc-frequency '11059200
28963 \end_layout
28964
28965 \begin_layout Itemize
28966 sdcdbsrc-serial nil
28967 \end_layout
28968
28969 \begin_layout Standard
28970 The following is a list of key mapping for the debugger interface.
28971 \end_layout
28972
28973 \begin_layout Standard
28974 \InsetSpace ~
28975
28976 \family typewriter
28977
28978 \newline
28979 ;;\InsetSpace ~
28980 Current Listing :: 
28981 \newline
28982 ;;key\InsetSpace ~
28983 \InsetSpace ~
28984 \InsetSpace ~
28985 \InsetSpace ~
28986 \InsetSpace ~
28987 \InsetSpace ~
28988 \InsetSpace ~
28989 \InsetSpace ~
28990 \InsetSpace ~
28991 \InsetSpace ~
28992 \InsetSpace ~
28993 \InsetSpace ~
28994 \InsetSpace ~
28995 \InsetSpace ~
28996 binding\InsetSpace ~
28997 \InsetSpace ~
28998 \InsetSpace ~
28999 \InsetSpace ~
29000 \InsetSpace ~
29001 \InsetSpace ~
29002 \InsetSpace ~
29003 \InsetSpace ~
29004 \InsetSpace ~
29005 \InsetSpace ~
29006 \InsetSpace ~
29007 \InsetSpace ~
29008 \InsetSpace ~
29009 \InsetSpace ~
29010 \InsetSpace ~
29011 \InsetSpace ~
29012 \InsetSpace ~
29013 \InsetSpace ~
29014 \InsetSpace ~
29015 \InsetSpace ~
29016 \InsetSpace ~
29017 \InsetSpace ~
29018 Comment 
29019 \newline
29020 ;;---\InsetSpace ~
29021 \InsetSpace ~
29022 \InsetSpace ~
29023 \InsetSpace ~
29024 \InsetSpace ~
29025 \InsetSpace ~
29026 \InsetSpace ~
29027 \InsetSpace ~
29028 \InsetSpace ~
29029 \InsetSpace ~
29030 \InsetSpace ~
29031 \InsetSpace ~
29032 \InsetSpace ~
29033 \InsetSpace ~
29034 -------\InsetSpace ~
29035 \InsetSpace ~
29036 \InsetSpace ~
29037 \InsetSpace ~
29038 \InsetSpace ~
29039 \InsetSpace ~
29040 \InsetSpace ~
29041 \InsetSpace ~
29042 \InsetSpace ~
29043 \InsetSpace ~
29044 \InsetSpace ~
29045 \InsetSpace ~
29046 \InsetSpace ~
29047 \InsetSpace ~
29048 \InsetSpace ~
29049 \InsetSpace ~
29050 \InsetSpace ~
29051 \InsetSpace ~
29052 \InsetSpace ~
29053 \InsetSpace ~
29054 \InsetSpace ~
29055 \InsetSpace ~
29056 -------
29057 \newline
29058 ;; 
29059 \newline
29060 ;;\InsetSpace ~
29061 n\InsetSpace ~
29062 \InsetSpace ~
29063 \InsetSpace ~
29064 \InsetSpace ~
29065 \InsetSpace ~
29066 \InsetSpace ~
29067 \InsetSpace ~
29068 \InsetSpace ~
29069 \InsetSpace ~
29070 \InsetSpace ~
29071 \InsetSpace ~
29072 \InsetSpace ~
29073 \InsetSpace ~
29074 \InsetSpace ~
29075 \InsetSpace ~
29076 sdcdb-next-fro
29077 m-src\InsetSpace ~
29078 \InsetSpace ~
29079 \InsetSpace ~
29080 \InsetSpace ~
29081 \InsetSpace ~
29082 \InsetSpace ~
29083 \InsetSpace ~
29084 \InsetSpace ~
29085 \InsetSpace ~
29086 \InsetSpace ~
29087 SDCDB next command 
29088 \newline
29089 ;;\InsetSpace ~
29090 b\InsetSpace ~
29091 \InsetSpace ~
29092 \InsetSpace ~
29093 \InsetSpace ~
29094 \InsetSpace ~
29095 \InsetSpace ~
29096 \InsetSpace ~
29097 \InsetSpace ~
29098 \InsetSpace ~
29099 \InsetSpace ~
29100 \InsetSpace ~
29101 \InsetSpace ~
29102 \InsetSpace ~
29103 \InsetSpace ~
29104 \InsetSpace ~
29105 sdcdb-back-from-src\InsetSpace ~
29106 \InsetSpace ~
29107 \InsetSpace ~
29108 \InsetSpace ~
29109 \InsetSpace ~
29110 \InsetSpace ~
29111 \InsetSpace ~
29112 \InsetSpace ~
29113 \InsetSpace ~
29114 \InsetSpace ~
29115 SDCDB back command 
29116 \newline
29117 ;;\InsetSpace ~
29118 c\InsetSpace ~
29119 \InsetSpace ~
29120 \InsetSpace ~
29121 \InsetSpace ~
29122 \InsetSpace ~
29123 \InsetSpace ~
29124 \InsetSpace ~
29125 \InsetSpace ~
29126 \InsetSpace ~
29127 \InsetSpace ~
29128 \InsetSpace ~
29129 \InsetSpace ~
29130 \InsetSpace ~
29131 \InsetSpace ~
29132 \InsetSpace ~
29133 sdcdb-cont-f
29134 rom-src\InsetSpace ~
29135 \InsetSpace ~
29136 \InsetSpace ~
29137 \InsetSpace ~
29138 \InsetSpace ~
29139 \InsetSpace ~
29140 \InsetSpace ~
29141 \InsetSpace ~
29142 \InsetSpace ~
29143 \InsetSpace ~
29144 SDCDB continue command
29145 \newline
29146 ;;\InsetSpace ~
29147 s\InsetSpace ~
29148 \InsetSpace ~
29149 \InsetSpace ~
29150 \InsetSpace ~
29151 \InsetSpace ~
29152 \InsetSpace ~
29153 \InsetSpace ~
29154 \InsetSpace ~
29155 \InsetSpace ~
29156 \InsetSpace ~
29157 \InsetSpace ~
29158 \InsetSpace ~
29159 \InsetSpace ~
29160 \InsetSpace ~
29161 \InsetSpace ~
29162 sdcdb-step-from-src\InsetSpace ~
29163 \InsetSpace ~
29164 \InsetSpace ~
29165 \InsetSpace ~
29166 \InsetSpace ~
29167 \InsetSpace ~
29168 \InsetSpace ~
29169 \InsetSpace ~
29170 \InsetSpace ~
29171 \InsetSpace ~
29172 SDCDB step command 
29173 \newline
29174 ;;\InsetSpace ~
29175 ?\InsetSpace ~
29176 \InsetSpace ~
29177 \InsetSpace ~
29178 \InsetSpace ~
29179 \InsetSpace ~
29180 \InsetSpace ~
29181 \InsetSpace ~
29182 \InsetSpace ~
29183 \InsetSpace ~
29184 \InsetSpace ~
29185 \InsetSpace ~
29186 \InsetSpace ~
29187 \InsetSpace ~
29188 \InsetSpace ~
29189 \InsetSpace ~
29190 sdcdb-w
29191 hatis-c-sexp\InsetSpace ~
29192 \InsetSpace ~
29193 \InsetSpace ~
29194 \InsetSpace ~
29195 \InsetSpace ~
29196 \InsetSpace ~
29197 \InsetSpace ~
29198 \InsetSpace ~
29199 \InsetSpace ~
29200 \InsetSpace ~
29201 SDCDB ptypecommand for data at 
29202 \newline
29203 ;;\InsetSpace ~
29204 \InsetSpace ~
29205 \InsetSpace ~
29206 \InsetSpace ~
29207 \InsetSpace ~
29208 \InsetSpace ~
29209 \InsetSpace ~
29210 \InsetSpace ~
29211 \InsetSpace ~
29212 \InsetSpace ~
29213 \InsetSpace ~
29214 \InsetSpace ~
29215 \InsetSpace ~
29216 \InsetSpace ~
29217 \InsetSpace ~
29218 \InsetSpace ~
29219 \InsetSpace ~
29220 \InsetSpace ~
29221 \InsetSpace ~
29222 \InsetSpace ~
29223 \InsetSpace ~
29224 \InsetSpace ~
29225 \InsetSpace ~
29226 \InsetSpace ~
29227 \InsetSpace ~
29228 \InsetSpace ~
29229 \InsetSpace ~
29230 \InsetSpace ~
29231 \InsetSpace ~
29232 \InsetSpace ~
29233 \InsetSpace ~
29234 \InsetSpace ~
29235 \InsetSpace ~
29236 \InsetSpace ~
29237 \InsetSpace ~
29238 \InsetSpace ~
29239 \InsetSpace ~
29240 \InsetSpace ~
29241 \InsetSpace ~
29242 \InsetSpace ~
29243 \InsetSpace ~
29244 \InsetSpace ~
29245 \InsetSpace ~
29246 \InsetSpace ~
29247 \InsetSpace ~
29248 \InsetSpace ~
29249 \InsetSpace ~
29250 buffer point 
29251 \newline
29252 ;;\InsetSpace ~
29253 x\InsetSpace ~
29254 \InsetSpace ~
29255 \InsetSpace ~
29256 \InsetSpace ~
29257 \InsetSpace ~
29258 \InsetSpace ~
29259 \InsetSpace ~
29260 \InsetSpace ~
29261 \InsetSpace ~
29262 \InsetSpace ~
29263 \InsetSpace ~
29264 \InsetSpace ~
29265 \InsetSpace ~
29266 \InsetSpace ~
29267 \InsetSpace ~
29268 sdcdbsrc-delete\InsetSpace ~
29269 \InsetSpace ~
29270 \InsetSpace ~
29271 \InsetSpace ~
29272 \InsetSpace ~
29273 \InsetSpace ~
29274 \InsetSpace ~
29275 \InsetSpace ~
29276 \InsetSpace ~
29277 \InsetSpace ~
29278 \InsetSpace ~
29279 \InsetSpace ~
29280 \InsetSpace ~
29281 \InsetSpace ~
29282 SDCD
29283 B Delete all breakpoints if no arg 
29284 \newline
29285 ;;\InsetSpace ~
29286 \InsetSpace ~
29287 \InsetSpace ~
29288 \InsetSpace ~
29289 \InsetSpace ~
29290 \InsetSpace ~
29291 \InsetSpace ~
29292 \InsetSpace ~
29293 \InsetSpace ~
29294 \InsetSpace ~
29295 \InsetSpace ~
29296 \InsetSpace ~
29297 \InsetSpace ~
29298 \InsetSpace ~
29299 \InsetSpace ~
29300 \InsetSpace ~
29301 \InsetSpace ~
29302 \InsetSpace ~
29303 \InsetSpace ~
29304 \InsetSpace ~
29305 \InsetSpace ~
29306 \InsetSpace ~
29307 \InsetSpace ~
29308 \InsetSpace ~
29309 \InsetSpace ~
29310 \InsetSpace ~
29311 \InsetSpace ~
29312 \InsetSpace ~
29313 \InsetSpace ~
29314 \InsetSpace ~
29315 \InsetSpace ~
29316 \InsetSpace ~
29317 \InsetSpace ~
29318 \InsetSpace ~
29319 \InsetSpace ~
29320 \InsetSpace ~
29321 \InsetSpace ~
29322 \InsetSpace ~
29323 \InsetSpace ~
29324 \InsetSpace ~
29325 \InsetSpace ~
29326 \InsetSpace ~
29327 \InsetSpace ~
29328 \InsetSpace ~
29329 \InsetSpace ~
29330 \InsetSpace ~
29331 \InsetSpace ~
29332 given or delete arg (C-u arg x) 
29333 \newline
29334 ;;\InsetSpace ~
29335 m\InsetSpace ~
29336 \InsetSpace ~
29337 \InsetSpace ~
29338 \InsetSpace ~
29339 \InsetSpace ~
29340 \InsetSpace ~
29341 \InsetSpace ~
29342 \InsetSpace ~
29343 \InsetSpace ~
29344 \InsetSpace ~
29345 \InsetSpace ~
29346 \InsetSpace ~
29347 \InsetSpace ~
29348 \InsetSpace ~
29349 \InsetSpace ~
29350 sdcdbsrc
29351 -frame\InsetSpace ~
29352 \InsetSpace ~
29353 \InsetSpace ~
29354 \InsetSpace ~
29355 \InsetSpace ~
29356 \InsetSpace ~
29357 \InsetSpace ~
29358 \InsetSpace ~
29359 \InsetSpace ~
29360 \InsetSpace ~
29361 \InsetSpace ~
29362 \InsetSpace ~
29363 \InsetSpace ~
29364 \InsetSpace ~
29365 \InsetSpace ~
29366 SDCDB Display current frame if no arg, 
29367 \newline
29368 ;;\InsetSpace ~
29369 \InsetSpace ~
29370 \InsetSpace ~
29371 \InsetSpace ~
29372 \InsetSpace ~
29373 \InsetSpace ~
29374 \InsetSpace ~
29375 \InsetSpace ~
29376 \InsetSpace ~
29377 \InsetSpace ~
29378 \InsetSpace ~
29379 \InsetSpace ~
29380 \InsetSpace ~
29381 \InsetSpace ~
29382 \InsetSpace ~
29383 \InsetSpace ~
29384 \InsetSpace ~
29385 \InsetSpace ~
29386 \InsetSpace ~
29387 \InsetSpace ~
29388 \InsetSpace ~
29389 \InsetSpace ~
29390 \InsetSpace ~
29391 \InsetSpace ~
29392 \InsetSpace ~
29393 \InsetSpace ~
29394 \InsetSpace ~
29395 \InsetSpace ~
29396 \InsetSpace ~
29397 \InsetSpace ~
29398 \InsetSpace ~
29399 \InsetSpace ~
29400 \InsetSpace ~
29401 \InsetSpace ~
29402 \InsetSpace ~
29403 \InsetSpace ~
29404 \InsetSpace ~
29405 \InsetSpace ~
29406 \InsetSpace ~
29407 \InsetSpace ~
29408 \InsetSpace ~
29409 \InsetSpace ~
29410 \InsetSpace ~
29411 \InsetSpace ~
29412 \InsetSpace ~
29413 \InsetSpace ~
29414 \InsetSpace ~
29415 given or display frame arg
29416  
29417 \newline
29418 ;;\InsetSpace ~
29419 \InsetSpace ~
29420 \InsetSpace ~
29421 \InsetSpace ~
29422 \InsetSpace ~
29423 \InsetSpace ~
29424 \InsetSpace ~
29425 \InsetSpace ~
29426 \InsetSpace ~
29427 \InsetSpace ~
29428 \InsetSpace ~
29429 \InsetSpace ~
29430 \InsetSpace ~
29431 \InsetSpace ~
29432 \InsetSpace ~
29433 \InsetSpace ~
29434 \InsetSpace ~
29435 \InsetSpace ~
29436 \InsetSpace ~
29437 \InsetSpace ~
29438 \InsetSpace ~
29439 \InsetSpace ~
29440 \InsetSpace ~
29441 \InsetSpace ~
29442 \InsetSpace ~
29443 \InsetSpace ~
29444 \InsetSpace ~
29445 \InsetSpace ~
29446 \InsetSpace ~
29447 \InsetSpace ~
29448 \InsetSpace ~
29449 \InsetSpace ~
29450 \InsetSpace ~
29451 \InsetSpace ~
29452 \InsetSpace ~
29453 \InsetSpace ~
29454 \InsetSpace ~
29455 \InsetSpace ~
29456 \InsetSpace ~
29457 \InsetSpace ~
29458 \InsetSpace ~
29459 \InsetSpace ~
29460 \InsetSpace ~
29461 \InsetSpace ~
29462 \InsetSpace ~
29463 \InsetSpace ~
29464 \InsetSpace ~
29465 buffer point 
29466 \newline
29467 ;;\InsetSpace ~
29468 !\InsetSpace ~
29469 \InsetSpace ~
29470 \InsetSpace ~
29471 \InsetSpace ~
29472 \InsetSpace ~
29473 \InsetSpace ~
29474 \InsetSpace ~
29475 \InsetSpace ~
29476 \InsetSpace ~
29477 \InsetSpace ~
29478 \InsetSpace ~
29479 \InsetSpace ~
29480 \InsetSpace ~
29481 \InsetSpace ~
29482 \InsetSpace ~
29483 sdcdbsrc-goto-sdcdb\InsetSpace ~
29484 \InsetSpace ~
29485 \InsetSpace ~
29486 \InsetSpace ~
29487 \InsetSpace ~
29488 \InsetSpace ~
29489 \InsetSpace ~
29490 \InsetSpace ~
29491 \InsetSpace ~
29492 \InsetSpace ~
29493 Goto the SDCDB output buffer 
29494 \newline
29495 ;;\InsetSpace ~
29496 p\InsetSpace ~
29497 \InsetSpace ~
29498 \InsetSpace ~
29499 \InsetSpace ~
29500 \InsetSpace ~
29501 \InsetSpace ~
29502 \InsetSpace ~
29503 \InsetSpace ~
29504 \InsetSpace ~
29505 \InsetSpace ~
29506 \InsetSpace ~
29507 \InsetSpace ~
29508 \InsetSpace ~
29509 \InsetSpace ~
29510 \InsetSpace ~
29511 sdcdb-prin
29512 t-c-sexp\InsetSpace ~
29513 \InsetSpace ~
29514 \InsetSpace ~
29515 \InsetSpace ~
29516 \InsetSpace ~
29517 \InsetSpace ~
29518 \InsetSpace ~
29519 \InsetSpace ~
29520 \InsetSpace ~
29521 \InsetSpace ~
29522 \InsetSpace ~
29523 SDCDB print command for data at 
29524 \newline
29525 ;;\InsetSpace ~
29526 \InsetSpace ~
29527 \InsetSpace ~
29528 \InsetSpace ~
29529 \InsetSpace ~
29530 \InsetSpace ~
29531 \InsetSpace ~
29532 \InsetSpace ~
29533 \InsetSpace ~
29534 \InsetSpace ~
29535 \InsetSpace ~
29536 \InsetSpace ~
29537 \InsetSpace ~
29538 \InsetSpace ~
29539 \InsetSpace ~
29540 \InsetSpace ~
29541 \InsetSpace ~
29542 \InsetSpace ~
29543 \InsetSpace ~
29544 \InsetSpace ~
29545 \InsetSpace ~
29546 \InsetSpace ~
29547 \InsetSpace ~
29548 \InsetSpace ~
29549 \InsetSpace ~
29550 \InsetSpace ~
29551 \InsetSpace ~
29552 \InsetSpace ~
29553 \InsetSpace ~
29554 \InsetSpace ~
29555 \InsetSpace ~
29556 \InsetSpace ~
29557 \InsetSpace ~
29558 \InsetSpace ~
29559 \InsetSpace ~
29560 \InsetSpace ~
29561 \InsetSpace ~
29562 \InsetSpace ~
29563 \InsetSpace ~
29564 \InsetSpace ~
29565 \InsetSpace ~
29566 \InsetSpace ~
29567 \InsetSpace ~
29568 \InsetSpace ~
29569 \InsetSpace ~
29570 \InsetSpace ~
29571 \InsetSpace ~
29572 buffer point 
29573 \newline
29574 ;;\InsetSpace ~
29575 g\InsetSpace ~
29576 \InsetSpace ~
29577 \InsetSpace ~
29578 \InsetSpace ~
29579 \InsetSpace ~
29580 \InsetSpace ~
29581 \InsetSpace ~
29582 \InsetSpace ~
29583 \InsetSpace ~
29584 \InsetSpace ~
29585 \InsetSpace ~
29586 \InsetSpace ~
29587 \InsetSpace ~
29588 \InsetSpace ~
29589 \InsetSpace ~
29590 sdcdbsrc-goto-sdcdb\InsetSpace ~
29591 \InsetSpace ~
29592 \InsetSpace ~
29593 \InsetSpace ~
29594 \InsetSpace ~
29595 \InsetSpace ~
29596 \InsetSpace ~
29597 \InsetSpace ~
29598 \InsetSpace ~
29599 \InsetSpace ~
29600 Got
29601 o the SDCDB output buffer 
29602 \newline
29603 ;;\InsetSpace ~
29604 t\InsetSpace ~
29605 \InsetSpace ~
29606 \InsetSpace ~
29607 \InsetSpace ~
29608 \InsetSpace ~
29609 \InsetSpace ~
29610 \InsetSpace ~
29611 \InsetSpace ~
29612 \InsetSpace ~
29613 \InsetSpace ~
29614 \InsetSpace ~
29615 \InsetSpace ~
29616 \InsetSpace ~
29617 \InsetSpace ~
29618 \InsetSpace ~
29619 sdcdbsrc-mode\InsetSpace ~
29620 \InsetSpace ~
29621 \InsetSpace ~
29622 \InsetSpace ~
29623 \InsetSpace ~
29624 \InsetSpace ~
29625 \InsetSpace ~
29626 \InsetSpace ~
29627 \InsetSpace ~
29628 \InsetSpace ~
29629 \InsetSpace ~
29630 \InsetSpace ~
29631 \InsetSpace ~
29632 \InsetSpace ~
29633 \InsetSpace ~
29634 \InsetSpace ~
29635 Toggles Sdcdbsrc mode (turns it
29636  off) 
29637 \newline
29638 ;; 
29639 \newline
29640 ;;\InsetSpace ~
29641 C-c\InsetSpace ~
29642 C-f\InsetSpace ~
29643 \InsetSpace ~
29644 \InsetSpace ~
29645 \InsetSpace ~
29646 \InsetSpace ~
29647 \InsetSpace ~
29648 \InsetSpace ~
29649 \InsetSpace ~
29650 \InsetSpace ~
29651 sdcdb-finish-from-src\InsetSpace ~
29652 \InsetSpace ~
29653 \InsetSpace ~
29654 \InsetSpace ~
29655 \InsetSpace ~
29656 \InsetSpace ~
29657 \InsetSpace ~
29658 \InsetSpace ~
29659 SDCDB finish command 
29660 \newline
29661 ;; 
29662 \newline
29663 ;;\InsetSpace ~
29664 C-x\InsetSpace ~
29665 SPC\InsetSpace ~
29666 \InsetSpace ~
29667 \InsetSpace ~
29668 \InsetSpace ~
29669 \InsetSpace ~
29670 \InsetSpace ~
29671 \InsetSpace ~
29672 \InsetSpace ~
29673 \InsetSpace ~
29674 sdcdb-brea
29675 k\InsetSpace ~
29676 \InsetSpace ~
29677 \InsetSpace ~
29678 \InsetSpace ~
29679 \InsetSpace ~
29680 \InsetSpace ~
29681 \InsetSpace ~
29682 \InsetSpace ~
29683 \InsetSpace ~
29684 \InsetSpace ~
29685 \InsetSpace ~
29686 \InsetSpace ~
29687 \InsetSpace ~
29688 \InsetSpace ~
29689 \InsetSpace ~
29690 \InsetSpace ~
29691 \InsetSpace ~
29692 \InsetSpace ~
29693 Set break for line with point 
29694 \newline
29695 ;;\InsetSpace ~
29696 ESC\InsetSpace ~
29697 t\InsetSpace ~
29698 \InsetSpace ~
29699 \InsetSpace ~
29700 \InsetSpace ~
29701 \InsetSpace ~
29702 \InsetSpace ~
29703 \InsetSpace ~
29704 \InsetSpace ~
29705 \InsetSpace ~
29706 \InsetSpace ~
29707 \InsetSpace ~
29708 sdcdbsrc-mode\InsetSpace ~
29709 \InsetSpace ~
29710 \InsetSpace ~
29711 \InsetSpace ~
29712 \InsetSpace ~
29713 \InsetSpace ~
29714 \InsetSpace ~
29715 \InsetSpace ~
29716 \InsetSpace ~
29717 \InsetSpace ~
29718 \InsetSpace ~
29719 \InsetSpace ~
29720 \InsetSpace ~
29721 \InsetSpace ~
29722 \InsetSpace ~
29723 \InsetSpace ~
29724 Toggle Sdcdbsrc mode 
29725 \newline
29726 ;;\InsetSpace ~
29727 ESC\InsetSpace ~
29728 m\InsetSpace ~
29729 \InsetSpace ~
29730 \InsetSpace ~
29731 \InsetSpace ~
29732 \InsetSpace ~
29733 \InsetSpace ~
29734 \InsetSpace ~
29735 \InsetSpace ~
29736 \InsetSpace ~
29737 \InsetSpace ~
29738 \InsetSpace ~
29739 sdc
29740 dbsrc-srcmode\InsetSpace ~
29741 \InsetSpace ~
29742 \InsetSpace ~
29743 \InsetSpace ~
29744 \InsetSpace ~
29745 \InsetSpace ~
29746 \InsetSpace ~
29747 \InsetSpace ~
29748 \InsetSpace ~
29749 \InsetSpace ~
29750 \InsetSpace ~
29751 \InsetSpace ~
29752 \InsetSpace ~
29753 Toggle list mode 
29754 \newline
29755 ;; 
29756 \newline
29757
29758 \family default
29759
29760 \newpage
29761
29762 \end_layout
29763
29764 \begin_layout Chapter
29765 TIPS
29766 \end_layout
29767
29768 \begin_layout Standard
29769 Here are a few guidelines that will help the compiler generate more efficient
29770  code, some of the tips are specific to this compiler others are generally
29771  good programming practice.
29772 \end_layout
29773
29774 \begin_layout Itemize
29775 Use the smallest data type to represent your data-value.
29776  If it is known in advance that the value is going to be less than 256 then
29777  use an 'unsigned char' instead of a 'short' or 'int'.
29778  Please note, that ANSI C requires both signed and unsigned chars to be
29779  promoted to 'signed int'
29780 \begin_inset LatexCommand \index{promotion to signed int}
29781
29782 \end_inset
29783
29784
29785 \begin_inset Marginal
29786 status collapsed
29787
29788 \begin_layout Standard
29789
29790 \series bold
29791 \InsetSpace ~
29792 !
29793 \end_layout
29794
29795 \end_inset
29796
29797  before doing any operation.
29798  This promotion
29799 \begin_inset LatexCommand \index{type promotion}
29800
29801 \end_inset
29802
29803
29804 \begin_inset LatexCommand \label{type promotion}
29805
29806 \end_inset
29807
29808  can be omitted, if the result is the same.
29809  The effect of the promotion rules together with the sign-extension is often
29810  surprising:
29811 \end_layout
29812
29813 \begin_deeper
29814 \begin_layout Verse
29815
29816 \family typewriter
29817 unsigned char uc = 0xfe;
29818 \newline
29819 if (uc * uc < 0) /* this is true! */
29820 \newline
29821 {
29822 \newline
29823 \InsetSpace ~
29824 \InsetSpace ~
29825 \InsetSpace ~
29826 \InsetSpace ~
29827 ....
29828 \newline
29829 }
29830 \end_layout
29831
29832 \begin_layout Standard
29833
29834 \family typewriter
29835 uc * uc
29836 \family default
29837  is evaluated as 
29838 \family typewriter
29839 (int) uc * (int) uc = (int) 0xfe * (int) 0xfe = (int) 0xfc04 = -1024
29840 \family default
29841 .
29842  
29843 \newline
29844 Another one:
29845 \end_layout
29846
29847 \begin_layout Verse
29848
29849 \family typewriter
29850 (unsigned char) -12 / (signed char) -3 = ...
29851 \end_layout
29852
29853 \begin_layout Standard
29854 No, the result is not 4:
29855 \end_layout
29856
29857 \begin_layout Verse
29858
29859 \family typewriter
29860 (int) (unsigned char) -12 / (int) (signed char) -3 =
29861 \newline
29862 (int) (unsigned char)
29863  0xf4 / (int) (signed char) 0xfd =
29864 \newline
29865 (int) 0x00f4 / (int) 0xfffd =
29866 \newline
29867 (int) 0x00f4
29868  / (int) 0xfffd =
29869 \newline
29870 (int) 244 / (int) -3 =
29871 \newline
29872 (int) -81 = (int) 0xffaf;
29873 \end_layout
29874
29875 \begin_layout Standard
29876 Don't complain, that gcc gives you a different result.
29877  gcc uses 32 bit ints, while SDCC uses 16 bit ints.
29878  Therefore the results are different.
29879 \newline
29880 From 
29881 \begin_inset Quotes sld
29882 \end_inset
29883
29884 comp.lang.c FAQ
29885 \begin_inset Quotes srd
29886 \end_inset
29887
29888 :
29889 \end_layout
29890
29891 \begin_layout Quote
29892
29893 \emph on
29894 If well-defined overflow characteristics are important and negative values
29895  are not, or if you want to steer clear of sign-extension problems when
29896  manipulating bits or bytes, use one of the corresponding unsigned types.
29897  (Beware when mixing signed and unsigned values in expressions, though.)
29898 \newline
29899 Although
29900  character types (especially unsigned char) can be used as "tiny" integers,
29901  doing so is sometimes more trouble than it's worth, due to unpredictable
29902  sign extension and increased code size.
29903 \end_layout
29904
29905 \end_deeper
29906 \begin_layout Itemize
29907 Use unsigned when it is known in advance that the value is not going to
29908  be negative.
29909  This helps especially if you are doing division or multiplication, bit-shifting
29910  or are using an array index.
29911 \end_layout
29912
29913 \begin_layout Itemize
29914 NEVER jump into a LOOP.
29915 \end_layout
29916
29917 \begin_layout Itemize
29918 Declare the variables to be local
29919 \begin_inset LatexCommand \index{local variables}
29920
29921 \end_inset
29922
29923  whenever possible, especially loop control variables (induction).
29924 \end_layout
29925
29926 \begin_layout Itemize
29927 Have a look at the assembly listing to get a 
29928 \begin_inset Quotes sld
29929 \end_inset
29930
29931 feeling
29932 \begin_inset Quotes srd
29933 \end_inset
29934
29935  for the code generation.
29936 \end_layout
29937
29938 \begin_layout Section
29939 Porting code from or to other compilers
29940 \begin_inset LatexCommand \label{sec:Porting-code-to-other-compilers}
29941
29942 \end_inset
29943
29944
29945 \end_layout
29946
29947 \begin_layout Itemize
29948 check whether endianness of the compilers differs and adapt where needed.
29949 \end_layout
29950
29951 \begin_layout Itemize
29952 check the device specific header files
29953 \begin_inset LatexCommand \index{Header files}
29954
29955 \end_inset
29956
29957
29958 \begin_inset LatexCommand \index{Include files}
29959
29960 \end_inset
29961
29962  for compiler specific syntax.
29963  Eventually include the file <compiler.h
29964 \begin_inset LatexCommand \index{compiler.h (include file)}
29965
29966 \end_inset
29967
29968
29969 \begin_inset LatexCommand \url{http://sdcc.svn.sourceforge.net/viewvc/sdcc/trunk/sdcc/device/include/mcs51/compiler.h?view=markup}
29970
29971 \end_inset
29972
29973  to allow using common header files.
29974  (see f.e.
29975  cc2510fx.h 
29976 \begin_inset LatexCommand \url{http://sdcc.svn.sourceforge.net/viewvc/sdcc/trunk/sdcc/device/include/mcs51/cc2510fx.h?view=markup}
29977
29978 \end_inset
29979
29980 ).
29981 \end_layout
29982
29983 \begin_layout Itemize
29984 check whether the startup code contains the correct initialization (watchdog,
29985  peripherals).
29986 \end_layout
29987
29988 \begin_layout Itemize
29989 check whether the sizes of short, int, long match.
29990 \end_layout
29991
29992 \begin_layout Itemize
29993 check if some 16 or 32 bit hardware registers require a specific addressing
29994  order (least significant or most significant byte first) and adapt if needed
29995  (
29996 \emph on
29997 first
29998 \emph default
29999  and 
30000 \emph on
30001 last
30002 \emph default
30003  relate to time and not to lower/upper memory location here, so this is
30004  
30005 \emph on
30006 not
30007 \emph default
30008  the same as endianness).
30009 \end_layout
30010
30011 \begin_layout Itemize
30012 check whether the keyword 
30013 \emph on
30014 volatile
30015 \emph default
30016  is used where needed.
30017  The compilers might differ in their optimization characteristics (as different
30018  versions of the same compiler might also use more clever optimizations
30019  this is good idea anyway).
30020  See section 
30021 \begin_inset LatexCommand \ref{sub:Common-interrupt-pitfall-volatile}
30022
30023 \end_inset
30024
30025 .
30026 \end_layout
30027
30028 \begin_layout Itemize
30029 check that the compilers are not told to supress warnings.
30030 \end_layout
30031
30032 \begin_layout Itemize
30033 check and convert compiler specific extensions (interrupts, memory areas,
30034  pragmas etc.).
30035 \end_layout
30036
30037 \begin_layout Itemize
30038 check for differences in type promotion.
30039  Especially check for math operations on 
30040 \family typewriter
30041 char
30042 \family default
30043  or 
30044 \family typewriter
30045 unsigned char
30046 \family default
30047  variables.
30048  For the sake of C99 compatibility SDCC will probably promote these to 
30049 \family typewriter
30050 int
30051 \family default
30052  more often than other compilers.
30053  Eventually insert explicit casts to 
30054 \family typewriter
30055 (char) 
30056 \family default
30057 or
30058 \family typewriter
30059  (unsigned char)
30060 \family default
30061 .
30062  Also check that the ~\InsetSpace ~
30063 operator
30064 \begin_inset LatexCommand \index{\~\/ Operator}
30065
30066 \end_inset
30067
30068  is not used on 
30069 \family typewriter
30070 bit
30071 \begin_inset LatexCommand \index{bit}
30072
30073 \end_inset
30074
30075
30076 \family default
30077  variables, use the !\InsetSpace ~
30078 operator instead.
30079  See sections 
30080 \begin_inset LatexCommand \ref{type promotion}
30081
30082 \end_inset
30083
30084  and 
30085 \begin_inset LatexCommand \ref{sec:Compatibility-with-previous}
30086
30087 \end_inset
30088
30089 .
30090 \end_layout
30091
30092 \begin_layout Itemize
30093 check the assembly code generated for interrupt routines (f.e.
30094  for calls to possibly non-reentrant library functions).
30095 \end_layout
30096
30097 \begin_layout Itemize
30098 check whether timing loops result in proper timing (or preferably consider
30099  a rewrite of the code with timer based delays instead).
30100 \end_layout
30101
30102 \begin_layout Itemize
30103 check for differences in printf parameters (some compilers push (va_arg
30104 \begin_inset LatexCommand \index{vararg, va\_arg}
30105
30106 \end_inset
30107
30108 ) char variables as 
30109 \family typewriter
30110 int
30111 \family default
30112  others push them as 
30113 \family typewriter
30114 char
30115 \family default
30116 .
30117  See section 
30118 \begin_inset LatexCommand \ref{sec:Compatibility-with-previous}
30119
30120 \end_inset
30121
30122 ).
30123 \end_layout
30124
30125 \begin_layout Itemize
30126 check the resulting memory map
30127 \begin_inset LatexCommand \index{Memory map}
30128
30129 \end_inset
30130
30131 .
30132  Usage of different memory spaces: code, stack, data (for mcs51/ds390 additional
30133 ly idata, pdata, xdata).
30134  Eventually check if unexpected library functions are included.
30135 \end_layout
30136
30137 \begin_layout Section
30138 Tools
30139 \begin_inset LatexCommand \index{Tools}
30140
30141 \end_inset
30142
30143  included in the distribution
30144 \end_layout
30145
30146 \begin_layout Standard
30147 \align left
30148 \begin_inset Tabular
30149 <lyxtabular version="3" rows="12" columns="3">
30150 <features>
30151 <column alignment="left" valignment="top" leftline="true" width="0pt">
30152 <column alignment="left" valignment="top" leftline="true" width="0pt">
30153 <column alignment="left" valignment="top" leftline="true" rightline="true" width="0pt">
30154 <row topline="true" bottomline="true">
30155 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
30156 \begin_inset Text
30157
30158 \begin_layout Standard
30159
30160 \series bold
30161 Name
30162 \end_layout
30163
30164 \end_inset
30165 </cell>
30166 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
30167 \begin_inset Text
30168
30169 \begin_layout Standard
30170
30171 \series bold
30172 Purpose
30173 \end_layout
30174
30175 \end_inset
30176 </cell>
30177 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
30178 \begin_inset Text
30179
30180 \begin_layout Standard
30181
30182 \series bold
30183 Directory
30184 \end_layout
30185
30186 \end_inset
30187 </cell>
30188 </row>
30189 <row topline="true">
30190 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
30191 \begin_inset Text
30192
30193 \begin_layout Standard
30194 uCsim
30195 \begin_inset LatexCommand \index{uCsim}
30196
30197 \end_inset
30198
30199
30200 \end_layout
30201
30202 \end_inset
30203 </cell>
30204 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
30205 \begin_inset Text
30206
30207 \begin_layout Standard
30208 Simulator for various architectures
30209 \end_layout
30210
30211 \end_inset
30212 </cell>
30213 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
30214 \begin_inset Text
30215
30216 \begin_layout Standard
30217 sdcc/sim/ucsim
30218 \end_layout
30219
30220 \end_inset
30221 </cell>
30222 </row>
30223 <row topline="true">
30224 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
30225 \begin_inset Text
30226
30227 \begin_layout Standard
30228 keil2sdcc.pl
30229 \end_layout
30230
30231 \end_inset
30232 </cell>
30233 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
30234 \begin_inset Text
30235
30236 \begin_layout Standard
30237 header file
30238 \begin_inset LatexCommand \index{Header files}
30239
30240 \end_inset
30241
30242
30243 \begin_inset LatexCommand \index{Include files}
30244
30245 \end_inset
30246
30247  conversion
30248 \end_layout
30249
30250 \end_inset
30251 </cell>
30252 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
30253 \begin_inset Text
30254
30255 \begin_layout Standard
30256 sdcc/support/scripts
30257 \end_layout
30258
30259 \end_inset
30260 </cell>
30261 </row>
30262 <row topline="true">
30263 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
30264 \begin_inset Text
30265
30266 \begin_layout Standard
30267 mh2h.c
30268 \end_layout
30269
30270 \end_inset
30271 </cell>
30272 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
30273 \begin_inset Text
30274
30275 \begin_layout Standard
30276 header file conversion
30277 \end_layout
30278
30279 \end_inset
30280 </cell>
30281 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
30282 \begin_inset Text
30283
30284 \begin_layout Standard
30285 sdcc/support/scripts
30286 \end_layout
30287
30288 \end_inset
30289 </cell>
30290 </row>
30291 <row topline="true">
30292 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
30293 \begin_inset Text
30294
30295 \begin_layout Standard
30296 as-gbz80
30297 \end_layout
30298
30299 \end_inset
30300 </cell>
30301 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
30302 \begin_inset Text
30303
30304 \begin_layout Standard
30305 Assembler
30306 \end_layout
30307
30308 \end_inset
30309 </cell>
30310 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
30311 \begin_inset Text
30312
30313 \begin_layout Standard
30314
30315 \family roman
30316 \series medium
30317 \shape up
30318 \size normal
30319 \emph off
30320 \bar no
30321 \noun off
30322 \color none
30323 sdcc/bin
30324 \end_layout
30325
30326 \end_inset
30327 </cell>
30328 </row>
30329 <row topline="true">
30330 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
30331 \begin_inset Text
30332
30333 \begin_layout Standard
30334 as-z80
30335 \end_layout
30336
30337 \end_inset
30338 </cell>
30339 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
30340 \begin_inset Text
30341
30342 \begin_layout Standard
30343 Assembler
30344 \end_layout
30345
30346 \end_inset
30347 </cell>
30348 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
30349 \begin_inset Text
30350
30351 \begin_layout Standard
30352
30353 \family roman
30354 \series medium
30355 \shape up
30356 \size normal
30357 \emph off
30358 \bar no
30359 \noun off
30360 \color none
30361 sdcc/bin
30362 \end_layout
30363
30364 \end_inset
30365 </cell>
30366 </row>
30367 <row topline="true">
30368 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
30369 \begin_inset Text
30370
30371 \begin_layout Standard
30372 asx8051
30373 \end_layout
30374
30375 \end_inset
30376 </cell>
30377 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
30378 \begin_inset Text
30379
30380 \begin_layout Standard
30381 Assembler
30382 \end_layout
30383
30384 \end_inset
30385 </cell>
30386 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
30387 \begin_inset Text
30388
30389 \begin_layout Standard
30390
30391 \family roman
30392 \series medium
30393 \shape up
30394 \size normal
30395 \emph off
30396 \bar no
30397 \noun off
30398 \color none
30399 sdcc/bin
30400 \end_layout
30401
30402 \end_inset
30403 </cell>
30404 </row>
30405 <row topline="true">
30406 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
30407 \begin_inset Text
30408
30409 \begin_layout Standard
30410 SDCDB
30411 \end_layout
30412
30413 \end_inset
30414 </cell>
30415 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
30416 \begin_inset Text
30417
30418 \begin_layout Standard
30419 Simulator
30420 \end_layout
30421
30422 \end_inset
30423 </cell>
30424 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
30425 \begin_inset Text
30426
30427 \begin_layout Standard
30428
30429 \family roman
30430 \series medium
30431 \shape up
30432 \size normal
30433 \emph off
30434 \bar no
30435 \noun off
30436 \color none
30437 sdcc/bin
30438 \end_layout
30439
30440 \end_inset
30441 </cell>
30442 </row>
30443 <row topline="true">
30444 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
30445 \begin_inset Text
30446
30447 \begin_layout Standard
30448 aslink
30449 \end_layout
30450
30451 \end_inset
30452 </cell>
30453 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
30454 \begin_inset Text
30455
30456 \begin_layout Standard
30457 Linker
30458 \end_layout
30459
30460 \end_inset
30461 </cell>
30462 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
30463 \begin_inset Text
30464
30465 \begin_layout Standard
30466
30467 \family roman
30468 \series medium
30469 \shape up
30470 \size normal
30471 \emph off
30472 \bar no
30473 \noun off
30474 \color none
30475 sdcc/bin
30476 \end_layout
30477
30478 \end_inset
30479 </cell>
30480 </row>
30481 <row topline="true">
30482 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
30483 \begin_inset Text
30484
30485 \begin_layout Standard
30486 link-z80
30487 \end_layout
30488
30489 \end_inset
30490 </cell>
30491 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
30492 \begin_inset Text
30493
30494 \begin_layout Standard
30495 Linker
30496 \end_layout
30497
30498 \end_inset
30499 </cell>
30500 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
30501 \begin_inset Text
30502
30503 \begin_layout Standard
30504
30505 \family roman
30506 \series medium
30507 \shape up
30508 \size normal
30509 \emph off
30510 \bar no
30511 \noun off
30512 \color none
30513 sdcc/bin
30514 \end_layout
30515
30516 \end_inset
30517 </cell>
30518 </row>
30519 <row topline="true">
30520 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
30521 \begin_inset Text
30522
30523 \begin_layout Standard
30524 link-gbz80
30525 \end_layout
30526
30527 \end_inset
30528 </cell>
30529 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
30530 \begin_inset Text
30531
30532 \begin_layout Standard
30533 Linker
30534 \end_layout
30535
30536 \end_inset
30537 </cell>
30538 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
30539 \begin_inset Text
30540
30541 \begin_layout Standard
30542
30543 \family roman
30544 \series medium
30545 \shape up
30546 \size normal
30547 \emph off
30548 \bar no
30549 \noun off
30550 \color none
30551 sdcc/bin
30552 \end_layout
30553
30554 \end_inset
30555 </cell>
30556 </row>
30557 <row topline="true" bottomline="true">
30558 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
30559 \begin_inset Text
30560
30561 \begin_layout Standard
30562 packihx
30563 \end_layout
30564
30565 \end_inset
30566 </cell>
30567 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
30568 \begin_inset Text
30569
30570 \begin_layout Standard
30571 Intel Hex packer 
30572 \begin_inset LatexCommand \index{packihx (tool)}
30573
30574 \end_inset
30575
30576
30577 \end_layout
30578
30579 \end_inset
30580 </cell>
30581 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
30582 \begin_inset Text
30583
30584 \begin_layout Standard
30585
30586 \family roman
30587 \series medium
30588 \shape up
30589 \size normal
30590 \emph off
30591 \bar no
30592 \noun off
30593 \color none
30594 sdcc/bin
30595 \end_layout
30596
30597 \end_inset
30598 </cell>
30599 </row>
30600 </lyxtabular>
30601
30602 \end_inset
30603
30604
30605 \newline
30606
30607 \end_layout
30608
30609 \begin_layout Section
30610 Documentation
30611 \begin_inset LatexCommand \index{Documentation}
30612
30613 \end_inset
30614
30615  included in the distribution
30616 \end_layout
30617
30618 \begin_layout Standard
30619 \align left
30620 \begin_inset Tabular
30621 <lyxtabular version="3" rows="10" columns="2">
30622 <features>
30623 <column alignment="block" valignment="top" leftline="true" width="40col%">
30624 <column alignment="block" valignment="top" leftline="true" rightline="true" width="60col%">
30625 <row topline="true" bottomline="true" endhead="true">
30626 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
30627 \begin_inset Text
30628
30629 \begin_layout Standard
30630
30631 \series bold
30632 Subject / Title
30633 \end_layout
30634
30635 \end_inset
30636 </cell>
30637 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
30638 \begin_inset Text
30639
30640 \begin_layout Standard
30641
30642 \series bold
30643 Filename / Where to get
30644 \end_layout
30645
30646 \end_inset
30647 </cell>
30648 </row>
30649 <row topline="true">
30650 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
30651 \begin_inset Text
30652
30653 \begin_layout Standard
30654 SDCC Compiler User Guide
30655 \end_layout
30656
30657 \end_inset
30658 </cell>
30659 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
30660 \begin_inset Text
30661
30662 \begin_layout Standard
30663 You're reading it right now
30664 \emph on
30665  \InsetSpace ~
30666 \InsetSpace ~
30667 \InsetSpace ~
30668
30669 \hfill
30670 online at:
30671 \emph default
30672
30673 \newline
30674
30675 \begin_inset LatexCommand \url{http://sdcc.sourceforge.net/doc/sdccman.pdf}
30676
30677 \end_inset
30678
30679
30680 \end_layout
30681
30682 \end_inset
30683 </cell>
30684 </row>
30685 <row topline="true">
30686 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
30687 \begin_inset Text
30688
30689 \begin_layout Standard
30690 Changelog of SDCC
30691 \end_layout
30692
30693 \end_inset
30694 </cell>
30695 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
30696 \begin_inset Text
30697
30698 \begin_layout Standard
30699 sdcc/Changelog
30700 \emph on
30701  \InsetSpace ~
30702 \InsetSpace ~
30703 \InsetSpace ~
30704
30705 \hfill
30706 online at:
30707 \emph default
30708
30709 \newline
30710
30711 \begin_inset LatexCommand \url{http://sdcc.svn.sourceforge.net/viewvc/*checkout*/sdcc/trunk/sdcc/ChangeLog}
30712
30713 \end_inset
30714
30715
30716 \end_layout
30717
30718 \end_inset
30719 </cell>
30720 </row>
30721 <row topline="true">
30722 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
30723 \begin_inset Text
30724
30725 \begin_layout Standard
30726 ASXXXX
30727 \begin_inset LatexCommand \index{asXXXX (as-gbz80, as-hc08, asx8051, as-z80)}
30728
30729 \end_inset
30730
30731
30732 \begin_inset LatexCommand \index{Assembler documentation}
30733
30734 \end_inset
30735
30736  Assemblers and
30737 \newline
30738 ASLINK
30739 \begin_inset LatexCommand \index{aslink}
30740
30741 \end_inset
30742
30743
30744 \begin_inset LatexCommand \index{Linker documentation}
30745
30746 \end_inset
30747
30748  Relocating Linker
30749 \end_layout
30750
30751 \end_inset
30752 </cell>
30753 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
30754 \begin_inset Text
30755
30756 \begin_layout Standard
30757 sdcc/as/doc/asxhtm.html 
30758 \emph on
30759 \InsetSpace ~
30760 \InsetSpace ~
30761 \InsetSpace ~
30762
30763 \hfill
30764 online at:
30765 \emph default
30766
30767 \newline
30768
30769 \begin_inset LatexCommand \url{http://sdcc.svn.sourceforge.net/viewvc/*checkout*/sdcc/trunk/sdcc/as/doc/asxhtm.html}
30770
30771 \end_inset
30772
30773
30774 \end_layout
30775
30776 \end_inset
30777 </cell>
30778 </row>
30779 <row topline="true">
30780 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
30781 \begin_inset Text
30782
30783 \begin_layout Standard
30784 SDCC regression test
30785 \begin_inset LatexCommand \index{Regression test}
30786
30787 \end_inset
30788
30789
30790 \end_layout
30791
30792 \end_inset
30793 </cell>
30794 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
30795 \begin_inset Text
30796
30797 \begin_layout Standard
30798 sdcc/doc/test_suite_spec.pdf 
30799 \emph on
30800 \InsetSpace ~
30801 \InsetSpace ~
30802 \InsetSpace ~
30803
30804 \hfill
30805 online at:
30806 \emph default
30807
30808 \newline
30809
30810 \begin_inset LatexCommand \url{http://sdcc.sourceforge.net/doc/test_suite_spec.pdf}
30811
30812 \end_inset
30813
30814
30815 \end_layout
30816
30817 \end_inset
30818 </cell>
30819 </row>
30820 <row topline="true">
30821 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
30822 \begin_inset Text
30823
30824 \begin_layout Standard
30825 Various notes
30826 \end_layout
30827
30828 \end_inset
30829 </cell>
30830 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
30831 \begin_inset Text
30832
30833 \begin_layout Standard
30834 sdcc/doc/* 
30835 \emph on
30836 \InsetSpace ~
30837 \InsetSpace ~
30838 \InsetSpace ~
30839
30840 \hfill
30841 online at:
30842 \emph default
30843
30844 \newline
30845
30846 \begin_inset LatexCommand \url{http://sdcc.svn.sourceforge.net/viewvc/sdcc/trunk/sdcc/doc/}
30847
30848 \end_inset
30849
30850
30851 \end_layout
30852
30853 \end_inset
30854 </cell>
30855 </row>
30856 <row topline="true">
30857 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
30858 \begin_inset Text
30859
30860 \begin_layout Standard
30861 Notes on debugging with SDCDB
30862 \begin_inset LatexCommand \index{SDCDB (debugger)}
30863
30864 \end_inset
30865
30866
30867 \end_layout
30868
30869 \end_inset
30870 </cell>
30871 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
30872 \begin_inset Text
30873
30874 \begin_layout Standard
30875 sdcc/debugger/README 
30876 \emph on
30877 \InsetSpace ~
30878 \InsetSpace ~
30879 \InsetSpace ~
30880
30881 \hfill
30882 online at
30883 \emph default
30884 :
30885 \newline
30886
30887 \begin_inset LatexCommand \url{http://sdcc.svn.sourceforge.net/viewvc/*checkout*/sdcc/trunk/sdcc/debugger/README}
30888
30889 \end_inset
30890
30891
30892 \end_layout
30893
30894 \end_inset
30895 </cell>
30896 </row>
30897 <row topline="true">
30898 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
30899 \begin_inset Text
30900
30901 \begin_layout Standard
30902 uCsim
30903 \begin_inset LatexCommand \index{uCsim}
30904
30905 \end_inset
30906
30907  Software simulator for microcontrollers
30908 \end_layout
30909
30910 \end_inset
30911 </cell>
30912 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
30913 \begin_inset Text
30914
30915 \begin_layout Standard
30916
30917 \family roman
30918 \series medium
30919 \shape up
30920 \size normal
30921 \emph off
30922 \bar no
30923 \noun off
30924 \color none
30925 sdcc/sim/ucsim/doc
30926 \family default
30927 \series default
30928 \shape default
30929 \size default
30930 \emph default
30931 \bar default
30932 \noun default
30933 /index.html 
30934 \emph on
30935 \InsetSpace ~
30936 \InsetSpace ~
30937 \InsetSpace ~
30938
30939 \hfill
30940 online at:
30941 \emph default
30942
30943 \newline
30944
30945 \begin_inset LatexCommand \url{http://sdcc.svn.sourceforge.net/viewvc/*checkout*/sdcc/trunk/sdcc/sim/ucsim/doc/index.html}
30946
30947 \end_inset
30948
30949
30950 \end_layout
30951
30952 \end_inset
30953 </cell>
30954 </row>
30955 <row topline="true">
30956 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
30957 \begin_inset Text
30958
30959 \begin_layout Standard
30960 Temporary notes on the pic16
30961 \begin_inset LatexCommand \index{PIC16}
30962
30963 \end_inset
30964
30965  port
30966 \end_layout
30967
30968 \end_inset
30969 </cell>
30970 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
30971 \begin_inset Text
30972
30973 \begin_layout Standard
30974 sdcc/src/pic16/NOTES 
30975 \emph on
30976 \InsetSpace ~
30977 \InsetSpace ~
30978 \InsetSpace ~
30979
30980 \hfill
30981 online at:
30982 \newline
30983
30984 \emph default
30985
30986 \begin_inset LatexCommand \url{http://sdcc.svn.sourceforge.net/viewvc/*checkout*/sdcc/trunk/sdcc/src/pic16/NOTES}
30987
30988 \end_inset
30989
30990
30991 \end_layout
30992
30993 \end_inset
30994 </cell>
30995 </row>
30996 <row topline="true" bottomline="true">
30997 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
30998 \begin_inset Text
30999
31000 \begin_layout Standard
31001 SDCC internal documentation (debugging file format)
31002 \end_layout
31003
31004 \end_inset
31005 </cell>
31006 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31007 \begin_inset Text
31008
31009 \begin_layout Standard
31010 sdcc/doc/
31011 \family roman
31012 \series medium
31013 \shape up
31014 \size normal
31015 \emph off
31016 \bar no
31017 \noun off
31018 \color none
31019 cdbfileformat.pd
31020 \family default
31021 \series default
31022 \shape default
31023 \size default
31024 \emph default
31025 \bar default
31026 \noun default
31027 f
31028 \emph on
31029  \InsetSpace ~
31030 \InsetSpace ~
31031 \InsetSpace ~
31032
31033 \hfill
31034 online at:
31035 \emph default
31036
31037 \newline
31038
31039 \begin_inset LatexCommand \url{http://sdcc.sourceforge.net/doc/cdbfileformat.pdf}
31040
31041 \end_inset
31042
31043
31044 \end_layout
31045
31046 \end_inset
31047 </cell>
31048 </row>
31049 </lyxtabular>
31050
31051 \end_inset
31052
31053
31054 \newline
31055
31056 \end_layout
31057
31058 \begin_layout Section
31059 Related open source tools
31060 \begin_inset LatexCommand \label{sec:Related-open-source-tools}
31061
31062 \end_inset
31063
31064
31065 \begin_inset LatexCommand \index{Related tools}
31066
31067 \end_inset
31068
31069
31070 \end_layout
31071
31072 \begin_layout Standard
31073 \align left
31074 \begin_inset Tabular
31075 <lyxtabular version="3" rows="16" columns="3">
31076 <features>
31077 <column alignment="left" valignment="top" leftline="true" width="0pt">
31078 <column alignment="block" valignment="top" leftline="true" width="30line%">
31079 <column alignment="left" valignment="top" leftline="true" rightline="true" width="0pt">
31080 <row topline="true" bottomline="true">
31081 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31082 \begin_inset Text
31083
31084 \begin_layout Standard
31085
31086 \series bold
31087 Name
31088 \end_layout
31089
31090 \end_inset
31091 </cell>
31092 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31093 \begin_inset Text
31094
31095 \begin_layout Standard
31096
31097 \series bold
31098 Purpose
31099 \end_layout
31100
31101 \end_inset
31102 </cell>
31103 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31104 \begin_inset Text
31105
31106 \begin_layout Standard
31107
31108 \series bold
31109 Where to get
31110 \end_layout
31111
31112 \end_inset
31113 </cell>
31114 </row>
31115 <row topline="true">
31116 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31117 \begin_inset Text
31118
31119 \begin_layout Standard
31120 gpsim
31121 \begin_inset LatexCommand \index{gpsim (pic simulator)}
31122
31123 \end_inset
31124
31125
31126 \end_layout
31127
31128 \end_inset
31129 </cell>
31130 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31131 \begin_inset Text
31132
31133 \begin_layout Standard
31134 PIC simulator
31135 \end_layout
31136
31137 \end_inset
31138 </cell>
31139 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31140 \begin_inset Text
31141
31142 \begin_layout Standard
31143 \begin_inset LatexCommand \url{http://www.dattalo.com/gnupic/gpsim.html}
31144
31145 \end_inset
31146
31147
31148 \end_layout
31149
31150 \end_inset
31151 </cell>
31152 </row>
31153 <row topline="true">
31154 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31155 \begin_inset Text
31156
31157 \begin_layout Standard
31158 gputils
31159 \begin_inset LatexCommand \index{gputils (pic tools)}
31160
31161 \end_inset
31162
31163
31164 \end_layout
31165
31166 \end_inset
31167 </cell>
31168 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31169 \begin_inset Text
31170
31171 \begin_layout Standard
31172 GNU PIC utilities
31173 \end_layout
31174
31175 \end_inset
31176 </cell>
31177 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31178 \begin_inset Text
31179
31180 \begin_layout Standard
31181 \begin_inset LatexCommand \url{http://sourceforge.net/projects/gputils}
31182
31183 \end_inset
31184
31185
31186 \end_layout
31187
31188 \end_inset
31189 </cell>
31190 </row>
31191 <row topline="true">
31192 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31193 \begin_inset Text
31194
31195 \begin_layout Standard
31196 flP5
31197 \end_layout
31198
31199 \end_inset
31200 </cell>
31201 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31202 \begin_inset Text
31203
31204 \begin_layout Standard
31205 PIC programmer
31206 \end_layout
31207
31208 \end_inset
31209 </cell>
31210 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31211 \begin_inset Text
31212
31213 \begin_layout Standard
31214 \begin_inset LatexCommand \url{http://freshmeat.net/projects/flp5/}
31215
31216 \end_inset
31217
31218
31219 \end_layout
31220
31221 \end_inset
31222 </cell>
31223 </row>
31224 <row topline="true">
31225 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31226 \begin_inset Text
31227
31228 \begin_layout Standard
31229 ec2drv/newcdb
31230 \end_layout
31231
31232 \end_inset
31233 </cell>
31234 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31235 \begin_inset Text
31236
31237 \begin_layout Standard
31238 Tools for Silicon Laboratories JTAG debug adapter, partly based on SDCDB
31239  (Unix only)
31240 \end_layout
31241
31242 \end_inset
31243 </cell>
31244 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31245 \begin_inset Text
31246
31247 \begin_layout Standard
31248 \begin_inset LatexCommand \url{http://sourceforge.net/projects/ec2drv}
31249
31250 \end_inset
31251
31252
31253 \end_layout
31254
31255 \end_inset
31256 </cell>
31257 </row>
31258 <row topline="true">
31259 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31260 \begin_inset Text
31261
31262 \begin_layout Standard
31263 indent
31264 \begin_inset LatexCommand \index{indent (source formatting tool)}
31265
31266 \end_inset
31267
31268
31269 \end_layout
31270
31271 \end_inset
31272 </cell>
31273 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31274 \begin_inset Text
31275
31276 \begin_layout Standard
31277 Formats C source - Master of the white spaces
31278 \end_layout
31279
31280 \end_inset
31281 </cell>
31282 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31283 \begin_inset Text
31284
31285 \begin_layout Standard
31286 \begin_inset LatexCommand \url{http://directory.fsf.org/GNU/indent.html}
31287
31288 \end_inset
31289
31290
31291 \end_layout
31292
31293 \end_inset
31294 </cell>
31295 </row>
31296 <row topline="true">
31297 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31298 \begin_inset Text
31299
31300 \begin_layout Standard
31301 srecord
31302 \begin_inset LatexCommand \index{srecord (bin, hex, ... tool)}
31303
31304 \end_inset
31305
31306
31307 \end_layout
31308
31309 \end_inset
31310 </cell>
31311 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31312 \begin_inset Text
31313
31314 \begin_layout Standard
31315 Object file conversion, checksumming, ...
31316 \end_layout
31317
31318 \end_inset
31319 </cell>
31320 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31321 \begin_inset Text
31322
31323 \begin_layout Standard
31324 \begin_inset LatexCommand \url{http://sourceforge.net/projects/srecord}
31325
31326 \end_inset
31327
31328
31329 \end_layout
31330
31331 \end_inset
31332 </cell>
31333 </row>
31334 <row topline="true">
31335 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31336 \begin_inset Text
31337
31338 \begin_layout Standard
31339 objdump
31340 \begin_inset LatexCommand \index{objdump (tool)}
31341
31342 \end_inset
31343
31344
31345 \end_layout
31346
31347 \end_inset
31348 </cell>
31349 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31350 \begin_inset Text
31351
31352 \begin_layout Standard
31353 Object file conversion, ...
31354 \end_layout
31355
31356 \end_inset
31357 </cell>
31358 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31359 \begin_inset Text
31360
31361 \begin_layout Standard
31362 Part of binutils (should be there anyway)
31363 \end_layout
31364
31365 \end_inset
31366 </cell>
31367 </row>
31368 <row topline="true">
31369 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31370 \begin_inset Text
31371
31372 \begin_layout Standard
31373 cmon51
31374 \end_layout
31375
31376 \end_inset
31377 </cell>
31378 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31379 \begin_inset Text
31380
31381 \begin_layout Standard
31382 8051 monitor (hex up-/download, single step, disassemble)
31383 \end_layout
31384
31385 \end_inset
31386 </cell>
31387 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31388 \begin_inset Text
31389
31390 \begin_layout Standard
31391 \begin_inset LatexCommand \url{http://sourceforge.net/projects/cmon51}
31392
31393 \end_inset
31394
31395
31396 \end_layout
31397
31398 \end_inset
31399 </cell>
31400 </row>
31401 <row topline="true">
31402 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31403 \begin_inset Text
31404
31405 \begin_layout Standard
31406 doxygen
31407 \begin_inset LatexCommand \index{doxygen (source documentation tool)}
31408
31409 \end_inset
31410
31411
31412 \end_layout
31413
31414 \end_inset
31415 </cell>
31416 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31417 \begin_inset Text
31418
31419 \begin_layout Standard
31420 Source code documentation system
31421 \end_layout
31422
31423 \end_inset
31424 </cell>
31425 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31426 \begin_inset Text
31427
31428 \begin_layout Standard
31429 \begin_inset LatexCommand \url{http://www.doxygen.org}
31430
31431 \end_inset
31432
31433
31434 \end_layout
31435
31436 \end_inset
31437 </cell>
31438 </row>
31439 <row topline="true">
31440 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31441 \begin_inset Text
31442
31443 \begin_layout Standard
31444 kdevelop
31445 \end_layout
31446
31447 \end_inset
31448 </cell>
31449 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31450 \begin_inset Text
31451
31452 \begin_layout Standard
31453 IDE (has anyone tried integrating SDCC & SDCDB? Unix only)
31454 \end_layout
31455
31456 \end_inset
31457 </cell>
31458 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31459 \begin_inset Text
31460
31461 \begin_layout Standard
31462 \begin_inset LatexCommand \url{http://www.kdevelop.org}
31463
31464 \end_inset
31465
31466
31467 \end_layout
31468
31469 \end_inset
31470 </cell>
31471 </row>
31472 <row topline="true">
31473 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31474 \begin_inset Text
31475
31476 \begin_layout Standard
31477 paulmon
31478 \end_layout
31479
31480 \end_inset
31481 </cell>
31482 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31483 \begin_inset Text
31484
31485 \begin_layout Standard
31486 8051 monitor (hex up-/download, single step, disassemble)
31487 \end_layout
31488
31489 \end_inset
31490 </cell>
31491 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31492 \begin_inset Text
31493
31494 \begin_layout Standard
31495 \begin_inset LatexCommand \url{http://www.pjrc.com/tech/8051/paulmon2.html}
31496
31497 \end_inset
31498
31499
31500 \end_layout
31501
31502 \end_inset
31503 </cell>
31504 </row>
31505 <row topline="true">
31506 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31507 \begin_inset Text
31508
31509 \begin_layout Standard
31510 splint
31511 \begin_inset LatexCommand \index{splint (syntax checking tool)}
31512
31513 \end_inset
31514
31515
31516 \end_layout
31517
31518 \end_inset
31519 </cell>
31520 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31521 \begin_inset Text
31522
31523 \begin_layout Standard
31524 Statically checks c sources (see 
31525 \begin_inset LatexCommand \ref{lyx:more-pedantic-SPLINT}
31526
31527 \end_inset
31528
31529 )
31530 \end_layout
31531
31532 \end_inset
31533 </cell>
31534 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31535 \begin_inset Text
31536
31537 \begin_layout Standard
31538 \begin_inset LatexCommand \url{http://www.splint.org}
31539
31540 \end_inset
31541
31542
31543 \end_layout
31544
31545 \end_inset
31546 </cell>
31547 </row>
31548 <row topline="true" bottomline="true">
31549 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31550 \begin_inset Text
31551
31552 \begin_layout Standard
31553 ddd
31554 \begin_inset LatexCommand \index{DDD (debugger)}
31555
31556 \end_inset
31557
31558
31559 \end_layout
31560
31561 \end_inset
31562 </cell>
31563 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31564 \begin_inset Text
31565
31566 \begin_layout Standard
31567 Debugger, serves nicely as GUI to SDCDB
31568 \begin_inset LatexCommand \index{SDCDB (debugger)}
31569
31570 \end_inset
31571
31572  (Unix only)
31573 \end_layout
31574
31575 \end_inset
31576 </cell>
31577 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31578 \begin_inset Text
31579
31580 \begin_layout Standard
31581 \begin_inset LatexCommand \url{http://www.gnu.org/software/ddd/}
31582
31583 \end_inset
31584
31585
31586 \end_layout
31587
31588 \end_inset
31589 </cell>
31590 </row>
31591 <row bottomline="true">
31592 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31593 \begin_inset Text
31594
31595 \begin_layout Standard
31596 d52
31597 \begin_inset LatexCommand \index{d52}
31598
31599 \end_inset
31600
31601
31602 \begin_inset LatexCommand \index{d52 (disassembler)}
31603
31604 \end_inset
31605
31606
31607 \end_layout
31608
31609 \end_inset
31610 </cell>
31611 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31612 \begin_inset Text
31613
31614 \begin_layout Standard
31615 Disassembler, can count instruction cycles
31616 \begin_inset LatexCommand \index{instruction cycles (count)}
31617
31618 \end_inset
31619
31620 , use with options -pnd
31621 \end_layout
31622
31623 \end_inset
31624 </cell>
31625 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31626 \begin_inset Text
31627
31628 \begin_layout Standard
31629 \begin_inset LatexCommand \url{http://www.8052.com/users/disasm/}
31630
31631 \end_inset
31632
31633
31634 \end_layout
31635
31636 \end_inset
31637 </cell>
31638 </row>
31639 <row bottomline="true">
31640 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31641 \begin_inset Text
31642
31643 \begin_layout Standard
31644 cmake
31645 \begin_inset LatexCommand \index{cmake}
31646
31647 \end_inset
31648
31649
31650 \end_layout
31651
31652 \end_inset
31653 </cell>
31654 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31655 \begin_inset Text
31656
31657 \begin_layout Standard
31658 Cross platform build system, generates Makefiles
31659 \begin_inset LatexCommand \index{Makefile}
31660
31661 \end_inset
31662
31663  and project workspaces
31664 \begin_inset LatexCommand \index{project workspace}
31665
31666 \end_inset
31667
31668
31669 \end_layout
31670
31671 \end_inset
31672 </cell>
31673 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31674 \begin_inset Text
31675
31676 \begin_layout Standard
31677 \begin_inset LatexCommand \url{http://www.cmake.org}
31678
31679 \end_inset
31680
31681
31682 \end_layout
31683
31684 \end_inset
31685 </cell>
31686 </row>
31687 </lyxtabular>
31688
31689 \end_inset
31690
31691
31692 \newline
31693
31694 \end_layout
31695
31696 \begin_layout Section
31697 Related documentation / recommended reading
31698 \end_layout
31699
31700 \begin_layout Standard
31701 \align left
31702 \begin_inset Tabular
31703 <lyxtabular version="3" rows="7" columns="3">
31704 <features>
31705 <column alignment="left" valignment="top" leftline="true" width="0pt">
31706 <column alignment="left" valignment="top" leftline="true" width="0">
31707 <column alignment="left" valignment="top" leftline="true" rightline="true" width="0pt">
31708 <row topline="true" bottomline="true">
31709 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31710 \begin_inset Text
31711
31712 \begin_layout Standard
31713
31714 \series bold
31715 Name
31716 \end_layout
31717
31718 \end_inset
31719 </cell>
31720 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31721 \begin_inset Text
31722
31723 \begin_layout Standard
31724
31725 \series bold
31726 Subject / Title
31727 \end_layout
31728
31729 \end_inset
31730 </cell>
31731 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31732 \begin_inset Text
31733
31734 \begin_layout Standard
31735
31736 \series bold
31737 Where to get
31738 \end_layout
31739
31740 \end_inset
31741 </cell>
31742 </row>
31743 <row topline="true">
31744 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31745 \begin_inset Text
31746
31747 \begin_layout Standard
31748
31749 \family roman
31750 \series medium
31751 \shape up
31752 \size normal
31753 \emph off
31754 \bar no
31755 \noun off
31756 \color none
31757 c-refcard.pdf
31758 \end_layout
31759
31760 \end_inset
31761 </cell>
31762 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31763 \begin_inset Text
31764
31765 \begin_layout Standard
31766 C Reference Card
31767 \begin_inset LatexCommand \index{C Reference card}
31768
31769 \end_inset
31770
31771 , 2 pages
31772 \end_layout
31773
31774 \end_inset
31775 </cell>
31776 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31777 \begin_inset Text
31778
31779 \begin_layout Standard
31780 \begin_inset LatexCommand \url{http://refcards.com/refcards/c/index.html}
31781
31782 \end_inset
31783
31784
31785 \end_layout
31786
31787 \end_inset
31788 </cell>
31789 </row>
31790 <row topline="true">
31791 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31792 \begin_inset Text
31793
31794 \begin_layout Standard
31795 c-faq
31796 \end_layout
31797
31798 \end_inset
31799 </cell>
31800 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31801 \begin_inset Text
31802
31803 \begin_layout Standard
31804 C-FAQ
31805 \begin_inset LatexCommand \index{C FAQ}
31806
31807 \end_inset
31808
31809
31810 \end_layout
31811
31812 \end_inset
31813 </cell>
31814 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31815 \begin_inset Text
31816
31817 \begin_layout Standard
31818 \begin_inset LatexCommand \url{http://www.c-faq.com}
31819
31820 \end_inset
31821
31822
31823 \end_layout
31824
31825 \end_inset
31826 </cell>
31827 </row>
31828 <row topline="true">
31829 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31830 \begin_inset Text
31831
31832 \begin_layout Standard
31833 ISO/IEC 9899:TC2
31834 \end_layout
31835
31836 \end_inset
31837 </cell>
31838 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31839 \begin_inset Text
31840
31841 \begin_layout Standard
31842 \begin_inset Quotes sld
31843 \end_inset
31844
31845 C-Standard
31846 \begin_inset Quotes srd
31847 \end_inset
31848
31849
31850 \end_layout
31851
31852 \end_inset
31853 </cell>
31854 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31855 \begin_inset Text
31856
31857 \begin_layout Standard
31858
31859 \size footnotesize
31860 \begin_inset LatexCommand \url{http://www.open-std.org/jtc1/sc22/wg14/www/standards.html#9899}
31861
31862 \end_inset
31863
31864
31865 \end_layout
31866
31867 \end_inset
31868 </cell>
31869 </row>
31870 <row topline="true">
31871 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31872 \begin_inset Text
31873
31874 \begin_layout Standard
31875 ISO/IEC DTR 18037
31876 \end_layout
31877
31878 \end_inset
31879 </cell>
31880 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31881 \begin_inset Text
31882
31883 \begin_layout Standard
31884 \begin_inset Quotes sld
31885 \end_inset
31886
31887 Extensions for Embedded C
31888 \begin_inset Quotes srd
31889 \end_inset
31890
31891
31892 \end_layout
31893
31894 \end_inset
31895 </cell>
31896 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31897 \begin_inset Text
31898
31899 \begin_layout Standard
31900
31901 \size footnotesize
31902 \begin_inset LatexCommand \url{http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1021.pdf}
31903
31904 \end_inset
31905
31906
31907 \end_layout
31908
31909 \end_inset
31910 </cell>
31911 </row>
31912 <row topline="true">
31913 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31914 \begin_inset Text
31915
31916 \begin_layout Standard
31917
31918 \end_layout
31919
31920 \end_inset
31921 </cell>
31922 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31923 \begin_inset Text
31924
31925 \begin_layout Standard
31926 Latest datasheet of target CPU
31927 \end_layout
31928
31929 \end_inset
31930 </cell>
31931 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31932 \begin_inset Text
31933
31934 \begin_layout Standard
31935 vendor
31936 \end_layout
31937
31938 \end_inset
31939 </cell>
31940 </row>
31941 <row topline="true" bottomline="true">
31942 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31943 \begin_inset Text
31944
31945 \begin_layout Standard
31946
31947 \end_layout
31948
31949 \end_inset
31950 </cell>
31951 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31952 \begin_inset Text
31953
31954 \begin_layout Standard
31955 Revision history of datasheet
31956 \end_layout
31957
31958 \end_inset
31959 </cell>
31960 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31961 \begin_inset Text
31962
31963 \begin_layout Standard
31964 vendor
31965 \end_layout
31966
31967 \end_inset
31968 </cell>
31969 </row>
31970 </lyxtabular>
31971
31972 \end_inset
31973
31974
31975 \newline
31976
31977 \end_layout
31978
31979 \begin_layout Section
31980 Application notes specifically for SDCC
31981 \end_layout
31982
31983 \begin_layout Standard
31984 SDCC makes no claims about the completeness of this list and about up-to-datenes
31985 s or correctness of the application notes
31986 \begin_inset LatexCommand \index{Application notes}
31987
31988 \end_inset
31989
31990 .
31991 \end_layout
31992
31993 \begin_layout Standard
31994 \align left
31995
31996 \size footnotesize
31997 \begin_inset Tabular
31998 <lyxtabular version="3" rows="7" columns="3">
31999 <features>
32000 <column alignment="block" valignment="top" leftline="true" width="17col%">
32001 <column alignment="block" valignment="top" leftline="true" width="27col%">
32002 <column alignment="block" valignment="top" leftline="true" rightline="true" width="57col%">
32003 <row topline="true" bottomline="true">
32004 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32005 \begin_inset Text
32006
32007 \begin_layout Standard
32008
32009 \series bold
32010 \size footnotesize
32011 Vendor
32012 \end_layout
32013
32014 \end_inset
32015 </cell>
32016 <cell alignment="left" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
32017 \begin_inset Text
32018
32019 \begin_layout Standard
32020
32021 \series bold
32022 \size footnotesize
32023 Subject / Title
32024 \end_layout
32025
32026 \end_inset
32027 </cell>
32028 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32029 \begin_inset Text
32030
32031 \begin_layout Standard
32032
32033 \series bold
32034 \size footnotesize
32035 Where to get
32036 \end_layout
32037
32038 \end_inset
32039 </cell>
32040 </row>
32041 <row topline="true">
32042 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32043 \begin_inset Text
32044
32045 \begin_layout Standard
32046
32047 \size footnotesize
32048 Maxim / Dallas
32049 \end_layout
32050
32051 \end_inset
32052 </cell>
32053 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32054 \begin_inset Text
32055
32056 \begin_layout Standard
32057
32058 \size footnotesize
32059 Using the SDCC Compiler for the DS80C400
32060 \begin_inset LatexCommand \index{DS80C400}
32061
32062 \end_inset
32063
32064
32065 \end_layout
32066
32067 \end_inset
32068 </cell>
32069 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32070 \begin_inset Text
32071
32072 \begin_layout Standard
32073
32074 \size footnotesize
32075 \begin_inset LatexCommand \url{http://pdfserv.maxim-ic.com/en/an/AN3346.pdf}
32076
32077 \end_inset
32078
32079
32080 \end_layout
32081
32082 \end_inset
32083 </cell>
32084 </row>
32085 <row topline="true">
32086 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32087 \begin_inset Text
32088
32089 \begin_layout Standard
32090
32091 \size footnotesize
32092 Maxim / Dallas
32093 \end_layout
32094
32095 \end_inset
32096 </cell>
32097 <cell multicolumn="1" alignment="left" valignment="top" topline="true" leftline="true" usebox="none" width="30line%">
32098 \begin_inset Text
32099
32100 \begin_layout Standard
32101
32102 \size footnotesize
32103 Using the Free SDCC C Compiler to Develop Firmware for the DS89C420/430/440/450
32104 \begin_inset LatexCommand \index{DS89C4x0}
32105
32106 \end_inset
32107
32108  Family of Microcontrollers
32109 \end_layout
32110
32111 \end_inset
32112 </cell>
32113 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32114 \begin_inset Text
32115
32116 \begin_layout Standard
32117
32118 \size footnotesize
32119 \begin_inset LatexCommand \url{http://pdfserv.maxim-ic.com/en/an/AN3477.pdf}
32120
32121 \end_inset
32122
32123
32124 \end_layout
32125
32126 \end_inset
32127 </cell>
32128 </row>
32129 <row topline="true">
32130 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32131 \begin_inset Text
32132
32133 \begin_layout Standard
32134
32135 \size footnotesize
32136 Silicon Laboratories / Cygnal
32137 \end_layout
32138
32139 \end_inset
32140 </cell>
32141 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32142 \begin_inset Text
32143
32144 \begin_layout Standard
32145
32146 \size footnotesize
32147 Integrating SDCC 8051 Tools Into The Silicon Labs IDE
32148 \begin_inset LatexCommand \index{IDE}
32149
32150 \end_inset
32151
32152
32153 \end_layout
32154
32155 \end_inset
32156 </cell>
32157 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32158 \begin_inset Text
32159
32160 \begin_layout Standard
32161
32162 \size footnotesize
32163 \begin_inset LatexCommand \url{http://www.silabs.com/public/documents/tpub_doc/anote/Microcontrollers/en/an198.pdf}
32164
32165 \end_inset
32166
32167
32168 \end_layout
32169
32170 \end_inset
32171 </cell>
32172 </row>
32173 <row topline="true">
32174 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32175 \begin_inset Text
32176
32177 \begin_layout Standard
32178
32179 \size footnotesize
32180 Ramtron / Goal Semiconductor
32181 \end_layout
32182
32183 \end_inset
32184 </cell>
32185 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32186 \begin_inset Text
32187
32188 \begin_layout Standard
32189
32190 \size footnotesize
32191 Interfacing SDCC to Syn and Textpad
32192 \end_layout
32193
32194 \end_inset
32195 </cell>
32196 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32197 \begin_inset Text
32198
32199 \begin_layout Standard
32200
32201 \size footnotesize
32202 \begin_inset LatexCommand \url{http://www.ramtron.com/doc/Products/Microcontroller/Support_Tools.asp}
32203
32204 \end_inset
32205
32206
32207 \end_layout
32208
32209 \end_inset
32210 </cell>
32211 </row>
32212 <row topline="true">
32213 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32214 \begin_inset Text
32215
32216 \begin_layout Standard
32217
32218 \size footnotesize
32219 Ramtron / Goal Semiconductor
32220 \end_layout
32221
32222 \end_inset
32223 </cell>
32224 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32225 \begin_inset Text
32226
32227 \begin_layout Standard
32228
32229 \size footnotesize
32230 Installing and Configuring SDCC and Crimson Editor 
32231 \end_layout
32232
32233 \end_inset
32234 </cell>
32235 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32236 \begin_inset Text
32237
32238 \begin_layout Standard
32239
32240 \size footnotesize
32241 \begin_inset LatexCommand \url{http://www.ramtron.com/doc/Products/Microcontroller/Support_Tools.asp}
32242
32243 \end_inset
32244
32245
32246 \end_layout
32247
32248 \end_inset
32249 </cell>
32250 </row>
32251 <row topline="true" bottomline="true">
32252 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32253 \begin_inset Text
32254
32255 \begin_layout Standard
32256
32257 \size footnotesize
32258 Texas Instruments
32259 \end_layout
32260
32261 \end_inset
32262 </cell>
32263 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32264 \begin_inset Text
32265
32266 \begin_layout Standard
32267
32268 \size footnotesize
32269 MSC12xx Programming with SDCC
32270 \end_layout
32271
32272 \end_inset
32273 </cell>
32274 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32275 \begin_inset Text
32276
32277 \begin_layout Standard
32278
32279 \size footnotesize
32280 \begin_inset LatexCommand \url{http://focus.ti.com/general/docs/lit/getliterature.tsp?literatureNumber=sbaa109&fileType=pdf}
32281
32282 \end_inset
32283
32284
32285 \end_layout
32286
32287 \end_inset
32288 </cell>
32289 </row>
32290 </lyxtabular>
32291
32292 \end_inset
32293
32294
32295 \end_layout
32296
32297 \begin_layout Section
32298 Some Questions
32299 \end_layout
32300
32301 \begin_layout Standard
32302 Some questions answered, some pointers given - it might be time to in turn
32303  ask 
32304 \emph on
32305 you
32306 \emph default
32307  some questions: 
32308 \end_layout
32309
32310 \begin_layout Itemize
32311 can you solve your project with the selected microcontroller? Would you
32312  find out early or rather late that your target is too small/slow/whatever?
32313  Can you switch to a slightly better device if it doesn't fit?
32314 \end_layout
32315
32316 \begin_layout Itemize
32317 should you solve the problem with an 8 bit CPU? Or would a 16/32 bit CPU
32318  and/or another programming language be more adequate? Would an operating
32319  system on the target device help?
32320 \end_layout
32321
32322 \begin_layout Itemize
32323 if you solved the problem, will the marketing department be happy?
32324 \end_layout
32325
32326 \begin_layout Itemize
32327 if the marketing department is happy, will customers be happy?
32328 \end_layout
32329
32330 \begin_layout Itemize
32331 if you're the project manager, marketing department and maybe even the customer
32332  in one person, have you tried to see the project from the outside?
32333 \end_layout
32334
32335 \begin_layout Itemize
32336 is the project done if you think it is done? Or is just that other interface/pro
32337 tocol/feature/configuration/option missing? How about website, manual(s),
32338  internationali(z|s)ation, packaging, labels, 2nd source for components,
32339  electromagnetic compatability/interference, documentation for production,
32340  production test software, update mechanism, patent issues?
32341 \end_layout
32342
32343 \begin_layout Itemize
32344 is your project adequately positioned in that magic triangle: fame, fortune,
32345  fun?
32346 \end_layout
32347
32348 \begin_layout Standard
32349 Maybe not all answers to these questions are known and some answers may
32350  even be 
32351 \emph on
32352 no
32353 \emph default
32354 , nevertheless knowing these questions may help you to avoid burnout
32355 \begin_inset Foot
32356 status open
32357
32358 \begin_layout Standard
32359 burnout is bad for electronic devices, programmers and motorcycle tyres
32360 \end_layout
32361
32362 \end_inset
32363
32364 .
32365  Chances are you didn't want to hear some of them...
32366 \end_layout
32367
32368 \begin_layout Chapter
32369 Support
32370 \begin_inset LatexCommand \index{Support}
32371
32372 \end_inset
32373
32374
32375 \end_layout
32376
32377 \begin_layout Standard
32378 SDCC has grown to be a large project.
32379  The compiler alone (without the preprocessor, assembler and linker) is
32380  well over 150,000 lines of code (blank stripped).
32381  The open source nature of this project is a key to its continued growth
32382  and support.
32383  You gain the benefit and support of many active software developers and
32384  end users.
32385  Is SDCC perfect? No, that's why we need your help.
32386  The developers take pride in fixing reported bugs.
32387  You can help by reporting the bugs and helping other SDCC users.
32388  There are lots of ways to contribute, and we encourage you to take part
32389  in making SDCC a great software package.
32390  
32391 \end_layout
32392
32393 \begin_layout Standard
32394 The SDCC project is hosted on the SDCC sourceforge site at 
32395 \begin_inset LatexCommand \htmlurl{http://sourceforge.net/projects/sdcc}
32396
32397 \end_inset
32398
32399 .
32400  You'll find the complete set of mailing lists
32401 \begin_inset LatexCommand \index{Mailing list(s)}
32402
32403 \end_inset
32404
32405 , forums, bug reporting system, patch submission
32406 \begin_inset LatexCommand \index{Patch submission}
32407
32408 \end_inset
32409
32410  system, download
32411 \begin_inset LatexCommand \index{download}
32412
32413 \end_inset
32414
32415  area and Subversion code repository
32416 \begin_inset LatexCommand \index{Subversion code repository}
32417
32418 \end_inset
32419
32420  there.
32421 \end_layout
32422
32423 \begin_layout Section
32424 Reporting Bugs
32425 \begin_inset LatexCommand \index{Bug reporting}
32426
32427 \end_inset
32428
32429
32430 \begin_inset LatexCommand \index{Reporting bugs}
32431
32432 \end_inset
32433
32434
32435 \end_layout
32436
32437 \begin_layout Standard
32438 The recommended way of reporting bugs is using the infrastructure of the
32439  sourceforge site.
32440  You can follow the status of bug reports there and have an overview about
32441  the known bugs.
32442 \end_layout
32443
32444 \begin_layout Standard
32445 Bug reports are automatically forwarded to the developer mailing list and
32446  will be fixed ASAP.
32447  When reporting a bug, it is very useful to include a small test program
32448  (the smaller the better) which reproduces the problem.
32449  If you can isolate the problem by looking at the generated assembly code,
32450  this can be very helpful.
32451  Compiling your program with the -
32452 \begin_inset ERT
32453 status collapsed
32454
32455 \begin_layout Standard
32456
32457
32458 \backslash
32459 /
32460 \end_layout
32461
32462 \end_inset
32463
32464 -dumpall
32465 \begin_inset LatexCommand \index{-\/-dumpall}
32466
32467 \end_inset
32468
32469  option can sometimes be useful in locating optimization problems.
32470  When reporting a bug please make sure you:
32471 \end_layout
32472
32473 \begin_layout Enumerate
32474 Attach the code you are compiling with SDCC.
32475  
32476 \end_layout
32477
32478 \begin_layout Enumerate
32479 Specify the exact command you use to run SDCC, or attach your Makefile.
32480  
32481 \end_layout
32482
32483 \begin_layout Enumerate
32484 Specify the SDCC version (type "
32485 \family sans
32486 \series bold
32487 sdcc -v
32488 \family default
32489 \series default
32490 "), your platform, and operating system.
32491  
32492 \end_layout
32493
32494 \begin_layout Enumerate
32495 Provide an exact copy of any error message or incorrect output.
32496  
32497 \end_layout
32498
32499 \begin_layout Enumerate
32500 Put something meaningful in the subject of your message.
32501 \end_layout
32502
32503 \begin_layout Standard
32504 Please attempt to include these 5 important parts, as applicable, in all
32505  requests for support or when reporting any problems or bugs with SDCC.
32506  Though this will make your message lengthy, it will greatly improve your
32507  chance that SDCC users and developers will be able to help you.
32508  Some SDCC developers are frustrated by bug reports without code provided
32509  that they can use to reproduce and ultimately fix the problem, so please
32510  be sure to provide sample code if you are reporting a bug! 
32511 \end_layout
32512
32513 \begin_layout Standard
32514 Please have a short check that you are using a recent version of SDCC and
32515  the bug is not yet known.
32516  This is the link for reporting bugs: 
32517 \begin_inset LatexCommand \htmlurl{http://sourceforge.net/tracker/?group_id=599&atid=100599}
32518
32519 \end_inset
32520
32521 .
32522  With SDCC on average having more than 200 downloads
32523 \begin_inset LatexCommand \index{download}
32524
32525 \end_inset
32526
32527  on sourceforge per day
32528 \begin_inset Foot
32529 status open
32530
32531 \begin_layout Standard
32532 220 daily downloads on average Jan-Sept 2006 and about 150 daily downloads
32533  between 2002 and 2005.
32534  This does not include other methods of distribution.
32535 \end_layout
32536
32537 \end_inset
32538
32539  there must be some users.
32540  So it's not exactly easy to find a new bug.
32541  If you find one we need it: 
32542 \emph on
32543 reporting bugs is good
32544 \emph default
32545 .
32546 \end_layout
32547
32548 \begin_layout Section
32549 Requesting Features
32550 \begin_inset LatexCommand \label{sub:Requesting-Features}
32551
32552 \end_inset
32553
32554
32555 \begin_inset LatexCommand \index{Feature request}
32556
32557 \end_inset
32558
32559
32560 \begin_inset LatexCommand \index{Requesting features}
32561
32562 \end_inset
32563
32564
32565 \end_layout
32566
32567 \begin_layout Standard
32568 Like bug reports feature requests are forwarded to the developer mailing
32569  list.
32570  This is the link for requesting features: 
32571 \begin_inset LatexCommand \htmlurl{http://sourceforge.net/tracker/?group_id=599&atid=350599}
32572
32573 \end_inset
32574
32575 .
32576 \end_layout
32577
32578 \begin_layout Section
32579 Submitting patches
32580 \end_layout
32581
32582 \begin_layout Standard
32583 Like bug reports contributed patches are forwarded to the developer mailing
32584  list.
32585  This is the link for submitting patches
32586 \begin_inset LatexCommand \index{Patch submission}
32587
32588 \end_inset
32589
32590
32591 \begin_inset LatexCommand \url{http://sourceforge.net/tracker/?group_id=599&atid=300599}
32592
32593 \end_inset
32594
32595 .
32596 \end_layout
32597
32598 \begin_layout Standard
32599 You need to specify some parameters to the 
32600 \family typewriter
32601 diff
32602 \family default
32603  command for the patches to be useful.
32604  If you modified more than one file a patch created f.e.
32605  with 
32606 \family sans
32607 \series bold
32608
32609 \begin_inset Quotes sld
32610 \end_inset
32611
32612 diff -Naur unmodified_directory modified_directory >my_changes.patch
32613 \begin_inset Quotes srd
32614 \end_inset
32615
32616
32617 \family default
32618 \series default
32619  will be fine, otherwise 
32620 \family sans
32621 \series bold
32622
32623 \begin_inset Quotes sld
32624 \end_inset
32625
32626 diff -u sourcefile.c.orig sourcefile.c >my_changes.patch
32627 \begin_inset Quotes srd
32628 \end_inset
32629
32630
32631 \series default
32632  
32633 \family default
32634 will do.
32635 \end_layout
32636
32637 \begin_layout Section
32638 Getting Help
32639 \end_layout
32640
32641 \begin_layout Standard
32642 These links should take you directly to the 
32643 \begin_inset LatexCommand \url[Mailing lists]{http://sourceforge.net/mail/?group_id=599}
32644
32645 \end_inset
32646
32647
32648 \begin_inset Foot
32649 status open
32650
32651 \begin_layout Standard
32652 Traffic on sdcc-devel and sdcc-user is about 100 mails/month each not counting
32653  automated messages (mid 2003)
32654 \end_layout
32655
32656 \end_inset
32657
32658  and the 
32659 \begin_inset LatexCommand \url[Forums]{http://sourceforge.net/forum/?group_id=599}
32660
32661 \end_inset
32662
32663 , lists
32664 \begin_inset LatexCommand \index{Mailing list(s)}
32665
32666 \end_inset
32667
32668  and forums are archived and searchable so if you are lucky someone already
32669  had a similar problem.
32670  While mails to the lists themselves are delivered promptly their web front
32671  end on sourceforge sometimes shows a severe time lag (up to several weeks),
32672  if you're seriously using SDCC please consider subscribing to the lists.
32673 \end_layout
32674
32675 \begin_layout Section
32676 ChangeLog
32677 \end_layout
32678
32679 \begin_layout Standard
32680 You can follow the status of the Subversion version
32681 \begin_inset LatexCommand \index{version}
32682
32683 \end_inset
32684
32685  of SDCC by watching the Changelog
32686 \begin_inset LatexCommand \index{Changelog}
32687
32688 \end_inset
32689
32690  in the Subversion repository
32691 \size footnotesize
32692  
32693 \begin_inset LatexCommand \htmlurl{http://sdcc.svn.sourceforge.net/viewcvs.cgi/*checkout*/sdcc/trunk/sdcc/ChangeLog}
32694
32695 \end_inset
32696
32697 .
32698 \end_layout
32699
32700 \begin_layout Section
32701 Subversion Source Code Repository
32702 \end_layout
32703
32704 \begin_layout Standard
32705 The output of 
32706 \family sans
32707 \series bold
32708 sdcc -
32709 \family default
32710
32711 \begin_inset ERT
32712 status open
32713
32714 \begin_layout Standard
32715
32716
32717 \backslash
32718 /
32719 \end_layout
32720
32721 \end_inset
32722
32723
32724 \family sans
32725 -version
32726 \family default
32727 \series default
32728  or the filenames of the snapshot versions of SDCC include date and its
32729  Subversion
32730 \begin_inset LatexCommand \index{Subversion code repository}
32731
32732 \end_inset
32733
32734  number.
32735  Subversion allows to download the source of recent or previous versions
32736  
32737 \begin_inset LatexCommand \url{http://sourceforge.net/svn/?group_id=599}
32738
32739 \end_inset
32740
32741  (by number or by date).
32742  An on-line source code browser and detailled instructions are also available
32743  there.
32744  SDCC versions starting from 1999 up to now are available (currently the
32745  versions prior to the conversion from cvs
32746 \begin_inset LatexCommand \index{cvs|see{Subversion}}
32747
32748 \end_inset
32749
32750  to Subversion (April 2006) are either by accessible by Subversion or by
32751  cvs).
32752 \end_layout
32753
32754 \begin_layout Section
32755 Release policy
32756 \begin_inset LatexCommand \index{Release policy}
32757
32758 \end_inset
32759
32760
32761 \end_layout
32762
32763 \begin_layout Standard
32764 Historically there often were long delays between official releases and
32765  the sourceforge download area tends to get not updated at all.
32766  Excuses in the past might have referred to problems with live range analysis,
32767  but as this was fixed a while ago, the current problem is that another
32768  excuse has to be found.
32769  Kidding aside, we have to get better there! On the other hand there are
32770  daily snapshots available at 
32771 \begin_inset LatexCommand \htmlurl[snap]{http://sdcc.sourceforge.net/snap.php}
32772
32773 \end_inset
32774
32775 , and you can always build the very last version (hopefully with many bugs
32776  fixed, and features added) from the source code available at 
32777 \begin_inset LatexCommand \htmlurl[Source]{http://sdcc.sourceforge.net/snap.php#Source}
32778
32779 \end_inset
32780
32781 .
32782  The SDCC Wiki
32783 \begin_inset LatexCommand \index{wiki}
32784
32785 \end_inset
32786
32787
32788 \begin_inset LatexCommand \index{SDCC Wiki}
32789
32790 \end_inset
32791
32792  at 
32793 \begin_inset LatexCommand \url{http://sdcc.wiki.sourceforge.net/}
32794
32795 \end_inset
32796
32797  also holds some information about past and future releases.
32798 \end_layout
32799
32800 \begin_layout Section
32801 Examples
32802 \begin_inset LatexCommand \index{Examples}
32803
32804 \end_inset
32805
32806
32807 \end_layout
32808
32809 \begin_layout Standard
32810 You'll find some small examples in the directory 
32811 \emph on
32812 sdcc/device/examples/.
32813  
32814 \emph default
32815 More examples and libraries are available at
32816 \emph on
32817  The SDCC Open Knowledge Resource 
32818 \begin_inset LatexCommand \url{http://sdccokr.dl9sec.de/}
32819
32820 \end_inset
32821
32822  
32823 \emph default
32824 web site or at 
32825 \begin_inset LatexCommand \url{http://www.pjrc.com/tech/8051/}
32826
32827 \end_inset
32828
32829 .
32830 \end_layout
32831
32832 \begin_layout Standard
32833 \begin_inset Note Note
32834 status collapsed
32835
32836 \begin_layout Standard
32837 I did insert a reference to Paul's web site here although it seems rather
32838  dedicated to a specific 8032 board (I think it's okay because it f.e.
32839  shows LCD/Harddisc interface and has a free 8051 monitor.
32840  Independent 8032 board vendors face hard competition of heavily subsidized
32841  development boards anyway).
32842 \end_layout
32843
32844 \begin_layout Standard
32845 Maybe we should include some links to real world applications.
32846  Preferably pointer to pointers (one for each architecture) so this stays
32847  manageable here?
32848 \end_layout
32849
32850 \end_inset
32851
32852
32853 \end_layout
32854
32855 \begin_layout Section
32856 Quality control
32857 \begin_inset LatexCommand \label{sec:Quality-control}
32858
32859 \end_inset
32860
32861
32862 \begin_inset LatexCommand \index{Quality control}
32863
32864 \end_inset
32865
32866
32867 \end_layout
32868
32869 \begin_layout Standard
32870 The compiler is passed through snaphot build compile and build checks.
32871  The so called 
32872 \shape italic
32873 regression tests
32874 \shape default
32875
32876 \begin_inset LatexCommand \index{Regression test}
32877
32878 \end_inset
32879
32880  check that SDCC itself compiles flawlessly on several host platforms (i386,
32881  Opteron, 64 bit Alpha, ppc64, Mac OS X on PPC, Solaris on Sparc) and checks
32882  the quality of the code generated by SDCC by running the code for several
32883  target platforms through simulators.
32884  The regression test suite comprises more than 100 files which expand to
32885  more than 500 test cases which include more than 4500 tests.
32886  The results of these tests are published daily on SDCC's snapshot page
32887  (click on the red or green symbols on the right side of 
32888 \begin_inset LatexCommand \url{http://sdcc.sourceforge.net/snap.php}
32889
32890 \end_inset
32891
32892 ).
32893 \end_layout
32894
32895 \begin_layout Standard
32896 There is a separate document 
32897 \shape italic
32898 test_suite.pdf 
32899 \begin_inset LatexCommand \index{Test suite}
32900
32901 \end_inset
32902
32903
32904 \shape default
32905  
32906 \begin_inset LatexCommand \url{http://sdcc.sourceforge.net/doc/test_suite_spec.pdf}
32907
32908 \end_inset
32909
32910  about the regression test suite.
32911 \end_layout
32912
32913 \begin_layout Standard
32914 You'll find the test code in the directory 
32915 \shape italic
32916 sdcc/support/regression
32917 \shape default
32918 .
32919  You can run these tests manually by running 
32920 \family sans
32921 make
32922 \family default
32923  in this directory (or f.e.
32924  
32925 \family sans
32926 \series bold
32927
32928 \begin_inset Quotes sld
32929 \end_inset
32930
32931 make test-mcs51
32932 \begin_inset Quotes srd
32933 \end_inset
32934
32935
32936 \family default
32937 \series default
32938  if you don't want to run the complete tests).
32939  The test code might also be interesting if you want to look for examples
32940 \begin_inset LatexCommand \index{Examples}
32941
32942 \end_inset
32943
32944  checking corner cases of SDCC or if you plan to submit patches
32945 \begin_inset LatexCommand \index{Patch submission}
32946
32947 \end_inset
32948
32949 .
32950 \end_layout
32951
32952 \begin_layout Standard
32953 The PIC14 port uses a different set of regression tests 
32954 \begin_inset LatexCommand \index{Regression test (PIC14)}
32955
32956 \end_inset
32957
32958 , you'll find them in the directory 
32959 \shape italic
32960 sdcc/src/regression
32961 \shape default
32962 .
32963 \end_layout
32964
32965 \begin_layout Section
32966 Use of SDCC in Education
32967 \end_layout
32968
32969 \begin_layout Standard
32970 In short: 
32971 \emph on
32972 highly
32973 \emph default
32974  encouraged
32975 \begin_inset Foot
32976 status open
32977
32978 \begin_layout Standard
32979 the phrase "use in education" might evoke the association "
32980 \emph on
32981 only
32982 \emph default
32983  fit for use in education".
32984  This connotation is not intended but nevertheless risked as the licensing
32985  of SDCC makes it difficult to offer educational discounts
32986 \end_layout
32987
32988 \end_inset
32989
32990 .
32991  If your rationales are to:
32992 \end_layout
32993
32994 \begin_layout Enumerate
32995 give students a chance to understand the 
32996 \emph on
32997 complete
32998 \emph default
32999  steps of code generation
33000 \end_layout
33001
33002 \begin_layout Enumerate
33003 have a curriculum that can be extended for years.
33004  Then you could use an fpga board as target and your curriculum will seamlessly
33005  extend from logic synthesis (
33006 \begin_inset LatexCommand \url[http://www.opencores.org]{opencores.org}
33007
33008 \end_inset
33009
33010
33011 \begin_inset LatexCommand \url[Oregano]{http://www.oregano.at/ip/ip01.htm}
33012
33013 \end_inset
33014
33015 ), over assembly programming, to C to FPGA compilers (
33016 \begin_inset LatexCommand \url[FPGAC]{http://sf.net/projects/fpgac}
33017
33018 \end_inset
33019
33020 ) and to C.
33021 \end_layout
33022
33023 \begin_layout Enumerate
33024 be able to insert excursions about skills like using a revision control
33025  system, submitting/applying patches, using a type-setting (as opposed to
33026  word-processing) engine LyX/LaTeX, using 
33027 \begin_inset LatexCommand \url[SourceForge]{http://www.sf.net}
33028
33029 \end_inset
33030
33031 , following some 
33032 \begin_inset LatexCommand \url[netiquette]{http://en.wikipedia.org/wiki/Netiquette}
33033
33034 \end_inset
33035
33036 , understanding BSD/LGPL/GPL/Proprietary licensing, growth models of Open
33037  Source Software, CPU simulation, compiler regression tests
33038 \begin_inset LatexCommand \index{Regression test}
33039
33040 \end_inset
33041
33042 .
33043  
33044 \newline
33045 And if there should be a shortage of ideas then you can always point students
33046  to the ever-growing feature request list 
33047 \begin_inset LatexCommand \htmlurl{http://sourceforge.net/tracker/?group_id=599&atid=350599}
33048
33049 \end_inset
33050
33051 .
33052 \end_layout
33053
33054 \begin_layout Enumerate
33055 not tie students to a specific host platform and instead allow them to use
33056  a host platform of 
33057 \emph on
33058 their
33059 \emph default
33060  choice (among them Alpha, i386, i386_64, Mac OS X, Mips, Sparc, Windows
33061  and eventually 
33062 \begin_inset LatexCommand \url[OLPC]{http://www.laptop.org}
33063
33064 \end_inset
33065
33066 )
33067 \end_layout
33068
33069 \begin_layout Enumerate
33070 not encourage students to use illegal copies of educational software
33071 \end_layout
33072
33073 \begin_layout Enumerate
33074 be immune to licensing/availability/price changes of the chosen tool chain
33075 \end_layout
33076
33077 \begin_layout Enumerate
33078 be able to change to a new target platform without having to adopt a new
33079  tool chain
33080 \end_layout
33081
33082 \begin_layout Enumerate
33083 have complete control over and insight into the tool chain
33084 \end_layout
33085
33086 \begin_layout Enumerate
33087 make your students aware about the pros and cons of open source software
33088  development
33089 \end_layout
33090
33091 \begin_layout Enumerate
33092 give back to the public as you are probably at least partially publically
33093  funded
33094 \end_layout
33095
33096 \begin_layout Enumerate
33097 give students a chance to publically prove their skills and to possibly
33098  see a world wide impact
33099 \end_layout
33100
33101 \begin_layout Standard
33102 then SDCC is probably among the first choices.
33103  Well, probably SDCC might be the only choice.
33104 \newpage
33105
33106 \end_layout
33107
33108 \begin_layout Chapter
33109 SDCC Technical Data
33110 \end_layout
33111
33112 \begin_layout Section
33113 Optimizations
33114 \begin_inset LatexCommand \index{Optimizations}
33115
33116 \end_inset
33117
33118
33119 \end_layout
33120
33121 \begin_layout Standard
33122 SDCC performs a host of standard optimizations in addition to some MCU specific
33123  optimizations.
33124  
33125 \end_layout
33126
33127 \begin_layout Subsection
33128 Sub-expression Elimination
33129 \begin_inset LatexCommand \index{Subexpression elimination}
33130
33131 \end_inset
33132
33133
33134 \end_layout
33135
33136 \begin_layout Standard
33137 The compiler does local and 
33138 \emph on
33139 g
33140 \emph default
33141 lobal 
33142 \emph on
33143 c
33144 \emph default
33145 ommon 
33146 \emph on
33147 s
33148 \emph default
33149 ubexpression 
33150 \emph on
33151 e
33152 \emph default
33153 limination, e.g.: 
33154 \end_layout
33155
33156 \begin_layout Verse
33157
33158 \family typewriter
33159 i = x + y + 1; 
33160 \newline
33161 j = x + y;
33162 \end_layout
33163
33164 \begin_layout Standard
33165 will be translated to
33166 \end_layout
33167
33168 \begin_layout Verse
33169
33170 \family typewriter
33171 iTemp = x + y; 
33172 \newline
33173 i = iTemp + 1; 
33174 \newline
33175 j = iTemp;
33176 \end_layout
33177
33178 \begin_layout Standard
33179 Some subexpressions are not as obvious as the above example, e.g.:
33180 \end_layout
33181
33182 \begin_layout Verse
33183
33184 \family typewriter
33185 a->b[i].c = 10; 
33186 \newline
33187 a->b[i].d = 11;
33188 \end_layout
33189
33190 \begin_layout Standard
33191 In this case the address arithmetic a->b[i] will be computed only once;
33192  the equivalent code in C would be.
33193 \end_layout
33194
33195 \begin_layout Verse
33196
33197 \family typewriter
33198 iTemp = a->b[i]; 
33199 \newline
33200 iTemp.c = 10; 
33201 \newline
33202 iTemp.d = 11;
33203 \end_layout
33204
33205 \begin_layout Standard
33206 The compiler will try to keep these temporary variables in registers.
33207 \end_layout
33208
33209 \begin_layout Subsection
33210 Dead-Code Elimination
33211 \begin_inset LatexCommand \index{Dead-code elimination}
33212
33213 \end_inset
33214
33215
33216 \end_layout
33217
33218 \begin_layout Verse
33219
33220 \family typewriter
33221 int global;
33222 \newline
33223
33224 \newline
33225 void f () { 
33226 \newline
33227 \InsetSpace ~
33228 \InsetSpace ~
33229 int i; 
33230 \newline
33231 \InsetSpace ~
33232 \InsetSpace ~
33233 i = 1; \InsetSpace ~
33234 \InsetSpace ~
33235 \InsetSpace ~
33236 \InsetSpace ~
33237 \InsetSpace ~
33238 /* dead store */ 
33239 \newline
33240 \InsetSpace ~
33241 \InsetSpace ~
33242 global = 1;\InsetSpace ~
33243 /* dead
33244  store */ 
33245 \newline
33246 \InsetSpace ~
33247 \InsetSpace ~
33248 global = 2; 
33249 \newline
33250 \InsetSpace ~
33251 \InsetSpace ~
33252 return; 
33253 \newline
33254 \InsetSpace ~
33255 \InsetSpace ~
33256 global = 3;\InsetSpace ~
33257 /* unreachable */ 
33258 \newline
33259 }
33260 \end_layout
33261
33262 \begin_layout Standard
33263 will be changed to
33264 \end_layout
33265
33266 \begin_layout Verse
33267
33268 \family typewriter
33269 int global;
33270 \newline
33271
33272 \newline
33273 void f () {
33274 \newline
33275 \InsetSpace ~
33276 \InsetSpace ~
33277 global = 2; 
33278 \newline
33279 }
33280 \end_layout
33281
33282 \begin_layout Subsection
33283 Copy-Propagation
33284 \begin_inset LatexCommand \index{Copy propagation}
33285
33286 \end_inset
33287
33288
33289 \end_layout
33290
33291 \begin_layout Verse
33292
33293 \family typewriter
33294 int f() { 
33295 \newline
33296 \InsetSpace ~
33297 \InsetSpace ~
33298 int i, j; 
33299 \newline
33300 \InsetSpace ~
33301 \InsetSpace ~
33302 i = 10; 
33303 \newline
33304 \InsetSpace ~
33305 \InsetSpace ~
33306 j = i; 
33307 \newline
33308 \InsetSpace ~
33309 \InsetSpace ~
33310 return j; 
33311 \newline
33312 }
33313 \end_layout
33314
33315 \begin_layout Standard
33316 will be changed to 
33317 \end_layout
33318
33319 \begin_layout Verse
33320
33321 \family typewriter
33322 int f() { 
33323 \newline
33324 \InsetSpace ~
33325 \InsetSpace ~
33326 int i, j; 
33327 \newline
33328 \InsetSpace ~
33329 \InsetSpace ~
33330 i = 10; 
33331 \newline
33332 \InsetSpace ~
33333 \InsetSpace ~
33334 j = 10; 
33335 \newline
33336 \InsetSpace ~
33337 \InsetSpace ~
33338 return 10; 
33339 \newline
33340 }
33341 \end_layout
33342
33343 \begin_layout Standard
33344 Note: the dead stores created by this copy propagation will be eliminated
33345  by dead-code elimination.
33346 \end_layout
33347
33348 \begin_layout Subsection
33349 Loop Optimizations
33350 \begin_inset LatexCommand \index{Loop optimization}
33351
33352 \end_inset
33353
33354
33355 \begin_inset LatexCommand \label{sub:Loop-Optimizations}
33356
33357 \end_inset
33358
33359
33360 \end_layout
33361
33362 \begin_layout Standard
33363 Two types of loop optimizations are done by SDCC 
33364 \emph on
33365 loop invariant
33366 \emph default
33367  lifting and
33368 \emph on
33369  strength reduction
33370 \emph default
33371  of loop induction variables.
33372  In addition to the strength reduction the optimizer marks the induction
33373  variables and the register allocator tries to keep the induction variables
33374  in registers for the duration of the loop.
33375  Because of this preference of the register allocator
33376 \begin_inset LatexCommand \index{Register allocation}
33377
33378 \end_inset
33379
33380 , loop induction optimization causes an increase in register pressure, which
33381  may cause unwanted spilling of other temporary variables into the stack
33382 \begin_inset LatexCommand \index{stack}
33383
33384 \end_inset
33385
33386  / data space.
33387  The compiler will generate a warning message when it is forced to allocate
33388  extra space either on the stack or data space.
33389  If this extra space allocation is undesirable then induction optimization
33390  can be eliminated either for the entire source file (with -
33391 \begin_inset ERT
33392 status collapsed
33393
33394 \begin_layout Standard
33395
33396
33397 \backslash
33398 /
33399 \end_layout
33400
33401 \end_inset
33402
33403 -noinduction option) or for a given function only using #pragma\InsetSpace ~
33404 noinduction
33405 \begin_inset LatexCommand \index{\#pragma noinduction}
33406
33407 \end_inset
33408
33409 .
33410 \newline
33411
33412 \newline
33413 Loop Invariant:
33414 \end_layout
33415
33416 \begin_layout Verse
33417
33418 \family typewriter
33419 for (i = 0 ; i < 100 ; i ++) 
33420 \newline
33421 \InsetSpace ~
33422 \InsetSpace ~
33423 \InsetSpace ~
33424 \InsetSpace ~
33425 f += k + l;
33426 \end_layout
33427
33428 \begin_layout Standard
33429 changed to
33430 \end_layout
33431
33432 \begin_layout Verse
33433
33434 \family typewriter
33435 itemp = k + l; 
33436 \newline
33437 for (i = 0; i < 100; i++) 
33438 \newline
33439 \InsetSpace ~
33440 \InsetSpace ~
33441 \InsetSpace ~
33442 \InsetSpace ~
33443 f += itemp;
33444 \end_layout
33445
33446 \begin_layout Standard
33447 As mentioned previously some loop invariants are not as apparent, all static
33448  address computations are also moved out of the loop.
33449 \newline
33450
33451 \newline
33452 Strength Reduction
33453 \begin_inset LatexCommand \index{Strength reduction}
33454
33455 \end_inset
33456
33457 , this optimization substitutes an expression by a cheaper expression:
33458 \end_layout
33459
33460 \begin_layout Verse
33461
33462 \family typewriter
33463 for (i=0;i < 100; i++)
33464 \newline
33465 \InsetSpace ~
33466 \InsetSpace ~
33467 \InsetSpace ~
33468 \InsetSpace ~
33469 ar[i*5] = i*3;
33470 \end_layout
33471
33472 \begin_layout Standard
33473 changed to
33474 \end_layout
33475
33476 \begin_layout Verse
33477
33478 \family typewriter
33479 itemp1 = 0; 
33480 \newline
33481 itemp2 = 0; 
33482 \newline
33483 for (i=0;i< 100;i++) { 
33484 \newline
33485 \InsetSpace ~
33486 \InsetSpace ~
33487 \InsetSpace ~
33488 \InsetSpace ~
33489 ar[itemp1] = itemp2; 
33490 \newline
33491 \InsetSpace ~
33492 \InsetSpace ~
33493 \InsetSpace ~
33494 \InsetSpace ~
33495 itemp1
33496  += 5; 
33497 \newline
33498 \InsetSpace ~
33499 \InsetSpace ~
33500 \InsetSpace ~
33501 \InsetSpace ~
33502 itemp2 += 3; 
33503 \newline
33504 }
33505 \end_layout
33506
33507 \begin_layout Standard
33508 The more expensive multiplication
33509 \begin_inset LatexCommand \index{Multiplication}
33510
33511 \end_inset
33512
33513  is changed to a less expensive addition.
33514 \end_layout
33515
33516 \begin_layout Subsection
33517 Loop Reversing
33518 \begin_inset LatexCommand \index{Loop reversing}
33519
33520 \end_inset
33521
33522
33523 \end_layout
33524
33525 \begin_layout Standard
33526 This optimization is done to reduce the overhead of checking loop boundaries
33527  for every iteration.
33528  Some simple loops can be reversed and implemented using a 
33529 \begin_inset Quotes eld
33530 \end_inset
33531
33532 decrement and jump if not zero
33533 \begin_inset Quotes erd
33534 \end_inset
33535
33536  instruction.
33537  SDCC checks for the following criterion to determine if a loop is reversible
33538  (note: more sophisticated compilers use data-dependency analysis to make
33539  this determination, SDCC uses a more simple minded analysis).
33540 \end_layout
33541
33542 \begin_layout Itemize
33543 The 'for' loop is of the form 
33544 \newline
33545
33546 \newline
33547
33548 \family typewriter
33549 for(<symbol> = <expression>; <sym> [< | <=] <expression>; [<sym>++ | <sym>
33550  += 1])
33551 \newline
33552 \InsetSpace ~
33553 \InsetSpace ~
33554 \InsetSpace ~
33555 \InsetSpace ~
33556 <for body>
33557 \end_layout
33558
33559 \begin_layout Itemize
33560 The <for body> does not contain 
33561 \begin_inset Quotes eld
33562 \end_inset
33563
33564 continue
33565 \begin_inset Quotes erd
33566 \end_inset
33567
33568  or 'break
33569 \begin_inset Quotes erd
33570 \end_inset
33571
33572 .
33573 \end_layout
33574
33575 \begin_layout Itemize
33576 All goto's are contained within the loop.
33577 \end_layout
33578
33579 \begin_layout Itemize
33580 No function calls within the loop.
33581 \end_layout
33582
33583 \begin_layout Itemize
33584 The loop control variable <sym> is not assigned any value within the loop
33585 \end_layout
33586
33587 \begin_layout Itemize
33588 The loop control variable does NOT participate in any arithmetic operation
33589  within the loop.
33590 \end_layout
33591
33592 \begin_layout Itemize
33593 There are NO switch statements in the loop.
33594 \end_layout
33595
33596 \begin_layout Subsection
33597 Algebraic Simplifications
33598 \end_layout
33599
33600 \begin_layout Standard
33601 SDCC does numerous algebraic simplifications, the following is a small sub-set
33602  of these optimizations.
33603 \end_layout
33604
33605 \begin_layout Verse
33606
33607 \family typewriter
33608 i = j + 0;\InsetSpace ~
33609 \InsetSpace ~
33610 \InsetSpace ~
33611 \InsetSpace ~
33612  /* changed to: */\InsetSpace ~
33613 \InsetSpace ~
33614 \InsetSpace ~
33615 \InsetSpace ~
33616  i = j; 
33617 \newline
33618 i /= 2;\InsetSpace ~
33619 \InsetSpace ~
33620 \InsetSpace ~
33621 \InsetSpace ~
33622 \InsetSpace ~
33623 \InsetSpace ~
33624 \InsetSpace ~
33625  /* changed to: */\InsetSpace ~
33626 \InsetSpace ~
33627 \InsetSpace ~
33628 \InsetSpace ~
33629  i >>= 1; 
33630 \newline
33631 i
33632  = j - j;\InsetSpace ~
33633 \InsetSpace ~
33634 \InsetSpace ~
33635 \InsetSpace ~
33636  /* changed to: */\InsetSpace ~
33637 \InsetSpace ~
33638 \InsetSpace ~
33639 \InsetSpace ~
33640  i = 0; 
33641 \newline
33642 i = j / 1;\InsetSpace ~
33643 \InsetSpace ~
33644 \InsetSpace ~
33645 \InsetSpace ~
33646  /* changed to: */\InsetSpace ~
33647 \InsetSpace ~
33648 \InsetSpace ~
33649 \InsetSpace ~
33650  i = j;
33651 \end_layout
33652
33653 \begin_layout Standard
33654 Note the subexpressions
33655 \begin_inset LatexCommand \index{Subexpression}
33656
33657 \end_inset
33658
33659  given above are generally introduced by macro expansions or as a result
33660  of copy/constant propagation.
33661 \end_layout
33662
33663 \begin_layout Subsection
33664 'switch' Statements
33665 \begin_inset LatexCommand \label{sub:'switch'-Statements}
33666
33667 \end_inset
33668
33669
33670 \begin_inset LatexCommand \index{switch statement}
33671
33672 \end_inset
33673
33674
33675 \end_layout
33676
33677 \begin_layout Standard
33678 SDCC can optimize switch statements to jump tables
33679 \begin_inset LatexCommand \index{jump tables}
33680
33681 \end_inset
33682
33683 .
33684  It makes the decision based on an estimate of the generated code size.
33685  SDCC is quite liberal in the requirements for jump table generation: 
33686 \end_layout
33687
33688 \begin_layout Itemize
33689 The labels need not be in order, and the starting number need not be one
33690  or zero, the case labels are in numerical sequence or not too many case
33691  labels are missing.
33692 \end_layout
33693
33694 \begin_deeper
33695 \begin_layout Verse
33696
33697 \family typewriter
33698 switch(i) {\InsetSpace ~
33699 \InsetSpace ~
33700 \InsetSpace ~
33701 \InsetSpace ~
33702 \InsetSpace ~
33703 \InsetSpace ~
33704 \InsetSpace ~
33705 \InsetSpace ~
33706 \InsetSpace ~
33707 \InsetSpace ~
33708 \InsetSpace ~
33709 \InsetSpace ~
33710 \InsetSpace ~
33711 \InsetSpace ~
33712 \InsetSpace ~
33713 \InsetSpace ~
33714 \InsetSpace ~
33715 \InsetSpace ~
33716 \InsetSpace ~
33717 \InsetSpace ~
33718 \InsetSpace ~
33719 \InsetSpace ~
33720 \InsetSpace ~
33721 \InsetSpace ~
33722 \InsetSpace ~
33723 \InsetSpace ~
33724 switch (i) { 
33725 \newline
33726 \InsetSpace ~
33727 \InsetSpace ~
33728 \InsetSpace ~
33729 case 4: ...\InsetSpace ~
33730 \InsetSpace ~
33731 \InsetSpace ~
33732 \InsetSpace ~
33733 \InsetSpace ~
33734 \InsetSpace ~
33735 \InsetSpace ~
33736 \InsetSpace ~
33737 \InsetSpace ~
33738 \InsetSpace ~
33739 \InsetSpace ~
33740 \InsetSpace ~
33741 \InsetSpace ~
33742 \InsetSpace ~
33743 \InsetSpace ~
33744 \InsetSpace ~
33745 \InsetSpace ~
33746 \InsetSpace ~
33747 \InsetSpace ~
33748 \InsetSpace ~
33749 \InsetSpace ~
33750 \InsetSpace ~
33751 \InsetSpace ~
33752 \InsetSpace ~
33753 \InsetSpace ~
33754 \InsetSpace ~
33755 case 0: ...
33756  
33757 \newline
33758 \InsetSpace ~
33759 \InsetSpace ~
33760 \InsetSpace ~
33761 case 5: ...\InsetSpace ~
33762 \InsetSpace ~
33763 \InsetSpace ~
33764 \InsetSpace ~
33765 \InsetSpace ~
33766 \InsetSpace ~
33767 \InsetSpace ~
33768 \InsetSpace ~
33769 \InsetSpace ~
33770 \InsetSpace ~
33771 \InsetSpace ~
33772 \InsetSpace ~
33773 \InsetSpace ~
33774 \InsetSpace ~
33775 \InsetSpace ~
33776 \InsetSpace ~
33777 \InsetSpace ~
33778 \InsetSpace ~
33779 \InsetSpace ~
33780 \InsetSpace ~
33781 \InsetSpace ~
33782 \InsetSpace ~
33783 \InsetSpace ~
33784 \InsetSpace ~
33785 \InsetSpace ~
33786 \InsetSpace ~
33787 case 1: ...
33788  
33789 \newline
33790 \InsetSpace ~
33791 \InsetSpace ~
33792 \InsetSpace ~
33793 case 3: ...\InsetSpace ~
33794 \InsetSpace ~
33795 \InsetSpace ~
33796 \InsetSpace ~
33797 \InsetSpace ~
33798 \InsetSpace ~
33799 \InsetSpace ~
33800 \InsetSpace ~
33801 \InsetSpace ~
33802 \InsetSpace ~
33803 \InsetSpace ~
33804 \InsetSpace ~
33805 \InsetSpace ~
33806 \InsetSpace ~
33807 \InsetSpace ~
33808 \InsetSpace ~
33809 \InsetSpace ~
33810 \InsetSpace ~
33811 \InsetSpace ~
33812 \InsetSpace ~
33813 \InsetSpace ~
33814 \InsetSpace ~
33815 \InsetSpace ~
33816 \InsetSpace ~
33817 \InsetSpace ~
33818 \InsetSpace ~
33819
33820 \newline
33821 \InsetSpace ~
33822 \InsetSpace ~
33823 \InsetSpace ~
33824 case 6: ...\InsetSpace ~
33825 \InsetSpace ~
33826 \InsetSpace ~
33827 \InsetSpace ~
33828 \InsetSpace ~
33829 \InsetSpace ~
33830 \InsetSpace ~
33831 \InsetSpace ~
33832 \InsetSpace ~
33833 \InsetSpace ~
33834 \InsetSpace ~
33835 \InsetSpace ~
33836 \InsetSpace ~
33837 \InsetSpace ~
33838 \InsetSpace ~
33839 \InsetSpace ~
33840 \InsetSpace ~
33841 \InsetSpace ~
33842 \InsetSpace ~
33843 \InsetSpace ~
33844 \InsetSpace ~
33845 \InsetSpace ~
33846 \InsetSpace ~
33847 \InsetSpace ~
33848 \InsetSpace ~
33849 \InsetSpace ~
33850 case 3: ...
33851  
33852 \newline
33853 \InsetSpace ~
33854 \InsetSpace ~
33855 \InsetSpace ~
33856 case 7: ...\InsetSpace ~
33857 \InsetSpace ~
33858 \InsetSpace ~
33859 \InsetSpace ~
33860 \InsetSpace ~
33861 \InsetSpace ~
33862 \InsetSpace ~
33863 \InsetSpace ~
33864 \InsetSpace ~
33865 \InsetSpace ~
33866 \InsetSpace ~
33867 \InsetSpace ~
33868 \InsetSpace ~
33869 \InsetSpace ~
33870 \InsetSpace ~
33871 \InsetSpace ~
33872 \InsetSpace ~
33873 \InsetSpace ~
33874 \InsetSpace ~
33875 \InsetSpace ~
33876 \InsetSpace ~
33877 \InsetSpace ~
33878 \InsetSpace ~
33879 \InsetSpace ~
33880 \InsetSpace ~
33881 \InsetSpace ~
33882 case 4: ...
33883  
33884 \newline
33885 \InsetSpace ~
33886 \InsetSpace ~
33887 \InsetSpace ~
33888 case 8: ...\InsetSpace ~
33889 \InsetSpace ~
33890 \InsetSpace ~
33891 \InsetSpace ~
33892 \InsetSpace ~
33893 \InsetSpace ~
33894 \InsetSpace ~
33895 \InsetSpace ~
33896 \InsetSpace ~
33897 \InsetSpace ~
33898 \InsetSpace ~
33899 \InsetSpace ~
33900 \InsetSpace ~
33901 \InsetSpace ~
33902 \InsetSpace ~
33903 \InsetSpace ~
33904 \InsetSpace ~
33905 \InsetSpace ~
33906 \InsetSpace ~
33907 \InsetSpace ~
33908 \InsetSpace ~
33909 \InsetSpace ~
33910 \InsetSpace ~
33911 \InsetSpace ~
33912 \InsetSpace ~
33913 \InsetSpace ~
33914 case 5: ...
33915  
33916 \newline
33917 \InsetSpace ~
33918 \InsetSpace ~
33919 \InsetSpace ~
33920 case 9: ...\InsetSpace ~
33921 \InsetSpace ~
33922 \InsetSpace ~
33923 \InsetSpace ~
33924 \InsetSpace ~
33925 \InsetSpace ~
33926 \InsetSpace ~
33927 \InsetSpace ~
33928 \InsetSpace ~
33929 \InsetSpace ~
33930 \InsetSpace ~
33931 \InsetSpace ~
33932 \InsetSpace ~
33933 \InsetSpace ~
33934 \InsetSpace ~
33935 \InsetSpace ~
33936 \InsetSpace ~
33937 \InsetSpace ~
33938 \InsetSpace ~
33939 \InsetSpace ~
33940 \InsetSpace ~
33941 \InsetSpace ~
33942 \InsetSpace ~
33943 \InsetSpace ~
33944 \InsetSpace ~
33945 \InsetSpace ~
33946 case 6: ...
33947  
33948 \newline
33949 \InsetSpace ~
33950 \InsetSpace ~
33951 \InsetSpace ~
33952 case 10: ...\InsetSpace ~
33953 \InsetSpace ~
33954 \InsetSpace ~
33955 \InsetSpace ~
33956 \InsetSpace ~
33957 \InsetSpace ~
33958 \InsetSpace ~
33959 \InsetSpace ~
33960 \InsetSpace ~
33961 \InsetSpace ~
33962 \InsetSpace ~
33963 \InsetSpace ~
33964 \InsetSpace ~
33965 \InsetSpace ~
33966 \InsetSpace ~
33967 \InsetSpace ~
33968 \InsetSpace ~
33969 \InsetSpace ~
33970 \InsetSpace ~
33971 \InsetSpace ~
33972 \InsetSpace ~
33973 \InsetSpace ~
33974 \InsetSpace ~
33975 \InsetSpace ~
33976 \InsetSpace ~
33977 case 7: ...
33978  
33979 \newline
33980 \InsetSpace ~
33981 \InsetSpace ~
33982 \InsetSpace ~
33983 case 11: ...\InsetSpace ~
33984 \InsetSpace ~
33985 \InsetSpace ~
33986 \InsetSpace ~
33987 \InsetSpace ~
33988 \InsetSpace ~
33989 \InsetSpace ~
33990 \InsetSpace ~
33991 \InsetSpace ~
33992 \InsetSpace ~
33993 \InsetSpace ~
33994 \InsetSpace ~
33995 \InsetSpace ~
33996 \InsetSpace ~
33997 \InsetSpace ~
33998 \InsetSpace ~
33999 \InsetSpace ~
34000 \InsetSpace ~
34001 \InsetSpace ~
34002 \InsetSpace ~
34003 \InsetSpace ~
34004 \InsetSpace ~
34005 \InsetSpace ~
34006 \InsetSpace ~
34007 \InsetSpace ~
34008 case 8: ...
34009  
34010 \newline
34011 }\InsetSpace ~
34012 \InsetSpace ~
34013 \InsetSpace ~
34014 \InsetSpace ~
34015 \InsetSpace ~
34016 \InsetSpace ~
34017 \InsetSpace ~
34018 \InsetSpace ~
34019 \InsetSpace ~
34020 \InsetSpace ~
34021 \InsetSpace ~
34022 \InsetSpace ~
34023 \InsetSpace ~
34024 \InsetSpace ~
34025 \InsetSpace ~
34026 \InsetSpace ~
34027 \InsetSpace ~
34028 \InsetSpace ~
34029 \InsetSpace ~
34030 \InsetSpace ~
34031 \InsetSpace ~
34032 \InsetSpace ~
34033 \InsetSpace ~
34034 \InsetSpace ~
34035 \InsetSpace ~
34036 \InsetSpace ~
34037 \InsetSpace ~
34038 \InsetSpace ~
34039 \InsetSpace ~
34040 \InsetSpace ~
34041 \InsetSpace ~
34042 \InsetSpace ~
34043 \InsetSpace ~
34044 \InsetSpace ~
34045 \InsetSpace ~
34046 \InsetSpace ~
34047 }
34048 \end_layout
34049
34050 \begin_layout Standard
34051 Both the above switch statements will be implemented using a jump-table.
34052  The example to the right side is slightly more efficient as the check for
34053  the lower boundary of the jump-table is not needed.
34054 \end_layout
34055
34056 \end_deeper
34057 \begin_layout Itemize
34058 The number of case labels is not larger than supported by the target architectur
34059 e.
34060 \end_layout
34061
34062 \begin_layout Itemize
34063 If the case labels are not in numerical sequence ('gaps' between cases)
34064  SDCC checks whether a jump table with additionally inserted dummy cases
34065  is still attractive.
34066  
34067 \end_layout
34068
34069 \begin_layout Itemize
34070 If the starting number is not zero and a check for the lower boundary of
34071  the jump-table can thus be eliminated SDCC might insert dummy cases 0,
34072  ...
34073  .
34074 \end_layout
34075
34076 \begin_layout Standard
34077 Switch statements which have large gaps in the numeric sequence or those
34078  that have too many case labels can be split into more than one switch statement
34079  for efficient code generation, e.g.:
34080 \end_layout
34081
34082 \begin_layout Verse
34083
34084 \family typewriter
34085 switch (i) { 
34086 \newline
34087 \InsetSpace ~
34088 \InsetSpace ~
34089 case 1: ...
34090  
34091 \newline
34092 \InsetSpace ~
34093 \InsetSpace ~
34094 case 2: ...
34095  
34096 \newline
34097 \InsetSpace ~
34098 \InsetSpace ~
34099 case 3: ...
34100  
34101 \newline
34102 \InsetSpace ~
34103 \InsetSpace ~
34104 case 4: ...
34105  
34106 \newline
34107 \InsetSpace ~
34108 \InsetSpace ~
34109 case 5: ...
34110  
34111 \newline
34112 \InsetSpace ~
34113 \InsetSpace ~
34114 case 6: ...
34115  
34116 \newline
34117 \InsetSpace ~
34118 \InsetSpace ~
34119 case 7: ...
34120  
34121 \newline
34122 \InsetSpace ~
34123 \InsetSpace ~
34124 case 101: ...
34125  
34126 \newline
34127 \InsetSpace ~
34128 \InsetSpace ~
34129 case 102: ...
34130  
34131 \newline
34132 \InsetSpace ~
34133 \InsetSpace ~
34134 case 103: ...
34135  
34136 \newline
34137 \InsetSpace ~
34138 \InsetSpace ~
34139 case 104: ...
34140  
34141 \newline
34142 \InsetSpace ~
34143 \InsetSpace ~
34144 case 105: ...
34145  
34146 \newline
34147 \InsetSpace ~
34148 \InsetSpace ~
34149 case 106: ...
34150  
34151 \newline
34152 \InsetSpace ~
34153 \InsetSpace ~
34154 case 107: ...
34155  
34156 \newline
34157 }
34158 \end_layout
34159
34160 \begin_layout Standard
34161 If the above switch statement is broken down into two switch statements
34162 \end_layout
34163
34164 \begin_layout Verse
34165
34166 \family typewriter
34167 switch (i) { 
34168 \newline
34169 \InsetSpace ~
34170 \InsetSpace ~
34171 case 1: ...
34172  
34173 \newline
34174 \InsetSpace ~
34175 \InsetSpace ~
34176 case 2: ...
34177  
34178 \newline
34179 \InsetSpace ~
34180 \InsetSpace ~
34181 case 3: ...
34182  
34183 \newline
34184 \InsetSpace ~
34185 \InsetSpace ~
34186 case 4: ...
34187  
34188 \newline
34189 \InsetSpace ~
34190 \InsetSpace ~
34191 case 5: ...
34192  
34193 \newline
34194 \InsetSpace ~
34195 \InsetSpace ~
34196 case 6: ...
34197  
34198 \newline
34199 \InsetSpace ~
34200 \InsetSpace ~
34201 case 7: ...
34202  
34203 \newline
34204 }
34205 \end_layout
34206
34207 \begin_layout Standard
34208 and
34209 \end_layout
34210
34211 \begin_layout Verse
34212
34213 \family typewriter
34214 switch (i) { 
34215 \newline
34216 \InsetSpace ~
34217 \InsetSpace ~
34218 case 101: ...
34219  
34220 \newline
34221 \InsetSpace ~
34222 \InsetSpace ~
34223 case 102: ...
34224  
34225 \newline
34226 \InsetSpace ~
34227 \InsetSpace ~
34228 case 103: ...
34229  
34230 \newline
34231 \InsetSpace ~
34232 \InsetSpace ~
34233 case 104: ...
34234  
34235 \newline
34236 \InsetSpace ~
34237 \InsetSpace ~
34238 case 105: ...
34239  
34240 \newline
34241 \InsetSpace ~
34242 \InsetSpace ~
34243 case 106: ...
34244  
34245 \newline
34246 \InsetSpace ~
34247 \InsetSpace ~
34248 case 107: ...
34249  
34250 \newline
34251 }
34252 \end_layout
34253
34254 \begin_layout Standard
34255 then both the switch statements will be implemented using jump-tables whereas
34256  the unmodified switch statement will not be.
34257 \end_layout
34258
34259 \begin_layout Standard
34260 \begin_inset Note Note
34261 status collapsed
34262
34263 \begin_layout Standard
34264 There might be reasons which SDCC cannot know about to either favour or
34265  not favour jump tables.
34266  If the target system has to be as quick for the last switch case as for
34267  the first (pro jump table), or if the switch argument is known to be zero
34268  in the majority of the cases (contra jump table).
34269 \end_layout
34270
34271 \end_inset
34272
34273
34274 \end_layout
34275
34276 \begin_layout Standard
34277 The pragma nojtbound
34278 \begin_inset LatexCommand \index{\#pragma nojtbound}
34279
34280 \end_inset
34281
34282  can be used to turn off checking the 
34283 \emph on
34284 j
34285 \emph default
34286 ump 
34287 \emph on
34288 t
34289 \emph default
34290 able 
34291 \emph on
34292 bound
34293 \emph default
34294 aries.
34295  It has no effect if a default label is supplied.
34296  Use of this pragma is dangerous: if the switch
34297 \begin_inset LatexCommand \index{switch statement}
34298
34299 \end_inset
34300
34301  argument is not matched by a case statement the processor will happily
34302  jump into Nirvana.
34303 \end_layout
34304
34305 \begin_layout Subsection
34306 Bit-shifting Operations
34307 \begin_inset LatexCommand \index{Bit shifting}
34308
34309 \end_inset
34310
34311 .
34312 \end_layout
34313
34314 \begin_layout Standard
34315 Bit shifting is one of the most frequently used operation in embedded programmin
34316 g.
34317  SDCC tries to implement bit-shift operations in the most efficient way
34318  possible, e.g.:
34319 \end_layout
34320
34321 \begin_layout Verse
34322
34323 \family typewriter
34324 unsigned char i;
34325 \newline
34326 ...
34327  
34328 \newline
34329 i >>= 4; 
34330 \newline
34331 ...
34332 \end_layout
34333
34334 \begin_layout Standard
34335 generates the following code:
34336 \end_layout
34337
34338 \begin_layout Verse
34339
34340 \family typewriter
34341 mov\InsetSpace ~
34342  a,_i 
34343 \newline
34344 swap a 
34345 \newline
34346 anl\InsetSpace ~
34347  a,#0x0f 
34348 \newline
34349 mov\InsetSpace ~
34350  _i,a
34351 \end_layout
34352
34353 \begin_layout Standard
34354 In general SDCC will never setup a loop if the shift count is known.
34355  Another example:
34356 \end_layout
34357
34358 \begin_layout Verse
34359
34360 \family typewriter
34361 unsigned int i; 
34362 \newline
34363 ...
34364  
34365 \newline
34366 i >>= 9; 
34367 \newline
34368 ...
34369 \end_layout
34370
34371 \begin_layout Standard
34372 will generate:
34373 \end_layout
34374
34375 \begin_layout Verse
34376
34377 \family typewriter
34378 mov\InsetSpace ~
34379 \InsetSpace ~
34380 a,(_i + 1) 
34381 \newline
34382 mov\InsetSpace ~
34383 \InsetSpace ~
34384 (_i + 1),#0x00 
34385 \newline
34386 clr\InsetSpace ~
34387 \InsetSpace ~
34388
34389 \newline
34390 rrc\InsetSpace ~
34391 \InsetSpace ~
34392
34393 \newline
34394 mov\InsetSpace ~
34395 \InsetSpace ~
34396 _i,a
34397 \end_layout
34398
34399 \begin_layout Subsection
34400 Bit-rotation
34401 \begin_inset LatexCommand \index{Bit rotation}
34402
34403 \end_inset
34404
34405
34406 \end_layout
34407
34408 \begin_layout Standard
34409 A special case of the bit-shift operation is bit rotation
34410 \begin_inset LatexCommand \index{rotating bits}
34411
34412 \end_inset
34413
34414 , SDCC recognizes the following expression to be a left bit-rotation:
34415 \end_layout
34416
34417 \begin_layout Verse
34418
34419 \family typewriter
34420 \series bold
34421 unsigned
34422 \series default
34423 \InsetSpace ~
34424 \InsetSpace ~
34425 char i;\InsetSpace ~
34426 \InsetSpace ~
34427 \InsetSpace ~
34428 \InsetSpace ~
34429 \InsetSpace ~
34430 \InsetSpace ~
34431 \InsetSpace ~
34432 \InsetSpace ~
34433 \InsetSpace ~
34434 \InsetSpace ~
34435 \InsetSpace ~
34436 /* unsigned is needed for rotation */ 
34437 \newline
34438 ...
34439  
34440 \newline
34441 i = ((i << 1) | (i >> 7)); 
34442 \family default
34443
34444 \newline
34445
34446 \family typewriter
34447 ...
34448 \end_layout
34449
34450 \begin_layout Standard
34451 will generate the following code:
34452 \end_layout
34453
34454 \begin_layout Verse
34455
34456 \family typewriter
34457 mov\InsetSpace ~
34458 \InsetSpace ~
34459 a,_i 
34460 \newline
34461 rl\InsetSpace ~
34462 \InsetSpace ~
34463 \InsetSpace ~
34464
34465 \newline
34466 mov\InsetSpace ~
34467 \InsetSpace ~
34468 _i,a
34469 \end_layout
34470
34471 \begin_layout Standard
34472 SDCC uses pattern matching on the parse tree to determine this operation.Variatio
34473 ns of this case will also be recognized as bit-rotation, i.e.: 
34474 \end_layout
34475
34476 \begin_layout Verse
34477
34478 \family typewriter
34479 i = ((i >> 7) | (i << 1)); /* left-bit rotation */
34480 \end_layout
34481
34482 \begin_layout Subsection
34483 Nibble and Byte Swapping
34484 \end_layout
34485
34486 \begin_layout Standard
34487 Other special cases of the bit-shift operations are nibble or byte swapping
34488 \begin_inset LatexCommand \index{swapping nibbles/bytes}
34489
34490 \end_inset
34491
34492 , SDCC recognizes the following expressions:
34493 \end_layout
34494
34495 \begin_layout Verse
34496
34497 \family typewriter
34498 \series bold
34499 unsigned
34500 \series default
34501 \InsetSpace ~
34502 \InsetSpace ~
34503 char i; 
34504 \newline
34505
34506 \series bold
34507 unsigned
34508 \series default
34509 \InsetSpace ~
34510 \InsetSpace ~
34511 int j; 
34512 \newline
34513 ...
34514  
34515 \newline
34516 i = ((i << 4) | (i >> 4)); 
34517 \family default
34518
34519 \newline
34520
34521 \family typewriter
34522 j = ((j << 8) | (j >> 8)); 
34523 \end_layout
34524
34525 \begin_layout Standard
34526 and generates a swap instruction for the nibble swapping
34527 \begin_inset LatexCommand \index{Nibble swapping}
34528
34529 \end_inset
34530
34531  or move instructions for the byte swapping
34532 \begin_inset LatexCommand \index{Byte swapping}
34533
34534 \end_inset
34535
34536 .
34537  The 
34538 \begin_inset Quotes sld
34539 \end_inset
34540
34541 j
34542 \begin_inset Quotes srd
34543 \end_inset
34544
34545  example can be used to convert from little to big-endian or vice versa.
34546  If you want to change the endianness of a 
34547 \emph on
34548 signed
34549 \emph default
34550  integer you have to cast to 
34551 \family typewriter
34552 (unsigned int)
34553 \family default
34554  first.
34555 \end_layout
34556
34557 \begin_layout Standard
34558 Note that SDCC stores numbers in little-endian
34559 \begin_inset Foot
34560 status open
34561
34562 \begin_layout Standard
34563 Usually 8-bit processors don't care much about endianness.
34564  This is not the case for the standard 8051 which only has an instruction
34565  to increment its 
34566 \emph on
34567 dptr
34568 \emph default
34569
34570 \begin_inset LatexCommand \index{DPTR}
34571
34572 \end_inset
34573
34574 -datapointer
34575 \emph on
34576  
34577 \emph default
34578 so little-endian is the more efficient byte order.
34579 \end_layout
34580
34581 \end_inset
34582
34583
34584 \begin_inset LatexCommand \index{little-endian}
34585
34586 \end_inset
34587
34588
34589 \begin_inset LatexCommand \index{Endianness}
34590
34591 \end_inset
34592
34593  format (i.e.
34594  lowest order first).
34595 \end_layout
34596
34597 \begin_layout Subsection
34598 Highest Order Bit
34599 \begin_inset LatexCommand \index{Highest Order Bit}
34600
34601 \end_inset
34602
34603  / Any Order Bit
34604 \begin_inset LatexCommand \index{Any Order Bit}
34605
34606 \end_inset
34607
34608
34609 \end_layout
34610
34611 \begin_layout Standard
34612 It is frequently required to obtain the highest order bit of an integral
34613  type (long, int, short or char types).
34614  Also obtaining any other order bit is not uncommon.
34615  SDCC recognizes the following expressions to yield the highest order bit
34616  and generates optimized code for it, e.g.:
34617 \end_layout
34618
34619 \begin_layout Verse
34620
34621 \family typewriter
34622 unsigned int gint; 
34623 \newline
34624
34625 \newline
34626 foo () { 
34627 \newline
34628 \InsetSpace ~
34629 \InsetSpace ~
34630 unsigned char hob1, aob1; 
34631 \newline
34632 \InsetSpace ~
34633 \InsetSpace ~
34634 bit hob2, hob3, aob2,
34635  aob3; 
34636 \newline
34637 \InsetSpace ~
34638 \InsetSpace ~
34639 ...
34640  
34641 \newline
34642 \InsetSpace ~
34643 \InsetSpace ~
34644 hob1 = (gint >> 15) & 1; 
34645 \newline
34646 \InsetSpace ~
34647 \InsetSpace ~
34648 hob2 = (gint >> 15) & 1; 
34649 \newline
34650 \InsetSpace ~
34651 \InsetSpace ~
34652 hob3 = gint & 0x8000;
34653  
34654 \newline
34655 \InsetSpace ~
34656 \InsetSpace ~
34657 aob1 = (gint >> 9) & 1; 
34658 \newline
34659 \InsetSpace ~
34660 \InsetSpace ~
34661 aob2 = (gint >> 8) & 1; 
34662 \newline
34663 \InsetSpace ~
34664 \InsetSpace ~
34665 aob3 = gint & 0x0800; 
34666 \newline
34667 \InsetSpace ~
34668 \InsetSpace ~
34669 ..
34670  
34671 \newline
34672 }
34673 \end_layout
34674
34675 \begin_layout Standard
34676 will generate the following code:
34677 \end_layout
34678
34679 \begin_layout Verse
34680
34681 \family typewriter
34682 \InsetSpace ~
34683 \InsetSpace ~
34684 \InsetSpace ~
34685 \InsetSpace ~
34686 \InsetSpace ~
34687 \InsetSpace ~
34688 \InsetSpace ~
34689 \InsetSpace ~
34690 \InsetSpace ~
34691 \InsetSpace ~
34692 \InsetSpace ~
34693 \InsetSpace ~
34694 \InsetSpace ~
34695 \InsetSpace ~
34696 \InsetSpace ~
34697 \InsetSpace ~
34698 \InsetSpace ~
34699 \InsetSpace ~
34700 \InsetSpace ~
34701 \InsetSpace ~
34702 \InsetSpace ~
34703 \InsetSpace ~
34704 \InsetSpace ~
34705 \InsetSpace ~
34706 \InsetSpace ~
34707  61 ;\InsetSpace ~
34708  hob.c 7 
34709 \newline
34710 000A E5*01\InsetSpace ~
34711 \InsetSpace ~
34712 \InsetSpace ~
34713 \InsetSpace ~
34714 \InsetSpace ~
34715 \InsetSpace ~
34716 \InsetSpace ~
34717 \InsetSpace ~
34718 \InsetSpace ~
34719 \InsetSpace ~
34720 \InsetSpace ~
34721 \InsetSpace ~
34722 \InsetSpace ~
34723 \InsetSpace ~
34724 \InsetSpace ~
34725  62\InsetSpace ~
34726 \InsetSpace ~
34727 \InsetSpace ~
34728 \InsetSpace ~
34729 \InsetSpace ~
34730 \InsetSpace ~
34731 \InsetSpace ~
34732 \InsetSpace ~
34733  mov\InsetSpace ~
34734 \InsetSpace ~
34735  a,(_gint + 1) 
34736 \newline
34737 000C 23\InsetSpace ~
34738 \InsetSpace ~
34739 \InsetSpace ~
34740 \InsetSpace ~
34741 \InsetSpace ~
34742 \InsetSpace ~
34743 \InsetSpace ~
34744 \InsetSpace ~
34745 \InsetSpace ~
34746 \InsetSpace ~
34747 \InsetSpace ~
34748 \InsetSpace ~
34749 \InsetSpace ~
34750 \InsetSpace ~
34751 \InsetSpace ~
34752 \InsetSpace ~
34753 \InsetSpace ~
34754 \InsetSpace ~
34755  63\InsetSpace ~
34756 \InsetSpace ~
34757 \InsetSpace ~
34758 \InsetSpace ~
34759 \InsetSpace ~
34760 \InsetSpace ~
34761 \InsetSpace ~
34762 \InsetSpace ~
34763  rl\InsetSpace ~
34764 \InsetSpace ~
34765 \InsetSpace ~
34766  a 
34767 \newline
34768 000D 54 01\InsetSpace ~
34769 \InsetSpace ~
34770 \InsetSpace ~
34771 \InsetSpace ~
34772 \InsetSpace ~
34773 \InsetSpace ~
34774 \InsetSpace ~
34775 \InsetSpace ~
34776 \InsetSpace ~
34777 \InsetSpace ~
34778 \InsetSpace ~
34779 \InsetSpace ~
34780 \InsetSpace ~
34781 \InsetSpace ~
34782 \InsetSpace ~
34783
34784  64\InsetSpace ~
34785 \InsetSpace ~
34786 \InsetSpace ~
34787 \InsetSpace ~
34788 \InsetSpace ~
34789 \InsetSpace ~
34790 \InsetSpace ~
34791 \InsetSpace ~
34792  anl\InsetSpace ~
34793 \InsetSpace ~
34794  a,#0x01 
34795 \newline
34796 000F F5*02\InsetSpace ~
34797 \InsetSpace ~
34798 \InsetSpace ~
34799 \InsetSpace ~
34800 \InsetSpace ~
34801 \InsetSpace ~
34802 \InsetSpace ~
34803 \InsetSpace ~
34804 \InsetSpace ~
34805 \InsetSpace ~
34806 \InsetSpace ~
34807 \InsetSpace ~
34808 \InsetSpace ~
34809 \InsetSpace ~
34810 \InsetSpace ~
34811  65\InsetSpace ~
34812 \InsetSpace ~
34813 \InsetSpace ~
34814 \InsetSpace ~
34815 \InsetSpace ~
34816 \InsetSpace ~
34817 \InsetSpace ~
34818 \InsetSpace ~
34819  mov\InsetSpace ~
34820 \InsetSpace ~
34821  _foo_hob1_1_1,a 
34822 \newline
34823 \InsetSpace ~
34824 \InsetSpace ~
34825 \InsetSpace ~
34826 \InsetSpace ~
34827 \InsetSpace ~
34828 \InsetSpace ~
34829 \InsetSpace ~
34830 \InsetSpace ~
34831 \InsetSpace ~
34832 \InsetSpace ~
34833 \InsetSpace ~
34834 \InsetSpace ~
34835 \InsetSpace ~
34836 \InsetSpace ~
34837 \InsetSpace ~
34838 \InsetSpace ~
34839 \InsetSpace ~
34840 \InsetSpace ~
34841 \InsetSpace ~
34842 \InsetSpace ~
34843 \InsetSpace ~
34844 \InsetSpace ~
34845 \InsetSpace ~
34846 \InsetSpace ~
34847 \InsetSpace ~
34848  66 ;\InsetSpace ~
34849  hob.c 8 
34850 \newline
34851 0011 E5*01\InsetSpace ~
34852 \InsetSpace ~
34853 \InsetSpace ~
34854 \InsetSpace ~
34855 \InsetSpace ~
34856 \InsetSpace ~
34857 \InsetSpace ~
34858 \InsetSpace ~
34859 \InsetSpace ~
34860 \InsetSpace ~
34861 \InsetSpace ~
34862 \InsetSpace ~
34863 \InsetSpace ~
34864 \InsetSpace ~
34865 \InsetSpace ~
34866
34867  67\InsetSpace ~
34868 \InsetSpace ~
34869 \InsetSpace ~
34870 \InsetSpace ~
34871 \InsetSpace ~
34872 \InsetSpace ~
34873 \InsetSpace ~
34874 \InsetSpace ~
34875  mov\InsetSpace ~
34876 \InsetSpace ~
34877  a,(_gint + 1) 
34878 \newline
34879 0013 33\InsetSpace ~
34880 \InsetSpace ~
34881 \InsetSpace ~
34882 \InsetSpace ~
34883 \InsetSpace ~
34884 \InsetSpace ~
34885 \InsetSpace ~
34886 \InsetSpace ~
34887 \InsetSpace ~
34888 \InsetSpace ~
34889 \InsetSpace ~
34890 \InsetSpace ~
34891 \InsetSpace ~
34892 \InsetSpace ~
34893 \InsetSpace ~
34894 \InsetSpace ~
34895 \InsetSpace ~
34896 \InsetSpace ~
34897  68\InsetSpace ~
34898 \InsetSpace ~
34899 \InsetSpace ~
34900 \InsetSpace ~
34901 \InsetSpace ~
34902 \InsetSpace ~
34903 \InsetSpace ~
34904 \InsetSpace ~
34905  rlc\InsetSpace ~
34906 \InsetSpace ~
34907  a 
34908 \newline
34909 0014 92*00\InsetSpace ~
34910 \InsetSpace ~
34911 \InsetSpace ~
34912 \InsetSpace ~
34913 \InsetSpace ~
34914 \InsetSpace ~
34915 \InsetSpace ~
34916 \InsetSpace ~
34917 \InsetSpace ~
34918 \InsetSpace ~
34919 \InsetSpace ~
34920 \InsetSpace ~
34921 \InsetSpace ~
34922 \InsetSpace ~
34923 \InsetSpace ~
34924  69\InsetSpace ~
34925 \InsetSpace ~
34926 \InsetSpace ~
34927 \InsetSpace ~
34928 \InsetSpace ~
34929 \InsetSpace ~
34930 \InsetSpace ~
34931 \InsetSpace ~
34932  mov\InsetSpace ~
34933 \InsetSpace ~
34934  _foo_hob2_1_1,c
34935  
34936 \newline
34937 \InsetSpace ~
34938 \InsetSpace ~
34939 \InsetSpace ~
34940 \InsetSpace ~
34941 \InsetSpace ~
34942 \InsetSpace ~
34943 \InsetSpace ~
34944 \InsetSpace ~
34945 \InsetSpace ~
34946 \InsetSpace ~
34947 \InsetSpace ~
34948 \InsetSpace ~
34949 \InsetSpace ~
34950 \InsetSpace ~
34951 \InsetSpace ~
34952 \InsetSpace ~
34953 \InsetSpace ~
34954 \InsetSpace ~
34955 \InsetSpace ~
34956 \InsetSpace ~
34957 \InsetSpace ~
34958 \InsetSpace ~
34959 \InsetSpace ~
34960 \InsetSpace ~
34961 \InsetSpace ~
34962  66 ;\InsetSpace ~
34963  hob.c 9 
34964 \newline
34965 0016 E5*01\InsetSpace ~
34966 \InsetSpace ~
34967 \InsetSpace ~
34968 \InsetSpace ~
34969 \InsetSpace ~
34970 \InsetSpace ~
34971 \InsetSpace ~
34972 \InsetSpace ~
34973 \InsetSpace ~
34974 \InsetSpace ~
34975 \InsetSpace ~
34976 \InsetSpace ~
34977 \InsetSpace ~
34978 \InsetSpace ~
34979 \InsetSpace ~
34980  67\InsetSpace ~
34981 \InsetSpace ~
34982 \InsetSpace ~
34983 \InsetSpace ~
34984 \InsetSpace ~
34985 \InsetSpace ~
34986 \InsetSpace ~
34987 \InsetSpace ~
34988  mov\InsetSpace ~
34989 \InsetSpace ~
34990  a,(_gint + 1) 
34991 \newline
34992 0018 33\InsetSpace ~
34993 \InsetSpace ~
34994 \InsetSpace ~
34995 \InsetSpace ~
34996 \InsetSpace ~
34997 \InsetSpace ~
34998 \InsetSpace ~
34999 \InsetSpace ~
35000 \InsetSpace ~
35001 \InsetSpace ~
35002 \InsetSpace ~
35003 \InsetSpace ~
35004 \InsetSpace ~
35005 \InsetSpace ~
35006 \InsetSpace ~
35007 \InsetSpace ~
35008 \InsetSpace ~
35009 \InsetSpace ~
35010  68\InsetSpace ~
35011 \InsetSpace ~
35012 \InsetSpace ~
35013 \InsetSpace ~
35014 \InsetSpace ~
35015 \InsetSpace ~
35016 \InsetSpace ~
35017 \InsetSpace ~
35018  rlc\InsetSpace ~
35019 \InsetSpace ~
35020  a 
35021 \newline
35022 0019 92*01\InsetSpace ~
35023 \InsetSpace ~
35024 \InsetSpace ~
35025 \InsetSpace ~
35026 \InsetSpace ~
35027 \InsetSpace ~
35028 \InsetSpace ~
35029 \InsetSpace ~
35030 \InsetSpace ~
35031 \InsetSpace ~
35032 \InsetSpace ~
35033 \InsetSpace ~
35034 \InsetSpace ~
35035 \InsetSpace ~
35036 \InsetSpace ~
35037
35038  69\InsetSpace ~
35039 \InsetSpace ~
35040 \InsetSpace ~
35041 \InsetSpace ~
35042 \InsetSpace ~
35043 \InsetSpace ~
35044 \InsetSpace ~
35045 \InsetSpace ~
35046  mov\InsetSpace ~
35047 \InsetSpace ~
35048  _foo_hob3_1_1,c 
35049 \newline
35050 \InsetSpace ~
35051 \InsetSpace ~
35052 \InsetSpace ~
35053 \InsetSpace ~
35054 \InsetSpace ~
35055 \InsetSpace ~
35056 \InsetSpace ~
35057 \InsetSpace ~
35058 \InsetSpace ~
35059 \InsetSpace ~
35060 \InsetSpace ~
35061 \InsetSpace ~
35062 \InsetSpace ~
35063 \InsetSpace ~
35064 \InsetSpace ~
35065 \InsetSpace ~
35066 \InsetSpace ~
35067 \InsetSpace ~
35068 \InsetSpace ~
35069 \InsetSpace ~
35070 \InsetSpace ~
35071 \InsetSpace ~
35072 \InsetSpace ~
35073 \InsetSpace ~
35074 \InsetSpace ~
35075  70 ;\InsetSpace ~
35076  hob.c 10 
35077 \newline
35078 001B E5*01\InsetSpace ~
35079 \InsetSpace ~
35080 \InsetSpace ~
35081 \InsetSpace ~
35082 \InsetSpace ~
35083 \InsetSpace ~
35084 \InsetSpace ~
35085 \InsetSpace ~
35086 \InsetSpace ~
35087 \InsetSpace ~
35088 \InsetSpace ~
35089 \InsetSpace ~
35090 \InsetSpace ~
35091 \InsetSpace ~
35092 \InsetSpace ~
35093  71\InsetSpace ~
35094 \InsetSpace ~
35095 \InsetSpace ~
35096 \InsetSpace ~
35097 \InsetSpace ~
35098 \InsetSpace ~
35099 \InsetSpace ~
35100 \InsetSpace ~
35101  mov\InsetSpace ~
35102 \InsetSpace ~
35103  a,(_gint + 1) 
35104 \newline
35105 001D
35106  03\InsetSpace ~
35107 \InsetSpace ~
35108 \InsetSpace ~
35109 \InsetSpace ~
35110 \InsetSpace ~
35111 \InsetSpace ~
35112 \InsetSpace ~
35113 \InsetSpace ~
35114 \InsetSpace ~
35115 \InsetSpace ~
35116 \InsetSpace ~
35117 \InsetSpace ~
35118 \InsetSpace ~
35119 \InsetSpace ~
35120 \InsetSpace ~
35121 \InsetSpace ~
35122 \InsetSpace ~
35123 \InsetSpace ~
35124  72\InsetSpace ~
35125 \InsetSpace ~
35126 \InsetSpace ~
35127 \InsetSpace ~
35128 \InsetSpace ~
35129 \InsetSpace ~
35130 \InsetSpace ~
35131 \InsetSpace ~
35132  rr\InsetSpace ~
35133 \InsetSpace ~
35134 \InsetSpace ~
35135  a 
35136 \newline
35137 001E 54 01\InsetSpace ~
35138 \InsetSpace ~
35139 \InsetSpace ~
35140 \InsetSpace ~
35141 \InsetSpace ~
35142 \InsetSpace ~
35143 \InsetSpace ~
35144 \InsetSpace ~
35145 \InsetSpace ~
35146 \InsetSpace ~
35147 \InsetSpace ~
35148 \InsetSpace ~
35149 \InsetSpace ~
35150 \InsetSpace ~
35151 \InsetSpace ~
35152  73\InsetSpace ~
35153 \InsetSpace ~
35154 \InsetSpace ~
35155 \InsetSpace ~
35156 \InsetSpace ~
35157 \InsetSpace ~
35158 \InsetSpace ~
35159 \InsetSpace ~
35160  anl\InsetSpace ~
35161 \InsetSpace ~
35162  a,#0x01 
35163 \newline
35164 0020 F5*03\InsetSpace ~
35165 \InsetSpace ~
35166 \InsetSpace ~
35167 \InsetSpace ~
35168 \InsetSpace ~
35169 \InsetSpace ~
35170 \InsetSpace ~
35171 \InsetSpace ~
35172 \InsetSpace ~
35173 \InsetSpace ~
35174 \InsetSpace ~
35175 \InsetSpace ~
35176 \InsetSpace ~
35177 \InsetSpace ~
35178 \InsetSpace ~
35179  74\InsetSpace ~
35180 \InsetSpace ~
35181 \InsetSpace ~
35182 \InsetSpace ~
35183 \InsetSpace ~
35184 \InsetSpace ~
35185 \InsetSpace ~
35186 \InsetSpace ~
35187  mov\InsetSpace ~
35188 \InsetSpace ~
35189  _foo_aob1_1_1,a
35190  
35191 \newline
35192 \InsetSpace ~
35193 \InsetSpace ~
35194 \InsetSpace ~
35195 \InsetSpace ~
35196 \InsetSpace ~
35197 \InsetSpace ~
35198 \InsetSpace ~
35199 \InsetSpace ~
35200 \InsetSpace ~
35201 \InsetSpace ~
35202 \InsetSpace ~
35203 \InsetSpace ~
35204 \InsetSpace ~
35205 \InsetSpace ~
35206 \InsetSpace ~
35207 \InsetSpace ~
35208 \InsetSpace ~
35209 \InsetSpace ~
35210 \InsetSpace ~
35211 \InsetSpace ~
35212 \InsetSpace ~
35213 \InsetSpace ~
35214 \InsetSpace ~
35215 \InsetSpace ~
35216 \InsetSpace ~
35217  75 ;\InsetSpace ~
35218  hob.c 11 
35219 \newline
35220 0022 E5*01\InsetSpace ~
35221 \InsetSpace ~
35222 \InsetSpace ~
35223 \InsetSpace ~
35224 \InsetSpace ~
35225 \InsetSpace ~
35226 \InsetSpace ~
35227 \InsetSpace ~
35228 \InsetSpace ~
35229 \InsetSpace ~
35230 \InsetSpace ~
35231 \InsetSpace ~
35232 \InsetSpace ~
35233 \InsetSpace ~
35234 \InsetSpace ~
35235  76\InsetSpace ~
35236 \InsetSpace ~
35237 \InsetSpace ~
35238 \InsetSpace ~
35239 \InsetSpace ~
35240 \InsetSpace ~
35241 \InsetSpace ~
35242 \InsetSpace ~
35243  mov\InsetSpace ~
35244 \InsetSpace ~
35245  a,(_gint + 1) 
35246 \newline
35247 0024 13\InsetSpace ~
35248 \InsetSpace ~
35249 \InsetSpace ~
35250 \InsetSpace ~
35251 \InsetSpace ~
35252 \InsetSpace ~
35253 \InsetSpace ~
35254 \InsetSpace ~
35255 \InsetSpace ~
35256 \InsetSpace ~
35257 \InsetSpace ~
35258 \InsetSpace ~
35259 \InsetSpace ~
35260 \InsetSpace ~
35261 \InsetSpace ~
35262 \InsetSpace ~
35263 \InsetSpace ~
35264 \InsetSpace ~
35265  77\InsetSpace ~
35266 \InsetSpace ~
35267 \InsetSpace ~
35268 \InsetSpace ~
35269 \InsetSpace ~
35270 \InsetSpace ~
35271 \InsetSpace ~
35272 \InsetSpace ~
35273  rrc\InsetSpace ~
35274 \InsetSpace ~
35275  a 
35276 \newline
35277 0025 92*02\InsetSpace ~
35278 \InsetSpace ~
35279 \InsetSpace ~
35280 \InsetSpace ~
35281 \InsetSpace ~
35282 \InsetSpace ~
35283 \InsetSpace ~
35284 \InsetSpace ~
35285 \InsetSpace ~
35286 \InsetSpace ~
35287 \InsetSpace ~
35288 \InsetSpace ~
35289 \InsetSpace ~
35290 \InsetSpace ~
35291 \InsetSpace ~
35292
35293  78\InsetSpace ~
35294 \InsetSpace ~
35295 \InsetSpace ~
35296 \InsetSpace ~
35297 \InsetSpace ~
35298 \InsetSpace ~
35299 \InsetSpace ~
35300 \InsetSpace ~
35301  mov\InsetSpace ~
35302 \InsetSpace ~
35303  _foo_aob2_1_1,c 
35304 \newline
35305 \InsetSpace ~
35306 \InsetSpace ~
35307 \InsetSpace ~
35308 \InsetSpace ~
35309 \InsetSpace ~
35310 \InsetSpace ~
35311 \InsetSpace ~
35312 \InsetSpace ~
35313 \InsetSpace ~
35314 \InsetSpace ~
35315 \InsetSpace ~
35316 \InsetSpace ~
35317 \InsetSpace ~
35318 \InsetSpace ~
35319 \InsetSpace ~
35320 \InsetSpace ~
35321 \InsetSpace ~
35322 \InsetSpace ~
35323 \InsetSpace ~
35324 \InsetSpace ~
35325 \InsetSpace ~
35326 \InsetSpace ~
35327 \InsetSpace ~
35328 \InsetSpace ~
35329 \InsetSpace ~
35330  79 ;\InsetSpace ~
35331  hob.c 12 
35332 \newline
35333 0027 E5*01\InsetSpace ~
35334 \InsetSpace ~
35335 \InsetSpace ~
35336 \InsetSpace ~
35337 \InsetSpace ~
35338 \InsetSpace ~
35339 \InsetSpace ~
35340 \InsetSpace ~
35341 \InsetSpace ~
35342 \InsetSpace ~
35343 \InsetSpace ~
35344 \InsetSpace ~
35345 \InsetSpace ~
35346 \InsetSpace ~
35347 \InsetSpace ~
35348  80\InsetSpace ~
35349 \InsetSpace ~
35350 \InsetSpace ~
35351 \InsetSpace ~
35352 \InsetSpace ~
35353 \InsetSpace ~
35354 \InsetSpace ~
35355 \InsetSpace ~
35356  mov\InsetSpace ~
35357 \InsetSpace ~
35358  a,(_gint + 1) 
35359 \newline
35360 0029
35361  A2 E3\InsetSpace ~
35362 \InsetSpace ~
35363 \InsetSpace ~
35364 \InsetSpace ~
35365 \InsetSpace ~
35366 \InsetSpace ~
35367 \InsetSpace ~
35368 \InsetSpace ~
35369 \InsetSpace ~
35370 \InsetSpace ~
35371 \InsetSpace ~
35372 \InsetSpace ~
35373 \InsetSpace ~
35374 \InsetSpace ~
35375 \InsetSpace ~
35376  81\InsetSpace ~
35377 \InsetSpace ~
35378 \InsetSpace ~
35379 \InsetSpace ~
35380 \InsetSpace ~
35381 \InsetSpace ~
35382 \InsetSpace ~
35383 \InsetSpace ~
35384  mov\InsetSpace ~
35385 \InsetSpace ~
35386  c,acc[3] 
35387 \newline
35388 002B 92*03\InsetSpace ~
35389 \InsetSpace ~
35390 \InsetSpace ~
35391 \InsetSpace ~
35392 \InsetSpace ~
35393 \InsetSpace ~
35394 \InsetSpace ~
35395 \InsetSpace ~
35396 \InsetSpace ~
35397 \InsetSpace ~
35398 \InsetSpace ~
35399 \InsetSpace ~
35400 \InsetSpace ~
35401 \InsetSpace ~
35402 \InsetSpace ~
35403  82\InsetSpace ~
35404 \InsetSpace ~
35405 \InsetSpace ~
35406 \InsetSpace ~
35407 \InsetSpace ~
35408 \InsetSpace ~
35409 \InsetSpace ~
35410 \InsetSpace ~
35411  mov\InsetSpace ~
35412 \InsetSpace ~
35413  _foo_aob3_1_1,c 
35414 \end_layout
35415
35416 \begin_layout Standard
35417 Other variations of these cases however will 
35418 \emph on
35419 not
35420 \emph default
35421  be recognized.
35422  They are standard C expressions, so I heartily recommend these be the only
35423  way to get the highest order bit, (it is portable).
35424  Of course it will be recognized even if it is embedded in other expressions,
35425  e.g.:
35426 \end_layout
35427
35428 \begin_layout Verse
35429
35430 \family typewriter
35431 xyz = gint + ((gint >> 15) & 1);
35432 \end_layout
35433
35434 \begin_layout Standard
35435 will still be recognized.
35436 \end_layout
35437
35438 \begin_layout Subsection
35439 Higher Order Byte
35440 \begin_inset LatexCommand \index{Higher Order Byte}
35441
35442 \end_inset
35443
35444  / Higher Order Word
35445 \begin_inset LatexCommand \index{Higher Order Word}
35446
35447 \end_inset
35448
35449
35450 \end_layout
35451
35452 \begin_layout Standard
35453 It is also frequently required to obtain a higher order byte or word of
35454  a larger integral type (long, int or short types).
35455  SDCC recognizes the following expressions to yield the higher order byte
35456  or word and generates optimized code for it, e.g.:
35457 \end_layout
35458
35459 \begin_layout Verse
35460
35461 \family typewriter
35462 unsigned int gint; 
35463 \newline
35464 unsigned long int glong; 
35465 \newline
35466
35467 \newline
35468 foo () { 
35469 \newline
35470 \InsetSpace ~
35471 \InsetSpace ~
35472 unsigned char hob1,
35473  hob2; 
35474 \newline
35475 \InsetSpace ~
35476 \InsetSpace ~
35477 unsigned int how1, how2; 
35478 \newline
35479 \InsetSpace ~
35480 \InsetSpace ~
35481 ...
35482  
35483 \newline
35484 \InsetSpace ~
35485 \InsetSpace ~
35486 hob1 = (gint >> 8) & 0xFF; 
35487 \newline
35488 \InsetSpace ~
35489 \InsetSpace ~
35490 hob2 = glong >> 24; 
35491 \newline
35492 \InsetSpace ~
35493 \InsetSpace ~
35494 how1 = (glong >> 16) & 0xFFFF;
35495  
35496 \newline
35497 \InsetSpace ~
35498 \InsetSpace ~
35499 how2 = glong >> 8; 
35500 \newline
35501 \InsetSpace ~
35502 \InsetSpace ~
35503 ..
35504  
35505 \newline
35506 }
35507 \end_layout
35508
35509 \begin_layout Standard
35510 will generate the following code:
35511 \end_layout
35512
35513 \begin_layout Verse
35514
35515 \family typewriter
35516 \InsetSpace ~
35517 \InsetSpace ~
35518 \InsetSpace ~
35519 \InsetSpace ~
35520 \InsetSpace ~
35521 \InsetSpace ~
35522 \InsetSpace ~
35523 \InsetSpace ~
35524 \InsetSpace ~
35525 \InsetSpace ~
35526 \InsetSpace ~
35527 \InsetSpace ~
35528 \InsetSpace ~
35529 \InsetSpace ~
35530 \InsetSpace ~
35531 \InsetSpace ~
35532 \InsetSpace ~
35533 \InsetSpace ~
35534 \InsetSpace ~
35535 \InsetSpace ~
35536 \InsetSpace ~
35537 \InsetSpace ~
35538 \InsetSpace ~
35539 \InsetSpace ~
35540 \InsetSpace ~
35541  91 ;\InsetSpace ~
35542  hob.c 15 
35543 \newline
35544 0037 85*01*06\InsetSpace ~
35545 \InsetSpace ~
35546 \InsetSpace ~
35547 \InsetSpace ~
35548 \InsetSpace ~
35549 \InsetSpace ~
35550 \InsetSpace ~
35551 \InsetSpace ~
35552 \InsetSpace ~
35553 \InsetSpace ~
35554 \InsetSpace ~
35555 \InsetSpace ~
35556  92\InsetSpace ~
35557 \InsetSpace ~
35558 \InsetSpace ~
35559 \InsetSpace ~
35560 \InsetSpace ~
35561 \InsetSpace ~
35562 \InsetSpace ~
35563 \InsetSpace ~
35564  mov\InsetSpace ~
35565 \InsetSpace ~
35566  _foo_hob1_1_1,(_gint + 1) 
35567 \newline
35568 \InsetSpace ~
35569 \InsetSpace ~
35570 \InsetSpace ~
35571 \InsetSpace ~
35572 \InsetSpace ~
35573 \InsetSpace ~
35574 \InsetSpace ~
35575 \InsetSpace ~
35576 \InsetSpace ~
35577 \InsetSpace ~
35578 \InsetSpace ~
35579 \InsetSpace ~
35580 \InsetSpace ~
35581 \InsetSpace ~
35582 \InsetSpace ~
35583 \InsetSpace ~
35584 \InsetSpace ~
35585 \InsetSpace ~
35586 \InsetSpace ~
35587 \InsetSpace ~
35588 \InsetSpace ~
35589 \InsetSpace ~
35590 \InsetSpace ~
35591 \InsetSpace ~
35592 \InsetSpace ~
35593  93 ;\InsetSpace ~
35594  hob.c
35595  16 
35596 \newline
35597 003A 85*05*07\InsetSpace ~
35598 \InsetSpace ~
35599 \InsetSpace ~
35600 \InsetSpace ~
35601 \InsetSpace ~
35602 \InsetSpace ~
35603 \InsetSpace ~
35604 \InsetSpace ~
35605 \InsetSpace ~
35606 \InsetSpace ~
35607 \InsetSpace ~
35608 \InsetSpace ~
35609  94\InsetSpace ~
35610 \InsetSpace ~
35611 \InsetSpace ~
35612 \InsetSpace ~
35613 \InsetSpace ~
35614 \InsetSpace ~
35615 \InsetSpace ~
35616 \InsetSpace ~
35617  mov\InsetSpace ~
35618 \InsetSpace ~
35619  _foo_hob2_1_1,(_glong + 3) 
35620 \newline
35621 \InsetSpace ~
35622 \InsetSpace ~
35623 \InsetSpace ~
35624 \InsetSpace ~
35625 \InsetSpace ~
35626 \InsetSpace ~
35627 \InsetSpace ~
35628 \InsetSpace ~
35629 \InsetSpace ~
35630 \InsetSpace ~
35631 \InsetSpace ~
35632 \InsetSpace ~
35633 \InsetSpace ~
35634 \InsetSpace ~
35635 \InsetSpace ~
35636 \InsetSpace ~
35637 \InsetSpace ~
35638 \InsetSpace ~
35639 \InsetSpace ~
35640 \InsetSpace ~
35641 \InsetSpace ~
35642 \InsetSpace ~
35643 \InsetSpace ~
35644 \InsetSpace ~
35645 \InsetSpace ~
35646  95 ;\InsetSpace ~
35647  hob.c 17 
35648 \newline
35649 003D 85*04*08\InsetSpace ~
35650 \InsetSpace ~
35651 \InsetSpace ~
35652 \InsetSpace ~
35653 \InsetSpace ~
35654 \InsetSpace ~
35655 \InsetSpace ~
35656 \InsetSpace ~
35657 \InsetSpace ~
35658 \InsetSpace ~
35659 \InsetSpace ~
35660 \InsetSpace ~
35661
35662  96\InsetSpace ~
35663 \InsetSpace ~
35664 \InsetSpace ~
35665 \InsetSpace ~
35666 \InsetSpace ~
35667 \InsetSpace ~
35668 \InsetSpace ~
35669 \InsetSpace ~
35670  mov\InsetSpace ~
35671 \InsetSpace ~
35672  _foo_how1_1_1,(_glong + 2) 
35673 \newline
35674 0040 85*05*09\InsetSpace ~
35675 \InsetSpace ~
35676 \InsetSpace ~
35677 \InsetSpace ~
35678 \InsetSpace ~
35679 \InsetSpace ~
35680 \InsetSpace ~
35681 \InsetSpace ~
35682 \InsetSpace ~
35683 \InsetSpace ~
35684 \InsetSpace ~
35685 \InsetSpace ~
35686  97\InsetSpace ~
35687 \InsetSpace ~
35688 \InsetSpace ~
35689 \InsetSpace ~
35690 \InsetSpace ~
35691 \InsetSpace ~
35692 \InsetSpace ~
35693 \InsetSpace ~
35694  mov\InsetSpace ~
35695 \InsetSpace ~
35696  (_foo_how1_1_1 +
35697  1),(_glong + 3) 
35698 \newline
35699 0043 85*03*0A\InsetSpace ~
35700 \InsetSpace ~
35701 \InsetSpace ~
35702 \InsetSpace ~
35703 \InsetSpace ~
35704 \InsetSpace ~
35705 \InsetSpace ~
35706 \InsetSpace ~
35707 \InsetSpace ~
35708 \InsetSpace ~
35709 \InsetSpace ~
35710 \InsetSpace ~
35711  98\InsetSpace ~
35712 \InsetSpace ~
35713 \InsetSpace ~
35714 \InsetSpace ~
35715 \InsetSpace ~
35716 \InsetSpace ~
35717 \InsetSpace ~
35718 \InsetSpace ~
35719  mov\InsetSpace ~
35720 \InsetSpace ~
35721  _foo_how2_1_1,(_glong + 1) 
35722 \newline
35723 0046 85*04*0B\InsetSpace ~
35724 \InsetSpace ~
35725 \InsetSpace ~
35726 \InsetSpace ~
35727 \InsetSpace ~
35728 \InsetSpace ~
35729 \InsetSpace ~
35730 \InsetSpace ~
35731 \InsetSpace ~
35732 \InsetSpace ~
35733 \InsetSpace ~
35734 \InsetSpace ~
35735
35736  99\InsetSpace ~
35737 \InsetSpace ~
35738 \InsetSpace ~
35739 \InsetSpace ~
35740 \InsetSpace ~
35741 \InsetSpace ~
35742 \InsetSpace ~
35743 \InsetSpace ~
35744  mov\InsetSpace ~
35745 \InsetSpace ~
35746  (_foo_how2_1_1 + 1),(_glong + 2) 
35747 \end_layout
35748
35749 \begin_layout Standard
35750 Again, variations of these cases may 
35751 \emph on
35752 not
35753 \emph default
35754  be recognized.
35755  They are standard C expressions, so I heartily recommend these be the only
35756  way to get the higher order byte/word, (it is portable).
35757  Of course it will be recognized even if it is embedded in other expressions,
35758  e.g.:
35759 \end_layout
35760
35761 \begin_layout Verse
35762
35763 \family typewriter
35764 xyz = gint + ((gint >> 8) & 0xFF);
35765 \end_layout
35766
35767 \begin_layout Standard
35768 will still be recognized.
35769 \end_layout
35770
35771 \begin_layout Subsection
35772 Peephole Optimizer
35773 \begin_inset LatexCommand \label{sub:Peephole-Optimizer}
35774
35775 \end_inset
35776
35777
35778 \begin_inset LatexCommand \index{Peephole optimizer}
35779
35780 \end_inset
35781
35782
35783 \end_layout
35784
35785 \begin_layout Standard
35786 The compiler uses a rule based, pattern matching and re-writing mechanism
35787  for peep-hole optimization.
35788  It is inspired by 
35789 \emph on
35790 copt
35791 \emph default
35792  a peep-hole optimizer by Christopher W.
35793  Fraser (cwfraser\InsetSpace ~
35794 @\InsetSpace ~
35795 microsoft.com).
35796  A default set of rules are compiled into the compiler, additional rules
35797  may be added with the 
35798 \emph on
35799 -
35800 \begin_inset ERT
35801 status collapsed
35802
35803 \begin_layout Standard
35804
35805
35806 \backslash
35807 /
35808 \end_layout
35809
35810 \end_inset
35811
35812 -peep-file
35813 \begin_inset LatexCommand \index{-\/-peep-file}
35814
35815 \end_inset
35816
35817  <filename>
35818 \emph default
35819  option.
35820  The rule language is best illustrated with examples.
35821 \end_layout
35822
35823 \begin_layout Verse
35824
35825 \family typewriter
35826 replace { 
35827 \newline
35828 \InsetSpace ~
35829 \InsetSpace ~
35830 mov %1,a 
35831 \newline
35832 \InsetSpace ~
35833 \InsetSpace ~
35834 mov a,%1
35835 \newline
35836 } by {
35837 \newline
35838 \InsetSpace ~
35839 \InsetSpace ~
35840 mov %1,a
35841 \newline
35842 }
35843 \end_layout
35844
35845 \begin_layout Standard
35846 The above rule will change the following assembly
35847 \begin_inset LatexCommand \index{Assembler routines}
35848
35849 \end_inset
35850
35851  sequence:
35852 \end_layout
35853
35854 \begin_layout Verse
35855
35856 \family typewriter
35857 mov r1,a 
35858 \newline
35859 mov a,r1
35860 \end_layout
35861
35862 \begin_layout Standard
35863 to
35864 \end_layout
35865
35866 \begin_layout Verse
35867
35868 \family typewriter
35869 mov r1,a
35870 \end_layout
35871
35872 \begin_layout Standard
35873 Note: All occurrences of a 
35874 \emph on
35875 %n
35876 \emph default
35877  (pattern variable) must denote the same string.
35878  With the above rule, the assembly sequence:
35879 \end_layout
35880
35881 \begin_layout Verse
35882
35883 \family typewriter
35884 mov r1,a 
35885 \newline
35886 mov a,r2
35887 \end_layout
35888
35889 \begin_layout Standard
35890 will remain unmodified.
35891 \newline
35892
35893 \newline
35894 Other special case optimizations may be added by the
35895  user (via 
35896 \emph on
35897 -
35898 \begin_inset ERT
35899 status collapsed
35900
35901 \begin_layout Standard
35902
35903
35904 \backslash
35905 /
35906 \end_layout
35907
35908 \end_inset
35909
35910 -peep-file option
35911 \emph default
35912 ).
35913  E.g.
35914  some variants of the 8051 MCU
35915 \begin_inset LatexCommand \index{MCS51 variants}
35916
35917 \end_inset
35918
35919  allow only 
35920 \family typewriter
35921 ajmp
35922 \family default
35923  and 
35924 \family typewriter
35925 acall
35926 \family default
35927 .
35928  The following two rules will change all 
35929 \family typewriter
35930 ljmp
35931 \family default
35932  and 
35933 \family typewriter
35934 lcall
35935 \family default
35936  to 
35937 \family typewriter
35938 ajmp
35939 \family default
35940  and 
35941 \family typewriter
35942 acall
35943 \end_layout
35944
35945 \begin_layout Verse
35946
35947 \family typewriter
35948 replace { lcall %1 } by { acall %1 } 
35949 \newline
35950 replace { ljmp %1 } by { ajmp %1 }
35951 \end_layout
35952
35953 \begin_layout Standard
35954 (NOTE: from version 2.7.3 on, you can use option -
35955 \emph on
35956
35957 \begin_inset ERT
35958 status collapsed
35959
35960 \begin_layout Standard
35961
35962
35963 \backslash
35964 /
35965 \end_layout
35966
35967 \end_inset
35968
35969
35970 \emph default
35971 -acall-ajmp
35972 \begin_inset LatexCommand \index{-\/-acall-ajmp}
35973
35974 \end_inset
35975
35976 , which also takes care of aligning the interrupt vectors properly.)
35977 \newline
35978
35979 \end_layout
35980
35981 \begin_layout Standard
35982 The 
35983 \emph on
35984 inline-assembler code
35985 \emph default
35986  is also passed through the peep hole optimizer, thus the peephole optimizer
35987  can also be used as an assembly level macro expander.
35988  The rules themselves are MCU dependent whereas the rule language infra-structur
35989 e is MCU independent.
35990  Peephole optimization rules for other MCU can be easily programmed using
35991  the rule language.
35992 \newline
35993
35994 \newline
35995 The syntax for a rule is as follows:
35996 \end_layout
35997
35998 \begin_layout Verse
35999
36000 \family typewriter
36001 rule := replace [ restart ] '{' <assembly sequence> '
36002 \backslash
36003 n' 
36004 \newline
36005 \InsetSpace ~
36006  \InsetSpace ~
36007  \InsetSpace ~
36008  \InsetSpace ~
36009  \InsetSpace ~
36010  \InsetSpace ~
36011  \InsetSpace ~
36012  \InsetSpace ~
36013  \InsetSpace ~
36014  \InsetSpace ~
36015  \InsetSpace ~
36016  \InsetSpace ~
36017  \InsetSpace ~
36018  \InsetSpace ~
36019  '}' by '{' '
36020 \backslash
36021 n' 
36022 \newline
36023 \InsetSpace ~
36024  \InsetSpace ~
36025  \InsetSpace ~
36026  \InsetSpace ~
36027  \InsetSpace ~
36028  \InsetSpace ~
36029  \InsetSpace ~
36030  \InsetSpace ~
36031  \InsetSpace ~
36032  \InsetSpace ~
36033  \InsetSpace ~
36034  \InsetSpace ~
36035  \InsetSpace ~
36036  \InsetSpace ~
36037  \InsetSpace ~
36038  \InsetSpace ~
36039  <assembly sequence> '
36040 \backslash
36041 n' 
36042 \newline
36043 \InsetSpace ~
36044  \InsetSpace ~
36045  \InsetSpace ~
36046  \InsetSpace ~
36047  \InsetSpace ~
36048  \InsetSpace ~
36049  \InsetSpace ~
36050  \InsetSpace ~
36051  \InsetSpace ~
36052  \InsetSpace ~
36053  \InsetSpace ~
36054  \InsetSpace ~
36055  \InsetSpace ~
36056  \InsetSpace ~
36057  '}' [if <functionName> ] '
36058 \backslash
36059 n' 
36060 \end_layout
36061
36062 \begin_layout Standard
36063 <assembly sequence> := assembly instruction (each instruction including
36064  labels must be on a separate line).
36065 \newline
36066
36067 \newline
36068 The optimizer will apply to the rules
36069  one by one from the top in the sequence of their appearance, it will terminate
36070  when all rules are exhausted.
36071  If the 'restart' option is specified, then the optimizer will start matching
36072  the rules again from the top, this option for a rule is expensive (performance)
36073 , it is intended to be used in situations where a transformation will trigger
36074  the same rule again.
36075  An example of this (not a good one, it has side effects) is the following
36076  rule:
36077 \end_layout
36078
36079 \begin_layout Verse
36080
36081 \family typewriter
36082 replace restart { 
36083 \newline
36084 \InsetSpace ~
36085 \InsetSpace ~
36086 pop %1 
36087 \newline
36088 \InsetSpace ~
36089 \InsetSpace ~
36090 push %1 } by { 
36091 \newline
36092 \InsetSpace ~
36093 \InsetSpace ~
36094 ; nop 
36095 \newline
36096 }
36097 \end_layout
36098
36099 \begin_layout Standard
36100 Note that the replace pattern cannot be a blank, but can be a comment line.
36101  Without the 'restart' option only the innermost 'pop' 'push' pair would
36102  be eliminated, i.e.:
36103 \end_layout
36104
36105 \begin_layout Verse
36106
36107 \family typewriter
36108 pop ar1 
36109 \newline
36110 pop ar2 
36111 \newline
36112 push ar2 
36113 \newline
36114 push ar1
36115 \end_layout
36116
36117 \begin_layout Standard
36118 would result in:
36119 \end_layout
36120
36121 \begin_layout Verse
36122
36123 \family typewriter
36124 pop ar1 
36125 \newline
36126 ; nop 
36127 \newline
36128 push ar1
36129 \end_layout
36130
36131 \begin_layout Standard
36132
36133 \emph on
36134 with
36135 \emph default
36136  the restart option the rule will be applied again to the resulting code
36137  and then all the pop-push pairs will be eliminated to yield:
36138 \end_layout
36139
36140 \begin_layout Verse
36141
36142 \family typewriter
36143 ; nop 
36144 \newline
36145 ; nop
36146 \end_layout
36147
36148 \begin_layout Standard
36149 A conditional function can be attached to a rule.
36150  Attaching rules are somewhat more involved, let me illustrate this with
36151  an example.
36152 \end_layout
36153
36154 \begin_layout Verse
36155
36156 \family typewriter
36157 replace { 
36158 \newline
36159 \InsetSpace ~
36160  \InsetSpace ~
36161  \InsetSpace ~
36162 ljmp %5 
36163 \newline
36164 %2:
36165 \newline
36166 } by { 
36167 \newline
36168 \InsetSpace ~
36169  \InsetSpace ~
36170  \InsetSpace ~
36171 sjmp %5 
36172 \newline
36173 %2:
36174 \newline
36175 } if labelInRange
36176 \end_layout
36177
36178 \begin_layout Standard
36179 The optimizer does a look-up of a function name table defined in function
36180  
36181 \emph on
36182 callFuncByName
36183 \emph default
36184  in the source file SDCCpeeph.c, with the name 
36185 \emph on
36186 labelInRange
36187 \emph default
36188 .
36189  If it finds a corresponding entry the function is called.
36190  Note there can be no parameters specified for these functions, in this
36191  case the use of 
36192 \emph on
36193 %5
36194 \emph default
36195  is crucial, since the function 
36196 \emph on
36197 labelInRange
36198 \emph default
36199  expects to find the label in that particular variable (the hash table containin
36200 g the variable bindings is passed as a parameter).
36201  If you want to code more such functions, take a close look at the function
36202  labelInRange and the calling mechanism in source file SDCCpeeph.c.
36203  Currently implemented are 
36204 \emph on
36205 labelInRange, labelRefCount, labelIsReturnOnly, operandsNotSame, xramMovcOption,
36206  24bitMode, portIsDS390, 24bitModeAndPortDS390 
36207 \emph default
36208 and
36209 \emph on
36210  notVolatile
36211 \emph default
36212 .
36213 \end_layout
36214
36215 \begin_layout Standard
36216 I know this whole thing is a little kludgey, but maybe some day we will
36217  have some better means.
36218  If you are looking at this file, you will see the default rules that are
36219  compiled into the compiler, you can add your own rules in the default set
36220  there if you get tired of specifying the -
36221 \begin_inset ERT
36222 status collapsed
36223
36224 \begin_layout Standard
36225
36226
36227 \backslash
36228 /
36229 \end_layout
36230
36231 \end_inset
36232
36233 -peep-file option.
36234 \end_layout
36235
36236 \begin_layout Section
36237 ANSI-Compliance
36238 \begin_inset LatexCommand \index{ANSI-compliance}
36239
36240 \end_inset
36241
36242
36243 \begin_inset LatexCommand \label{sub:ANSI-Compliance}
36244
36245 \end_inset
36246
36247
36248 \end_layout
36249
36250 \begin_layout Standard
36251 The latest publically available version of the standard 
36252 \emph on
36253 ISO/IEC 9899 - Programming languages - C
36254 \emph default
36255  should be available at: 
36256 \begin_inset LatexCommand \url{http://www.open-std.org/jtc1/sc22/wg14/www/standards.html#9899}
36257
36258 \end_inset
36259
36260 .
36261 \newline
36262
36263 \end_layout
36264
36265 \begin_layout Standard
36266 Deviations from the compliance:
36267 \end_layout
36268
36269 \begin_layout Itemize
36270 functions are not reentrant
36271 \begin_inset LatexCommand \index{reentrant}
36272
36273 \end_inset
36274
36275  unless explicitly declared as such or the 
36276 \series bold
36277 -
36278 \begin_inset ERT
36279 status collapsed
36280
36281 \begin_layout Standard
36282
36283
36284 \backslash
36285 /
36286 \end_layout
36287
36288 \end_inset
36289
36290 -stack-auto
36291 \begin_inset LatexCommand \index{-\/-stack-auto}
36292
36293 \end_inset
36294
36295
36296 \series default
36297  command line option is specified.
36298 \end_layout
36299
36300 \begin_layout Itemize
36301 structures
36302 \begin_inset LatexCommand \index{struct}
36303
36304 \end_inset
36305
36306  and unions
36307 \begin_inset LatexCommand \index{union}
36308
36309 \end_inset
36310
36311  cannot be assigned values directly, cannot be passed as function parameters
36312  or assigned to each other and cannot be a return value
36313 \begin_inset LatexCommand \index{return value}
36314
36315 \end_inset
36316
36317  from a function, e.g.:
36318 \end_layout
36319
36320 \begin_deeper
36321 \begin_layout Verse
36322
36323 \family typewriter
36324 struct s { ...
36325  }; 
36326 \newline
36327 struct s s1, s2; 
36328 \newline
36329 foo() 
36330 \newline
36331
36332 \newline
36333 \InsetSpace ~
36334 \InsetSpace ~
36335 \InsetSpace ~
36336 \InsetSpace ~
36337 ...
36338  
36339 \newline
36340 \InsetSpace ~
36341 \InsetSpace ~
36342 \InsetSpace ~
36343 \InsetSpace ~
36344 s1 = s2 ; /* is invalid in SDCC although allowed in ANSI */ 
36345 \newline
36346 \InsetSpace ~
36347 \InsetSpace ~
36348 \InsetSpace ~
36349 \InsetSpace ~
36350 ...
36351  
36352 \newline
36353 }
36354 \newline
36355
36356 \series bold
36357 struct
36358 \series default
36359  s foo1 (
36360 \series bold
36361 struct
36362 \series default
36363  s parms) /* invalid in SDCC although allowed in ANSI */
36364 \newline
36365
36366 \newline
36367 \InsetSpace ~
36368 \InsetSpace ~
36369 \InsetSpace ~
36370 \InsetSpace ~
36371 struct s rets;
36372  
36373 \newline
36374 \InsetSpace ~
36375 \InsetSpace ~
36376 \InsetSpace ~
36377 \InsetSpace ~
36378 ...
36379  
36380 \newline
36381 \InsetSpace ~
36382 \InsetSpace ~
36383 \InsetSpace ~
36384 \InsetSpace ~
36385 return rets; /* is invalid in SDCC although allowed in ANSI */ 
36386 \newline
36387 }
36388 \end_layout
36389
36390 \end_deeper
36391 \begin_layout Itemize
36392 initialization of structure arrays must be fully braced.
36393 \end_layout
36394
36395 \begin_deeper
36396 \begin_layout Verse
36397
36398 \family typewriter
36399 struct s { char x } a[] = {1, 2};\InsetSpace ~
36400 \InsetSpace ~
36401 \InsetSpace ~
36402 \InsetSpace ~
36403 \InsetSpace ~
36404 /* invalid in SDCC */
36405 \newline
36406 struct s { char x
36407  } a[] = {{1}, {2}}; /* OK */
36408 \end_layout
36409
36410 \end_deeper
36411 \begin_layout Itemize
36412 'long long
36413 \begin_inset LatexCommand \index{long long (not supported)}
36414
36415 \end_inset
36416
36417 ' (64 bit integers
36418 \begin_inset LatexCommand \index{int (64 bit) (not supported)}
36419
36420 \end_inset
36421
36422 ) not supported.
36423 \end_layout
36424
36425 \begin_layout Itemize
36426 'double
36427 \begin_inset LatexCommand \index{double (not supported)}
36428
36429 \end_inset
36430
36431 ' precision floating point 
36432 \begin_inset LatexCommand \index{Floating point support}
36433
36434 \end_inset
36435
36436 not supported.
36437 \end_layout
36438
36439 \begin_layout Itemize
36440 Old K&R style
36441 \begin_inset LatexCommand \index{K\&R style}
36442
36443 \end_inset
36444
36445  function declarations are NOT allowed.
36446 \end_layout
36447
36448 \begin_deeper
36449 \begin_layout Verse
36450
36451 \family typewriter
36452 foo(i,j) /* this old style of function declarations */ 
36453 \newline
36454 int i,j; /* is valid
36455  in ANSI but not valid in SDCC */ 
36456 \newline
36457
36458 \newline
36459 \InsetSpace ~
36460 \InsetSpace ~
36461 \InsetSpace ~
36462 \InsetSpace ~
36463 ...
36464  
36465 \newline
36466 }
36467 \end_layout
36468
36469 \end_deeper
36470 \begin_layout Itemize
36471 Most enhancements in C99 are not supported, e.g.:
36472 \end_layout
36473
36474 \begin_deeper
36475 \begin_layout Verse
36476
36477 \family typewriter
36478 for (
36479 \series bold
36480 int
36481 \series default
36482  i=0; i<10; i++) /* is invalid in SDCC although allowed in C99 */
36483 \end_layout
36484
36485 \end_deeper
36486 \begin_layout Itemize
36487 But some have been added recently in SDCC 2.7.0.
36488  They must be considered alpha quality however.
36489 \end_layout
36490
36491 \begin_deeper
36492 \begin_layout Verse
36493
36494 \family typewriter
36495 \series bold
36496 inline
36497 \begin_inset LatexCommand \index{inline (not supported)}
36498
36499 \end_inset
36500
36501
36502 \series default
36503  int increment (int a) { return a+1; } /* inlines the increment without
36504  function call overhead */
36505 \newline
36506 int * 
36507 \series bold
36508 restrict
36509 \begin_inset LatexCommand \index{inline (not supported)}
36510
36511 \end_inset
36512
36513
36514 \series default
36515  p; /* accepted but ignored */
36516 \end_layout
36517
36518 \end_deeper
36519 \begin_layout Itemize
36520 Certain words that are valid identifiers in the standard may be reserved
36521  words in SDCC unless the 
36522 \series bold
36523 -
36524 \begin_inset ERT
36525 status collapsed
36526
36527 \begin_layout Standard
36528
36529
36530 \backslash
36531 /
36532 \end_layout
36533
36534 \end_inset
36535
36536 -std-c89
36537 \begin_inset LatexCommand \index{-\/-std-c89}
36538
36539 \end_inset
36540
36541  or -
36542 \begin_inset ERT
36543 status collapsed
36544
36545 \begin_layout Standard
36546
36547
36548 \backslash
36549 /
36550 \end_layout
36551
36552 \end_inset
36553
36554 -std-c99
36555 \begin_inset LatexCommand \index{-\/-std-c99}
36556
36557 \end_inset
36558
36559
36560 \series default
36561  command line options are used.
36562  These may include (depending on the selected processor): 'at', 'banked',
36563  'bit', 'code', 'critical', 'data', 'eeprom', 'far', 'flash', 'idata', 'interrup
36564 t', 'near', 'nonbanked', 'pdata', 'reentrant', 'sbit', 'sfr', 'shadowregs',
36565  'sram', 'using', 'wparam', 'xdata', '_overlay', '_asm', '_endasm', and
36566  '_naked'.
36567  Compliant equivalents of these keywords are always available in a form
36568  that begin with two underscores
36569 \begin_inset LatexCommand \index{\_\_ (prefix for extended keywords)}
36570
36571 \end_inset
36572
36573 , f.e.
36574  '__data' instead of 'data'.
36575 \end_layout
36576
36577 \begin_layout Section
36578 Cyclomatic Complexity
36579 \begin_inset LatexCommand \index{Cyclomatic complexity}
36580
36581 \end_inset
36582
36583
36584 \end_layout
36585
36586 \begin_layout Standard
36587 Cyclomatic complexity of a function is defined as the number of independent
36588  paths the program can take during execution of the function.
36589  This is an important number since it defines the number test cases you
36590  have to generate to validate the function.
36591  The accepted industry standard for complexity number is 10, if the cyclomatic
36592  complexity reported by SDCC exceeds 10 you should think about simplification
36593  of the function logic.
36594  Note that the complexity level is not related to the number of lines of
36595  code in a function.
36596  Large functions can have low complexity, and small functions can have large
36597  complexity levels.
36598  
36599 \newline
36600
36601 \newline
36602 SDCC uses the following formula to compute the complexity:
36603 \newline
36604
36605 \end_layout
36606
36607 \begin_layout Standard
36608 complexity = (number of edges in control flow graph) - (number of nodes
36609  in control flow graph) + 2;
36610 \newline
36611
36612 \newline
36613 Having said that the industry standard is 10,
36614  you should be aware that in some cases it be may unavoidable to have a
36615  complexity level of less than 10.
36616  For example if you have switch statement with more than 10 case labels,
36617  each case label adds one to the complexity level.
36618  The complexity level is by no means an absolute measure of the algorithmic
36619  complexity of the function, it does however provide a good starting point
36620  for which functions you might look at for further optimization.
36621 \end_layout
36622
36623 \begin_layout Section
36624 Retargetting for other Processors
36625 \end_layout
36626
36627 \begin_layout Standard
36628 The issues for retargetting the compiler are far too numerous to be covered
36629  by this document.
36630  What follows is a brief description of each of the seven phases of the
36631  compiler and its MCU dependency.
36632 \end_layout
36633
36634 \begin_layout Itemize
36635 Parsing the source and building the annotated parse tree.
36636  This phase is largely MCU independent (except for the language extensions).
36637  Syntax & semantic checks are also done in this phase, along with some initial
36638  optimizations like back patching labels and the pattern matching optimizations
36639  like bit-rotation etc.
36640 \end_layout
36641
36642 \begin_layout Itemize
36643 The second phase involves generating an intermediate code which can be easy
36644  manipulated during the later phases.
36645  This phase is entirely MCU independent.
36646  The intermediate code generation assumes the target machine has unlimited
36647  number of registers, and designates them with the name iTemp.
36648  The compiler can be made to dump a human readable form of the code generated
36649  by using the -
36650 \begin_inset ERT
36651 status collapsed
36652
36653 \begin_layout Standard
36654
36655
36656 \backslash
36657 /
36658 \end_layout
36659
36660 \end_inset
36661
36662 -dumpraw option.
36663 \end_layout
36664
36665 \begin_layout Itemize
36666 This phase does the bulk of the standard optimizations and is also MCU independe
36667 nt.
36668  This phase can be broken down into several sub-phases:
36669 \newline
36670
36671 \newline
36672 Break down intermediate
36673  code (iCode) into basic blocks.
36674 \newline
36675 Do control flow & data flow analysis on the
36676  basic blocks.
36677 \newline
36678 Do local common subexpression elimination, then global subexpressio
36679 n elimination
36680 \newline
36681 Dead code elimination
36682 \newline
36683 Loop optimizations
36684 \newline
36685 If loop optimizations
36686  caused any changes then do 'global subexpression elimination' and 'dead
36687  code elimination' again.
36688 \end_layout
36689
36690 \begin_layout Itemize
36691 This phase determines the live-ranges; by live range I mean those iTemp
36692  variables defined by the compiler that still survive after all the optimization
36693 s.
36694  Live range analysis
36695 \begin_inset LatexCommand \index{Live range analysis}
36696
36697 \end_inset
36698
36699  is essential for register allocation, since these computation determines
36700  which of these iTemps will be assigned to registers, and for how long.
36701 \end_layout
36702
36703 \begin_layout Itemize
36704 Phase five is register allocation.
36705  There are two parts to this process.
36706 \newline
36707
36708 \newline
36709 The first part I call 'register packing'
36710  (for lack of a better term).
36711  In this case several MCU specific expression folding is done to reduce
36712  register pressure.
36713 \newline
36714
36715 \newline
36716 The second part is more MCU independent and deals with
36717  allocating registers to the remaining live ranges.
36718  A lot of MCU specific code does creep into this phase because of the limited
36719  number of index registers available in the 8051.
36720 \end_layout
36721
36722 \begin_layout Itemize
36723 The Code generation phase is (unhappily), entirely MCU dependent and very
36724  little (if any at all) of this code can be reused for other MCU.
36725  However the scheme for allocating a homogenized assembler operand for each
36726  iCode operand may be reused.
36727 \end_layout
36728
36729 \begin_layout Itemize
36730 As mentioned in the optimization section the peep-hole optimizer is rule
36731  based system, which can reprogrammed for other MCUs.
36732 \end_layout
36733
36734 \begin_layout Standard
36735 More information is available on SDCC Wiki
36736 \begin_inset LatexCommand \index{wiki}
36737
36738 \end_inset
36739
36740  (preliminary link 
36741 \begin_inset LatexCommand \url{http://sdcc.wiki.sourceforge.net/SDCC+internals+and+porting}
36742
36743 \end_inset
36744
36745 ) and in the thread 
36746 \begin_inset LatexCommand \url{http://sf.net/mailarchive/message.php?msg_id=13954144}
36747
36748 \end_inset
36749
36750  .
36751 \end_layout
36752
36753 \begin_layout Chapter
36754 Compiler internals
36755 \begin_inset LatexCommand \index{Compiler internals}
36756
36757 \end_inset
36758
36759
36760 \end_layout
36761
36762 \begin_layout Section
36763 The anatomy of the compiler
36764 \begin_inset LatexCommand \label{sub:The-anatomy-of}
36765
36766 \end_inset
36767
36768
36769 \end_layout
36770
36771 \begin_layout Standard
36772
36773 \shape italic
36774 This is an excerpt from an article published in Circuit Cellar Magazine
36775  in 
36776 \series bold
36777 August 2000
36778 \series default
36779 .
36780  It's a little outdated (the compiler is much more efficient now and user/develo
36781 per friendly), but pretty well exposes the guts of it all.
36782 \shape default
36783
36784 \newline
36785
36786 \newline
36787 The current version of SDCC can generate code for Intel 8051 and Z80 MCU.
36788  It is fairly easy to retarget for other 8-bit MCU.
36789  Here we take a look at some of the internals of the compiler.
36790  
36791 \end_layout
36792
36793 \begin_layout Paragraph*
36794 Parsing
36795 \begin_inset LatexCommand \index{Parsing}
36796
36797 \end_inset
36798
36799  
36800 \end_layout
36801
36802 \begin_layout Standard
36803 Parsing the input source file and creating an AST (Annotated Syntax Tree
36804 \begin_inset LatexCommand \index{Annotated syntax tree}
36805
36806 \end_inset
36807
36808 ).
36809  This phase also involves propagating types (annotating each node of the
36810  parse tree with type information) and semantic analysis.
36811  There are some MCU specific parsing rules.
36812  For example the storage classes, the extended storage classes are MCU specific
36813  while there may be a xdata storage class for 8051 there is no such storage
36814  class for z80 or Atmel AVR.
36815  SDCC allows MCU specific storage class extensions, i.e.
36816  xdata will be treated as a storage class specifier when parsing 8051 C
36817  code but will be treated as a C identifier when parsing z80 or ATMEL AVR
36818  C code.
36819 \end_layout
36820
36821 \begin_layout Paragraph*
36822 Generating iCode
36823 \begin_inset LatexCommand \index{iCode}
36824
36825 \end_inset
36826
36827
36828 \end_layout
36829
36830 \begin_layout Standard
36831 Intermediate code generation.
36832  In this phase the AST is broken down into three-operand form (iCode).
36833  These three operand forms are represented as doubly linked lists.
36834  ICode is the term given to the intermediate form generated by the compiler.
36835  ICode example section shows some examples of iCode generated for some simple
36836  C source functions.
36837 \end_layout
36838
36839 \begin_layout Paragraph*
36840 Optimizations
36841 \begin_inset LatexCommand \index{Optimizations}
36842
36843 \end_inset
36844
36845 .
36846 \end_layout
36847
36848 \begin_layout Standard
36849 Bulk of the target independent optimizations is performed in this phase.
36850  The optimizations include constant propagation, common sub-expression eliminati
36851 on, loop invariant code movement, strength reduction of loop induction variables
36852  and dead-code elimination.
36853 \end_layout
36854
36855 \begin_layout Paragraph*
36856 Live range analysis
36857 \begin_inset LatexCommand \index{Live range analysis}
36858
36859 \end_inset
36860
36861
36862 \end_layout
36863
36864 \begin_layout Standard
36865 During intermediate code generation phase, the compiler assumes the target
36866  machine has infinite number of registers and generates a lot of temporary
36867  variables.
36868  The live range computation determines the lifetime of each of these compiler-ge
36869 nerated temporaries.
36870  A picture speaks a thousand words.
36871  ICode example sections show the live range annotations for each of the
36872  operand.
36873  It is important to note here, each iCode is assigned a number in the order
36874  of its execution in the function.
36875  The live ranges are computed in terms of these numbers.
36876  The from number is the number of the iCode which first defines the operand
36877  and the to number signifies the iCode which uses this operand last.
36878 \end_layout
36879
36880 \begin_layout Paragraph*
36881 Register Allocation
36882 \begin_inset LatexCommand \index{Register allocation}
36883
36884 \end_inset
36885
36886
36887 \end_layout
36888
36889 \begin_layout Standard
36890 The register allocation determines the type and number of registers needed
36891  by each operand.
36892  In most MCUs only a few registers can be used for indirect addressing.
36893  In case of 8051 for example the registers R0 & R1 can be used to indirectly
36894  address the internal ram and DPTR to indirectly address the external ram.
36895  The compiler will try to allocate the appropriate register to pointer variables
36896  if it can.
36897  ICode example section shows the operands annotated with the registers assigned
36898  to them.
36899  The compiler will try to keep operands in registers as much as possible;
36900  there are several schemes the compiler uses to do achieve this.
36901  When the compiler runs out of registers the compiler will check to see
36902  if there are any live operands which is not used or defined in the current
36903  basic block being processed, if there are any found then it will push that
36904  operand and use the registers in this block, the operand will then be popped
36905  at the end of the basic block.
36906  
36907 \end_layout
36908
36909 \begin_layout Standard
36910 There are other MCU specific considerations in this phase.
36911  Some MCUs have an accumulator; very short-lived operands could be assigned
36912  to the accumulator instead of a general-purpose register.
36913 \end_layout
36914
36915 \begin_layout Paragraph*
36916 Code generation
36917 \end_layout
36918
36919 \begin_layout Standard
36920 Figure II gives a table of iCode
36921 \begin_inset LatexCommand \index{iCode}
36922
36923 \end_inset
36924
36925  operations supported by the compiler.
36926  The code generation involves translating these operations into corresponding
36927  assembly code for the processor.
36928  This sounds overly simple but that is the essence of code generation.
36929  Some of the iCode operations are generated on a MCU specific manner for
36930  example, the z80 port does not use registers to pass parameters so the
36931  SEND and RECV iCode operations will not be generated, and it also does
36932  not support JUMPTABLES.
36933  
36934 \newline
36935
36936 \end_layout
36937
36938 \begin_layout Standard
36939
36940 \size footnotesize
36941 Figure II 
36942 \begin_inset Tabular
36943 <lyxtabular version="3" rows="39" columns="4">
36944 <features islongtable="true" headBottomDL="true">
36945 <column alignment="block" valignment="top" leftline="true" width="13col%">
36946 <column alignment="left" valignment="top" leftline="true" width="13col%">
36947 <column alignment="block" valignment="top" leftline="true" width="22col%">
36948 <column alignment="block" valignment="top" leftline="true" rightline="true" width="40col%">
36949 <row topline="true" bottomline="true" endhead="true">
36950 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
36951 \begin_inset Text
36952
36953 \begin_layout Standard
36954
36955 \series bold
36956 iCode
36957 \series default
36958
36959 \begin_inset LatexCommand \index{iCode}
36960
36961 \end_inset
36962
36963
36964 \end_layout
36965
36966 \end_inset
36967 </cell>
36968 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
36969 \begin_inset Text
36970
36971 \begin_layout Standard
36972
36973 \series bold
36974 Operands
36975 \end_layout
36976
36977 \end_inset
36978 </cell>
36979 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
36980 \begin_inset Text
36981
36982 \begin_layout Standard
36983
36984 \series bold
36985 Description
36986 \end_layout
36987
36988 \end_inset
36989 </cell>
36990 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
36991 \begin_inset Text
36992
36993 \begin_layout Standard
36994
36995 \series bold
36996 C Equivalent
36997 \end_layout
36998
36999 \end_inset
37000 </cell>
37001 </row>
37002 <row topline="true">
37003 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37004 \begin_inset Text
37005
37006 \begin_layout Standard
37007
37008 \size footnotesize
37009 '!'
37010 \end_layout
37011
37012 \end_inset
37013 </cell>
37014 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37015 \begin_inset Text
37016
37017 \begin_layout Standard
37018
37019 \size footnotesize
37020 IC_LEFT() IC_RESULT()
37021 \end_layout
37022
37023 \end_inset
37024 </cell>
37025 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37026 \begin_inset Text
37027
37028 \begin_layout Standard
37029
37030 \size footnotesize
37031 NOT operation 
37032 \end_layout
37033
37034 \end_inset
37035 </cell>
37036 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
37037 \begin_inset Text
37038
37039 \begin_layout Standard
37040
37041 \size footnotesize
37042 IC_RESULT = ! IC_LEFT;
37043 \end_layout
37044
37045 \end_inset
37046 </cell>
37047 </row>
37048 <row topline="true">
37049 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37050 \begin_inset Text
37051
37052 \begin_layout Standard
37053
37054 \size footnotesize
37055 '~'
37056 \end_layout
37057
37058 \end_inset
37059 </cell>
37060 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37061 \begin_inset Text
37062
37063 \begin_layout Standard
37064
37065 \size footnotesize
37066 IC_LEFT() IC_RESULT()
37067 \end_layout
37068
37069 \end_inset
37070 </cell>
37071 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37072 \begin_inset Text
37073
37074 \begin_layout Standard
37075
37076 \size footnotesize
37077 Bitwise complement of 
37078 \end_layout
37079
37080 \end_inset
37081 </cell>
37082 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
37083 \begin_inset Text
37084
37085 \begin_layout Standard
37086
37087 \size footnotesize
37088 IC_RESULT = ~IC_LEFT;
37089 \end_layout
37090
37091 \end_inset
37092 </cell>
37093 </row>
37094 <row topline="true">
37095 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37096 \begin_inset Text
37097
37098 \begin_layout Standard
37099
37100 \size footnotesize
37101 RRC
37102 \end_layout
37103
37104 \end_inset
37105 </cell>
37106 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37107 \begin_inset Text
37108
37109 \begin_layout Standard
37110
37111 \size footnotesize
37112 IC_LEFT() IC_RESULT()
37113 \end_layout
37114
37115 \end_inset
37116 </cell>
37117 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37118 \begin_inset Text
37119
37120 \begin_layout Standard
37121
37122 \size footnotesize
37123 Rotate right with carry
37124 \end_layout
37125
37126 \end_inset
37127 </cell>
37128 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
37129 \begin_inset Text
37130
37131 \begin_layout Standard
37132
37133 \size footnotesize
37134 IC_RESULT = (IC_LEFT << 1) | (IC_LEFT >> (sizeof(IC_LEFT)*8-1));
37135 \end_layout
37136
37137 \end_inset
37138 </cell>
37139 </row>
37140 <row topline="true">
37141 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37142 \begin_inset Text
37143
37144 \begin_layout Standard
37145
37146 \size footnotesize
37147 RLC
37148 \end_layout
37149
37150 \end_inset
37151 </cell>
37152 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37153 \begin_inset Text
37154
37155 \begin_layout Standard
37156
37157 \size footnotesize
37158 IC_LEFT() IC_RESULT()
37159 \end_layout
37160
37161 \end_inset
37162 </cell>
37163 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37164 \begin_inset Text
37165
37166 \begin_layout Standard
37167
37168 \size footnotesize
37169 Rotate left with carry
37170 \end_layout
37171
37172 \end_inset
37173 </cell>
37174 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
37175 \begin_inset Text
37176
37177 \begin_layout Standard
37178
37179 \size footnotesize
37180 IC_RESULT = (IC_LEFT << (sizeof(LC_LEFT)*8-1) ) | (IC_LEFT >> 1);
37181 \end_layout
37182
37183 \end_inset
37184 </cell>
37185 </row>
37186 <row topline="true">
37187 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37188 \begin_inset Text
37189
37190 \begin_layout Standard
37191
37192 \size footnotesize
37193 GETHBIT
37194 \end_layout
37195
37196 \end_inset
37197 </cell>
37198 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37199 \begin_inset Text
37200
37201 \begin_layout Standard
37202
37203 \size footnotesize
37204 IC_LEFT() IC_RESULT()
37205 \end_layout
37206
37207 \end_inset
37208 </cell>
37209 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37210 \begin_inset Text
37211
37212 \begin_layout Standard
37213
37214 \size footnotesize
37215 Get the highest order bit of IC_LEFT
37216 \end_layout
37217
37218 \end_inset
37219 </cell>
37220 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
37221 \begin_inset Text
37222
37223 \begin_layout Standard
37224
37225 \size footnotesize
37226 IC_RESULT = (IC_LEFT >> (sizeof(IC_LEFT)*8 -1));
37227 \end_layout
37228
37229 \end_inset
37230 </cell>
37231 </row>
37232 <row topline="true">
37233 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37234 \begin_inset Text
37235
37236 \begin_layout Standard
37237
37238 \size footnotesize
37239 UNARYMINUS
37240 \end_layout
37241
37242 \end_inset
37243 </cell>
37244 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37245 \begin_inset Text
37246
37247 \begin_layout Standard
37248
37249 \size footnotesize
37250 IC_LEFT() IC_RESULT()
37251 \end_layout
37252
37253 \end_inset
37254 </cell>
37255 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37256 \begin_inset Text
37257
37258 \begin_layout Standard
37259
37260 \size footnotesize
37261 Unary minus
37262 \end_layout
37263
37264 \end_inset
37265 </cell>
37266 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
37267 \begin_inset Text
37268
37269 \begin_layout Standard
37270
37271 \size footnotesize
37272 IC_RESULT = - IC_LEFT;
37273 \end_layout
37274
37275 \end_inset
37276 </cell>
37277 </row>
37278 <row topline="true">
37279 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37280 \begin_inset Text
37281
37282 \begin_layout Standard
37283
37284 \size footnotesize
37285 IPUSH
37286 \end_layout
37287
37288 \end_inset
37289 </cell>
37290 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37291 \begin_inset Text
37292
37293 \begin_layout Standard
37294
37295 \size footnotesize
37296 IC_LEFT()
37297 \end_layout
37298
37299 \end_inset
37300 </cell>
37301 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37302 \begin_inset Text
37303
37304 \begin_layout Standard
37305
37306 \size footnotesize
37307 Push the operand into stack
37308 \end_layout
37309
37310 \end_inset
37311 </cell>
37312 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
37313 \begin_inset Text
37314
37315 \begin_layout Standard
37316
37317 \size footnotesize
37318 NONE
37319 \end_layout
37320
37321 \end_inset
37322 </cell>
37323 </row>
37324 <row topline="true">
37325 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37326 \begin_inset Text
37327
37328 \begin_layout Standard
37329
37330 \size footnotesize
37331 IPOP
37332 \end_layout
37333
37334 \end_inset
37335 </cell>
37336 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37337 \begin_inset Text
37338
37339 \begin_layout Standard
37340
37341 \size footnotesize
37342 IC_LEFT()
37343 \end_layout
37344
37345 \end_inset
37346 </cell>
37347 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37348 \begin_inset Text
37349
37350 \begin_layout Standard
37351
37352 \size footnotesize
37353 Pop the operand from the stack 
37354 \end_layout
37355
37356 \end_inset
37357 </cell>
37358 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
37359 \begin_inset Text
37360
37361 \begin_layout Standard
37362
37363 \size footnotesize
37364 NONE
37365 \end_layout
37366
37367 \end_inset
37368 </cell>
37369 </row>
37370 <row topline="true">
37371 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37372 \begin_inset Text
37373
37374 \begin_layout Standard
37375
37376 \size footnotesize
37377 CALL
37378 \end_layout
37379
37380 \end_inset
37381 </cell>
37382 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37383 \begin_inset Text
37384
37385 \begin_layout Standard
37386
37387 \size footnotesize
37388 IC_LEFT() IC_RESULT()
37389 \end_layout
37390
37391 \end_inset
37392 </cell>
37393 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37394 \begin_inset Text
37395
37396 \begin_layout Standard
37397
37398 \size footnotesize
37399 Call the function represented by IC_LEFT 
37400 \end_layout
37401
37402 \end_inset
37403 </cell>
37404 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
37405 \begin_inset Text
37406
37407 \begin_layout Standard
37408
37409 \size footnotesize
37410 IC_RESULT = IC_LEFT();
37411 \end_layout
37412
37413 \end_inset
37414 </cell>
37415 </row>
37416 <row topline="true">
37417 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37418 \begin_inset Text
37419
37420 \begin_layout Standard
37421
37422 \size footnotesize
37423 PCALL
37424 \end_layout
37425
37426 \end_inset
37427 </cell>
37428 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37429 \begin_inset Text
37430
37431 \begin_layout Standard
37432
37433 \size footnotesize
37434 IC_LEFT() IC_RESULT()
37435 \end_layout
37436
37437 \end_inset
37438 </cell>
37439 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37440 \begin_inset Text
37441
37442 \begin_layout Standard
37443
37444 \size footnotesize
37445 Call via function pointer
37446 \end_layout
37447
37448 \end_inset
37449 </cell>
37450 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
37451 \begin_inset Text
37452
37453 \begin_layout Standard
37454
37455 \size footnotesize
37456 IC_RESULT = (*IC_LEFT)();
37457 \end_layout
37458
37459 \end_inset
37460 </cell>
37461 </row>
37462 <row topline="true">
37463 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37464 \begin_inset Text
37465
37466 \begin_layout Standard
37467
37468 \size footnotesize
37469 RETURN
37470 \end_layout
37471
37472 \end_inset
37473 </cell>
37474 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37475 \begin_inset Text
37476
37477 \begin_layout Standard
37478
37479 \size footnotesize
37480 IC_LEFT()
37481 \end_layout
37482
37483 \end_inset
37484 </cell>
37485 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37486 \begin_inset Text
37487
37488 \begin_layout Standard
37489
37490 \size footnotesize
37491 Return the value in operand IC_LEFT 
37492 \end_layout
37493
37494 \end_inset
37495 </cell>
37496 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
37497 \begin_inset Text
37498
37499 \begin_layout Standard
37500
37501 \size footnotesize
37502 return IC_LEFT;
37503 \end_layout
37504
37505 \end_inset
37506 </cell>
37507 </row>
37508 <row topline="true">
37509 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37510 \begin_inset Text
37511
37512 \begin_layout Standard
37513
37514 \size footnotesize
37515 LABEL
37516 \end_layout
37517
37518 \end_inset
37519 </cell>
37520 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37521 \begin_inset Text
37522
37523 \begin_layout Standard
37524
37525 \size footnotesize
37526 IC_LABEL() 
37527 \end_layout
37528
37529 \end_inset
37530 </cell>
37531 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37532 \begin_inset Text
37533
37534 \begin_layout Standard
37535
37536 \size footnotesize
37537 Label
37538 \end_layout
37539
37540 \end_inset
37541 </cell>
37542 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
37543 \begin_inset Text
37544
37545 \begin_layout Standard
37546
37547 \size footnotesize
37548 IC_LABEL:
37549 \end_layout
37550
37551 \end_inset
37552 </cell>
37553 </row>
37554 <row topline="true">
37555 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37556 \begin_inset Text
37557
37558 \begin_layout Standard
37559
37560 \size footnotesize
37561 GOTO
37562 \end_layout
37563
37564 \end_inset
37565 </cell>
37566 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37567 \begin_inset Text
37568
37569 \begin_layout Standard
37570
37571 \size footnotesize
37572 IC_LABEL() 
37573 \end_layout
37574
37575 \end_inset
37576 </cell>
37577 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37578 \begin_inset Text
37579
37580 \begin_layout Standard
37581
37582 \size footnotesize
37583 Goto label
37584 \end_layout
37585
37586 \end_inset
37587 </cell>
37588 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
37589 \begin_inset Text
37590
37591 \begin_layout Standard
37592
37593 \size footnotesize
37594 goto IC_LABEL();
37595 \end_layout
37596
37597 \end_inset
37598 </cell>
37599 </row>
37600 <row topline="true">
37601 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37602 \begin_inset Text
37603
37604 \begin_layout Standard
37605
37606 \size footnotesize
37607 '+'
37608 \end_layout
37609
37610 \end_inset
37611 </cell>
37612 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37613 \begin_inset Text
37614
37615 \begin_layout Standard
37616
37617 \size footnotesize
37618 IC_LEFT() IC_RIGHT() IC_RESULT()
37619 \end_layout
37620
37621 \end_inset
37622 </cell>
37623 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37624 \begin_inset Text
37625
37626 \begin_layout Standard
37627
37628 \size footnotesize
37629 Addition
37630 \end_layout
37631
37632 \end_inset
37633 </cell>
37634 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
37635 \begin_inset Text
37636
37637 \begin_layout Standard
37638
37639 \size footnotesize
37640 IC_RESULT = IC_LEFT + IC_RIGHT
37641 \end_layout
37642
37643 \end_inset
37644 </cell>
37645 </row>
37646 <row topline="true">
37647 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37648 \begin_inset Text
37649
37650 \begin_layout Standard
37651
37652 \size footnotesize
37653 '-'
37654 \end_layout
37655
37656 \end_inset
37657 </cell>
37658 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37659 \begin_inset Text
37660
37661 \begin_layout Standard
37662
37663 \size footnotesize
37664 IC_LEFT() IC_RIGHT() IC_RESULT()
37665 \end_layout
37666
37667 \end_inset
37668 </cell>
37669 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37670 \begin_inset Text
37671
37672 \begin_layout Standard
37673
37674 \size footnotesize
37675 Subtraction
37676 \end_layout
37677
37678 \end_inset
37679 </cell>
37680 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
37681 \begin_inset Text
37682
37683 \begin_layout Standard
37684
37685 \size footnotesize
37686 IC_RESULT = IC_LEFT - IC_RIGHT 
37687 \end_layout
37688
37689 \end_inset
37690 </cell>
37691 </row>
37692 <row topline="true">
37693 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37694 \begin_inset Text
37695
37696 \begin_layout Standard
37697
37698 \size footnotesize
37699 '*'
37700 \end_layout
37701
37702 \end_inset
37703 </cell>
37704 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37705 \begin_inset Text
37706
37707 \begin_layout Standard
37708
37709 \size footnotesize
37710 IC_LEFT() IC_RIGHT() IC_RESULT()
37711 \end_layout
37712
37713 \end_inset
37714 </cell>
37715 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37716 \begin_inset Text
37717
37718 \begin_layout Standard
37719
37720 \size footnotesize
37721 Multiplication 
37722 \end_layout
37723
37724 \end_inset
37725 </cell>
37726 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
37727 \begin_inset Text
37728
37729 \begin_layout Standard
37730
37731 \size footnotesize
37732 IC_RESULT = IC_LEFT * IC_RIGHT;
37733 \end_layout
37734
37735 \end_inset
37736 </cell>
37737 </row>
37738 <row topline="true">
37739 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37740 \begin_inset Text
37741
37742 \begin_layout Standard
37743
37744 \size footnotesize
37745 '/'
37746 \end_layout
37747
37748 \end_inset
37749 </cell>
37750 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37751 \begin_inset Text
37752
37753 \begin_layout Standard
37754
37755 \size footnotesize
37756 IC_LEFT() IC_RIGHT() IC_RESULT()
37757 \end_layout
37758
37759 \end_inset
37760 </cell>
37761 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37762 \begin_inset Text
37763
37764 \begin_layout Standard
37765
37766 \size footnotesize
37767 Division
37768 \end_layout
37769
37770 \end_inset
37771 </cell>
37772 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
37773 \begin_inset Text
37774
37775 \begin_layout Standard
37776
37777 \size footnotesize
37778 IC_RESULT = IC_LEFT / IC_RIGHT;
37779 \end_layout
37780
37781 \end_inset
37782 </cell>
37783 </row>
37784 <row topline="true">
37785 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37786 \begin_inset Text
37787
37788 \begin_layout Standard
37789
37790 \size footnotesize
37791 '%'
37792 \end_layout
37793
37794 \end_inset
37795 </cell>
37796 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37797 \begin_inset Text
37798
37799 \begin_layout Standard
37800
37801 \size footnotesize
37802 IC_LEFT() IC_RIGHT() IC_RESULT()
37803 \end_layout
37804
37805 \end_inset
37806 </cell>
37807 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37808 \begin_inset Text
37809
37810 \begin_layout Standard
37811
37812 \size footnotesize
37813 Modulus
37814 \end_layout
37815
37816 \end_inset
37817 </cell>
37818 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
37819 \begin_inset Text
37820
37821 \begin_layout Standard
37822
37823 \size footnotesize
37824 IC_RESULT = IC_LEFT % IC_RIGHT;
37825 \end_layout
37826
37827 \end_inset
37828 </cell>
37829 </row>
37830 <row topline="true">
37831 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37832 \begin_inset Text
37833
37834 \begin_layout Standard
37835
37836 \size footnotesize
37837 '<'
37838 \end_layout
37839
37840 \end_inset
37841 </cell>
37842 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37843 \begin_inset Text
37844
37845 \begin_layout Standard
37846
37847 \size footnotesize
37848 IC_LEFT() IC_RIGHT() IC_RESULT()
37849 \end_layout
37850
37851 \end_inset
37852 </cell>
37853 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37854 \begin_inset Text
37855
37856 \begin_layout Standard
37857
37858 \size footnotesize
37859 Less than
37860 \end_layout
37861
37862 \end_inset
37863 </cell>
37864 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
37865 \begin_inset Text
37866
37867 \begin_layout Standard
37868
37869 \size footnotesize
37870 IC_RESULT = IC_LEFT < IC_RIGHT;
37871 \end_layout
37872
37873 \end_inset
37874 </cell>
37875 </row>
37876 <row topline="true">
37877 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37878 \begin_inset Text
37879
37880 \begin_layout Standard
37881
37882 \size footnotesize
37883 '>'
37884 \end_layout
37885
37886 \end_inset
37887 </cell>
37888 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37889 \begin_inset Text
37890
37891 \begin_layout Standard
37892
37893 \size footnotesize
37894 IC_LEFT() IC_RIGHT() IC_RESULT()
37895 \end_layout
37896
37897 \end_inset
37898 </cell>
37899 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37900 \begin_inset Text
37901
37902 \begin_layout Standard
37903
37904 \size footnotesize
37905 Greater than 
37906 \end_layout
37907
37908 \end_inset
37909 </cell>
37910 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
37911 \begin_inset Text
37912
37913 \begin_layout Standard
37914
37915 \size footnotesize
37916 IC_RESULT = IC_LEFT > IC_RIGHT;
37917 \end_layout
37918
37919 \end_inset
37920 </cell>
37921 </row>
37922 <row topline="true">
37923 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37924 \begin_inset Text
37925
37926 \begin_layout Standard
37927
37928 \size footnotesize
37929 EQ_OP
37930 \end_layout
37931
37932 \end_inset
37933 </cell>
37934 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37935 \begin_inset Text
37936
37937 \begin_layout Standard
37938
37939 \size footnotesize
37940 IC_LEFT() IC_RIGHT() IC_RESULT()
37941 \end_layout
37942
37943 \end_inset
37944 </cell>
37945 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37946 \begin_inset Text
37947
37948 \begin_layout Standard
37949
37950 \size footnotesize
37951 Equal to 
37952 \end_layout
37953
37954 \end_inset
37955 </cell>
37956 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
37957 \begin_inset Text
37958
37959 \begin_layout Standard
37960
37961 \size footnotesize
37962 IC_RESULT = IC_LEFT == IC_RIGHT;
37963 \end_layout
37964
37965 \end_inset
37966 </cell>
37967 </row>
37968 <row topline="true">
37969 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37970 \begin_inset Text
37971
37972 \begin_layout Standard
37973
37974 \size footnotesize
37975 AND_OP
37976 \end_layout
37977
37978 \end_inset
37979 </cell>
37980 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37981 \begin_inset Text
37982
37983 \begin_layout Standard
37984
37985 \size footnotesize
37986 IC_LEFT() IC_RIGHT() IC_RESULT() 
37987 \end_layout
37988
37989 \end_inset
37990 </cell>
37991 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37992 \begin_inset Text
37993
37994 \begin_layout Standard
37995
37996 \size footnotesize
37997 Logical and operation
37998 \end_layout
37999
38000 \end_inset
38001 </cell>
38002 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
38003 \begin_inset Text
38004
38005 \begin_layout Standard
38006
38007 \size footnotesize
38008 IC_RESULT = IC_LEFT && IC_RIGHT; 
38009 \end_layout
38010
38011 \end_inset
38012 </cell>
38013 </row>
38014 <row topline="true">
38015 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38016 \begin_inset Text
38017
38018 \begin_layout Standard
38019
38020 \size footnotesize
38021 OR_OP
38022 \end_layout
38023
38024 \end_inset
38025 </cell>
38026 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38027 \begin_inset Text
38028
38029 \begin_layout Standard
38030
38031 \size footnotesize
38032 IC_LEFT() IC_RIGHT() IC_RESULT() 
38033 \end_layout
38034
38035 \end_inset
38036 </cell>
38037 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38038 \begin_inset Text
38039
38040 \begin_layout Standard
38041
38042 \size footnotesize
38043 Logical or operation 
38044 \end_layout
38045
38046 \end_inset
38047 </cell>
38048 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
38049 \begin_inset Text
38050
38051 \begin_layout Standard
38052
38053 \size footnotesize
38054 IC_RESULT = IC_LEFT || IC_RIGHT; 
38055 \end_layout
38056
38057 \end_inset
38058 </cell>
38059 </row>
38060 <row topline="true">
38061 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38062 \begin_inset Text
38063
38064 \begin_layout Standard
38065
38066 \size footnotesize
38067 '^'
38068 \end_layout
38069
38070 \end_inset
38071 </cell>
38072 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38073 \begin_inset Text
38074
38075 \begin_layout Standard
38076
38077 \size footnotesize
38078 IC_LEFT() IC_RIGHT() IC_RESULT() 
38079 \end_layout
38080
38081 \end_inset
38082 </cell>
38083 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38084 \begin_inset Text
38085
38086 \begin_layout Standard
38087
38088 \size footnotesize
38089 Exclusive OR
38090 \end_layout
38091
38092 \end_inset
38093 </cell>
38094 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
38095 \begin_inset Text
38096
38097 \begin_layout Standard
38098
38099 \size footnotesize
38100 IC_RESULT = IC_LEFT ^ IC_RIGHT;
38101 \end_layout
38102
38103 \end_inset
38104 </cell>
38105 </row>
38106 <row topline="true">
38107 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38108 \begin_inset Text
38109
38110 \begin_layout Standard
38111
38112 \size footnotesize
38113 '|'
38114 \end_layout
38115
38116 \end_inset
38117 </cell>
38118 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38119 \begin_inset Text
38120
38121 \begin_layout Standard
38122
38123 \size footnotesize
38124 IC_LEFT() IC_RIGHT() IC_RESULT() 
38125 \end_layout
38126
38127 \end_inset
38128 </cell>
38129 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38130 \begin_inset Text
38131
38132 \begin_layout Standard
38133
38134 \size footnotesize
38135 Bitwise OR 
38136 \end_layout
38137
38138 \end_inset
38139 </cell>
38140 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
38141 \begin_inset Text
38142
38143 \begin_layout Standard
38144
38145 \size footnotesize
38146 IC_RESULT = IC_LEFT | IC_RIGHT;
38147 \end_layout
38148
38149 \end_inset
38150 </cell>
38151 </row>
38152 <row topline="true">
38153 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38154 \begin_inset Text
38155
38156 \begin_layout Standard
38157
38158 \size footnotesize
38159 BITWISEAND
38160 \end_layout
38161
38162 \end_inset
38163 </cell>
38164 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38165 \begin_inset Text
38166
38167 \begin_layout Standard
38168
38169 \size footnotesize
38170 IC_LEFT() IC_RIGHT() IC_RESULT()
38171 \end_layout
38172
38173 \end_inset
38174 </cell>
38175 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38176 \begin_inset Text
38177
38178 \begin_layout Standard
38179
38180 \size footnotesize
38181 Bitwise AND 
38182 \end_layout
38183
38184 \end_inset
38185 </cell>
38186 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
38187 \begin_inset Text
38188
38189 \begin_layout Standard
38190
38191 \size footnotesize
38192 IC_RESULT = IC_LEFT & IC_RIGHT;
38193 \end_layout
38194
38195 \end_inset
38196 </cell>
38197 </row>
38198 <row topline="true">
38199 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38200 \begin_inset Text
38201
38202 \begin_layout Standard
38203
38204 \size footnotesize
38205 LEFT_OP
38206 \end_layout
38207
38208 \end_inset
38209 </cell>
38210 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38211 \begin_inset Text
38212
38213 \begin_layout Standard
38214
38215 \size footnotesize
38216 IC_LEFT() IC_RIGHT() IC_RESULT()
38217 \end_layout
38218
38219 \end_inset
38220 </cell>
38221 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38222 \begin_inset Text
38223
38224 \begin_layout Standard
38225
38226 \size footnotesize
38227 Left shift 
38228 \end_layout
38229
38230 \end_inset
38231 </cell>
38232 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
38233 \begin_inset Text
38234
38235 \begin_layout Standard
38236
38237 \size footnotesize
38238 IC_RESULT = IC_LEFT << IC_RIGHT 
38239 \end_layout
38240
38241 \end_inset
38242 </cell>
38243 </row>
38244 <row topline="true">
38245 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38246 \begin_inset Text
38247
38248 \begin_layout Standard
38249
38250 \size footnotesize
38251 RIGHT_OP
38252 \end_layout
38253
38254 \end_inset
38255 </cell>
38256 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38257 \begin_inset Text
38258
38259 \begin_layout Standard
38260
38261 \size footnotesize
38262 IC_LEFT() IC_RIGHT() IC_RESULT()
38263 \end_layout
38264
38265 \end_inset
38266 </cell>
38267 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38268 \begin_inset Text
38269
38270 \begin_layout Standard
38271
38272 \size footnotesize
38273 Right shift
38274 \end_layout
38275
38276 \end_inset
38277 </cell>
38278 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
38279 \begin_inset Text
38280
38281 \begin_layout Standard
38282
38283 \size footnotesize
38284 IC_RESULT = IC_LEFT >> IC_RIGHT 
38285 \end_layout
38286
38287 \end_inset
38288 </cell>
38289 </row>
38290 <row topline="true">
38291 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38292 \begin_inset Text
38293
38294 \begin_layout Standard
38295
38296 \size footnotesize
38297 GET_VALUE_
38298 \newline
38299 AT_ ADDRESS
38300 \end_layout
38301
38302 \end_inset
38303 </cell>
38304 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38305 \begin_inset Text
38306
38307 \begin_layout Standard
38308
38309 \size footnotesize
38310 IC_LEFT() IC_RESULT()
38311 \end_layout
38312
38313 \end_inset
38314 </cell>
38315 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38316 \begin_inset Text
38317
38318 \begin_layout Standard
38319
38320 \size footnotesize
38321 Indirect fetch 
38322 \end_layout
38323
38324 \end_inset
38325 </cell>
38326 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
38327 \begin_inset Text
38328
38329 \begin_layout Standard
38330
38331 \size footnotesize
38332 IC_RESULT = (*IC_LEFT);
38333 \end_layout
38334
38335 \end_inset
38336 </cell>
38337 </row>
38338 <row topline="true">
38339 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38340 \begin_inset Text
38341
38342 \begin_layout Standard
38343
38344 \size footnotesize
38345 POINTER_SET
38346 \end_layout
38347
38348 \end_inset
38349 </cell>
38350 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38351 \begin_inset Text
38352
38353 \begin_layout Standard
38354
38355 \size footnotesize
38356 IC_RIGHT() IC_RESULT() 
38357 \end_layout
38358
38359 \end_inset
38360 </cell>
38361 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38362 \begin_inset Text
38363
38364 \begin_layout Standard
38365
38366 \size footnotesize
38367 Indirect set
38368 \end_layout
38369
38370 \end_inset
38371 </cell>
38372 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
38373 \begin_inset Text
38374
38375 \begin_layout Standard
38376
38377 \size footnotesize
38378 (*IC_RESULT) = IC_RIGHT;
38379 \end_layout
38380
38381 \end_inset
38382 </cell>
38383 </row>
38384 <row topline="true">
38385 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38386 \begin_inset Text
38387
38388 \begin_layout Standard
38389
38390 \size footnotesize
38391 '='
38392 \end_layout
38393
38394 \end_inset
38395 </cell>
38396 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38397 \begin_inset Text
38398
38399 \begin_layout Standard
38400
38401 \size footnotesize
38402 IC_RIGHT() IC_RESULT()
38403 \end_layout
38404
38405 \end_inset
38406 </cell>
38407 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38408 \begin_inset Text
38409
38410 \begin_layout Standard
38411
38412 \size footnotesize
38413 Assignment
38414 \end_layout
38415
38416 \end_inset
38417 </cell>
38418 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
38419 \begin_inset Text
38420
38421 \begin_layout Standard
38422
38423 \size footnotesize
38424 IC_RESULT = IC_RIGHT;
38425 \end_layout
38426
38427 \end_inset
38428 </cell>
38429 </row>
38430 <row topline="true">
38431 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38432 \begin_inset Text
38433
38434 \begin_layout Standard
38435
38436 \size footnotesize
38437 IFX
38438 \end_layout
38439
38440 \end_inset
38441 </cell>
38442 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38443 \begin_inset Text
38444
38445 \begin_layout Standard
38446
38447 \size footnotesize
38448 IC_COND IC_TRUE IC_LABEL
38449 \end_layout
38450
38451 \end_inset
38452 </cell>
38453 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38454 \begin_inset Text
38455
38456 \begin_layout Standard
38457
38458 \size footnotesize
38459 Conditional jump.
38460  If true label is present then jump to true label if condition is true else
38461  jump to false label if condition is false 
38462 \end_layout
38463
38464 \end_inset
38465 </cell>
38466 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
38467 \begin_inset Text
38468
38469 \begin_layout Standard
38470
38471 \size footnotesize
38472 if (IC_COND) goto IC_TRUE; 
38473 \newline
38474 \InsetSpace ~
38475 \InsetSpace ~
38476 Or 
38477 \newline
38478 If (!IC_COND) goto IC_FALSE;
38479 \end_layout
38480
38481 \end_inset
38482 </cell>
38483 </row>
38484 <row topline="true">
38485 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38486 \begin_inset Text
38487
38488 \begin_layout Standard
38489
38490 \size footnotesize
38491 ADDRESS_OF
38492 \end_layout
38493
38494 \end_inset
38495 </cell>
38496 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38497 \begin_inset Text
38498
38499 \begin_layout Standard
38500
38501 \size footnotesize
38502 IC_LEFT() IC_RESULT()
38503 \end_layout
38504
38505 \end_inset
38506 </cell>
38507 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38508 \begin_inset Text
38509
38510 \begin_layout Standard
38511
38512 \size footnotesize
38513 Address of 
38514 \end_layout
38515
38516 \end_inset
38517 </cell>
38518 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
38519 \begin_inset Text
38520
38521 \begin_layout Standard
38522
38523 \size footnotesize
38524 IC_RESULT = &IC_LEFT();
38525 \end_layout
38526
38527 \end_inset
38528 </cell>
38529 </row>
38530 <row topline="true">
38531 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38532 \begin_inset Text
38533
38534 \begin_layout Standard
38535
38536 \size footnotesize
38537 JUMPTABLE
38538 \end_layout
38539
38540 \end_inset
38541 </cell>
38542 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38543 \begin_inset Text
38544
38545 \begin_layout Standard
38546
38547 \size footnotesize
38548 IC_JTCOND IC_JTLABELS
38549 \end_layout
38550
38551 \end_inset
38552 </cell>
38553 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38554 \begin_inset Text
38555
38556 \begin_layout Standard
38557
38558 \size footnotesize
38559 Jump to list of labels depending on the value of JTCOND
38560 \end_layout
38561
38562 \end_inset
38563 </cell>
38564 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
38565 \begin_inset Text
38566
38567 \begin_layout Standard
38568
38569 \size footnotesize
38570 Switch statement
38571 \end_layout
38572
38573 \end_inset
38574 </cell>
38575 </row>
38576 <row topline="true">
38577 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38578 \begin_inset Text
38579
38580 \begin_layout Standard
38581
38582 \size footnotesize
38583 CAST
38584 \end_layout
38585
38586 \end_inset
38587 </cell>
38588 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38589 \begin_inset Text
38590
38591 \begin_layout Standard
38592
38593 \size footnotesize
38594 IC_RIGHT() IC_LEFT() IC_RESULT()
38595 \end_layout
38596
38597 \end_inset
38598 </cell>
38599 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38600 \begin_inset Text
38601
38602 \begin_layout Standard
38603
38604 \size footnotesize
38605 Cast types 
38606 \end_layout
38607
38608 \end_inset
38609 </cell>
38610 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
38611 \begin_inset Text
38612
38613 \begin_layout Standard
38614
38615 \size footnotesize
38616 IC_RESULT = (typeof IC_LEFT) IC_RIGHT;
38617 \end_layout
38618
38619 \end_inset
38620 </cell>
38621 </row>
38622 <row topline="true">
38623 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38624 \begin_inset Text
38625
38626 \begin_layout Standard
38627
38628 \size footnotesize
38629 SEND
38630 \end_layout
38631
38632 \end_inset
38633 </cell>
38634 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38635 \begin_inset Text
38636
38637 \begin_layout Standard
38638
38639 \size footnotesize
38640 IC_LEFT()
38641 \end_layout
38642
38643 \end_inset
38644 </cell>
38645 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38646 \begin_inset Text
38647
38648 \begin_layout Standard
38649
38650 \size footnotesize
38651 This is used for passing parameters in registers; 
38652 \newline
38653 move IC_LEFT to the next
38654  available parameter register.
38655 \end_layout
38656
38657 \end_inset
38658 </cell>
38659 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
38660 \begin_inset Text
38661
38662 \begin_layout Standard
38663
38664 \size footnotesize
38665 None
38666 \end_layout
38667
38668 \end_inset
38669 </cell>
38670 </row>
38671 <row topline="true">
38672 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38673 \begin_inset Text
38674
38675 \begin_layout Standard
38676
38677 \size footnotesize
38678 RECV
38679 \end_layout
38680
38681 \end_inset
38682 </cell>
38683 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38684 \begin_inset Text
38685
38686 \begin_layout Standard
38687
38688 \size footnotesize
38689 IC_RESULT()
38690 \end_layout
38691
38692 \end_inset
38693 </cell>
38694 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38695 \begin_inset Text
38696
38697 \begin_layout Standard
38698
38699 \size footnotesize
38700 This is used for receiving parameters passed in registers;
38701 \newline
38702 Move the values
38703  in the next parameter register to IC_RESULT 
38704 \end_layout
38705
38706 \end_inset
38707 </cell>
38708 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
38709 \begin_inset Text
38710
38711 \begin_layout Standard
38712
38713 \size footnotesize
38714 None
38715 \end_layout
38716
38717 \end_inset
38718 </cell>
38719 </row>
38720 <row topline="true" bottomline="true">
38721 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38722 \begin_inset Text
38723
38724 \begin_layout Standard
38725
38726 \shape slanted
38727 \size footnotesize
38728 (some more have been added)
38729 \end_layout
38730
38731 \end_inset
38732 </cell>
38733 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38734 \begin_inset Text
38735
38736 \begin_layout Standard
38737
38738 \end_layout
38739
38740 \end_inset
38741 </cell>
38742 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38743 \begin_inset Text
38744
38745 \begin_layout Standard
38746
38747 \end_layout
38748
38749 \end_inset
38750 </cell>
38751 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
38752 \begin_inset Text
38753
38754 \begin_layout Standard
38755
38756 \shape slanted
38757 \size footnotesize
38758 see f.e.
38759  
38760 \family typewriter
38761 gen51Code()
38762 \family default
38763  in 
38764 \family typewriter
38765 src/mcs51/gen.c
38766 \end_layout
38767
38768 \end_inset
38769 </cell>
38770 </row>
38771 </lyxtabular>
38772
38773 \end_inset
38774
38775
38776 \end_layout
38777
38778 \begin_layout Standard
38779 \begin_inset Note Note
38780 status collapsed
38781
38782 \begin_layout Standard
38783 In the original article Figure II was announced to be downloadable on 
38784 \shape italic
38785 Circuit Cellar
38786 \shape default
38787 's web site.
38788  ftp://ftp.circuitcellar.com/pub/Circuit_Cellar/2000/121/dutta.ZIP
38789 \end_layout
38790
38791 \end_inset
38792
38793
38794 \end_layout
38795
38796 \begin_layout Paragraph*
38797 ICode Example
38798 \begin_inset LatexCommand \index{iCode}
38799
38800 \end_inset
38801
38802
38803 \end_layout
38804
38805 \begin_layout Standard
38806 This section shows some details of iCode.
38807  The example C code does not do anything useful; it is used as an example
38808  to illustrate the intermediate code generated by the compiler.
38809 \end_layout
38810
38811 \begin_layout Verse
38812
38813 \family typewriter
38814 1.\InsetSpace ~
38815 xdata int * p;
38816 \newline
38817 2.\InsetSpace ~
38818 int gint;
38819 \newline
38820 3.\InsetSpace ~
38821 /* This function does nothing useful.
38822  It is used
38823 \newline
38824 4.\InsetSpace ~
38825 \InsetSpace ~
38826 \InsetSpace ~
38827 \InsetSpace ~
38828 for the purpose of explaining iCode */
38829 \newline
38830 5.\InsetSpace ~
38831 short function (data
38832  int *x)
38833 \newline
38834 6.\InsetSpace ~
38835 {
38836 \newline
38837 7.\InsetSpace ~
38838 \InsetSpace ~
38839 \InsetSpace ~
38840 short i=10; \InsetSpace ~
38841 \InsetSpace ~
38842 /* dead initialization eliminated */
38843 \newline
38844 8.\InsetSpace ~
38845 \InsetSpace ~
38846 \InsetSpace ~
38847 short sum=10;
38848  /* dead initialization eliminated */
38849 \newline
38850 9.\InsetSpace ~
38851 \InsetSpace ~
38852 \InsetSpace ~
38853 short mul;
38854 \newline
38855 10.\InsetSpace ~
38856 \InsetSpace ~
38857 int j ;
38858 \newline
38859 11.\InsetSpace ~
38860 \InsetSpace ~
38861 while (*x) *x++
38862  = *p++; 
38863 \newline
38864 12.\InsetSpace ~
38865 \InsetSpace ~
38866 \InsetSpace ~
38867 \InsetSpace ~
38868 sum = 0 ; 
38869 \newline
38870 13.\InsetSpace ~
38871 \InsetSpace ~
38872 mul = 0;
38873 \newline
38874 14.\InsetSpace ~
38875 \InsetSpace ~
38876 /* compiler detects i,j to be induction
38877  variables */
38878 \newline
38879 15.\InsetSpace ~
38880 \InsetSpace ~
38881 for (i = 0, j = 10 ; i < 10 ; i++, j
38882 \family default
38883 -
38884 \begin_inset ERT
38885 status collapsed
38886
38887 \begin_layout Standard
38888
38889
38890 \backslash
38891 /
38892 \end_layout
38893
38894 \end_inset
38895
38896 -
38897 \family typewriter
38898 ) {
38899 \newline
38900 16.\InsetSpace ~
38901 \InsetSpace ~
38902 \InsetSpace ~
38903 \InsetSpace ~
38904 sum += i;
38905 \newline
38906 17.\InsetSpace ~
38907 \InsetSpace ~
38908 \InsetSpace ~
38909 \InsetSpace ~
38910 mul += i * 3; \InsetSpace ~
38911 \InsetSpace ~
38912 /* this multiplication remains */
38913 \newline
38914 18.\InsetSpace ~
38915 \InsetSpace ~
38916 \InsetSpace ~
38917 \InsetSpace ~
38918 gint +=
38919  j * 3;\InsetSpace ~
38920 \InsetSpace ~
38921 /* this multiplication changed to addition */
38922 \newline
38923 19.\InsetSpace ~
38924 \InsetSpace ~
38925 }
38926 \newline
38927 20.\InsetSpace ~
38928 \InsetSpace ~
38929 return sum+mul;
38930 \newline
38931 21.\InsetSpace ~
38932 }
38933 \end_layout
38934
38935 \begin_layout Standard
38936 In addition to the operands each iCode contains information about the filename
38937  and line it corresponds to in the source file.
38938  The first field in the listing should be interpreted as follows:
38939 \newline
38940
38941 \shape italic
38942 \size footnotesize
38943 Filename(linenumber: iCode Execution sequence number : ICode hash table
38944  key : loop depth of the iCode).
38945 \shape default
38946 \size default
38947
38948 \newline
38949 Then follows the human readable form of the ICode operation.
38950  Each operand of this triplet form can be of three basic types a) compiler
38951  generated temporary b) user defined variable c) a constant value.
38952  Note that local variables and parameters are replaced by compiler generated
38953  temporaries.
38954  Live ranges
38955 \begin_inset LatexCommand \index{Live range analysis}
38956
38957 \end_inset
38958
38959  are computed only for temporaries (i.e.
38960  live ranges are not computed for global variables).
38961  Registers
38962 \begin_inset LatexCommand \index{Register allocation}
38963
38964 \end_inset
38965
38966  are allocated for temporaries only.
38967  Operands are formatted in the following manner:
38968 \newline
38969
38970 \shape italic
38971 \size footnotesize
38972 Operand Name [lr live-from : live-to ] { type information } [ registers
38973  allocated ].
38974 \shape default
38975 \size default
38976
38977 \newline
38978 As mentioned earlier the live ranges are computed in terms of the execution
38979  sequence number of the iCodes, for example 
38980 \newline
38981 the iTemp0 is live from (i.e.
38982  first defined in iCode with execution sequence number 3, and is last used
38983  in the iCode with sequence number 5).
38984  For induction variables such as iTemp21 the live range computation extends
38985  the lifetime from the start to the end of the loop.
38986 \newline
38987 The register allocator
38988  used the live range information to allocate registers, the same registers
38989  may be used for different temporaries if their live ranges do not overlap,
38990  for example r0 is allocated to both iTemp6 and to iTemp17 since their live
38991  ranges do not overlap.
38992  In addition the allocator also takes into consideration the type and usage
38993  of a temporary, for example itemp6 is a pointer to near space and is used
38994  as to fetch data from (i.e.
38995  used in GET_VALUE_AT_ADDRESS) so it is allocated a pointer register (r0).
38996  Some short lived temporaries are allocated to special registers which have
38997  meaning to the code generator e.g.
38998  iTemp13 is allocated to a pseudo register CC which tells the back end that
38999  the temporary is used only for a conditional jump the code generation makes
39000  use of this information to optimize a compare and jump ICode.
39001 \newline
39002 There are several
39003  loop optimizations
39004 \begin_inset LatexCommand \index{Loop optimization}
39005
39006 \end_inset
39007
39008  performed by the compiler.
39009  It can detect induction variables iTemp21(i) and iTemp23(j).
39010  Also note the compiler does selective strength reduction
39011 \begin_inset LatexCommand \index{Strength reduction}
39012
39013 \end_inset
39014
39015 , i.e.
39016  the multiplication of an induction variable in line 18 (gint = j * 3) is
39017  changed to addition, a new temporary iTemp17 is allocated and assigned
39018  a initial value, a constant 3 is then added for each iteration of the loop.
39019  The compiler does not change the multiplication
39020 \begin_inset LatexCommand \index{Multiplication}
39021
39022 \end_inset
39023
39024  in line 17 however since the processor does support an 8 * 8 bit multiplication.
39025 \newline
39026
39027 Note the dead code elimination
39028 \begin_inset LatexCommand \index{Dead-code elimination}
39029
39030 \end_inset
39031
39032  optimization eliminated the dead assignments in line 7 & 8 to I and sum
39033  respectively.
39034 \newline
39035
39036 \end_layout
39037
39038 \begin_layout Standard
39039
39040 \size footnotesize
39041 Sample.c (5:1:0:0) _entry($9) :
39042 \end_layout
39043
39044 \begin_layout Standard
39045
39046 \size footnotesize
39047 Sample.c(5:2:1:0) proc _function [lr0:0]{function short}
39048 \end_layout
39049
39050 \begin_layout Standard
39051
39052 \size footnotesize
39053 Sample.c(11:3:2:0) iTemp0 [lr3:5]{_near * int}[r2] = recv 
39054 \end_layout
39055
39056 \begin_layout Standard
39057
39058 \size footnotesize
39059 Sample.c(11:4:53:0) preHeaderLbl0($11) :
39060 \end_layout
39061
39062 \begin_layout Standard
39063
39064 \size footnotesize
39065 Sample.c(11:5:55:0) iTemp6 [lr5:16]{_near * int}[r0] := iTemp0 [lr3:5]{_near
39066  * int}[r2]
39067 \end_layout
39068
39069 \begin_layout Standard
39070
39071 \size footnotesize
39072 Sample.c(11:6:5:1) _whilecontinue_0($1) :
39073 \end_layout
39074
39075 \begin_layout Standard
39076
39077 \size footnotesize
39078 Sample.c(11:7:7:1) iTemp4 [lr7:8]{int}[r2 r3] = @[iTemp6 [lr5:16]{_near *
39079  int}[r0]]
39080 \end_layout
39081
39082 \begin_layout Standard
39083
39084 \size footnotesize
39085 Sample.c(11:8:8:1) if iTemp4 [lr7:8]{int}[r2 r3] == 0 goto _whilebreak_0($3)
39086 \end_layout
39087
39088 \begin_layout Standard
39089
39090 \size footnotesize
39091 Sample.c(11:9:14:1) iTemp7 [lr9:13]{_far * int}[DPTR] := _p [lr0:0]{_far
39092  * int}
39093 \end_layout
39094
39095 \begin_layout Standard
39096
39097 \size footnotesize
39098 Sample.c(11:10:15:1) _p [lr0:0]{_far * int} = _p [lr0:0]{_far * int} + 0x2
39099  {short}
39100 \end_layout
39101
39102 \begin_layout Standard
39103
39104 \size footnotesize
39105 Sample.c(11:13:18:1) iTemp10 [lr13:14]{int}[r2 r3] = @[iTemp7 [lr9:13]{_far
39106  * int}[DPTR]]
39107 \end_layout
39108
39109 \begin_layout Standard
39110
39111 \size footnotesize
39112 Sample.c(11:14:19:1) *(iTemp6 [lr5:16]{_near * int}[r0]) := iTemp10 [lr13:14]{int
39113 }[r2 r3]
39114 \end_layout
39115
39116 \begin_layout Standard
39117
39118 \size footnotesize
39119 Sample.c(11:15:12:1) iTemp6 [lr5:16]{_near * int}[r0] = iTemp6 [lr5:16]{_near
39120  * int}[r0] + 0x2 {short}
39121 \end_layout
39122
39123 \begin_layout Standard
39124
39125 \size footnotesize
39126 Sample.c(11:16:20:1) goto _whilecontinue_0($1)
39127 \end_layout
39128
39129 \begin_layout Standard
39130
39131 \size footnotesize
39132 Sample.c(11:17:21:0)_whilebreak_0($3) :
39133 \end_layout
39134
39135 \begin_layout Standard
39136
39137 \size footnotesize
39138 Sample.c(12:18:22:0) iTemp2 [lr18:40]{short}[r2] := 0x0 {short}
39139 \end_layout
39140
39141 \begin_layout Standard
39142
39143 \size footnotesize
39144 Sample.c(13:19:23:0) iTemp11 [lr19:40]{short}[r3] := 0x0 {short}
39145 \end_layout
39146
39147 \begin_layout Standard
39148
39149 \size footnotesize
39150 Sample.c(15:20:54:0)preHeaderLbl1($13) :
39151 \end_layout
39152
39153 \begin_layout Standard
39154
39155 \size footnotesize
39156 Sample.c(15:21:56:0) iTemp21 [lr21:38]{short}[r4] := 0x0 {short}
39157 \end_layout
39158
39159 \begin_layout Standard
39160
39161 \size footnotesize
39162 Sample.c(15:22:57:0) iTemp23 [lr22:38]{int}[r5 r6] := 0xa {int}
39163 \end_layout
39164
39165 \begin_layout Standard
39166
39167 \size footnotesize
39168 Sample.c(15:23:58:0) iTemp17 [lr23:38]{int}[r7 r0] := 0x1e {int}
39169 \end_layout
39170
39171 \begin_layout Standard
39172
39173 \size footnotesize
39174 Sample.c(15:24:26:1)_forcond_0($4) :
39175 \end_layout
39176
39177 \begin_layout Standard
39178
39179 \size footnotesize
39180 Sample.c(15:25:27:1) iTemp13 [lr25:26]{char}[CC] = iTemp21 [lr21:38]{short}[r4]
39181  < 0xa {short}
39182 \end_layout
39183
39184 \begin_layout Standard
39185
39186 \size footnotesize
39187 Sample.c(15:26:28:1) if iTemp13 [lr25:26]{char}[CC] == 0 goto _forbreak_0($7)
39188 \end_layout
39189
39190 \begin_layout Standard
39191
39192 \size footnotesize
39193 Sample.c(16:27:31:1) iTemp2 [lr18:40]{short}[r2] = iTemp2 [lr18:40]{short}[r2]
39194  + ITemp21 [lr21:38]{short}[r4]
39195 \end_layout
39196
39197 \begin_layout Standard
39198
39199 \size footnotesize
39200 Sample.c(17:29:33:1) iTemp15 [lr29:30]{short}[r1] = iTemp21 [lr21:38]{short}[r4]
39201  * 0x3 {short}
39202 \end_layout
39203
39204 \begin_layout Standard
39205
39206 \size footnotesize
39207 Sample.c(17:30:34:1) iTemp11 [lr19:40]{short}[r3] = iTemp11 [lr19:40]{short}[r3]
39208  + iTemp15 [lr29:30]{short}[r1]
39209 \end_layout
39210
39211 \begin_layout Standard
39212
39213 \size footnotesize
39214 Sample.c(18:32:36:1:1) iTemp17 [lr23:38]{int}[r7 r0]= iTemp17 [lr23:38]{int}[r7
39215  r0]- 0x3 {short}
39216 \end_layout
39217
39218 \begin_layout Standard
39219
39220 \size footnotesize
39221 Sample.c(18:33:37:1) _gint [lr0:0]{int} = _gint [lr0:0]{int} + iTemp17 [lr23:38]{
39222 int}[r7 r0]
39223 \end_layout
39224
39225 \begin_layout Standard
39226
39227 \size footnotesize
39228 Sample.c(15:36:42:1) iTemp21 [lr21:38]{short}[r4] = iTemp21 [lr21:38]{short}[r4]
39229  + 0x1 {short}
39230 \end_layout
39231
39232 \begin_layout Standard
39233
39234 \size footnotesize
39235 Sample.c(15:37:45:1) iTemp23 [lr22:38]{int}[r5 r6]= iTemp23 [lr22:38]{int}[r5
39236  r6]- 0x1 {short}
39237 \end_layout
39238
39239 \begin_layout Standard
39240
39241 \size footnotesize
39242 Sample.c(19:38:47:1) goto _forcond_0($4)
39243 \end_layout
39244
39245 \begin_layout Standard
39246
39247 \size footnotesize
39248 Sample.c(19:39:48:0)_forbreak_0($7) :
39249 \end_layout
39250
39251 \begin_layout Standard
39252
39253 \size footnotesize
39254 Sample.c(20:40:49:0) iTemp24 [lr40:41]{short}[DPTR] = iTemp2 [lr18:40]{short}[r2]
39255  + ITemp11 [lr19:40]{short}[r3]
39256 \end_layout
39257
39258 \begin_layout Standard
39259
39260 \size footnotesize
39261 Sample.c(20:41:50:0) ret iTemp24 [lr40:41]{short}
39262 \end_layout
39263
39264 \begin_layout Standard
39265
39266 \size footnotesize
39267 Sample.c(20:42:51:0)_return($8) :
39268 \end_layout
39269
39270 \begin_layout Standard
39271
39272 \size footnotesize
39273 Sample.c(20:43:52:0) eproc _function [lr0:0]{ ia0 re0 rm0}{function short}
39274 \size default
39275
39276 \newline
39277
39278 \newline
39279 Finally the code generated for this function:
39280 \newline
39281
39282 \end_layout
39283
39284 \begin_layout Standard
39285
39286 \size footnotesize
39287 .area DSEG (DATA)
39288 \end_layout
39289
39290 \begin_layout Standard
39291
39292 \size footnotesize
39293 _p::
39294 \end_layout
39295
39296 \begin_layout Standard
39297
39298 \size footnotesize
39299 \InsetSpace ~
39300 \InsetSpace ~
39301 .ds 2
39302 \end_layout
39303
39304 \begin_layout Standard
39305
39306 \size footnotesize
39307 _gint::
39308 \end_layout
39309
39310 \begin_layout Standard
39311
39312 \size footnotesize
39313 \InsetSpace ~
39314 \InsetSpace ~
39315 .ds 2
39316 \end_layout
39317
39318 \begin_layout Standard
39319
39320 \size footnotesize
39321 ; sample.c 5
39322 \end_layout
39323
39324 \begin_layout Standard
39325
39326 \size footnotesize
39327 ; ----------------------------------------------
39328 \end_layout
39329
39330 \begin_layout Standard
39331
39332 \size footnotesize
39333 ; function function
39334 \end_layout
39335
39336 \begin_layout Standard
39337
39338 \size footnotesize
39339 ; ----------------------------------------------
39340 \end_layout
39341
39342 \begin_layout Standard
39343
39344 \size footnotesize
39345 _function:
39346 \end_layout
39347
39348 \begin_layout Standard
39349
39350 \size footnotesize
39351 ; iTemp0 [lr3:5]{_near * int}[r2] = recv 
39352 \end_layout
39353
39354 \begin_layout Standard
39355
39356 \size footnotesize
39357 \InsetSpace ~
39358 \InsetSpace ~
39359 mov r2,dpl
39360 \end_layout
39361
39362 \begin_layout Standard
39363
39364 \size footnotesize
39365 ; iTemp6 [lr5:16]{_near * int}[r0] := iTemp0 [lr3:5]{_near * int}[r2]
39366 \end_layout
39367
39368 \begin_layout Standard
39369
39370 \size footnotesize
39371 \InsetSpace ~
39372 \InsetSpace ~
39373 mov ar0,r2
39374 \end_layout
39375
39376 \begin_layout Standard
39377
39378 \size footnotesize
39379 ;_whilecontinue_0($1) :
39380 \end_layout
39381
39382 \begin_layout Standard
39383
39384 \size footnotesize
39385 00101$:
39386 \end_layout
39387
39388 \begin_layout Standard
39389
39390 \size footnotesize
39391 ; iTemp4 [lr7:8]{int}[r2 r3] = @[iTemp6 [lr5:16]{_near * int}[r0]]
39392 \end_layout
39393
39394 \begin_layout Standard
39395
39396 \size footnotesize
39397 ; if iTemp4 [lr7:8]{int}[r2 r3] == 0 goto _whilebreak_0($3)
39398 \end_layout
39399
39400 \begin_layout Standard
39401
39402 \size footnotesize
39403 \InsetSpace ~
39404 \InsetSpace ~
39405 mov ar2,@r0
39406 \end_layout
39407
39408 \begin_layout Standard
39409
39410 \size footnotesize
39411 \InsetSpace ~
39412 \InsetSpace ~
39413 inc r0
39414 \end_layout
39415
39416 \begin_layout Standard
39417
39418 \size footnotesize
39419 \InsetSpace ~
39420 \InsetSpace ~
39421 mov ar3,@r0
39422 \end_layout
39423
39424 \begin_layout Standard
39425
39426 \size footnotesize
39427 \InsetSpace ~
39428 \InsetSpace ~
39429 dec r0
39430 \end_layout
39431
39432 \begin_layout Standard
39433
39434 \size footnotesize
39435 \InsetSpace ~
39436 \InsetSpace ~
39437 mov a,r2
39438 \end_layout
39439
39440 \begin_layout Standard
39441
39442 \size footnotesize
39443 \InsetSpace ~
39444 \InsetSpace ~
39445 orl a,r3
39446 \end_layout
39447
39448 \begin_layout Standard
39449
39450 \size footnotesize
39451 \InsetSpace ~
39452 \InsetSpace ~
39453 jz 00103$
39454 \end_layout
39455
39456 \begin_layout Standard
39457
39458 \size footnotesize
39459 00114$:
39460 \end_layout
39461
39462 \begin_layout Standard
39463
39464 \size footnotesize
39465 ; iTemp7 [lr9:13]{_far * int}[DPTR] := _p [lr0:0]{_far * int}
39466 \end_layout
39467
39468 \begin_layout Standard
39469
39470 \size footnotesize
39471 \InsetSpace ~
39472 \InsetSpace ~
39473 mov dpl,_p
39474 \end_layout
39475
39476 \begin_layout Standard
39477
39478 \size footnotesize
39479 \InsetSpace ~
39480 \InsetSpace ~
39481 mov dph,(_p + 1)
39482 \end_layout
39483
39484 \begin_layout Standard
39485
39486 \size footnotesize
39487 ; _p [lr0:0]{_far * int} = _p [lr0:0]{_far * int} + 0x2 {short}
39488 \end_layout
39489
39490 \begin_layout Standard
39491
39492 \size footnotesize
39493 \InsetSpace ~
39494 \InsetSpace ~
39495 mov a,#0x02
39496 \end_layout
39497
39498 \begin_layout Standard
39499
39500 \size footnotesize
39501 \InsetSpace ~
39502 \InsetSpace ~
39503 add a,_p
39504 \end_layout
39505
39506 \begin_layout Standard
39507
39508 \size footnotesize
39509 \InsetSpace ~
39510 \InsetSpace ~
39511 mov _p,a
39512 \end_layout
39513
39514 \begin_layout Standard
39515
39516 \size footnotesize
39517 \InsetSpace ~
39518 \InsetSpace ~
39519 clr a
39520 \end_layout
39521
39522 \begin_layout Standard
39523
39524 \size footnotesize
39525 \InsetSpace ~
39526 \InsetSpace ~
39527 addc a,(_p + 1)
39528 \end_layout
39529
39530 \begin_layout Standard
39531
39532 \size footnotesize
39533 \InsetSpace ~
39534 \InsetSpace ~
39535 mov (_p + 1),a
39536 \end_layout
39537
39538 \begin_layout Standard
39539
39540 \size footnotesize
39541 ; iTemp10 [lr13:14]{int}[r2 r3] = @[iTemp7 [lr9:13]{_far * int}[DPTR]]
39542 \end_layout
39543
39544 \begin_layout Standard
39545
39546 \size footnotesize
39547 \InsetSpace ~
39548 \InsetSpace ~
39549 movx a,@dptr
39550 \end_layout
39551
39552 \begin_layout Standard
39553
39554 \size footnotesize
39555 \InsetSpace ~
39556 \InsetSpace ~
39557 mov r2,a
39558 \end_layout
39559
39560 \begin_layout Standard
39561
39562 \size footnotesize
39563 \InsetSpace ~
39564 \InsetSpace ~
39565 inc dptr
39566 \end_layout
39567
39568 \begin_layout Standard
39569
39570 \size footnotesize
39571 \InsetSpace ~
39572 \InsetSpace ~
39573 movx a,@dptr
39574 \end_layout
39575
39576 \begin_layout Standard
39577
39578 \size footnotesize
39579 \InsetSpace ~
39580 \InsetSpace ~
39581 mov r3,a
39582 \end_layout
39583
39584 \begin_layout Standard
39585
39586 \size footnotesize
39587 ; *(iTemp6 [lr5:16]{_near * int}[r0]) := iTemp10 [lr13:14]{int}[r2 r3]
39588 \end_layout
39589
39590 \begin_layout Standard
39591
39592 \size footnotesize
39593 \InsetSpace ~
39594 \InsetSpace ~
39595 mov @r0,ar2
39596 \end_layout
39597
39598 \begin_layout Standard
39599
39600 \size footnotesize
39601 \InsetSpace ~
39602 \InsetSpace ~
39603 inc r0
39604 \end_layout
39605
39606 \begin_layout Standard
39607
39608 \size footnotesize
39609 \InsetSpace ~
39610 \InsetSpace ~
39611 mov @r0,ar3
39612 \end_layout
39613
39614 \begin_layout Standard
39615
39616 \size footnotesize
39617 ; iTemp6 [lr5:16]{_near * int}[r0] = 
39618 \end_layout
39619
39620 \begin_layout Standard
39621
39622 \size footnotesize
39623 ; iTemp6 [lr5:16]{_near * int}[r0] + 
39624 \end_layout
39625
39626 \begin_layout Standard
39627
39628 \size footnotesize
39629 ; 0x2 {short}
39630 \end_layout
39631
39632 \begin_layout Standard
39633
39634 \size footnotesize
39635 \InsetSpace ~
39636 \InsetSpace ~
39637 inc r0
39638 \end_layout
39639
39640 \begin_layout Standard
39641
39642 \size footnotesize
39643 ; goto _whilecontinue_0($1)
39644 \end_layout
39645
39646 \begin_layout Standard
39647
39648 \size footnotesize
39649 \InsetSpace ~
39650 \InsetSpace ~
39651 sjmp 00101$
39652 \end_layout
39653
39654 \begin_layout Standard
39655
39656 \size footnotesize
39657 ; _whilebreak_0($3) :
39658 \end_layout
39659
39660 \begin_layout Standard
39661
39662 \size footnotesize
39663 00103$:
39664 \end_layout
39665
39666 \begin_layout Standard
39667
39668 \size footnotesize
39669 ; iTemp2 [lr18:40]{short}[r2] := 0x0 {short}
39670 \end_layout
39671
39672 \begin_layout Standard
39673
39674 \size footnotesize
39675 \InsetSpace ~
39676 \InsetSpace ~
39677 mov r2,#0x00
39678 \end_layout
39679
39680 \begin_layout Standard
39681
39682 \size footnotesize
39683 ; iTemp11 [lr19:40]{short}[r3] := 0x0 {short}
39684 \end_layout
39685
39686 \begin_layout Standard
39687
39688 \size footnotesize
39689 \InsetSpace ~
39690 \InsetSpace ~
39691 mov r3,#0x00
39692 \end_layout
39693
39694 \begin_layout Standard
39695
39696 \size footnotesize
39697 ; iTemp21 [lr21:38]{short}[r4] := 0x0 {short}
39698 \end_layout
39699
39700 \begin_layout Standard
39701
39702 \size footnotesize
39703 \InsetSpace ~
39704 \InsetSpace ~
39705 mov r4,#0x00
39706 \end_layout
39707
39708 \begin_layout Standard
39709
39710 \size footnotesize
39711 ; iTemp23 [lr22:38]{int}[r5 r6] := 0xa {int}
39712 \end_layout
39713
39714 \begin_layout Standard
39715
39716 \size footnotesize
39717 \InsetSpace ~
39718 \InsetSpace ~
39719 mov r5,#0x0A
39720 \end_layout
39721
39722 \begin_layout Standard
39723
39724 \size footnotesize
39725 \InsetSpace ~
39726 \InsetSpace ~
39727 mov r6,#0x00
39728 \end_layout
39729
39730 \begin_layout Standard
39731
39732 \size footnotesize
39733 ; iTemp17 [lr23:38]{int}[r7 r0] := 0x1e {int}
39734 \end_layout
39735
39736 \begin_layout Standard
39737
39738 \size footnotesize
39739 \InsetSpace ~
39740 \InsetSpace ~
39741 mov r7,#0x1E
39742 \end_layout
39743
39744 \begin_layout Standard
39745
39746 \size footnotesize
39747 \InsetSpace ~
39748 \InsetSpace ~
39749 mov r0,#0x00
39750 \end_layout
39751
39752 \begin_layout Standard
39753
39754 \size footnotesize
39755 ; _forcond_0($4) :
39756 \end_layout
39757
39758 \begin_layout Standard
39759
39760 \size footnotesize
39761 00104$:
39762 \end_layout
39763
39764 \begin_layout Standard
39765
39766 \size footnotesize
39767 ; iTemp13 [lr25:26]{char}[CC] = iTemp21 [lr21:38]{short}[r4] < 0xa {short}
39768 \end_layout
39769
39770 \begin_layout Standard
39771
39772 \size footnotesize
39773 ; if iTemp13 [lr25:26]{char}[CC] == 0 goto _forbreak_0($7)
39774 \end_layout
39775
39776 \begin_layout Standard
39777
39778 \size footnotesize
39779 \InsetSpace ~
39780 \InsetSpace ~
39781 clr c
39782 \end_layout
39783
39784 \begin_layout Standard
39785
39786 \size footnotesize
39787 \InsetSpace ~
39788 \InsetSpace ~
39789 mov a,r4
39790 \end_layout
39791
39792 \begin_layout Standard
39793
39794 \size footnotesize
39795 \InsetSpace ~
39796 \InsetSpace ~
39797 xrl a,#0x80
39798 \end_layout
39799
39800 \begin_layout Standard
39801
39802 \size footnotesize
39803 \InsetSpace ~
39804 \InsetSpace ~
39805 subb a,#0x8a
39806 \end_layout
39807
39808 \begin_layout Standard
39809
39810 \size footnotesize
39811 \InsetSpace ~
39812 \InsetSpace ~
39813 jnc 00107$
39814 \end_layout
39815
39816 \begin_layout Standard
39817
39818 \size footnotesize
39819 00115$:
39820 \end_layout
39821
39822 \begin_layout Standard
39823
39824 \size footnotesize
39825 ; iTemp2 [lr18:40]{short}[r2] = iTemp2 [lr18:40]{short}[r2] + 
39826 \end_layout
39827
39828 \begin_layout Standard
39829
39830 \size footnotesize
39831 ; iTemp21 [lr21:38]{short}[r4]
39832 \end_layout
39833
39834 \begin_layout Standard
39835
39836 \size footnotesize
39837 \InsetSpace ~
39838 \InsetSpace ~
39839 mov a,r4
39840 \end_layout
39841
39842 \begin_layout Standard
39843
39844 \size footnotesize
39845 \InsetSpace ~
39846 \InsetSpace ~
39847 add a,r2
39848 \end_layout
39849
39850 \begin_layout Standard
39851
39852 \size footnotesize
39853 \InsetSpace ~
39854 \InsetSpace ~
39855 mov r2,a
39856 \end_layout
39857
39858 \begin_layout Standard
39859
39860 \size footnotesize
39861 ; iTemp15 [lr29:30]{short}[r1] = iTemp21 [lr21:38]{short}[r4] * 0x3 {short}
39862 \end_layout
39863
39864 \begin_layout Standard
39865
39866 \size footnotesize
39867 \InsetSpace ~
39868 \InsetSpace ~
39869 mov b,#0x03
39870 \end_layout
39871
39872 \begin_layout Standard
39873
39874 \size footnotesize
39875 \InsetSpace ~
39876 \InsetSpace ~
39877 mov a,r4
39878 \end_layout
39879
39880 \begin_layout Standard
39881
39882 \size footnotesize
39883 \InsetSpace ~
39884 \InsetSpace ~
39885 mul ab
39886 \end_layout
39887
39888 \begin_layout Standard
39889
39890 \size footnotesize
39891 \InsetSpace ~
39892 \InsetSpace ~
39893 mov r1,a
39894 \end_layout
39895
39896 \begin_layout Standard
39897
39898 \size footnotesize
39899 ; iTemp11 [lr19:40]{short}[r3] = iTemp11 [lr19:40]{short}[r3] + 
39900 \end_layout
39901
39902 \begin_layout Standard
39903
39904 \size footnotesize
39905 ; iTemp15 [lr29:30]{short}[r1]
39906 \end_layout
39907
39908 \begin_layout Standard
39909
39910 \size footnotesize
39911 \InsetSpace ~
39912 \InsetSpace ~
39913 add a,r3
39914 \end_layout
39915
39916 \begin_layout Standard
39917
39918 \size footnotesize
39919 \InsetSpace ~
39920 \InsetSpace ~
39921 mov r3,a
39922 \end_layout
39923
39924 \begin_layout Standard
39925
39926 \size footnotesize
39927 ; iTemp17 [lr23:38]{int}[r7 r0]= iTemp17 [lr23:38]{int}[r7 r0]- 0x3 {short}
39928 \end_layout
39929
39930 \begin_layout Standard
39931
39932 \size footnotesize
39933 \InsetSpace ~
39934 \InsetSpace ~
39935 mov a,r7
39936 \end_layout
39937
39938 \begin_layout Standard
39939
39940 \size footnotesize
39941 \InsetSpace ~
39942 \InsetSpace ~
39943 add a,#0xfd
39944 \end_layout
39945
39946 \begin_layout Standard
39947
39948 \size footnotesize
39949 \InsetSpace ~
39950 \InsetSpace ~
39951 mov r7,a
39952 \end_layout
39953
39954 \begin_layout Standard
39955
39956 \size footnotesize
39957 \InsetSpace ~
39958 \InsetSpace ~
39959 mov a,r0
39960 \end_layout
39961
39962 \begin_layout Standard
39963
39964 \size footnotesize
39965 \InsetSpace ~
39966 \InsetSpace ~
39967 addc a,#0xff
39968 \end_layout
39969
39970 \begin_layout Standard
39971
39972 \size footnotesize
39973 \InsetSpace ~
39974 \InsetSpace ~
39975 mov r0,a
39976 \end_layout
39977
39978 \begin_layout Standard
39979
39980 \size footnotesize
39981 ; _gint [lr0:0]{int} = _gint [lr0:0]{int} + iTemp17 [lr23:38]{int}[r7 r0]
39982 \end_layout
39983
39984 \begin_layout Standard
39985
39986 \size footnotesize
39987 \InsetSpace ~
39988 \InsetSpace ~
39989 mov a,r7
39990 \end_layout
39991
39992 \begin_layout Standard
39993
39994 \size footnotesize
39995 \InsetSpace ~
39996 \InsetSpace ~
39997 add a,_gint
39998 \end_layout
39999
40000 \begin_layout Standard
40001
40002 \size footnotesize
40003 \InsetSpace ~
40004 \InsetSpace ~
40005 mov _gint,a
40006 \end_layout
40007
40008 \begin_layout Standard
40009
40010 \size footnotesize
40011 \InsetSpace ~
40012 \InsetSpace ~
40013 mov a,r0
40014 \end_layout
40015
40016 \begin_layout Standard
40017
40018 \size footnotesize
40019 \InsetSpace ~
40020 \InsetSpace ~
40021 addc a,(_gint + 1)
40022 \end_layout
40023
40024 \begin_layout Standard
40025
40026 \size footnotesize
40027 \InsetSpace ~
40028 \InsetSpace ~
40029 mov (_gint + 1),a
40030 \end_layout
40031
40032 \begin_layout Standard
40033
40034 \size footnotesize
40035 ; iTemp21 [lr21:38]{short}[r4] = iTemp21 [lr21:38]{short}[r4] + 0x1 {short}
40036 \end_layout
40037
40038 \begin_layout Standard
40039
40040 \size footnotesize
40041 \InsetSpace ~
40042 \InsetSpace ~
40043 inc r4
40044 \end_layout
40045
40046 \begin_layout Standard
40047
40048 \size footnotesize
40049 ; iTemp23 [lr22:38]{int}[r5 r6]= iTemp23 [lr22:38]{int}[r5 r6]- 0x1 {short}
40050 \end_layout
40051
40052 \begin_layout Standard
40053
40054 \size footnotesize
40055 \InsetSpace ~
40056 \InsetSpace ~
40057 dec r5
40058 \end_layout
40059
40060 \begin_layout Standard
40061
40062 \size footnotesize
40063 \InsetSpace ~
40064 \InsetSpace ~
40065 cjne r5,#0xff,00104$
40066 \end_layout
40067
40068 \begin_layout Standard
40069
40070 \size footnotesize
40071 \InsetSpace ~
40072 \InsetSpace ~
40073 dec r6
40074 \end_layout
40075
40076 \begin_layout Standard
40077
40078 \size footnotesize
40079 ; goto _forcond_0($4)
40080 \end_layout
40081
40082 \begin_layout Standard
40083
40084 \size footnotesize
40085 \InsetSpace ~
40086 \InsetSpace ~
40087 sjmp 00104$
40088 \end_layout
40089
40090 \begin_layout Standard
40091
40092 \size footnotesize
40093 ; _forbreak_0($7) :
40094 \end_layout
40095
40096 \begin_layout Standard
40097
40098 \size footnotesize
40099 00107$:
40100 \end_layout
40101
40102 \begin_layout Standard
40103
40104 \size footnotesize
40105 ; ret iTemp24 [lr40:41]{short}
40106 \end_layout
40107
40108 \begin_layout Standard
40109
40110 \size footnotesize
40111 \InsetSpace ~
40112 \InsetSpace ~
40113 mov a,r3
40114 \end_layout
40115
40116 \begin_layout Standard
40117
40118 \size footnotesize
40119 \InsetSpace ~
40120 \InsetSpace ~
40121 add a,r2
40122 \end_layout
40123
40124 \begin_layout Standard
40125
40126 \size footnotesize
40127 \InsetSpace ~
40128 \InsetSpace ~
40129 mov dpl,a
40130 \end_layout
40131
40132 \begin_layout Standard
40133
40134 \size footnotesize
40135 ; _return($8) :
40136 \end_layout
40137
40138 \begin_layout Standard
40139
40140 \size footnotesize
40141 00108$:
40142 \end_layout
40143
40144 \begin_layout Standard
40145
40146 \size footnotesize
40147 \InsetSpace ~
40148 \InsetSpace ~
40149 ret
40150 \newline
40151
40152 \end_layout
40153
40154 \begin_layout Section
40155 A few words about basic block successors, predecessors and dominators
40156 \end_layout
40157
40158 \begin_layout Standard
40159 Successors are basic blocks
40160 \begin_inset LatexCommand \index{Basic blocks}
40161
40162 \end_inset
40163
40164  that might execute after this basic block.
40165 \newline
40166 Predecessors are basic blocks
40167  that might execute before reaching this basic block.
40168 \newline
40169 Dominators are basic
40170  blocks that WILL execute before reaching this basic block.
40171 \newline
40172
40173 \end_layout
40174
40175 \begin_layout Standard
40176 [basic block 1]
40177 \end_layout
40178
40179 \begin_layout Standard
40180 if (something)
40181 \end_layout
40182
40183 \begin_layout Standard
40184 \InsetSpace ~
40185 \InsetSpace ~
40186 \InsetSpace ~
40187 \InsetSpace ~
40188 [basic block 2]
40189 \end_layout
40190
40191 \begin_layout Standard
40192 else
40193 \end_layout
40194
40195 \begin_layout Standard
40196 \InsetSpace ~
40197 \InsetSpace ~
40198 \InsetSpace ~
40199 \InsetSpace ~
40200 [basic block 3]
40201 \end_layout
40202
40203 \begin_layout Standard
40204 [basic block 4]
40205 \newline
40206
40207 \end_layout
40208
40209 \begin_layout Standard
40210 a) succList of [BB2] = [BB4], of [BB3] = [BB4], of [BB1] = [BB2,BB3]
40211 \end_layout
40212
40213 \begin_layout Standard
40214 b) predList of [BB2] = [BB1], of [BB3] = [BB1], of [BB4] = [BB2,BB3]
40215 \end_layout
40216
40217 \begin_layout Standard
40218 c) domVect of [BB4] = BB1 ...
40219  here we are not sure if BB2 or BB3 was executed but we are SURE that BB1
40220  was executed.
40221 \end_layout
40222
40223 \begin_layout Chapter
40224 Acknowledgments
40225 \end_layout
40226
40227 \begin_layout Standard
40228 \begin_inset LatexCommand \url{http://sdcc.sourceforge.net#Who}
40229
40230 \end_inset
40231
40232
40233 \newline
40234
40235 \newline
40236
40237 \emph on
40238 Thanks to all the other volunteer developers who have helped with coding,
40239  testing, web-page creation, distribution sets, etc.
40240  You know who you are :-)
40241 \emph default
40242
40243 \newline
40244
40245 \newline
40246
40247 \emph on
40248 Thanks to Sourceforge 
40249 \begin_inset LatexCommand \url{http://www.sf.net}
40250
40251 \end_inset
40252
40253  which has hosted the project since 1999 and donates significant download
40254  bandwidth.
40255 \emph default
40256
40257 \newline
40258
40259 \newline
40260
40261 \emph on
40262 Also thanks to all SDCC Distributed Compile Farm members for donating CPU
40263  cycles and bandwidth for snapshot builds.
40264 \newline
40265
40266 \end_layout
40267
40268 \begin_layout Standard
40269 This document was initially written by Sandeep Dutta
40270 \end_layout
40271
40272 \begin_layout Standard
40273 All product names mentioned herein may be trademarks
40274 \begin_inset LatexCommand \index{Trademarks}
40275
40276 \end_inset
40277
40278  of their respective companies.
40279  
40280 \end_layout
40281
40282 \begin_layout Section*
40283 Alphabetical index
40284 \end_layout
40285
40286 \begin_layout Standard
40287 To avoid confusion, the installation and building options for SDCC itself
40288  (chapter 2) are not part of the index.
40289 \end_layout
40290
40291 \begin_layout Standard
40292 \begin_inset LatexCommand \printindex{}
40293
40294 \end_inset
40295
40296
40297 \end_layout
40298
40299 \end_body
40300 \end_document