* .version, doc/sdccman.lyx: bumped version to 2.7.4 to indicate the full
[fw/sdcc] / doc / sdccman.lyx
1 #LyX 1.4.5 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.4
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 Standard
3975 Universal (ppc and i386) binaries can be produced on Mac OS X 10.4.x with
3976  Xcode.
3977  Run 'configure' with:
3978 \end_layout
3979
3980 \begin_layout LyX-Code
3981 ./configure 
3982 \backslash
3983
3984 \end_layout
3985
3986 \begin_layout LyX-Code
3987 LDFLAGS="-Wl,-syslibroot,/Developer/SDKs/MacOSX10.4u.sdk -arch i386 -arch
3988  ppc" 
3989 \backslash
3990
3991 \end_layout
3992
3993 \begin_layout LyX-Code
3994 CXXFLAGS = "-O2 -isysroot /Developer/SDKs/MacOSX10.4u.sdk -arch i386 -arch
3995  ppc" 
3996 \backslash
3997
3998 \end_layout
3999
4000 \begin_layout LyX-Code
4001 CFLAGS = "-O2 -isysroot /Developer/SDKs/MacOSX10.4u.sdk -arch i386 -arch ppc"
4002 \end_layout
4003
4004 \begin_layout Subsection
4005 Cross compiling SDCC on Linux for Windows
4006 \end_layout
4007
4008 \begin_layout Standard
4009 With the Mingw32 gcc cross compiler it's easy to compile SDCC for Win32.
4010  See section 'Configure Options'.
4011 \end_layout
4012
4013 \begin_layout Subsection
4014 Building SDCC using Cygwin and Mingw32
4015 \end_layout
4016
4017 \begin_layout Standard
4018 For building and installing a Cygwin executable follow the instructions
4019  for Linux.
4020 \newline
4021
4022 \newline
4023 On Cygwin a 
4024 \begin_inset Quotes sld
4025 \end_inset
4026
4027 native
4028 \begin_inset Quotes srd
4029 \end_inset
4030
4031  Win32-binary can be built, which will not need the Cygwin-DLL.
4032  For the necessary 'configure' options see section 'configure options' or
4033  the script 'sdcc/support/scripts/sdcc_cygwin_mingw32'.
4034 \newline
4035
4036 \newline
4037 In order to install
4038  Cygwin on Windows download setup.exe from 
4039 \begin_inset LatexCommand \url[www.cygwin.com]{http://www.cygwin.com/}
4040
4041 \end_inset
4042
4043 .
4044  Run it, set the 
4045 \begin_inset Quotes sld
4046 \end_inset
4047
4048 default text file type
4049 \begin_inset Quotes srd
4050 \end_inset
4051
4052  to 
4053 \begin_inset Quotes sld
4054 \end_inset
4055
4056 unix
4057 \begin_inset Quotes srd
4058 \end_inset
4059
4060  and download/install at least the following packages.
4061  Some packages are selected by default, others will be automatically selected
4062  because of dependencies with the manually selected packages.
4063  Never deselect these packages!
4064 \end_layout
4065
4066 \begin_layout Itemize
4067 flex
4068 \end_layout
4069
4070 \begin_layout Itemize
4071 bison
4072 \end_layout
4073
4074 \begin_layout Itemize
4075 gcc ; version 3.x is fine, no need to use the old 2.9x
4076 \end_layout
4077
4078 \begin_layout Itemize
4079 binutils ; selected with gcc
4080 \end_layout
4081
4082 \begin_layout Itemize
4083 make
4084 \end_layout
4085
4086 \begin_layout Itemize
4087 rxvt ; a nice console, which makes life much easier under windoze (see below)
4088 \end_layout
4089
4090 \begin_layout Itemize
4091 man ; not really needed for building SDCC, but you'll miss it sooner or
4092  later
4093 \end_layout
4094
4095 \begin_layout Itemize
4096 less ; not really needed for building SDCC, but you'll miss it sooner or
4097  later
4098 \end_layout
4099
4100 \begin_layout Itemize
4101 svn ; only if you use Subversion access
4102 \end_layout
4103
4104 \begin_layout Standard
4105 If you want to develop something you'll need:
4106 \end_layout
4107
4108 \begin_layout Itemize
4109 python ; for the regression tests
4110 \end_layout
4111
4112 \begin_layout Itemize
4113 gdb ; the gnu debugger, together with the nice GUI 
4114 \begin_inset Quotes sld
4115 \end_inset
4116
4117 insight
4118 \begin_inset Quotes srd
4119 \end_inset
4120
4121
4122 \end_layout
4123
4124 \begin_layout Itemize
4125 openssh ; to access the CF or commit changes
4126 \end_layout
4127
4128 \begin_layout Itemize
4129 autoconf and autoconf-devel ; if you want to fight with 'configure', don't
4130  use autoconf-stable!
4131 \end_layout
4132
4133 \begin_layout Standard
4134 rxvt is a nice console with history.
4135  Replace in your cygwin.bat the line
4136 \end_layout
4137
4138 \begin_layout LyX-Code
4139 bash -
4140 \begin_inset ERT
4141 status collapsed
4142
4143 \begin_layout Standard
4144
4145
4146 \backslash
4147 /
4148 \end_layout
4149
4150 \end_inset
4151
4152 -login -i 
4153 \end_layout
4154
4155 \begin_layout Standard
4156 with (one line):
4157 \end_layout
4158
4159 \begin_layout LyX-Code
4160 rxvt -sl 1000 -fn "Lucida Console-12" -sr -cr red
4161 \end_layout
4162
4163 \begin_layout LyX-Code
4164      -bg black -fg white -geometry 100x65 -e bash -
4165 \begin_inset ERT
4166 status collapsed
4167
4168 \begin_layout Standard
4169
4170
4171 \backslash
4172 /
4173 \end_layout
4174
4175 \end_inset
4176
4177 -login
4178 \end_layout
4179
4180 \begin_layout Standard
4181 Text selected with the mouse is automatically copied to the clipboard, pasting
4182  works with shift-insert.
4183 \newline
4184
4185 \newline
4186 The other good tip is to make sure you have no //c/-styl
4187 e paths anywhere, use /cygdrive/c/ instead.
4188  Using // invokes a network lookup which is very slow.
4189  If you think 
4190 \begin_inset Quotes sld
4191 \end_inset
4192
4193 cygdrive
4194 \begin_inset Quotes srd
4195 \end_inset
4196
4197  is too long, you can change it with e.g.
4198 \end_layout
4199
4200 \begin_layout LyX-Code
4201 mount -s -u -c /mnt
4202 \end_layout
4203
4204 \begin_layout Standard
4205 SDCC sources use the unix line ending LF.
4206  Life is much easier, if you store the source tree on a drive which is mounted
4207  in binary mode.
4208  And use an editor which can handle LF-only line endings.
4209  Make sure not to commit files with windows line endings.
4210  The tabulator spacing
4211 \begin_inset LatexCommand \index{tabulator spacing (8 columns)}
4212
4213 \end_inset
4214
4215  used in the project is 8.
4216  Although a tabulator spacing of 8 is a sensible choice for programmers
4217  (it's a power of 2 and allows to display 8/16 bit signed variables without
4218  loosing columns) the plan is to move towards using only spaces in the source.
4219 \end_layout
4220
4221 \begin_layout Subsection
4222 Building SDCC Using Microsoft Visual C++ 6.0/NET (MSVC)
4223 \end_layout
4224
4225 \begin_layout Standard
4226
4227 \series medium
4228 Download the source package
4229 \series default
4230  either from the SDCC Subversion repository or from the 
4231 \begin_inset LatexCommand \url[snapshot builds]{http://sdcc.sourceforge.net/snap.php}
4232
4233 \end_inset
4234
4235
4236 \series medium
4237 , it will be named something like sdcc
4238 \series default
4239 -src
4240 \series medium
4241 -yyyymmdd-rrrr.tar.bz2.
4242
4243 \series default
4244  SDCC is distributed with all the projects, workspaces, and files you need
4245  to build it using Visual C++ 6.0/NET (except for SDCDB and ucSim).
4246  The workspace name is 'sdcc.dsw'.
4247  Please note that as it is now, all the executables are created in a folder
4248  called sdcc
4249 \backslash
4250 bin_vc.
4251  Once built you need to copy the executables from sdcc
4252 \backslash
4253 bin_vc to sdcc
4254 \backslash
4255 bin before running SDCC.
4256  
4257 \newline
4258
4259 \newline
4260 WARNING: Visual studio is very picky with line terminations; it expects
4261  the 0x0d, 0x0a DOS style line endings, not the 0x0a Unix style line endings.
4262  When using the Subversion repository it's easiest to configure the svn
4263  client to convert automatically for you.
4264  If however you are getting a message such as "This makefile was not generated
4265  by Developer Studio etc.
4266  etc.
4267 \begin_inset Quotes srd
4268 \end_inset
4269
4270  when opening the sdcc.dsw workspace or any of the *.dsp projects, then you
4271  need to convert the Unix style line endings to DOS style line endings.
4272  To do so you can use the 
4273 \begin_inset Quotes sld
4274 \end_inset
4275
4276 unix2dos
4277 \begin_inset Quotes srd
4278 \end_inset
4279
4280  utility freely available on the internet.
4281  Doug Hawkins reported in the sdcc-user list that this works:
4282 \newline
4283
4284 \newline
4285 C:
4286 \backslash
4287 Programming
4288 \backslash
4289 SDCC> unix2dos sdcc.dsw
4290 \newline
4291 C:
4292 \backslash
4293 Programming
4294 \backslash
4295 SDCC> for /R %I in (*.dsp) do @unix2dos "%I"
4296 \newline
4297
4298 \newline
4299 In order to build SDCC with MSVC
4300  you need win32 executables of bison.exe, flex.exe, and gawk.exe.
4301  One good place to get them is 
4302 \begin_inset LatexCommand \url[here]{http://unxutils.sourceforge.net}
4303
4304 \end_inset
4305
4306
4307 \newline
4308
4309 \newline
4310 Download the file UnxUtils
4311 \begin_inset LatexCommand \index{UnxUtils}
4312
4313 \end_inset
4314
4315 .zip.
4316  Now you have to install the utilities and setup MSVC so it can locate the
4317  required programs.
4318  Here there are two alternatives (choose one!):
4319 \end_layout
4320
4321 \begin_layout Enumerate
4322 The easy way:
4323 \newline
4324
4325 \newline
4326 a) Extract UnxUtils.zip to your C:
4327 \backslash
4328  hard disk PRESERVING the original paths, otherwise bison won't work.
4329  (If you are using WinZip make certain that 'Use folder names' is selected)
4330 \newline
4331
4332 \newline
4333 b)
4334  In the Visual C++ IDE click Tools, Options, select the Directory tab, in
4335  'Show directories for:' select 'Executable files', and in the directories
4336  window add a new path: 'C:
4337 \backslash
4338 user
4339 \backslash
4340 local
4341 \backslash
4342 wbin', click ok.
4343 \newline
4344
4345 \newline
4346 (As a side effect, you get a bunch of Unix utilities that
4347  could be useful, such as diff and patch.)
4348 \end_layout
4349
4350 \begin_layout Enumerate
4351 A more compact way:
4352 \newline
4353
4354 \newline
4355 This one avoids extracting a bunch of files you may not
4356  use, but requires some extra work:
4357 \newline
4358
4359 \newline
4360 a) Create a directory were to put the
4361  tools needed, or use a directory already present.
4362  Say for example 'C:
4363 \backslash
4364 util'.
4365 \newline
4366
4367 \newline
4368 b) Extract 'bison.exe', 'bison.hairy', 'bison.simple', 'flex.exe', and
4369  gawk.exe to such directory WITHOUT preserving the original paths.
4370  (If you are using WinZip make certain that 'Use folder names' is not selected)
4371 \newline
4372
4373 \newline
4374 c
4375 ) Rename bison.exe to '_bison.exe'.
4376 \newline
4377
4378 \newline
4379 d) Create a batch file 'bison.bat' in 'C:
4380 \backslash
4381 util
4382 \backslash
4383 ' and add these lines: 
4384 \newline
4385 \InsetSpace ~
4386 \InsetSpace ~
4387 set BISON_SIMPLE=C:
4388 \backslash
4389 util
4390 \backslash
4391 bison.simple 
4392 \newline
4393 \InsetSpace ~
4394 \InsetSpace ~
4395 set BISON_HAIRY=C:
4396 \backslash
4397 util
4398 \backslash
4399 bison.hairy
4400 \newline
4401 \InsetSpace ~
4402 \InsetSpace ~
4403 _bison %1 %2 %3 %4 %5 %6 %7 %8 %9
4404 \newline
4405
4406 \newline
4407 Steps 'c' and 'd' are needed
4408  because bison requires by default that the files 'bison.simple' and 'bison.hairy'
4409  reside in some weird Unix directory, '/usr/local/share/' I think.
4410  So it is necessary to tell bison where those files are located if they
4411  are not in such directory.
4412  That is the function of the environment variables BISON_SIMPLE and BISON_HAIRY.
4413 \newline
4414
4415 \newline
4416 e
4417 ) In the Visual C++ IDE click Tools, Options, select the Directory tab,
4418  in 'Show directories for:' select 'Executable files', and in the directories
4419  window add a new path: 'c:
4420 \backslash
4421 util', click ok.
4422  Note that you can use any other path instead of 'c:
4423 \backslash
4424 util', even the path where the Visual C++ tools are, probably: 'C:
4425 \backslash
4426 Program Files
4427 \backslash
4428 Microsoft Visual Studio
4429 \backslash
4430 Common
4431 \backslash
4432 Tools'.
4433  So you don't have to execute step 'e' :)
4434 \end_layout
4435
4436 \begin_layout Standard
4437 That is it.
4438  Open 'sdcc.dsw' in Visual Studio, click 'build all', when it finishes copy
4439  the executables from sdcc
4440 \backslash
4441 bin_vc to sdcc
4442 \backslash
4443 bin, and you can compile using SDCC.
4444 \end_layout
4445
4446 \begin_layout Subsection
4447 Building SDCC Using Borland
4448 \end_layout
4449
4450 \begin_layout Enumerate
4451 From the sdcc directory, run the command "make -f Makefile.bcc".
4452  This should regenerate all the .exe files in the bin directory except for
4453  SDCDB and ucSim.
4454 \end_layout
4455
4456 \begin_layout Enumerate
4457 If you modify any source files and need to rebuild, be aware that the dependenci
4458 es may not be correctly calculated.
4459  The safest option is to delete all .obj files and run the build again.
4460  From a Cygwin BASH prompt, this can easily be done with the command (be
4461  sure you are in the sdcc directory):
4462 \newline
4463
4464 \newline
4465
4466 \family sans
4467 \series bold
4468 find .
4469  
4470 \backslash
4471 ( -name '*.obj' -o -name '*.lib' -o -name '*.rul' 
4472 \backslash
4473 ) -print -exec rm {} 
4474 \backslash
4475 ;
4476 \family default
4477 \series default
4478
4479 \newline
4480
4481 \newline
4482 or on Windows NT/2000/XP from the command prompt with the command:
4483 \newline
4484
4485 \family sans
4486 \series bold
4487
4488 \newline
4489 del /s *.obj *.lib *.rul
4490 \family default
4491 \series default
4492  from the sdcc directory.
4493 \end_layout
4494
4495 \begin_layout Subsection
4496 Windows Install Using a ZIP Package
4497 \end_layout
4498
4499 \begin_layout Enumerate
4500 Download the binary zip package from 
4501 \begin_inset LatexCommand \url{http://sdcc.sf.net/snap.php}
4502
4503 \end_inset
4504
4505  and unpack it using your favorite unpacking tool (gunzip, WinZip, etc).
4506  This should unpack to a group of sub-directories.
4507  An example directory structure after unpacking the mingw32 package is:
4508  c:
4509 \backslash
4510 sdcc
4511 \backslash
4512 bin for the executables, c:
4513 \backslash
4514 sdcc
4515 \backslash
4516 include and c:
4517 \backslash
4518 sdcc
4519 \backslash
4520 lib for the include and libraries.
4521 \end_layout
4522
4523 \begin_layout Enumerate
4524 Adjust your environment variable PATH to include the location of the bin
4525  directory or start sdcc using the full path.
4526 \end_layout
4527
4528 \begin_layout Subsection
4529 Windows Install Using the Setup Program
4530 \begin_inset LatexCommand \label{sub:Windows-Install}
4531
4532 \end_inset
4533
4534
4535 \end_layout
4536
4537 \begin_layout Standard
4538 Download the setup program 
4539 \emph on
4540 sdcc-x.y.z-setup.exe
4541 \emph default
4542  for an official release from 
4543 \newline
4544
4545 \begin_inset LatexCommand \url{http://sf.net/project/showfiles.php?group_id=599}
4546
4547 \end_inset
4548
4549  or a setup program for one of the snapshots 
4550 \emph on
4551 sdcc-yyyymmdd-xxxx-setup.exe
4552 \emph default
4553  from 
4554 \begin_inset LatexCommand \url{http://sdcc.sf.net/snap.php}
4555
4556 \end_inset
4557
4558  and execute it.
4559  A windows typical installer will guide you through the installation process.
4560 \end_layout
4561
4562 \begin_layout Subsection
4563 VPATH
4564 \begin_inset LatexCommand \index{VPATH}
4565
4566 \end_inset
4567
4568  feature
4569 \end_layout
4570
4571 \begin_layout Standard
4572 SDCC supports the VPATH feature provided by configure and make.
4573  It allows to separate the source and build trees.
4574  Here's an example:
4575 \end_layout
4576
4577 \begin_layout Standard
4578
4579 \family typewriter
4580 cd ~\InsetSpace ~
4581 \InsetSpace ~
4582 \InsetSpace ~
4583 \InsetSpace ~
4584 \InsetSpace ~
4585 \InsetSpace ~
4586 \InsetSpace ~
4587 \InsetSpace ~
4588 \InsetSpace ~
4589 \InsetSpace ~
4590 \InsetSpace ~
4591 \InsetSpace ~
4592 \InsetSpace ~
4593 \InsetSpace ~
4594 \InsetSpace ~
4595 \InsetSpace ~
4596 \InsetSpace ~
4597 \InsetSpace ~
4598 \InsetSpace ~
4599 \InsetSpace ~
4600 \InsetSpace ~
4601 # cd $HOME
4602 \end_layout
4603
4604 \begin_layout Standard
4605
4606 \family typewriter
4607 tar -xzf sdcc.src.tar.gz\InsetSpace ~
4608 # extract source to directory sdcc
4609 \end_layout
4610
4611 \begin_layout Standard
4612
4613 \family typewriter
4614 mkdir sdcc.build\InsetSpace ~
4615 \InsetSpace ~
4616 \InsetSpace ~
4617 \InsetSpace ~
4618 \InsetSpace ~
4619 \InsetSpace ~
4620 \InsetSpace ~
4621 \InsetSpace ~
4622 \InsetSpace ~
4623 # put output in sdcc.build
4624 \end_layout
4625
4626 \begin_layout Standard
4627
4628 \family typewriter
4629 cd sdcc.build
4630 \end_layout
4631
4632 \begin_layout Standard
4633
4634 \family typewriter
4635 ../sdcc/configure\InsetSpace ~
4636 \InsetSpace ~
4637 \InsetSpace ~
4638 \InsetSpace ~
4639 \InsetSpace ~
4640 \InsetSpace ~
4641 \InsetSpace ~
4642 \InsetSpace ~
4643 # configure is doing all the magic!
4644 \end_layout
4645
4646 \begin_layout Standard
4647
4648 \family typewriter
4649 make
4650 \end_layout
4651
4652 \begin_layout Standard
4653 \noindent
4654 That's it! 
4655 \series bold
4656 configure
4657 \series default
4658  will create the directory tree will all the necessary Makefiles in ~/sdcc.build.
4659  It automagically computes the variables srcdir, top_srcdir and top_buildir
4660  for each directory.
4661  After running 
4662 \series bold
4663 make
4664 \series default
4665  the generated files will be in ~/sdcc.build, while the source files stay
4666  in ~/sdcc.
4667 \newline
4668 This is not only usefull for building different binaries, e.g.
4669  when cross compiling.
4670  It also gives you a much better overview in the source tree when all the
4671  generated files are not scattered between the source files.
4672  And the best thing is: if you want to change a file you can leave the original
4673  file untouched in the source directory.
4674  Simply copy it to the build directory, edit it, enter `make clean', `rm
4675  Makefile.dep' and `make'.
4676  
4677 \series bold
4678 make
4679 \series default
4680  will do the rest for you!
4681 \end_layout
4682
4683 \begin_layout Section
4684 Building the Documentation
4685 \end_layout
4686
4687 \begin_layout Standard
4688 Add -
4689 \begin_inset ERT
4690 status collapsed
4691
4692 \begin_layout Standard
4693
4694
4695 \backslash
4696 /
4697 \end_layout
4698
4699 \end_inset
4700
4701 -enable-doc to the configure arguments to build the documentation together
4702  with all the other stuff.
4703  You will need several tools (LyX, LaTeX, LaTeX2HTML, pdflatex, dvipdf,
4704  dvips and makeindex) to get the job done.
4705  Another possibility is to change to the doc directory and to type 
4706 \family sans
4707 \series bold
4708
4709 \begin_inset Quotes srd
4710 \end_inset
4711
4712 make
4713 \begin_inset Quotes srd
4714 \end_inset
4715
4716
4717 \family default
4718 \series default
4719  there.
4720  You're invited to make changes and additions to this manual (sdcc/doc/sdccman.ly
4721 x).
4722  Using LyX 
4723 \begin_inset LatexCommand \url{http://www.lyx.org}
4724
4725 \end_inset
4726
4727  as editor is straightforward.
4728  Prebuilt documentation in html and pdf format is available from 
4729 \begin_inset LatexCommand \url{http://sdcc.sf.net/snap.php}
4730
4731 \end_inset
4732
4733 .
4734 \end_layout
4735
4736 \begin_layout Section
4737 Reading the Documentation
4738 \begin_inset LatexCommand \index{Documentation}
4739
4740 \end_inset
4741
4742
4743 \end_layout
4744
4745 \begin_layout Standard
4746 Currently reading the document in pdf format is recommended, as for unknown
4747  reason the hyperlinks are working there whereas in the html version they
4748  are not
4749 \begin_inset Foot
4750 status open
4751
4752 \begin_layout Standard
4753 If you should know why please drop us a note
4754 \end_layout
4755
4756 \end_inset
4757
4758 .
4759  
4760 \newline
4761 You'll find the pdf version
4762 \begin_inset LatexCommand \index{PDF version of this document}
4763
4764 \end_inset
4765
4766  at 
4767 \begin_inset LatexCommand \url{http://sdcc.sf.net/doc/sdccman.pdf}
4768
4769 \end_inset
4770
4771 .
4772  
4773 \newline
4774 A html version
4775 \begin_inset LatexCommand \index{HTML version of this document}
4776
4777 \end_inset
4778
4779  should be online at 
4780 \begin_inset LatexCommand \url{http://sdcc.sf.net/doc/sdccman.html/index.html}
4781
4782 \end_inset
4783
4784 .
4785 \newline
4786 This documentation is in some aspects different from a commercial documentation:
4787  
4788 \end_layout
4789
4790 \begin_layout Itemize
4791 It tries to document SDCC for several processor architectures in one document
4792  (commercially these probably would be separate documents/products).
4793  This document
4794 \begin_inset LatexCommand \index{Status of documentation}
4795
4796 \end_inset
4797
4798  currently matches SDCC for mcs51 and DS390 best and does give too few informati
4799 on about f.e.
4800  Z80, PIC14, PIC16 and HC08.
4801 \end_layout
4802
4803 \begin_layout Itemize
4804 There are many references pointing away from this documentation.
4805  Don't let this distract you.
4806  If there f.e.
4807  was a reference like 
4808 \begin_inset LatexCommand \url{http://www.opencores.org}
4809
4810 \end_inset
4811
4812  together with a statement 
4813 \begin_inset Quotes sld
4814 \end_inset
4815
4816 some processors which are targetted by SDCC can be implemented in a 
4817 \emph on
4818 f
4819 \emph default
4820 ield 
4821 \emph on
4822 p
4823 \emph default
4824 rogrammable 
4825 \emph on
4826 g
4827 \emph default
4828 ate 
4829 \emph on
4830 a
4831 \emph default
4832 rray
4833 \begin_inset LatexCommand \index{FPGA (field programmable gate array)}
4834
4835 \end_inset
4836
4837
4838 \begin_inset Quotes srd
4839 \end_inset
4840
4841  or 
4842 \begin_inset LatexCommand \url{http://sf.net/projects/fpgac}
4843
4844 \end_inset
4845
4846
4847 \begin_inset LatexCommand \index{FpgaC ((subset of) C to FPGA compiler)}
4848
4849 \end_inset
4850
4851  
4852 \begin_inset Quotes sld
4853 \end_inset
4854
4855 have you ever heard of an open source compiler that compiles a subset of
4856  C for an FPGA?
4857 \begin_inset Quotes srd
4858 \end_inset
4859
4860  we expect you to have a quick look there and come back.
4861  If you read this you are on the right track.
4862 \end_layout
4863
4864 \begin_layout Itemize
4865 Some sections attribute more space to problems, restrictions and warnings
4866  than to the solution.
4867 \end_layout
4868
4869 \begin_layout Itemize
4870 The installation section and the section about the debugger is intimidating.
4871 \end_layout
4872
4873 \begin_layout Itemize
4874 There are still lots of typos and there are more different writing styles
4875  than pictures.
4876 \end_layout
4877
4878 \begin_layout Section
4879 Testing the SDCC Compiler
4880 \begin_inset LatexCommand \label{sec:Testing-the-SDCC}
4881
4882 \end_inset
4883
4884
4885 \end_layout
4886
4887 \begin_layout Standard
4888 The first thing you should do after installing your SDCC compiler is to
4889  see if it runs.
4890  Type 
4891 \family sans
4892 \series bold
4893 "sdcc -
4894 \begin_inset ERT
4895 status collapsed
4896
4897 \begin_layout Standard
4898
4899
4900 \backslash
4901 /
4902 \end_layout
4903
4904 \end_inset
4905
4906 -version"
4907 \begin_inset LatexCommand \index{version}
4908
4909 \end_inset
4910
4911
4912 \family default
4913 \series default
4914  at the prompt, and the program should run and output its version like:
4915  
4916 \newline
4917
4918 \family typewriter
4919 SDCC : mcs51/z80/avr/ds390/pic16/pic14/ds400/hc08 2.5.6 #4169 (May 8 2006)
4920  (UNIX)
4921 \end_layout
4922
4923 \begin_layout Standard
4924 If it doesn't run, or gives a message about not finding sdcc program, then
4925  you need to check over your installation.
4926  Make sure that the sdcc bin directory is in your executable search path
4927  defined by the PATH environment setting (
4928 \series medium
4929 see 
4930 \series default
4931 section 
4932 \begin_inset LatexCommand \ref{sub:Install-Trouble-shooting}
4933
4934 \end_inset
4935
4936 \InsetSpace ~
4937
4938 \series medium
4939 Install trouble-shooting for suggestions
4940 \series default
4941 ).
4942  Make sure that the sdcc program is in the bin folder, if not perhaps something
4943  did not install correctly.
4944 \newline
4945
4946 \newline
4947
4948 \series medium
4949 SDCC 
4950 \series default
4951 is commonly installed as described in section 
4952 \begin_inset Quotes sld
4953 \end_inset
4954
4955 Install and search paths
4956 \begin_inset Quotes srd
4957 \end_inset
4958
4959 .
4960 \newline
4961
4962 \newline
4963
4964 \series medium
4965 Make sure the compiler works on a very simple example.
4966  Type in the following test.c program using your favorite 
4967 \series default
4968 ASCII 
4969 \series medium
4970 editor:
4971 \end_layout
4972
4973 \begin_layout Verse
4974
4975 \family typewriter
4976 char test;
4977 \newline
4978
4979 \newline
4980 void main(void) {
4981 \newline
4982 \InsetSpace ~
4983 \InsetSpace ~
4984 \InsetSpace ~
4985 \InsetSpace ~
4986 test=0;
4987 \newline
4988 }
4989 \end_layout
4990
4991 \begin_layout Standard
4992
4993 \series medium
4994 Compile this using the following command: 
4995 \family sans
4996 \series bold
4997 "sdcc -c test.c".
4998
4999 \family default
5000 \series default
5001  
5002 \series medium
5003 If all goes well, the compiler will generate a test.asm and test.rel file.
5004  Congratulations, you've just compiled your first program with SDCC.
5005  We used the -c option to tell SDCC not to link the generated code, just
5006  to keep things simple for this step.
5007 \series default
5008
5009 \newline
5010
5011 \newline
5012
5013 \series medium
5014 The next step is to try it with the linker.
5015  Type in 
5016 \family sans
5017 \series bold
5018 "sdcc test.c
5019 \family default
5020 \series default
5021 "
5022 \series medium
5023 .
5024  If all goes well the compiler will link with the libraries and produce
5025  a test.ihx output file.
5026  If this step fails
5027 \series default
5028  
5029 \series medium
5030 (no test.ihx, and the linker generates warnings), then the problem is most
5031  likely that 
5032 \series default
5033 SDCC
5034 \series medium
5035  cannot find the 
5036 \series default
5037 /
5038 \series medium
5039 usr/local/share/sdcc/lib directory
5040 \series default
5041  
5042 \series medium
5043 (see 
5044 \series default
5045 section 
5046 \begin_inset LatexCommand \ref{sub:Install-Trouble-shooting}
5047
5048 \end_inset
5049
5050 \InsetSpace ~
5051
5052 \series medium
5053 Install trouble-shooting for suggestions).
5054 \series default
5055
5056 \newline
5057
5058 \newline
5059
5060 \series medium
5061 The final test is to ensure 
5062 \series default
5063 SDCC
5064 \series medium
5065  can use the 
5066 \series default
5067 standard
5068 \series medium
5069  header files and libraries.
5070  Edit test.c and change it to the following:
5071 \end_layout
5072
5073 \begin_layout Verse
5074
5075 \family typewriter
5076 #include <string.h>
5077 \newline
5078
5079 \newline
5080 char str1[10];
5081 \newline
5082
5083 \newline
5084 void main(void) {
5085 \newline
5086 \InsetSpace ~
5087 \InsetSpace ~
5088 strcpy(str1, "testing");
5089 \newline
5090 }
5091 \end_layout
5092
5093 \begin_layout Standard
5094
5095 \series medium
5096 Compile this by typing 
5097 \family sans
5098 \series bold
5099 "sdcc test.c"
5100 \family default
5101 \series medium
5102 .
5103  This should generate a test.ihx output file, and it should give no warnings
5104  such as not finding the string.h file.
5105  If it cannot find the string.h file, then the problem is that 
5106 \series default
5107 SDCC
5108 \series medium
5109  cannot find the /usr/local/share/sdcc/include directory
5110 \series default
5111  
5112 \series medium
5113 (see the 
5114 \series default
5115 section 
5116 \begin_inset LatexCommand \ref{sub:Install-Trouble-shooting}
5117
5118 \end_inset
5119
5120 \InsetSpace ~
5121
5122 \series medium
5123 Install trouble-shooting section for suggestions).
5124
5125 \series default
5126  Use option 
5127 \series bold
5128 -
5129 \begin_inset ERT
5130 status collapsed
5131
5132 \begin_layout Standard
5133
5134
5135 \backslash
5136 /
5137 \end_layout
5138
5139 \end_inset
5140
5141 -print-search-dirs
5142 \series default
5143
5144 \begin_inset LatexCommand \index{-\/-print-search-dirs}
5145
5146 \end_inset
5147
5148  to find exactly where SDCC is looking for the include and lib files.
5149 \end_layout
5150
5151 \begin_layout Section
5152 Install Trouble-shooting
5153 \begin_inset LatexCommand \label{sub:Install-Trouble-shooting}
5154
5155 \end_inset
5156
5157
5158 \begin_inset LatexCommand \index{Install trouble-shooting}
5159
5160 \end_inset
5161
5162
5163 \end_layout
5164
5165 \begin_layout Subsection
5166 If SDCC does not build correctly
5167 \end_layout
5168
5169 \begin_layout Standard
5170 A thing to try is starting from scratch by unpacking the .tgz source package
5171  again in an empty directory.
5172  Configure it like:
5173 \newline
5174
5175 \newline
5176
5177 \family sans
5178 \series bold
5179 ./configure 2>&1 | tee configure.log
5180 \family default
5181 \series default
5182
5183 \newline
5184
5185 \newline
5186 and build it like:
5187 \newline
5188
5189 \newline
5190
5191 \family sans
5192 \series bold
5193 make 2>&1 | tee make.log
5194 \family default
5195 \series default
5196
5197 \newline
5198
5199 \newline
5200 If anything goes wrong, you can review the log files to locate the problem.
5201  Or a relevant part of this can be attached to an email that could be helpful
5202  when requesting help from the mailing list.
5203 \end_layout
5204
5205 \begin_layout Subsection
5206 What the 
5207 \begin_inset Quotes sld
5208 \end_inset
5209
5210 ./configure
5211 \begin_inset Quotes srd
5212 \end_inset
5213
5214  does
5215 \end_layout
5216
5217 \begin_layout Standard
5218 The 
5219 \begin_inset Quotes sld
5220 \end_inset
5221
5222 ./configure
5223 \begin_inset Quotes srd
5224 \end_inset
5225
5226  command is a script that analyzes your system and performs some configuration
5227  to ensure the source package compiles on your system.
5228  It will take a few minutes to run, and will compile a few tests to determine
5229  what compiler features are installed.
5230 \end_layout
5231
5232 \begin_layout Subsection
5233 What the 
5234 \begin_inset Quotes sld
5235 \end_inset
5236
5237 make
5238 \begin_inset Quotes srd
5239 \end_inset
5240
5241  does
5242 \end_layout
5243
5244 \begin_layout Standard
5245 This runs the GNU make tool, which automatically compiles all the source
5246  packages into the final installed binary executables.
5247 \end_layout
5248
5249 \begin_layout Subsection
5250 What the 
5251 \begin_inset Quotes sld
5252 \end_inset
5253
5254 make install
5255 \begin_inset Quotes erd
5256 \end_inset
5257
5258  command does.
5259 \end_layout
5260
5261 \begin_layout Standard
5262 This will install the compiler, other executables libraries and include
5263  files into the appropriate directories.
5264  See sections 
5265 \begin_inset LatexCommand \ref{sub:Install-paths}
5266
5267 \end_inset
5268
5269 ,\InsetSpace ~
5270
5271 \begin_inset LatexCommand \ref{sub:Search-Paths}
5272
5273 \end_inset
5274
5275 \InsetSpace ~
5276 about install and search paths.
5277 \newline
5278 On most systems you will need super-user privilege
5279 s to do this.
5280 \end_layout
5281
5282 \begin_layout Section
5283 Components of SDCC
5284 \end_layout
5285
5286 \begin_layout Standard
5287 SDCC is not just a compiler, but a collection of tools by various developers.
5288  These include linkers, assemblers, simulators and other components.
5289  Here is a summary of some of the components.
5290  Note that the included simulator and assembler have separate documentation
5291  which you can find in the source package in their respective directories.
5292  As SDCC grows to include support for other processors, other packages from
5293  various developers are included and may have their own sets of documentation.
5294 \newline
5295
5296 \newline
5297 You
5298  might want to look at the files which are installed in <installdir>.
5299  At the time of this writing, we find the following programs for gcc-builds:
5300 \newline
5301
5302  
5303 \newline
5304 In <installdir>/bin:
5305 \end_layout
5306
5307 \begin_layout Itemize
5308 sdcc - The compiler.
5309 \end_layout
5310
5311 \begin_layout Itemize
5312 sdcpp - The C preprocessor.
5313 \end_layout
5314
5315 \begin_layout Itemize
5316 asx8051 - The assembler for 8051 type processors.
5317 \end_layout
5318
5319 \begin_layout Itemize
5320 as-z80
5321 \series bold
5322
5323 \series default
5324 as-gbz80 - The Z80 and GameBoy Z80 assemblers.
5325 \end_layout
5326
5327 \begin_layout Itemize
5328 aslink -The linker for 8051 type processors.
5329 \end_layout
5330
5331 \begin_layout Itemize
5332 link-z80
5333 \series bold
5334
5335 \series default
5336 link-gbz80 - The Z80 and GameBoy Z80 linkers.
5337 \end_layout
5338
5339 \begin_layout Itemize
5340 s51 - The ucSim 8051 simulator.
5341 \end_layout
5342
5343 \begin_layout Itemize
5344 sdcdb - The source debugger.
5345 \end_layout
5346
5347 \begin_layout Itemize
5348 packihx - A tool to pack (compress) Intel hex files.
5349 \end_layout
5350
5351 \begin_layout Standard
5352 In <installdir>/share/sdcc/include
5353 \end_layout
5354
5355 \begin_layout Itemize
5356 the include files
5357 \end_layout
5358
5359 \begin_layout Standard
5360 In <installdir>/share/sdcc/lib
5361 \end_layout
5362
5363 \begin_layout Itemize
5364 the subdirs src and small, large, z80, gbz80 and ds390 with the precompiled
5365  relocatables.
5366 \end_layout
5367
5368 \begin_layout Standard
5369 In <installdir>/share/sdcc/doc
5370 \end_layout
5371
5372 \begin_layout Itemize
5373 the documentation
5374 \end_layout
5375
5376 \begin_layout Standard
5377 As development for other processors proceeds, this list will expand to include
5378  executables to support processors like AVR, PIC, etc.
5379 \end_layout
5380
5381 \begin_layout Subsection
5382 sdcc - The Compiler
5383 \end_layout
5384
5385 \begin_layout Standard
5386 This is the actual compiler, it in turn uses the c-preprocessor and invokes
5387  the assembler and linkage editor.
5388 \end_layout
5389
5390 \begin_layout Subsection
5391 sdcpp - The C-Preprocessor
5392 \end_layout
5393
5394 \begin_layout Standard
5395 The preprocessor
5396 \begin_inset LatexCommand \index{sdcpp (preprocessor)}
5397
5398 \end_inset
5399
5400  is a modified version of the GNU cpp
5401 \begin_inset LatexCommand \index{cpp|see{sdcpp}}
5402
5403 \end_inset
5404
5405  preprocessor 
5406 \begin_inset LatexCommand \url{http://gcc.gnu.org/}
5407
5408 \end_inset
5409
5410 .
5411  The C preprocessor is used to pull in #include sources, process #ifdef
5412  statements, #defines and so on.
5413 \end_layout
5414
5415 \begin_layout Subsection
5416 as
5417 \emph on
5418 xxxx
5419 \emph default
5420 , aslink, link-
5421 \emph on
5422 xxx
5423 \emph default
5424  - The Assemblers and Linkage Editors
5425 \end_layout
5426
5427 \begin_layout Standard
5428 This is retargettable assembler & linkage editor, it was developed by Alan
5429  Baldwin.
5430  John Hartman created the version for 8051, and I (Sandeep) have made some
5431  enhancements and bug fixes for it to work properly with SDCC.
5432 \end_layout
5433
5434 \begin_layout Subsection
5435 s51 - The Simulator
5436 \end_layout
5437
5438 \begin_layout Standard
5439 S51
5440 \begin_inset LatexCommand \index{s51}
5441
5442 \end_inset
5443
5444  is a free open source simulator developed by Daniel Drotos.
5445  The simulator is built as part of the build process.
5446  For more information visit Daniel's web site at: 
5447 \begin_inset LatexCommand \url{http://mazsola.iit.uni-miskolc.hu/~drdani/embedded/s51}
5448
5449 \end_inset
5450
5451 .
5452  It currently supports the core mcs51, the Dallas DS80C390 and the Phillips
5453  XA51 family.
5454 \end_layout
5455
5456 \begin_layout Subsection
5457 sdcdb - Source Level Debugger
5458 \end_layout
5459
5460 \begin_layout Standard
5461 SDCDB
5462 \begin_inset LatexCommand \index{SDCDB (debugger)}
5463
5464 \end_inset
5465
5466  is the companion source level debugger.
5467  More about SDCDB in section 
5468 \begin_inset LatexCommand \ref{cha:Debugging-with-SDCDB}
5469
5470 \end_inset
5471
5472 .
5473  The current version of the debugger uses Daniel's Simulator S51
5474 \begin_inset LatexCommand \index{s51}
5475
5476 \end_inset
5477
5478 , but can be easily changed to use other simulators.
5479 \end_layout
5480
5481 \begin_layout Chapter
5482 Using SDCC
5483 \end_layout
5484
5485 \begin_layout Section
5486 Compiling
5487 \end_layout
5488
5489 \begin_layout Subsection
5490 Single Source File Projects
5491 \end_layout
5492
5493 \begin_layout Standard
5494 For single source file 8051 projects the process is very simple.
5495  Compile your programs with the following command 
5496 \family sans
5497 \series bold
5498 "sdcc sourcefile.c".
5499
5500 \family default
5501 \series default
5502  This will compile, assemble and link your source file.
5503  Output files are as follows:
5504 \end_layout
5505
5506 \begin_layout Itemize
5507 sourcefile.asm
5508 \begin_inset LatexCommand \index{<file>.asm}
5509
5510 \end_inset
5511
5512  - Assembler source
5513 \begin_inset LatexCommand \index{Assembler source}
5514
5515 \end_inset
5516
5517  file created by the compiler
5518 \end_layout
5519
5520 \begin_layout Itemize
5521 sourcefile.lst
5522 \begin_inset LatexCommand \index{<file>.lst}
5523
5524 \end_inset
5525
5526  - Assembler listing
5527 \begin_inset LatexCommand \index{Assembler listing}
5528
5529 \end_inset
5530
5531  file created by the Assembler
5532 \end_layout
5533
5534 \begin_layout Itemize
5535 sourcefile.rst
5536 \begin_inset LatexCommand \index{<file>.rst}
5537
5538 \end_inset
5539
5540  - Assembler listing
5541 \begin_inset LatexCommand \index{Assembler listing}
5542
5543 \end_inset
5544
5545  file updated with linkedit information, created by linkage editor
5546 \end_layout
5547
5548 \begin_layout Itemize
5549 sourcefile.sym
5550 \begin_inset LatexCommand \index{<file>.sym}
5551
5552 \end_inset
5553
5554  - symbol listing
5555 \begin_inset LatexCommand \index{Symbol listing}
5556
5557 \end_inset
5558
5559  for the sourcefile, created by the assembler
5560 \end_layout
5561
5562 \begin_layout Itemize
5563 sourcefile.rel
5564 \begin_inset LatexCommand \index{<file>.rel}
5565
5566 \end_inset
5567
5568  or sourcefile.o
5569 \begin_inset LatexCommand \index{<file>.o}
5570
5571 \end_inset
5572
5573  - Object file
5574 \begin_inset LatexCommand \index{Object file}
5575
5576 \end_inset
5577
5578  created by the assembler, input to Linkage editor
5579 \end_layout
5580
5581 \begin_layout Itemize
5582 sourcefile.map
5583 \begin_inset LatexCommand \index{<file>.map}
5584
5585 \end_inset
5586
5587  - The memory map
5588 \begin_inset LatexCommand \index{Memory map}
5589
5590 \end_inset
5591
5592  for the load module, created by the Linker
5593 \end_layout
5594
5595 \begin_layout Itemize
5596 sourcefile.mem
5597 \begin_inset LatexCommand \index{<file>.mem}
5598
5599 \end_inset
5600
5601  - A file with a summary of the memory usage
5602 \end_layout
5603
5604 \begin_layout Itemize
5605 sourcefile.ihx
5606 \begin_inset LatexCommand \index{<file>.ihx}
5607
5608 \end_inset
5609
5610  - The load module in Intel hex format
5611 \begin_inset LatexCommand \index{Intel hex format}
5612
5613 \end_inset
5614
5615  (you can select the Motorola S19 format
5616 \begin_inset LatexCommand \index{Motorola S19 format}
5617
5618 \end_inset
5619
5620  with -
5621 \begin_inset ERT
5622 status collapsed
5623
5624 \begin_layout Standard
5625
5626
5627 \backslash
5628 /
5629 \end_layout
5630
5631 \end_inset
5632
5633 -out-fmt-s19
5634 \begin_inset LatexCommand \index{-\/-out-fmt-s19}
5635
5636 \end_inset
5637
5638 .
5639  If you need another format you might want to use 
5640 \family sans
5641 \shape italic
5642 objdump
5643 \family default
5644 \shape default
5645
5646 \begin_inset LatexCommand \index{objdump (tool)}
5647
5648 \end_inset
5649
5650  or
5651 \family sans
5652 \shape italic
5653  srecord
5654 \family default
5655 \shape default
5656
5657 \begin_inset LatexCommand \index{srecord (bin, hex, ... tool)}
5658
5659 \end_inset
5660
5661
5662 \begin_inset Note Note
5663 status collapsed
5664
5665 \begin_layout Standard
5666 hyperlinks needed
5667 \end_layout
5668
5669 \end_inset
5670
5671  - see also section 
5672 \begin_inset LatexCommand \vref{sub:Postprocessing-the-Intel}
5673
5674 \end_inset
5675
5676 ).
5677  Both formats are documented in the documentation of srecord
5678 \begin_inset LatexCommand \index{srecord (bin, hex, ... tool)}
5679
5680 \end_inset
5681
5682
5683 \end_layout
5684
5685 \begin_layout Itemize
5686 sourcefile.adb
5687 \begin_inset LatexCommand \index{<file>.adb}
5688
5689 \end_inset
5690
5691  - An intermediate file containing debug information needed to create the
5692  .cdb file (with -
5693 \begin_inset ERT
5694 status collapsed
5695
5696 \begin_layout Standard
5697
5698
5699 \backslash
5700 /
5701 \end_layout
5702
5703 \end_inset
5704
5705 -debug
5706 \begin_inset LatexCommand \index{-\/-debug}
5707
5708 \end_inset
5709
5710
5711 \end_layout
5712
5713 \begin_layout Itemize
5714 sourcefile.cdb
5715 \begin_inset LatexCommand \index{<file>.cdb}
5716
5717 \end_inset
5718
5719  - An optional file (with -
5720 \begin_inset ERT
5721 status collapsed
5722
5723 \begin_layout Standard
5724
5725
5726 \backslash
5727 /
5728 \end_layout
5729
5730 \end_inset
5731
5732 -debug) containing debug information.
5733  The format is documented in cdbfileformat.pdf
5734 \end_layout
5735
5736 \begin_layout Itemize
5737 sourcefile.
5738  - (no extension)
5739 \begin_inset LatexCommand \index{<file> (no extension)}
5740
5741 \end_inset
5742
5743  An optional AOMF or AOMF51
5744 \begin_inset LatexCommand \index{AOMF, AOMF51}
5745
5746 \end_inset
5747
5748  
5749 \begin_inset LatexCommand \label{OMF file}
5750
5751 \end_inset
5752
5753 file containing debug information (generated with option -
5754 \begin_inset ERT
5755 status collapsed
5756
5757 \begin_layout Standard
5758
5759
5760 \backslash
5761 /
5762 \end_layout
5763
5764 \end_inset
5765
5766 -debug).
5767  The (Intel)
5768 \emph on
5769  a
5770 \emph default
5771 bsolute 
5772 \emph on
5773 o
5774 \emph default
5775 bject 
5776 \emph on
5777 m
5778 \emph default
5779 odule 
5780 \emph on
5781 f
5782 \emph default
5783 ormat is a subformat of the OMF51 format and is commonly used by third party
5784  tools (debuggers
5785 \begin_inset LatexCommand \index{Debugger}
5786
5787 \end_inset
5788
5789 , simulators, emulators).
5790 \end_layout
5791
5792 \begin_layout Itemize
5793 sourcefile.dump*
5794 \begin_inset LatexCommand \index{<file>.dump*}
5795
5796 \end_inset
5797
5798  - Dump file to debug the compiler it self (generated with option -
5799 \begin_inset ERT
5800 status collapsed
5801
5802 \begin_layout Standard
5803
5804
5805 \backslash
5806 /
5807 \end_layout
5808
5809 \end_inset
5810
5811 -dumpall) (see section 
5812 \begin_inset LatexCommand \ref{sub:Intermediate-Dump-Options}
5813
5814 \end_inset
5815
5816 \InsetSpace ~
5817  and section 
5818 \begin_inset LatexCommand \ref{sub:The-anatomy-of}
5819
5820 \end_inset
5821
5822 \InsetSpace ~
5823
5824 \begin_inset Quotes sld
5825 \end_inset
5826
5827 Anatomy of the compiler
5828 \begin_inset Quotes srd
5829 \end_inset
5830
5831 ).
5832 \end_layout
5833
5834 \begin_layout Subsection
5835 Postprocessing the Intel Hex
5836 \begin_inset LatexCommand \index{Intel hex format}
5837
5838 \end_inset
5839
5840  file
5841 \begin_inset LatexCommand \label{sub:Postprocessing-the-Intel}
5842
5843 \end_inset
5844
5845
5846 \end_layout
5847
5848 \begin_layout Standard
5849 In most cases this won't be needed but the Intel Hex file
5850 \begin_inset LatexCommand \index{<file>.ihx}
5851
5852 \end_inset
5853
5854  which is generated by SDCC might include lines of varying length and the
5855  addresses within the file are not guaranteed to be strictly ascending.
5856  If your toolchain or a bootloader does not like this you can use the tool
5857  
5858 \family typewriter
5859 packihx
5860 \family default
5861
5862 \begin_inset LatexCommand \index{packihx (tool)}
5863
5864 \end_inset
5865
5866  which is part of the SDCC distribution: 
5867 \newline
5868
5869 \newline
5870
5871 \family sans
5872 \series bold
5873  packihx sourcefile.ihx >sourcefile.hex
5874 \family default
5875 \series default
5876
5877 \newline
5878
5879 \newline
5880 The separately available
5881 \emph on
5882  srecord
5883 \emph default
5884
5885 \begin_inset LatexCommand \index{srecord (bin, hex, ... tool)}
5886
5887 \end_inset
5888
5889  package additionally allows to set undefined locations to a predefined
5890  value, to insert checksums
5891 \begin_inset LatexCommand \index{checksum}
5892
5893 \end_inset
5894
5895  of various flavours (crc, add, xor) and to perform other manipulations
5896  (convert, split, crop, offset, ...).
5897  
5898 \newline
5899
5900 \newline
5901
5902 \family sans
5903 \series bold
5904 srec_cat\InsetSpace ~
5905 \InsetSpace ~
5906 sourcefile.ihx -intel\InsetSpace ~
5907 \InsetSpace ~
5908 -o sourcefile.hex -intel
5909 \newline
5910
5911 \newline
5912
5913 \family default
5914 \series default
5915 An example for a more complex command line
5916 \begin_inset Foot
5917 status open
5918
5919 \begin_layout Standard
5920 the command backfills
5921 \begin_inset LatexCommand \index{backfill unused memory}
5922
5923 \end_inset
5924
5925  unused memory with 0x12 and the overall 16 bit sum of the complete 64 kByte
5926  block is zero.
5927  If the program counter on an mcs51 runs wild the backfill pattern 0x12
5928  will be interpreted as an 
5929 \family typewriter
5930 lcall
5931 \family default
5932  to address 
5933 \family typewriter
5934 0x1212
5935 \family default
5936  (where an emergency routine could sit).
5937 \end_layout
5938
5939 \end_inset
5940
5941  could look like:
5942 \newline
5943
5944 \newline
5945
5946 \family sans
5947 \series bold
5948 \size footnotesize
5949 srec_cat\InsetSpace ~
5950 sourcefile.ihx -intel\InsetSpace ~
5951 \InsetSpace ~
5952 -fill 0x12 0x0000 0xfffe\InsetSpace ~
5953 -little-endian-checksum-nega
5954 tive 0xfffe 0x02 0x02\InsetSpace ~
5955 \InsetSpace ~
5956 -o sourcefile.hex -intel
5957 \size default
5958
5959 \newline
5960
5961 \newline
5962
5963 \family default
5964 \series default
5965 The srecord package is available at 
5966 \begin_inset LatexCommand \url{http://sf.net/projects/srecord}
5967
5968 \end_inset
5969
5970  .
5971 \end_layout
5972
5973 \begin_layout Subsection
5974 Projects with Multiple Source Files
5975 \end_layout
5976
5977 \begin_layout Standard
5978 SDCC can compile only ONE file at a time.
5979  Let us for example assume that you have a project containing the following
5980  files:
5981 \newline
5982
5983 \newline
5984 foo1.c (contains some functions)
5985 \newline
5986 foo2.c (contains some more functions)
5987 \newline
5988 foomai
5989 n.c (contains more functions and the function main)
5990 \newline
5991
5992 \size footnotesize
5993
5994 \newline
5995
5996 \size default
5997 The first two files will need to be compiled separately with the commands:
5998 \size footnotesize
5999  
6000 \size default
6001
6002 \newline
6003
6004 \newline
6005
6006 \family sans
6007 \series bold
6008 sdcc\InsetSpace ~
6009 -c\InsetSpace ~
6010 foo1.c
6011 \family default
6012 \series default
6013 \size footnotesize
6014
6015 \newline
6016
6017 \family sans
6018 \series bold
6019 \size default
6020 sdcc\InsetSpace ~
6021 -c\InsetSpace ~
6022 foo2.c
6023 \family default
6024 \series default
6025
6026 \newline
6027
6028 \newline
6029 Then compile the source file containing the 
6030 \emph on
6031 main()
6032 \emph default
6033  function and link
6034 \begin_inset LatexCommand \index{Linker}
6035
6036 \end_inset
6037
6038  the files together with the following command: 
6039 \newline
6040
6041 \newline
6042
6043 \family sans
6044 \series bold
6045 sdcc\InsetSpace ~
6046 foomain.c\InsetSpace ~
6047 foo1.rel\InsetSpace ~
6048 foo2.rel
6049 \family default
6050 \series default
6051
6052 \begin_inset LatexCommand \index{<file>.rel}
6053
6054 \end_inset
6055
6056
6057 \newline
6058
6059 \newline
6060 Alternatively, 
6061 \emph on
6062 foomain.c 
6063 \emph default
6064 can be separately compiled as well: 
6065 \family sans
6066 \series bold
6067
6068 \newline
6069
6070 \newline
6071 sdcc\InsetSpace ~
6072 -c\InsetSpace ~
6073 foomain.c
6074 \newline
6075 sdcc foomain.rel foo1.rel foo2.rel
6076 \newline
6077
6078 \newline
6079
6080 \family default
6081 \series default
6082 The file containing the 
6083 \emph on
6084 main()
6085 \emph default
6086  function
6087 \emph on
6088  
6089 \emph default
6090 \noun on
6091 must
6092 \noun default
6093  be the 
6094 \noun on
6095 first
6096 \noun default
6097  file specified in the command line, since the linkage editor processes
6098  file in the order they are presented to it.
6099  The linker is invoked from SDCC using a script file with extension .lnk
6100 \begin_inset LatexCommand \index{<file>.lnk}
6101
6102 \end_inset
6103
6104 .
6105  You can view this file to troubleshoot linking problems such as those arising
6106  from missing libraries.
6107 \end_layout
6108
6109 \begin_layout Subsection
6110 Projects with Additional Libraries
6111 \begin_inset LatexCommand \index{Libraries}
6112
6113 \end_inset
6114
6115
6116 \end_layout
6117
6118 \begin_layout Standard
6119 Some reusable routines may be compiled into a library, see the documentation
6120  for the assembler and linkage editor (which are in <installdir>/share/sdcc/doc)
6121  for how to create a 
6122 \emph on
6123 .lib
6124 \begin_inset LatexCommand \index{<file>.lib}
6125
6126 \end_inset
6127
6128
6129 \emph default
6130  library file.
6131  Libraries created in this manner can be included in the command line.
6132  Make sure you include the -L <library-path> option to tell the linker where
6133  to look for these files if they are not in the current directory.
6134  Here is an example, assuming you have the source file 
6135 \emph on
6136 foomain.c
6137 \emph default
6138  and a library
6139 \emph on
6140  foolib.lib
6141 \emph default
6142  in the directory 
6143 \emph on
6144 mylib
6145 \emph default
6146  (if that is not the same as your current project):
6147 \newline
6148
6149 \newline
6150
6151 \family sans
6152 \series bold
6153 sdcc foomain.c foolib.lib -L mylib
6154 \newline
6155
6156 \newline
6157
6158 \family default
6159 \series default
6160 Note here that
6161 \emph on
6162  mylib
6163 \emph default
6164  must be an absolute path name.
6165 \newline
6166
6167 \newline
6168 The most efficient way to use libraries is
6169  to keep separate modules in separate source files.
6170  The lib file now should name all the modules.rel
6171 \begin_inset LatexCommand \index{<file>.rel}
6172
6173 \end_inset
6174
6175  files.
6176  For an example see the standard library file 
6177 \emph on
6178 libsdcc.lib
6179 \emph default
6180  in the directory <installdir>/share/lib/small.
6181 \end_layout
6182
6183 \begin_layout Subsection
6184 Using sdcclib to Create and Manage Libraries
6185 \begin_inset LatexCommand \index{sdcclib}
6186
6187 \end_inset
6188
6189
6190 \end_layout
6191
6192 \begin_layout Standard
6193 Alternatively, instead of having a .rel file for each entry on the library
6194  file as described in the preceding section, sdcclib can be used to embed
6195  all the modules belonging to such library in the library file itself.
6196  This results in a larger library file, but it greatly reduces the number
6197  of disk files accessed by the linker.
6198   Additionally, the packed library file contains an index of all include
6199  modules and symbols that significantly speeds up the linking process.
6200  To display a list of options supported by sdcclib type:
6201 \newline
6202
6203 \end_layout
6204
6205 \begin_layout Standard
6206
6207 \family sans
6208 \series bold
6209 sdcclib -?
6210 \begin_inset LatexCommand \index{sdcclib}
6211
6212 \end_inset
6213
6214
6215 \newline
6216
6217 \newline
6218
6219 \family default
6220 \series default
6221 To create a new library file, start by compiling all the required modules.
6222  For example:
6223 \newline
6224
6225 \end_layout
6226
6227 \begin_layout Standard
6228
6229 \family sans
6230 \series bold
6231 sdcc -c _divsint.c
6232 \end_layout
6233
6234 \begin_layout Standard
6235
6236 \family sans
6237 \series bold
6238 sdcc -c _divuint.c
6239 \end_layout
6240
6241 \begin_layout Standard
6242
6243 \family sans
6244 \series bold
6245 sdcc -c _modsint.c
6246 \end_layout
6247
6248 \begin_layout Standard
6249
6250 \family sans
6251 \series bold
6252 sdcc -c _moduint.c
6253 \end_layout
6254
6255 \begin_layout Standard
6256
6257 \family sans
6258 \series bold
6259 sdcc -c _mulint.c
6260 \newline
6261
6262 \end_layout
6263
6264 \begin_layout Standard
6265 This will create files _divsint.rel, _divuint.rel, _modsint.rel, _moduint.rel,
6266  and _mulint.rel.
6267  The next step is to add the .rel files to the library file:
6268 \newline
6269
6270 \end_layout
6271
6272 \begin_layout Standard
6273
6274 \family sans
6275 \series bold
6276 sdcclib libint.lib _divsint.rel
6277 \family default
6278
6279 \begin_inset LatexCommand \index{sdcclib}
6280
6281 \end_inset
6282
6283
6284 \end_layout
6285
6286 \begin_layout Standard
6287
6288 \family sans
6289 \series bold
6290 sdcclib libint.lib _divuint.rel
6291 \end_layout
6292
6293 \begin_layout Standard
6294
6295 \family sans
6296 \series bold
6297 sdcclib libint.lib _modsint.rel
6298 \end_layout
6299
6300 \begin_layout Standard
6301
6302 \family sans
6303 \series bold
6304 sdcclib libint.lib _moduint.rel
6305 \end_layout
6306
6307 \begin_layout Standard
6308
6309 \family sans
6310 \series bold
6311 sdcclib libint.lib _mulint.rel
6312 \family default
6313 \series default
6314
6315 \newline
6316
6317 \end_layout
6318
6319 \begin_layout Standard
6320 Or, if you preffer:
6321 \family sans
6322 \series bold
6323
6324 \newline
6325
6326 \end_layout
6327
6328 \begin_layout Standard
6329
6330 \family sans
6331 \series bold
6332 sdcclib libint.lib _divsint.rel _divuint.rel _modsint.rel _moduint.rel _mulint.rel
6333 \family default
6334 \series default
6335
6336 \newline
6337
6338 \end_layout
6339
6340 \begin_layout Standard
6341 If the file already exists in the library, it will be replaced.
6342  If a list of .rel files is available, you can tell sdcclib to add those
6343  files to a library.
6344  For example, if the file 'myliblist.txt' contains
6345 \family sans
6346 \series bold
6347
6348 \newline
6349
6350 \end_layout
6351
6352 \begin_layout Standard
6353
6354 \family sans
6355 \series bold
6356 _divsint.rel
6357 \end_layout
6358
6359 \begin_layout Standard
6360
6361 \family sans
6362 \series bold
6363 _divuint.rel
6364 \end_layout
6365
6366 \begin_layout Standard
6367
6368 \family sans
6369 \series bold
6370 _modsint.rel
6371 \end_layout
6372
6373 \begin_layout Standard
6374
6375 \family sans
6376 \series bold
6377 _moduint.rel
6378 \end_layout
6379
6380 \begin_layout Standard
6381
6382 \family sans
6383 \series bold
6384 _mulint.rel
6385 \family default
6386 \series default
6387
6388 \newline
6389
6390 \end_layout
6391
6392 \begin_layout Standard
6393 Use
6394 \family sans
6395 \series bold
6396
6397 \newline
6398
6399 \end_layout
6400
6401 \begin_layout Standard
6402
6403 \family sans
6404 \series bold
6405 sdcclib -l libint.lib myliblist.txt
6406 \family default
6407 \series default
6408
6409 \newline
6410
6411 \end_layout
6412
6413 \begin_layout Standard
6414 Additionally, you can instruct sdcclib to compiles the files before adding
6415  them to the library.
6416  This is achieved using the environment variables SDCCLIB_CC and/or SDCCLIB_AS.
6417  For example:
6418 \family sans
6419 \series bold
6420
6421 \newline
6422
6423 \end_layout
6424
6425 \begin_layout Standard
6426
6427 \family sans
6428 \series bold
6429 set SDCCLIB_CC=sdcc -c
6430 \end_layout
6431
6432 \begin_layout Standard
6433
6434 \family sans
6435 \series bold
6436 sdcclib -l libint.lib myliblist.txt
6437 \family default
6438 \series default
6439
6440 \newline
6441
6442 \end_layout
6443
6444 \begin_layout Standard
6445 To see what modules and symbols are included in the library, options -s
6446  and -m are available.
6447  For example:
6448 \newline
6449
6450 \newline
6451
6452 \family sans
6453 \series bold
6454 sdcclib -s libint.lib
6455 \family default
6456
6457 \begin_inset LatexCommand \index{sdcclib}
6458
6459 \end_inset
6460
6461
6462 \newline
6463
6464 \family typewriter
6465 \series default
6466 _divsint.rel:
6467 \end_layout
6468
6469 \begin_layout Standard
6470
6471 \family typewriter
6472 __divsint_a_1_1
6473 \end_layout
6474
6475 \begin_layout Standard
6476
6477 \family typewriter
6478 __divsint_PARM_2
6479 \end_layout
6480
6481 \begin_layout Standard
6482
6483 \family typewriter
6484 __divsint
6485 \newline
6486 _divuint.rel:
6487 \end_layout
6488
6489 \begin_layout Standard
6490
6491 \family typewriter
6492 __divuint_a_1_1
6493 \end_layout
6494
6495 \begin_layout Standard
6496
6497 \family typewriter
6498 __divuint_PARM_2
6499 \end_layout
6500
6501 \begin_layout Standard
6502
6503 \family typewriter
6504 __divuint_reste_1_1
6505 \end_layout
6506
6507 \begin_layout Standard
6508
6509 \family typewriter
6510 __divuint_count_1_1
6511 \end_layout
6512
6513 \begin_layout Standard
6514
6515 \family typewriter
6516 __divuint
6517 \newline
6518 _modsint.rel:
6519 \end_layout
6520
6521 \begin_layout Standard
6522
6523 \family typewriter
6524 __modsint_a_1_1
6525 \end_layout
6526
6527 \begin_layout Standard
6528
6529 \family typewriter
6530 __modsint_PARM_2
6531 \end_layout
6532
6533 \begin_layout Standard
6534
6535 \family typewriter
6536 __modsint
6537 \newline
6538 _moduint.rel:
6539 \end_layout
6540
6541 \begin_layout Standard
6542
6543 \family typewriter
6544 __moduint_a_1_1
6545 \end_layout
6546
6547 \begin_layout Standard
6548
6549 \family typewriter
6550 __moduint_PARM_2
6551 \end_layout
6552
6553 \begin_layout Standard
6554
6555 \family typewriter
6556 __moduint_count_1_1
6557 \end_layout
6558
6559 \begin_layout Standard
6560
6561 \family typewriter
6562 __moduint
6563 \newline
6564 _mulint.rel:
6565 \end_layout
6566
6567 \begin_layout Standard
6568
6569 \family typewriter
6570 __mulint_PARM_2
6571 \end_layout
6572
6573 \begin_layout Standard
6574
6575 \family typewriter
6576 __mulint
6577 \family default
6578 \series bold
6579
6580 \newline
6581
6582 \end_layout
6583
6584 \begin_layout Standard
6585 If the source files are compiled using -
6586 \begin_inset ERT
6587 status collapsed
6588
6589 \begin_layout Standard
6590
6591
6592 \backslash
6593 /
6594 \end_layout
6595
6596 \end_inset
6597
6598 -debug
6599 \begin_inset LatexCommand \index{-\/-debug}
6600
6601 \end_inset
6602
6603 , the corresponding debug information file .adb will be include in the library
6604  file as well.
6605  The library files created with sdcclib are plain text files, so they can
6606  be viewed with a text editor.
6607  It is not recomended to modify a library file created with sdcclib using
6608  a text editor, as there are file indexes numbers located accross the file
6609  used by the linker to quickly locate the required module to link.
6610  Once a .rel file (as well as a .adb file) is added to a library using sdcclib,
6611  it can be safely deleted, since all the information required for linking
6612  is embedded in the library file itself.
6613  Library files created using sdcclib are used as described in the preceding
6614  sections.
6615 \begin_inset VSpace bigskip
6616 \end_inset
6617
6618
6619 \end_layout
6620
6621 \begin_layout Section
6622 Command Line Options
6623 \begin_inset LatexCommand \index{Command Line Options}
6624
6625 \end_inset
6626
6627
6628 \begin_inset LatexCommand \label{sec:Command-Line-Options}
6629
6630 \end_inset
6631
6632
6633 \end_layout
6634
6635 \begin_layout Subsection
6636 Processor Selection Options
6637 \begin_inset LatexCommand \index{Options processor selection}
6638
6639 \end_inset
6640
6641
6642 \begin_inset LatexCommand \index{Processor selection options}
6643
6644 \end_inset
6645
6646
6647 \end_layout
6648
6649 \begin_layout List
6650 \labelwidthstring 00.00.0000
6651
6652 \series bold
6653 -mmcs51
6654 \begin_inset LatexCommand \index{-mmcs51}
6655
6656 \end_inset
6657
6658
6659 \series default
6660  Generate code for the Intel MCS51
6661 \begin_inset LatexCommand \index{MCS51}
6662
6663 \end_inset
6664
6665  family of processors.
6666  This is the default processor target.
6667 \end_layout
6668
6669 \begin_layout List
6670 \labelwidthstring 00.00.0000
6671
6672 \series bold
6673 -mds390
6674 \begin_inset LatexCommand \index{-mds390}
6675
6676 \end_inset
6677
6678
6679 \series default
6680  Generate code for the Dallas DS80C390
6681 \begin_inset LatexCommand \index{DS80C390}
6682
6683 \end_inset
6684
6685  processor.
6686 \end_layout
6687
6688 \begin_layout List
6689 \labelwidthstring 00.00.0000
6690
6691 \series bold
6692 -mds400
6693 \begin_inset LatexCommand \index{-mds400}
6694
6695 \end_inset
6696
6697
6698 \series default
6699  Generate code for the Dallas DS80C400
6700 \begin_inset LatexCommand \index{DS80C400}
6701
6702 \end_inset
6703
6704  processor.
6705 \end_layout
6706
6707 \begin_layout List
6708 \labelwidthstring 00.00.0000
6709
6710 \series bold
6711 -mhc08
6712 \begin_inset LatexCommand \index{-mhc08}
6713
6714 \end_inset
6715
6716
6717 \series default
6718  Generate code for the Freescale/Motorola HC08
6719 \begin_inset LatexCommand \index{HC08}
6720
6721 \end_inset
6722
6723  family of processors.
6724 \end_layout
6725
6726 \begin_layout List
6727 \labelwidthstring 00.00.0000
6728
6729 \series bold
6730 -mz80
6731 \begin_inset LatexCommand \index{-mz80}
6732
6733 \end_inset
6734
6735
6736 \series default
6737  Generate code for the Zilog Z80
6738 \begin_inset LatexCommand \index{Z80}
6739
6740 \end_inset
6741
6742  family of processors.
6743 \end_layout
6744
6745 \begin_layout List
6746 \labelwidthstring 00.00.0000
6747
6748 \series bold
6749 -mgbz80
6750 \begin_inset LatexCommand \index{-mgbz80}
6751
6752 \end_inset
6753
6754
6755 \series default
6756  Generate code for the GameBoy Z80
6757 \begin_inset LatexCommand \index{gbz80 (GameBoy Z80)}
6758
6759 \end_inset
6760
6761  processor (Not actively maintained).
6762 \end_layout
6763
6764 \begin_layout List
6765 \labelwidthstring 00.00.0000
6766
6767 \series bold
6768 -mavr
6769 \begin_inset LatexCommand \index{-mavr}
6770
6771 \end_inset
6772
6773
6774 \series default
6775  Generate code for the Atmel AVR
6776 \begin_inset LatexCommand \index{AVR}
6777
6778 \end_inset
6779
6780  processor (Not maintained, not complete).
6781  AVR users should probably have a look at winavr 
6782 \begin_inset LatexCommand \url{http://sourceforge.net/projects/winavr}
6783
6784 \end_inset
6785
6786  or 
6787 \begin_inset LatexCommand \url{http://www.avrfreaks.net/index.php?name=PNphpBB2&file=index}
6788
6789 \end_inset
6790
6791 , which is based on AVR-port of the gcc compiler.
6792 \end_layout
6793
6794 \begin_layout Standard
6795 \begin_inset Note Note
6796 status collapsed
6797
6798 \begin_layout Standard
6799 I think it is fair to direct users there for now.
6800  Open source is also about avoiding unnecessary work .
6801  But I didn't find the 'official' link.
6802 \end_layout
6803
6804 \end_inset
6805
6806
6807 \end_layout
6808
6809 \begin_layout List
6810 \labelwidthstring 00.00.0000
6811
6812 \series bold
6813 -mpic14
6814 \begin_inset LatexCommand \index{-mpic14}
6815
6816 \end_inset
6817
6818
6819 \series default
6820  Generate code for the Microchip PIC 14
6821 \begin_inset LatexCommand \index{PIC14}
6822
6823 \end_inset
6824
6825 -bit processors (p16f84 and variants.
6826  In development, not complete).
6827 \end_layout
6828
6829 \begin_layout Standard
6830 \begin_inset Note Note
6831 status collapsed
6832
6833 \begin_layout Standard
6834 p16f627 p16f628 p16f84 p16f873 p16f877?
6835 \end_layout
6836
6837 \end_inset
6838
6839
6840 \end_layout
6841
6842 \begin_layout List
6843 \labelwidthstring 00.00.0000
6844
6845 \series bold
6846 -mpic16
6847 \begin_inset LatexCommand \index{-mpic16}
6848
6849 \end_inset
6850
6851
6852 \series default
6853  Generate code for the Microchip PIC 16
6854 \begin_inset LatexCommand \index{PIC16}
6855
6856 \end_inset
6857
6858 -bit processors (p18f452 and variants.
6859  In development, not complete).
6860 \end_layout
6861
6862 \begin_layout List
6863 \labelwidthstring 00.00.0000
6864
6865 \series bold
6866 -mtlcs900h
6867 \series default
6868  Generate code for the Toshiba TLCS-900H
6869 \begin_inset LatexCommand \index{TLCS-900H}
6870
6871 \end_inset
6872
6873  processor (Not maintained, not complete).
6874 \end_layout
6875
6876 \begin_layout List
6877 \labelwidthstring 00.00.0000
6878
6879 \series bold
6880 -mxa51
6881 \begin_inset LatexCommand \index{-mxa51}
6882
6883 \end_inset
6884
6885
6886 \series default
6887  Generate code for the Phillips XA51
6888 \begin_inset LatexCommand \index{XA51}
6889
6890 \end_inset
6891
6892  processor (Not maintained, not complete).
6893 \end_layout
6894
6895 \begin_layout Standard
6896 \begin_inset VSpace bigskip
6897 \end_inset
6898
6899
6900 \end_layout
6901
6902 \begin_layout Subsection
6903 Preprocessor Options
6904 \begin_inset LatexCommand \index{Options preprocessor}
6905
6906 \end_inset
6907
6908
6909 \begin_inset LatexCommand \index{Preprocessor options}
6910
6911 \end_inset
6912
6913
6914 \begin_inset LatexCommand \index{sdcpp (preprocessor)}
6915
6916 \end_inset
6917
6918
6919 \end_layout
6920
6921 \begin_layout List
6922 \labelwidthstring 00.00.0000
6923
6924 \series bold
6925 -I<path>
6926 \begin_inset LatexCommand \index{-I<path>}
6927
6928 \end_inset
6929
6930
6931 \series default
6932  The additional location where the preprocessor will look for <..h> or 
6933 \begin_inset Quotes eld
6934 \end_inset
6935
6936 ..h
6937 \begin_inset Quotes erd
6938 \end_inset
6939
6940  files.
6941 \end_layout
6942
6943 \begin_layout List
6944 \labelwidthstring 00.00.0000
6945
6946 \series bold
6947 -D<macro[=value]>
6948 \begin_inset LatexCommand \index{-D<macro[=value]>}
6949
6950 \end_inset
6951
6952
6953 \series default
6954  Command line definition of macros.
6955  Passed to the preprocessor.
6956 \end_layout
6957
6958 \begin_layout List
6959 \labelwidthstring 00.00.0000
6960
6961 \series bold
6962 -M
6963 \begin_inset LatexCommand \index{-M}
6964
6965 \end_inset
6966
6967
6968 \series default
6969  Tell the preprocessor to output a rule suitable for make describing the
6970  dependencies of each object file.
6971  For each source file, the preprocessor outputs one make-rule whose target
6972  is the object file name for that source file and whose dependencies are
6973  all the files `#include'd in it.
6974  This rule may be a single line or may be continued with `
6975 \backslash
6976 '-newline if it is long.
6977  The list of rules is printed on standard output instead of the preprocessed
6978  C program.
6979  `-M' implies `-E
6980 \begin_inset LatexCommand \index{-E}
6981
6982 \end_inset
6983
6984 '.
6985 \end_layout
6986
6987 \begin_layout List
6988 \labelwidthstring 00.00.0000
6989
6990 \series bold
6991 -C
6992 \begin_inset LatexCommand \index{-C}
6993
6994 \end_inset
6995
6996
6997 \series default
6998  Tell the preprocessor not to discard comments.
6999  Used with the `-E' option.
7000 \end_layout
7001
7002 \begin_layout List
7003 \labelwidthstring 00.00.0000
7004
7005 \series bold
7006 -MM
7007 \begin_inset LatexCommand \index{-MM}
7008
7009 \end_inset
7010
7011
7012 \size large
7013 \bar under
7014  
7015 \series default
7016 \size default
7017 \bar default
7018 Like `-M' but the output mentions only the user header files included with
7019  `#include 
7020 \begin_inset Quotes eld
7021 \end_inset
7022
7023 file"'.
7024  System header files included with `#include <file>' are omitted.
7025 \end_layout
7026
7027 \begin_layout List
7028 \labelwidthstring 00.00.0000
7029
7030 \series bold
7031 -Aquestion(answer)
7032 \begin_inset LatexCommand \index{-Aquestion(answer)}
7033
7034 \end_inset
7035
7036
7037 \series default
7038  Assert the answer answer for question, in case it is tested with a preprocessor
7039  conditional such as `#if #question(answer)'.
7040  `-A-' disables the standard assertions that normally describe the target
7041  machine.
7042 \end_layout
7043
7044 \begin_layout List
7045 \labelwidthstring 00.00.0000
7046
7047 \series bold
7048 -Umacro
7049 \begin_inset LatexCommand \index{-Umacro}
7050
7051 \end_inset
7052
7053
7054 \series default
7055  Undefine macro macro.
7056  `-U' options are evaluated after all `-D' options, but before any `-include'
7057  and `-imacros' options.
7058 \end_layout
7059
7060 \begin_layout List
7061 \labelwidthstring 00.00.0000
7062
7063 \series bold
7064 -dM
7065 \begin_inset LatexCommand \index{-dM}
7066
7067 \end_inset
7068
7069
7070 \series default
7071  Tell the preprocessor to output only a list of the macro definitions that
7072  are in effect at the end of preprocessing.
7073  Used with the `-E' option.
7074 \end_layout
7075
7076 \begin_layout List
7077 \labelwidthstring 00.00.0000
7078
7079 \series bold
7080 -dD
7081 \begin_inset LatexCommand \index{-dD}
7082
7083 \end_inset
7084
7085
7086 \series default
7087  Tell the preprocessor to pass all macro definitions into the output, in
7088  their proper sequence in the rest of the output.
7089 \end_layout
7090
7091 \begin_layout List
7092 \labelwidthstring 00.00.0000
7093
7094 \series bold
7095 -dN
7096 \begin_inset LatexCommand \index{-dN}
7097
7098 \end_inset
7099
7100
7101 \size large
7102 \bar under
7103  
7104 \series default
7105 \size default
7106 \bar default
7107 Like `-dD' except that the macro arguments and contents are omitted.
7108  Only `#define name' is included in the output.
7109 \end_layout
7110
7111 \begin_layout List
7112 \labelwidthstring 00.00.0000
7113
7114 \series bold
7115 -pedantic-parse-number
7116 \begin_inset LatexCommand \index{pedantic}
7117
7118 \end_inset
7119
7120
7121 \begin_inset LatexCommand \index{-pedantic-parse-number}
7122
7123 \end_inset
7124
7125
7126 \size large
7127 \bar under
7128
7129 \begin_inset LatexCommand \label{lyx:-pedantic-parse-number}
7130
7131 \end_inset
7132
7133  
7134 \series default
7135 \size default
7136 \bar default
7137 Pedantic parse numbers so that situations like 0xfe-LO_B(3) are parsed properly
7138  and the macro LO_B(3) gets expanded.
7139  See also #pragma pedantic_parse_number 
7140 \begin_inset LatexCommand \vpageref{ite:pedantic_parse_number}
7141
7142 \end_inset
7143
7144  in section
7145 \begin_inset LatexCommand \ref{sec:Pragmas}
7146
7147 \end_inset
7148
7149  
7150 \emph on
7151 Note: this functionality is not in conformance with C99 standard!
7152 \end_layout
7153
7154 \begin_layout List
7155 \labelwidthstring 00.00.0000
7156
7157 \series bold
7158 -Wp\InsetSpace ~
7159 preprocessorOption[,preprocessorOption]
7160 \series default
7161
7162 \begin_inset LatexCommand \index{-Wp preprocessorOption[,preprocessorOption]}
7163
7164 \end_inset
7165
7166 ...
7167  Pass the preprocessorOption to the preprocessor 
7168 \family typewriter
7169 sdcpp
7170 \family default
7171
7172 \begin_inset LatexCommand \index{sdcpp (preprocessor)}
7173
7174 \end_inset
7175
7176 .
7177  SDCC uses an adapted version of the preprocessor 
7178 \emph on
7179 cpp
7180 \emph default
7181  of the GNU Compiler Collection
7182 \begin_inset LatexCommand \index{gcc (GNU Compiler Collection)}
7183
7184 \end_inset
7185
7186  (
7187 \emph on
7188 gcc
7189 \emph default
7190  
7191 \begin_inset LatexCommand \url{http://gcc.gnu.org/}
7192
7193 \end_inset
7194
7195 ), if you need more dedicated options please refer to the GCC\InsetSpace ~
7196 4.1.1\InsetSpace ~
7197 CPP\InsetSpace ~
7198 Manual
7199  at 
7200 \begin_inset LatexCommand \htmlurl{http://www.gnu.org/software/gcc/onlinedocs/}
7201
7202 \end_inset
7203
7204 .
7205 \end_layout
7206
7207 \begin_layout Standard
7208 \begin_inset VSpace bigskip
7209 \end_inset
7210
7211
7212 \end_layout
7213
7214 \begin_layout Subsection
7215 Linker Options
7216 \begin_inset LatexCommand \index{Options linker}
7217
7218 \end_inset
7219
7220
7221 \begin_inset LatexCommand \index{Linker options}
7222
7223 \end_inset
7224
7225
7226 \end_layout
7227
7228 \begin_layout List
7229 \labelwidthstring 00.00.0000
7230
7231 \series bold
7232 -L\InsetSpace ~
7233 -
7234 \series default
7235
7236 \begin_inset ERT
7237 status collapsed
7238
7239 \begin_layout Standard
7240
7241
7242 \backslash
7243 /
7244 \end_layout
7245
7246 \end_inset
7247
7248
7249 \series bold
7250 -lib-path
7251 \begin_inset LatexCommand \index{-\/-lib-path <path>}
7252
7253 \end_inset
7254
7255
7256 \begin_inset LatexCommand \index{-L -\/-lib-path}
7257
7258 \end_inset
7259
7260
7261 \series default
7262 \InsetSpace ~
7263 <absolute path to additional libraries> This option is passed to the linkage
7264  editor's additional libraries
7265 \begin_inset LatexCommand \index{Libraries}
7266
7267 \end_inset
7268
7269  search path.
7270  The path name must be absolute.
7271  Additional library files may be specified in the command line.
7272  See section Compiling programs for more details.
7273 \end_layout
7274
7275 \begin_layout List
7276 \labelwidthstring 00.00.0000
7277
7278 \series bold
7279 -
7280 \begin_inset ERT
7281 status collapsed
7282
7283 \begin_layout Standard
7284
7285
7286 \backslash
7287 /
7288 \end_layout
7289
7290 \end_inset
7291
7292 -xram-loc
7293 \series default
7294
7295 \begin_inset LatexCommand \index{-\/-xram-loc <Value>}
7296
7297 \end_inset
7298
7299 \InsetSpace ~
7300 <Value> The start location of the external ram
7301 \begin_inset LatexCommand \index{xdata (mcs51, ds390 storage class)}
7302
7303 \end_inset
7304
7305 , default value is 0.
7306  The value entered can be in Hexadecimal or Decimal format, e.g.: -
7307 \begin_inset ERT
7308 status collapsed
7309
7310 \begin_layout Standard
7311
7312
7313 \backslash
7314 /
7315 \end_layout
7316
7317 \end_inset
7318
7319 -xram-loc 0x8000 or -
7320 \begin_inset ERT
7321 status collapsed
7322
7323 \begin_layout Standard
7324
7325
7326 \backslash
7327 /
7328 \end_layout
7329
7330 \end_inset
7331
7332 -xram-loc 32768.
7333 \end_layout
7334
7335 \begin_layout List
7336 \labelwidthstring 00.00.0000
7337
7338 \series bold
7339 -
7340 \begin_inset ERT
7341 status collapsed
7342
7343 \begin_layout Standard
7344
7345
7346 \backslash
7347 /
7348 \end_layout
7349
7350 \end_inset
7351
7352 -code-loc
7353 \series default
7354
7355 \begin_inset LatexCommand \index{-\/-code-loc <Value>}
7356
7357 \end_inset
7358
7359 \InsetSpace ~
7360 <Value> The start location of the code
7361 \begin_inset LatexCommand \index{code}
7362
7363 \end_inset
7364
7365  segment, default value 0.
7366  Note when this option is used the interrupt vector table
7367 \begin_inset LatexCommand \index{interrupt vector table}
7368
7369 \end_inset
7370
7371  is also relocated to the given address.
7372  The value entered can be in Hexadecimal or Decimal format, e.g.: -
7373 \begin_inset ERT
7374 status collapsed
7375
7376 \begin_layout Standard
7377
7378
7379 \backslash
7380 /
7381 \end_layout
7382
7383 \end_inset
7384
7385 -code-loc 0x8000 or -
7386 \begin_inset ERT
7387 status collapsed
7388
7389 \begin_layout Standard
7390
7391
7392 \backslash
7393 /
7394 \end_layout
7395
7396 \end_inset
7397
7398 -code-loc 32768.
7399 \end_layout
7400
7401 \begin_layout List
7402 \labelwidthstring 00.00.0000
7403
7404 \series bold
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
7419 \series default
7420
7421 \begin_inset LatexCommand \index{-\/-stack-loc <Value>}
7422
7423 \end_inset
7424
7425 \InsetSpace ~
7426 <Value> By default the stack
7427 \begin_inset LatexCommand \index{stack}
7428
7429 \end_inset
7430
7431  is placed after the data segment.
7432  Using this option the stack can be placed anywhere in the internal memory
7433  space of the 8051.
7434  The value entered can be in Hexadecimal or Decimal format, e.g.
7435  -
7436 \begin_inset ERT
7437 status collapsed
7438
7439 \begin_layout Standard
7440
7441
7442 \backslash
7443 /
7444 \end_layout
7445
7446 \end_inset
7447
7448 -stack-loc 0x20 or -
7449 \begin_inset ERT
7450 status collapsed
7451
7452 \begin_layout Standard
7453
7454
7455 \backslash
7456 /
7457 \end_layout
7458
7459 \end_inset
7460
7461 -stack-loc 32.
7462  Since the sp register is incremented before a push or call, the initial
7463  sp will be set to one byte prior the provided value.
7464  The provided value should not overlap any other memory areas such as used
7465  register banks or the data segment and with enough space for the current
7466  application.
7467  The 
7468 \series bold
7469 -
7470 \begin_inset ERT
7471 status collapsed
7472
7473 \begin_layout Standard
7474
7475
7476 \backslash
7477 /
7478 \end_layout
7479
7480 \end_inset
7481
7482 -pack-iram
7483 \series default
7484 \InsetSpace ~
7485
7486 \begin_inset LatexCommand \index{-\/-pack-iram}
7487
7488 \end_inset
7489
7490  option (which is now a default setting) will override this setting, so
7491  you should also specify the 
7492 \series bold
7493 -
7494 \begin_inset ERT
7495 status collapsed
7496
7497 \begin_layout Standard
7498
7499
7500 \backslash
7501 /
7502 \end_layout
7503
7504 \end_inset
7505
7506 -no-pack-iram
7507 \series default
7508 \InsetSpace ~
7509
7510 \begin_inset LatexCommand \index{-\/-no-pack-iram}
7511
7512 \end_inset
7513
7514  option if you need to manually place the stack.
7515 \end_layout
7516
7517 \begin_layout List
7518 \labelwidthstring 00.00.0000
7519
7520 \series bold
7521 -
7522 \begin_inset ERT
7523 status collapsed
7524
7525 \begin_layout Standard
7526
7527
7528 \backslash
7529 /
7530 \end_layout
7531
7532 \end_inset
7533
7534 -xstack-loc
7535 \series default
7536
7537 \begin_inset LatexCommand \index{-\/-xstack-loc <Value>}
7538
7539 \end_inset
7540
7541 \InsetSpace ~
7542 <Value> By default the external stack
7543 \begin_inset LatexCommand \index{xstack}
7544
7545 \end_inset
7546
7547  is placed after the pdata
7548 \begin_inset LatexCommand \index{pdata (mcs51, ds390 storage class)}
7549
7550 \end_inset
7551
7552  segment.
7553  Using this option the xstack can be placed anywhere in the external memory
7554  space of the 8051.
7555  The value entered can be in Hexadecimal or Decimal format, e.g.
7556  -
7557 \begin_inset ERT
7558 status collapsed
7559
7560 \begin_layout Standard
7561
7562
7563 \backslash
7564 /
7565 \end_layout
7566
7567 \end_inset
7568
7569 -xstack-loc 0x8000 or -
7570 \begin_inset ERT
7571 status collapsed
7572
7573 \begin_layout Standard
7574
7575
7576 \backslash
7577 /
7578 \end_layout
7579
7580 \end_inset
7581
7582 -stack-loc 32768.
7583  The provided value should not overlap any other memory areas such as the
7584  pdata or xdata segment and with enough space for the current application.
7585 \end_layout
7586
7587 \begin_layout List
7588 \labelwidthstring 00.00.0000
7589
7590 \series bold
7591 -
7592 \begin_inset ERT
7593 status collapsed
7594
7595 \begin_layout Standard
7596
7597
7598 \backslash
7599 /
7600 \end_layout
7601
7602 \end_inset
7603
7604 -data-loc
7605 \series default
7606
7607 \begin_inset LatexCommand \index{-\/-data-loc <Value>}
7608
7609 \end_inset
7610
7611 \InsetSpace ~
7612 <Value> The start location of the internal ram data
7613 \begin_inset LatexCommand \index{data (mcs51, ds390 storage class)}
7614
7615 \end_inset
7616
7617  segment.
7618  The value entered can be in Hexadecimal or Decimal format, eg.
7619  -
7620 \begin_inset ERT
7621 status collapsed
7622
7623 \begin_layout Standard
7624
7625
7626 \backslash
7627 /
7628 \end_layout
7629
7630 \end_inset
7631
7632 -data-loc 0x20 or -
7633 \begin_inset ERT
7634 status collapsed
7635
7636 \begin_layout Standard
7637
7638
7639 \backslash
7640 /
7641 \end_layout
7642
7643 \end_inset
7644
7645 -data-loc 32.
7646  (By default, the start location of the internal ram data segment  is set
7647  as low as possible in memory, taking into account the used register banks
7648  and the bit segment at address 0x20.
7649  For example if register banks 0 and 1 are used without bit variables, the
7650  data segment will be set, if -
7651 \begin_inset ERT
7652 status collapsed
7653
7654 \begin_layout Standard
7655
7656
7657 \backslash
7658 /
7659 \end_layout
7660
7661 \end_inset
7662
7663 -data-loc is not used, to location 0x10.)
7664 \end_layout
7665
7666 \begin_layout List
7667 \labelwidthstring 00.00.0000
7668
7669 \series bold
7670 -
7671 \begin_inset ERT
7672 status collapsed
7673
7674 \begin_layout Standard
7675
7676
7677 \backslash
7678 /
7679 \end_layout
7680
7681 \end_inset
7682
7683 -idata-loc
7684 \series default
7685
7686 \begin_inset LatexCommand \index{-\/-idata-loc <Value>}
7687
7688 \end_inset
7689
7690 \InsetSpace ~
7691 <Value> The start location of the indirectly addressable internal ram
7692 \begin_inset LatexCommand \index{idata (mcs51, ds390 storage class)}
7693
7694 \end_inset
7695
7696  of the 8051, default value is 0x80.
7697  The value entered can be in Hexadecimal or Decimal format, eg.
7698  -
7699 \begin_inset ERT
7700 status collapsed
7701
7702 \begin_layout Standard
7703
7704
7705 \backslash
7706 /
7707 \end_layout
7708
7709 \end_inset
7710
7711 -idata-loc 0x88 or -
7712 \begin_inset ERT
7713 status collapsed
7714
7715 \begin_layout Standard
7716
7717
7718 \backslash
7719 /
7720 \end_layout
7721
7722 \end_inset
7723
7724 -idata-loc 136.
7725 \end_layout
7726
7727 \begin_layout List
7728 \labelwidthstring 00.00.0000
7729
7730 \series bold
7731 -
7732 \begin_inset ERT
7733 status collapsed
7734
7735 \begin_layout Standard
7736
7737
7738 \backslash
7739 /
7740 \end_layout
7741
7742 \end_inset
7743
7744 -bit-loc
7745 \series default
7746 \InsetSpace ~
7747 <Value> The start location of the bit
7748 \begin_inset LatexCommand \index{bit}
7749
7750 \end_inset
7751
7752  addressable internal ram of the 8051.
7753  This is 
7754 \emph on
7755 not
7756 \emph default
7757  implemented yet.
7758  Instead an option can be passed directly to the linker: -Wl\InsetSpace ~
7759 -bBSEG=<Value>.
7760 \end_layout
7761
7762 \begin_layout List
7763 \labelwidthstring 00.00.0000
7764
7765 \series bold
7766 -
7767 \begin_inset ERT
7768 status collapsed
7769
7770 \begin_layout Standard
7771
7772
7773 \backslash
7774 /
7775 \end_layout
7776
7777 \end_inset
7778
7779 -out-fmt-ihx
7780 \begin_inset LatexCommand \index{-\/-out-fmt-ihx}
7781
7782 \end_inset
7783
7784
7785 \bar under
7786  
7787 \series default
7788 \bar default
7789 The linker output (final object code) is in Intel Hex format.
7790 \begin_inset LatexCommand \index{Intel hex format}
7791
7792 \end_inset
7793
7794  This is the default option.
7795  The format itself is documented in the documentation of srecord
7796 \begin_inset LatexCommand \index{srecord (bin, hex, ... tool)}
7797
7798 \end_inset
7799
7800 .
7801 \end_layout
7802
7803 \begin_layout List
7804 \labelwidthstring 00.00.0000
7805
7806 \series bold
7807 -
7808 \begin_inset ERT
7809 status collapsed
7810
7811 \begin_layout Standard
7812
7813
7814 \backslash
7815 /
7816 \end_layout
7817
7818 \end_inset
7819
7820 -out-fmt-s19
7821 \begin_inset LatexCommand \index{-\/-out-fmt-s19}
7822
7823 \end_inset
7824
7825
7826 \bar under
7827  
7828 \series default
7829 \bar default
7830 The linker output (final object code) is in Motorola S19 format
7831 \begin_inset LatexCommand \index{Motorola S19 format}
7832
7833 \end_inset
7834
7835 .
7836  The format itself is documented in the documentation of srecord.
7837 \end_layout
7838
7839 \begin_layout List
7840 \labelwidthstring 00.00.0000
7841
7842 \series bold
7843 -
7844 \begin_inset ERT
7845 status collapsed
7846
7847 \begin_layout Standard
7848
7849
7850 \backslash
7851 /
7852 \end_layout
7853
7854 \end_inset
7855
7856 -out-fmt-elf
7857 \begin_inset LatexCommand \index{-\/-out-fmt-s19}
7858
7859 \end_inset
7860
7861
7862 \begin_inset LatexCommand \index{HC08!Options!-\/-out-fmt-elf}
7863
7864 \end_inset
7865
7866
7867 \bar under
7868  
7869 \series default
7870 \bar default
7871 The linker output (final object code) is in ELF format
7872 \begin_inset LatexCommand \index{ELF format}
7873
7874 \end_inset
7875
7876 .
7877  (Currently only supported for the HC08
7878 \begin_inset LatexCommand \index{HC08}
7879
7880 \end_inset
7881
7882  processors)
7883 \end_layout
7884
7885 \begin_layout List
7886 \labelwidthstring 00.00.0000
7887
7888 \series bold
7889 -Wl\InsetSpace ~
7890 linkOption[,linkOption]
7891 \series default
7892
7893 \begin_inset LatexCommand \index{-Wl linkOption[,linkOption]}
7894
7895 \end_inset
7896
7897 ...
7898  Pass the linkOption to the linker.
7899  If a bootloader is used an option like 
7900 \begin_inset Quotes sld
7901 \end_inset
7902
7903 -Wl\InsetSpace ~
7904 -bCSEG=0x1000
7905 \begin_inset Quotes srd
7906 \end_inset
7907
7908  would be typical to set the start of the code segment.
7909  See also #pragma constseg and #pragma codeseg in section 
7910 \begin_inset LatexCommand \ref{sec:Pragmas}
7911
7912 \end_inset
7913
7914  .
7915  File sdcc/as/doc/asxhtm.html has more on linker options.
7916 \end_layout
7917
7918 \begin_layout Standard
7919 \begin_inset VSpace bigskip
7920 \end_inset
7921
7922
7923 \end_layout
7924
7925 \begin_layout Subsection
7926 MCS51 Options
7927 \begin_inset LatexCommand \index{Options MCS51}
7928
7929 \end_inset
7930
7931
7932 \begin_inset LatexCommand \index{MCS51 options}
7933
7934 \end_inset
7935
7936
7937 \end_layout
7938
7939 \begin_layout List
7940 \labelwidthstring 00.00.0000
7941
7942 \series bold
7943 -
7944 \begin_inset ERT
7945 status collapsed
7946
7947 \begin_layout Standard
7948
7949
7950 \backslash
7951 /
7952 \end_layout
7953
7954 \end_inset
7955
7956 -model-small
7957 \begin_inset LatexCommand \index{-\/-model-small}
7958
7959 \end_inset
7960
7961
7962 \series default
7963 \size large
7964 \emph on
7965  
7966 \size default
7967 \emph default
7968 Generate code for Small Model programs, see section Memory Models for more
7969  details.
7970  This is the default model.
7971 \end_layout
7972
7973 \begin_layout List
7974 \labelwidthstring 00.00.0000
7975
7976 \series bold
7977 -
7978 \begin_inset ERT
7979 status collapsed
7980
7981 \begin_layout Standard
7982
7983
7984 \backslash
7985 /
7986 \end_layout
7987
7988 \end_inset
7989
7990 -model-medium
7991 \begin_inset LatexCommand \index{-\/-model-medium}
7992
7993 \end_inset
7994
7995
7996 \series default
7997  Generate code for Medium model programs, see section Memory Models for
7998  more details.
7999  If this option is used all source files in the project have to be compiled
8000  with this option.
8001  It must also be used when invoking the linker.
8002 \end_layout
8003
8004 \begin_layout List
8005 \labelwidthstring 00.00.0000
8006
8007 \series bold
8008 -
8009 \begin_inset ERT
8010 status collapsed
8011
8012 \begin_layout Standard
8013
8014
8015 \backslash
8016 /
8017 \end_layout
8018
8019 \end_inset
8020
8021 -model-large
8022 \begin_inset LatexCommand \index{-\/-model-large}
8023
8024 \end_inset
8025
8026
8027 \series default
8028  Generate code for Large model programs, see section Memory Models for more
8029  details.
8030  If this option is used all source files in the project have to be compiled
8031  with this option.
8032  It must also be used when invoking the linker.
8033 \end_layout
8034
8035 \begin_layout List
8036 \labelwidthstring 00.00.0000
8037
8038 \series bold
8039 -
8040 \begin_inset ERT
8041 status collapsed
8042
8043 \begin_layout Standard
8044
8045
8046 \backslash
8047 /
8048 \end_layout
8049
8050 \end_inset
8051
8052 -xstack
8053 \begin_inset LatexCommand \index{-\/-xstack}
8054
8055 \end_inset
8056
8057
8058 \series default
8059  Uses a pseudo stack in the pdata
8060 \begin_inset LatexCommand \index{pdata (mcs51, ds390 storage class)}
8061
8062 \end_inset
8063
8064  area (usually the first 256 bytes in the external ram) for allocating variables
8065  and passing parameters.
8066  See section 
8067 \begin_inset LatexCommand \ref{sub:External-Stack}
8068
8069 \end_inset
8070
8071 \InsetSpace ~
8072  External Stack for more details.
8073 \end_layout
8074
8075 \begin_layout List
8076 \labelwidthstring 00.00.0000
8077
8078 \series bold
8079 -
8080 \begin_inset ERT
8081 status collapsed
8082
8083 \begin_layout Standard
8084
8085
8086 \backslash
8087 /
8088 \end_layout
8089
8090 \end_inset
8091
8092 -iram-size
8093 \series default
8094 \InsetSpace ~
8095 <Value>
8096 \begin_inset LatexCommand \index{-\/-iram-size <Value>}
8097
8098 \end_inset
8099
8100  Causes the linker to check if the internal ram usage is within limits of
8101  the given value.
8102 \end_layout
8103
8104 \begin_layout List
8105 \labelwidthstring 00.00.0000
8106
8107 \series bold
8108 -
8109 \begin_inset ERT
8110 status collapsed
8111
8112 \begin_layout Standard
8113
8114
8115 \backslash
8116 /
8117 \end_layout
8118
8119 \end_inset
8120
8121 -xram-size
8122 \series default
8123 \InsetSpace ~
8124 <Value>
8125 \begin_inset LatexCommand \index{-\/-xram-size <Value>}
8126
8127 \end_inset
8128
8129  Causes the linker to check if the external ram usage is within limits of
8130  the given value.
8131 \end_layout
8132
8133 \begin_layout List
8134 \labelwidthstring 00.00.0000
8135
8136 \series bold
8137 -
8138 \begin_inset ERT
8139 status collapsed
8140
8141 \begin_layout Standard
8142
8143
8144 \backslash
8145 /
8146 \end_layout
8147
8148 \end_inset
8149
8150 -code-size
8151 \series default
8152 \InsetSpace ~
8153 <Value>
8154 \begin_inset LatexCommand \index{-\/-code-size <Value>}
8155
8156 \end_inset
8157
8158  Causes the linker to check if the code memory usage is within limits of
8159  the given value.
8160 \end_layout
8161
8162 \begin_layout List
8163 \labelwidthstring 00.00.0000
8164
8165 \series bold
8166 -
8167 \begin_inset ERT
8168 status collapsed
8169
8170 \begin_layout Standard
8171
8172
8173 \backslash
8174 /
8175 \end_layout
8176
8177 \end_inset
8178
8179 -stack-size
8180 \series default
8181 \InsetSpace ~
8182 <Value>
8183 \begin_inset LatexCommand \index{-\/-stack-size <Value>}
8184
8185 \end_inset
8186
8187  Causes the linker to check if there is at minimum <Value> bytes for stack.
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 -pack-iram
8208 \series default
8209 \InsetSpace ~
8210
8211 \begin_inset LatexCommand \index{-\/-pack-iram}
8212
8213 \end_inset
8214
8215  Causes the linker to use unused register banks for data variables and pack
8216  data, idata and stack together.
8217  This is the default now.
8218 \end_layout
8219
8220 \begin_layout List
8221 \labelwidthstring 00.00.0000
8222
8223 \series bold
8224 -
8225 \begin_inset ERT
8226 status collapsed
8227
8228 \begin_layout Standard
8229
8230
8231 \backslash
8232 /
8233 \end_layout
8234
8235 \end_inset
8236
8237 -no-pack-iram
8238 \series default
8239 \InsetSpace ~
8240
8241 \begin_inset LatexCommand \index{-\/-no-pack-iram}
8242
8243 \end_inset
8244
8245  Causes the linker to use old style for allocating memory areas.
8246 \end_layout
8247
8248 \begin_layout List
8249 \labelwidthstring 00.00.0000
8250
8251 \series bold
8252 -
8253 \begin_inset ERT
8254 status collapsed
8255
8256 \begin_layout Standard
8257
8258
8259 \backslash
8260 /
8261 \end_layout
8262
8263 \end_inset
8264
8265 -acall-ajmp
8266 \series default
8267 \InsetSpace ~
8268
8269 \begin_inset LatexCommand \index{-\/-acall-ajmp}
8270
8271 \end_inset
8272
8273  Replaces the three byte instructions lcall/ljmp with the two byte instructions
8274  acall/ajmp.
8275  Only use this option if your code is in the same 2k block of memory.
8276  You may need to use this option for some 8051 derivatives which lack the
8277  lcall/ljmp instructions..
8278 \end_layout
8279
8280 \begin_layout Standard
8281 \begin_inset VSpace bigskip
8282 \end_inset
8283
8284
8285 \end_layout
8286
8287 \begin_layout Subsection
8288 DS390 / DS400 Options
8289 \begin_inset LatexCommand \index{Options DS390}
8290
8291 \end_inset
8292
8293
8294 \begin_inset LatexCommand \index{DS390}
8295
8296 \end_inset
8297
8298
8299 \end_layout
8300
8301 \begin_layout List
8302 \labelwidthstring 00.00.0000
8303
8304 \series bold
8305 -
8306 \begin_inset ERT
8307 status collapsed
8308
8309 \begin_layout Standard
8310
8311
8312 \backslash
8313 /
8314 \end_layout
8315
8316 \end_inset
8317
8318 -model-flat24
8319 \series default
8320
8321 \begin_inset LatexCommand \index{DS390!Options!-\/-model-flat24}
8322
8323 \end_inset
8324
8325
8326 \size large
8327 \emph on
8328  
8329 \size default
8330 \emph default
8331 Generate 24-bit flat mode code.
8332  This is the one and only that the ds390 code generator supports right now
8333  and is default when using 
8334 \emph on
8335 -mds390
8336 \emph default
8337 .
8338  See section Memory Models for more details.
8339 \end_layout
8340
8341 \begin_layout List
8342 \labelwidthstring 00.00.0000
8343
8344 \series bold
8345 -
8346 \begin_inset ERT
8347 status collapsed
8348
8349 \begin_layout Standard
8350
8351
8352 \backslash
8353 /
8354 \end_layout
8355
8356 \end_inset
8357
8358 -protect-sp-update
8359 \begin_inset LatexCommand \index{DS390!Options!-\/-protect-sp-update}
8360
8361 \end_inset
8362
8363
8364 \series default
8365  disable interrupts during ESP:SP updates.
8366 \end_layout
8367
8368 \begin_layout List
8369 \labelwidthstring 00.00.0000
8370
8371 \series bold
8372 -
8373 \begin_inset ERT
8374 status collapsed
8375
8376 \begin_layout Standard
8377
8378
8379 \backslash
8380 /
8381 \end_layout
8382
8383 \end_inset
8384
8385 -stack-10bit
8386 \series default
8387
8388 \begin_inset LatexCommand \index{DS390!Options!-\/-stack-10bit}
8389
8390 \end_inset
8391
8392  Generate code for the 10 bit stack mode of the Dallas DS80C390 part.
8393  This is the one and only that the ds390 code generator supports right now
8394  and is default when using 
8395 \emph on
8396 -mds390
8397 \emph default
8398 .
8399  In this mode, the stack is located in the lower 1K of the internal RAM,
8400  which is mapped to 0x400000.
8401  Note that the support is incomplete, since it still uses a single byte
8402  as the stack pointer.
8403  This means that only the lower 256 bytes of the potential 1K stack space
8404  will actually be used.
8405  However, this does allow you to reclaim the precious 256 bytes of low RAM
8406  for use for the DATA and IDATA segments.
8407  The compiler will not generate any code to put the processor into 10 bit
8408  stack mode.
8409  It is important to ensure that the processor is in this mode before calling
8410  any re-entrant functions compiled with this option.
8411  In principle, this should work with the 
8412 \emph on
8413 -
8414 \begin_inset ERT
8415 status collapsed
8416
8417 \begin_layout Standard
8418
8419
8420 \backslash
8421 /
8422 \end_layout
8423
8424 \end_inset
8425
8426 -stack-auto
8427 \begin_inset LatexCommand \index{-\/-stack-auto}
8428
8429 \end_inset
8430
8431
8432 \emph default
8433  option, but that has not been tested.
8434  It is incompatible with the 
8435 \emph on
8436 -
8437 \begin_inset ERT
8438 status collapsed
8439
8440 \begin_layout Standard
8441
8442
8443 \backslash
8444 /
8445 \end_layout
8446
8447 \end_inset
8448
8449 -xstack
8450 \begin_inset LatexCommand \index{-\/-xstack}
8451
8452 \end_inset
8453
8454
8455 \emph default
8456  option.
8457  It also only makes sense if the processor is in 24 bit contiguous addressing
8458  mode (see the 
8459 \emph on
8460 -
8461 \begin_inset ERT
8462 status collapsed
8463
8464 \begin_layout Standard
8465
8466
8467 \backslash
8468 /
8469 \end_layout
8470
8471 \end_inset
8472
8473 -model-flat24 option
8474 \emph default
8475 ).
8476 \series bold
8477
8478 \begin_inset Note Note
8479 status collapsed
8480
8481 \begin_layout List
8482 \labelwidthstring 00.00.0000
8483
8484 \series bold
8485 -
8486 \begin_inset ERT
8487 status open
8488
8489 \begin_layout Standard
8490
8491
8492 \backslash
8493 /
8494 \end_layout
8495
8496 \end_inset
8497
8498 -stack-8-bit - switches off the 10-bit mode
8499 \end_layout
8500
8501 \end_inset
8502
8503
8504 \end_layout
8505
8506 \begin_layout List
8507 \labelwidthstring 00.00.0000
8508
8509 \series bold
8510 -
8511 \begin_inset ERT
8512 status collapsed
8513
8514 \begin_layout Standard
8515
8516
8517 \backslash
8518 /
8519 \end_layout
8520
8521 \end_inset
8522
8523 -stack-probe
8524 \begin_inset LatexCommand \index{DS390!Options!-\/-stack-probe}
8525
8526 \end_inset
8527
8528
8529 \series default
8530  insert call to function __stack_probe at each function prologue.
8531 \end_layout
8532
8533 \begin_layout List
8534 \labelwidthstring 00.00.0000
8535
8536 \series bold
8537 -
8538 \begin_inset ERT
8539 status open
8540
8541 \begin_layout Standard
8542
8543
8544 \backslash
8545 /
8546 \end_layout
8547
8548 \end_inset
8549
8550 -tini-libid
8551 \begin_inset LatexCommand \index{DS390!Options!-\/-tini-libid}
8552
8553 \end_inset
8554
8555
8556 \series default
8557  <nnnn> LibraryID used in -mTININative.
8558  
8559 \end_layout
8560
8561 \begin_layout List
8562 \labelwidthstring 00.00.0000
8563
8564 \series bold
8565 -
8566 \begin_inset ERT
8567 status collapsed
8568
8569 \begin_layout Standard
8570
8571
8572 \backslash
8573 /
8574 \end_layout
8575
8576 \end_inset
8577
8578 -use-accelerator
8579 \begin_inset LatexCommand \index{DS390!Options!-\/-use-accelerator}
8580
8581 \end_inset
8582
8583
8584 \series default
8585  generate code for DS390 Arithmetic Accelerator.
8586  
8587 \end_layout
8588
8589 \begin_layout Standard
8590 \begin_inset VSpace bigskip
8591 \end_inset
8592
8593
8594 \end_layout
8595
8596 \begin_layout Subsection
8597 Z80 Options
8598 \begin_inset LatexCommand \index{Options Z80}
8599
8600 \end_inset
8601
8602
8603 \begin_inset LatexCommand \index{Z80}
8604
8605 \end_inset
8606
8607
8608 \end_layout
8609
8610 \begin_layout List
8611 \labelwidthstring 00.00.0000
8612
8613 \series bold
8614 -
8615 \begin_inset ERT
8616 status collapsed
8617
8618 \begin_layout Standard
8619
8620
8621 \backslash
8622 /
8623 \end_layout
8624
8625 \end_inset
8626
8627 -callee-saves-bc
8628 \series default
8629
8630 \begin_inset LatexCommand \index{Z80!Options!-\/-callee-saves-bc}
8631
8632 \end_inset
8633
8634
8635 \size large
8636 \emph on
8637  
8638 \size default
8639 \emph default
8640 Force a called function to always save BC.
8641 \end_layout
8642
8643 \begin_layout List
8644 \labelwidthstring 00.00.0000
8645
8646 \series bold
8647 -
8648 \begin_inset ERT
8649 status collapsed
8650
8651 \begin_layout Standard
8652
8653
8654 \backslash
8655 /
8656 \end_layout
8657
8658 \end_inset
8659
8660 -no-std-crt0
8661 \series default
8662
8663 \begin_inset LatexCommand \index{Z80!Options!-\/-no-std-crt0}
8664
8665 \end_inset
8666
8667  When linking, skip the standard crt0.o object file.
8668  You must provide your own crt0.o for your system when linking.
8669 \end_layout
8670
8671 \begin_layout List
8672 \labelwidthstring 00.00.0000
8673
8674 \series bold
8675 -
8676 \begin_inset ERT
8677 status collapsed
8678
8679 \begin_layout Standard
8680
8681
8682 \backslash
8683 /
8684 \end_layout
8685
8686 \end_inset
8687
8688 -portmode=
8689 \series default
8690 <Value>
8691 \begin_inset LatexCommand \index{Z80!Options!-\/-portmode=<Value>}
8692
8693 \end_inset
8694
8695  Determinate PORT I/O mode (<Value> is z80 or z180).
8696 \end_layout
8697
8698 \begin_layout List
8699 \labelwidthstring 00.00.0000
8700
8701 \series bold
8702 -
8703 \begin_inset ERT
8704 status collapsed
8705
8706 \begin_layout Standard
8707
8708
8709 \backslash
8710 /
8711 \end_layout
8712
8713 \end_inset
8714
8715 -asm=
8716 \series default
8717 <Value>
8718 \begin_inset LatexCommand \index{Z80!Options!-\/-asm=<Value>}
8719
8720 \end_inset
8721
8722  Define assembler name (<Value> is rgbds, asxxxx, isas or z80asm).
8723 \end_layout
8724
8725 \begin_layout List
8726 \labelwidthstring 00.00.0000
8727
8728 \series bold
8729 -
8730 \begin_inset ERT
8731 status collapsed
8732
8733 \begin_layout Standard
8734
8735
8736 \backslash
8737 /
8738 \end_layout
8739
8740 \end_inset
8741
8742 -codeseg
8743 \series default
8744 \InsetSpace ~
8745 <Value>
8746 \begin_inset LatexCommand \index{Z80!Options!-\/-codeseg <Value>}
8747
8748 \end_inset
8749
8750  Use <Value> for the code segment name.
8751 \end_layout
8752
8753 \begin_layout List
8754 \labelwidthstring 00.00.0000
8755
8756 \series bold
8757 -
8758 \begin_inset ERT
8759 status collapsed
8760
8761 \begin_layout Standard
8762
8763
8764 \backslash
8765 /
8766 \end_layout
8767
8768 \end_inset
8769
8770 -constseg
8771 \series default
8772 \InsetSpace ~
8773 <Value>
8774 \begin_inset LatexCommand \index{Z80!Options!-\/-constseg <Value>}
8775
8776 \end_inset
8777
8778  Use <Value> for the const segment name.
8779 \end_layout
8780
8781 \begin_layout List
8782 \labelwidthstring 00.00.0000
8783 \begin_inset VSpace bigskip
8784 \end_inset
8785
8786
8787 \end_layout
8788
8789 \begin_layout Subsection
8790 GBZ80 Options
8791 \begin_inset LatexCommand \index{Options GBZ80}
8792
8793 \end_inset
8794
8795
8796 \begin_inset LatexCommand \index{GBZ80}
8797
8798 \end_inset
8799
8800
8801 \end_layout
8802
8803 \begin_layout List
8804 \labelwidthstring 00.00.0000
8805
8806 \series bold
8807 -
8808 \begin_inset ERT
8809 status collapsed
8810
8811 \begin_layout Standard
8812
8813
8814 \backslash
8815 /
8816 \end_layout
8817
8818 \end_inset
8819
8820 -callee-saves-bc
8821 \series default
8822
8823 \begin_inset LatexCommand \index{GBZ80!Options!-\/-callee-saves-bc}
8824
8825 \end_inset
8826
8827
8828 \size large
8829 \emph on
8830  
8831 \size default
8832 \emph default
8833 Force a called function to always save BC.
8834 \end_layout
8835
8836 \begin_layout List
8837 \labelwidthstring 00.00.0000
8838
8839 \series bold
8840 -bo
8841 \series default
8842 \InsetSpace ~
8843 <Num>
8844 \begin_inset LatexCommand \index{GBZ80!Options!-bo <Num>}
8845
8846 \end_inset
8847
8848  Use code bank <Num>.
8849 \end_layout
8850
8851 \begin_layout List
8852 \labelwidthstring 00.00.0000
8853
8854 \series bold
8855 -ba
8856 \series default
8857 \InsetSpace ~
8858 <Num>
8859 \begin_inset LatexCommand \index{GBZ80!Options!-ba <Num>}
8860
8861 \end_inset
8862
8863  Use data bank <Num>.
8864 \end_layout
8865
8866 \begin_layout List
8867 \labelwidthstring 00.00.0000
8868
8869 \series bold
8870 -
8871 \begin_inset ERT
8872 status collapsed
8873
8874 \begin_layout Standard
8875
8876
8877 \backslash
8878 /
8879 \end_layout
8880
8881 \end_inset
8882
8883 -codeseg
8884 \series default
8885 \InsetSpace ~
8886 <Value>
8887 \begin_inset LatexCommand \index{GBZ80!Options!-\/-codeseg <Value>}
8888
8889 \end_inset
8890
8891  Use <Value> for the code segment name.
8892 \end_layout
8893
8894 \begin_layout List
8895 \labelwidthstring 00.00.0000
8896
8897 \series bold
8898 -
8899 \begin_inset ERT
8900 status collapsed
8901
8902 \begin_layout Standard
8903
8904
8905 \backslash
8906 /
8907 \end_layout
8908
8909 \end_inset
8910
8911 -constseg
8912 \series default
8913 \InsetSpace ~
8914 <Value>
8915 \begin_inset LatexCommand \index{GBZ80!Options!-\/-constseg <Value>}
8916
8917 \end_inset
8918
8919  Use <Value> for the const segment name.
8920 \end_layout
8921
8922 \begin_layout Standard
8923 \begin_inset VSpace bigskip
8924 \end_inset
8925
8926
8927 \end_layout
8928
8929 \begin_layout Subsection
8930 Optimization Options
8931 \begin_inset LatexCommand \index{Options optimization}
8932
8933 \end_inset
8934
8935
8936 \begin_inset LatexCommand \index{Optimization options}
8937
8938 \end_inset
8939
8940
8941 \end_layout
8942
8943 \begin_layout List
8944 \labelwidthstring 00.00.0000
8945
8946 \series bold
8947 -
8948 \begin_inset ERT
8949 status collapsed
8950
8951 \begin_layout Standard
8952
8953
8954 \backslash
8955 /
8956 \end_layout
8957
8958 \end_inset
8959
8960 -nogcse
8961 \begin_inset LatexCommand \index{-\/-nogcse}
8962
8963 \end_inset
8964
8965
8966 \series default
8967  Will not do global subexpression elimination, this option may be used when
8968  the compiler creates undesirably large stack/data spaces to store compiler
8969  temporaries (
8970 \emph on
8971 s
8972 \emph default
8973 pill 
8974 \emph on
8975 loc
8976 \emph default
8977 ations, sloc
8978 \begin_inset LatexCommand \index{sloc (spill location)}
8979
8980 \end_inset
8981
8982 ).
8983  A warning message will be generated when this happens and the compiler
8984  will indicate the number of extra bytes it allocated.
8985  It is recommended that this option NOT be used, #pragma\InsetSpace ~
8986 nogcse
8987 \begin_inset LatexCommand \index{\#pragma nogcse}
8988
8989 \end_inset
8990
8991  can be used to turn off global subexpression elimination
8992 \begin_inset LatexCommand \index{Subexpression elimination}
8993
8994 \end_inset
8995
8996  for a given function only.
8997 \end_layout
8998
8999 \begin_layout List
9000 \labelwidthstring 00.00.0000
9001
9002 \series bold
9003 -
9004 \begin_inset ERT
9005 status collapsed
9006
9007 \begin_layout Standard
9008
9009
9010 \backslash
9011 /
9012 \end_layout
9013
9014 \end_inset
9015
9016 -noinvariant
9017 \begin_inset LatexCommand \index{-\/-noinvariant}
9018
9019 \end_inset
9020
9021
9022 \series default
9023  Will not do loop invariant optimizations, this may be turned off for reasons
9024  explained for the previous option.
9025  For more details of loop optimizations performed see Loop Invariants in
9026  section 
9027 \begin_inset LatexCommand \ref{sub:Loop-Optimizations}
9028
9029 \end_inset
9030
9031 .
9032  It is recommended that this option NOT be used, #pragma\InsetSpace ~
9033 noinvariant
9034 \begin_inset LatexCommand \index{\#pragma noinvariant}
9035
9036 \end_inset
9037
9038  can be used to turn off invariant optimizations for a given function only.
9039 \end_layout
9040
9041 \begin_layout List
9042 \labelwidthstring 00.00.0000
9043
9044 \series bold
9045 -
9046 \begin_inset ERT
9047 status collapsed
9048
9049 \begin_layout Standard
9050
9051
9052 \backslash
9053 /
9054 \end_layout
9055
9056 \end_inset
9057
9058 -noinduction
9059 \begin_inset LatexCommand \index{-\/-noinduction}
9060
9061 \end_inset
9062
9063
9064 \series default
9065  Will not do loop induction optimizations, see section strength reduction
9066  for more details.
9067  It is recommended that this option is NOT used, #pragma\InsetSpace ~
9068 noinduction
9069 \begin_inset LatexCommand \index{\#pragma noinduction}
9070
9071 \end_inset
9072
9073  can be used to turn off induction optimizations for a given function only.
9074 \end_layout
9075
9076 \begin_layout List
9077 \labelwidthstring 00.00.0000
9078
9079 \series bold
9080 -
9081 \begin_inset ERT
9082 status collapsed
9083
9084 \begin_layout Standard
9085
9086
9087 \backslash
9088 /
9089 \end_layout
9090
9091 \end_inset
9092
9093 -nojtbound
9094 \begin_inset LatexCommand \index{-\/-nojtbound}
9095
9096 \end_inset
9097
9098
9099 \size large
9100 \bar under
9101  
9102 \series default
9103 \size default
9104 \bar default
9105  Will not generate boundary condition check when switch statements
9106 \begin_inset LatexCommand \index{switch statement}
9107
9108 \end_inset
9109
9110  are implemented using jump-tables.
9111  See section 
9112 \begin_inset LatexCommand \ref{sub:'switch'-Statements}
9113
9114 \end_inset
9115
9116 \InsetSpace ~
9117 Switch Statements for more details.
9118  It is recommended that this option is NOT used, #pragma\InsetSpace ~
9119 nojtbound
9120 \begin_inset LatexCommand \index{\#pragma nojtbound}
9121
9122 \end_inset
9123
9124  can be used to turn off boundary checking for jump tables for a given function
9125  only.
9126 \end_layout
9127
9128 \begin_layout List
9129 \labelwidthstring 00.00.0000
9130
9131 \series bold
9132 -
9133 \begin_inset ERT
9134 status collapsed
9135
9136 \begin_layout Standard
9137
9138
9139 \backslash
9140 /
9141 \end_layout
9142
9143 \end_inset
9144
9145 -noloopreverse
9146 \begin_inset LatexCommand \index{-\/-noloopreverse}
9147
9148 \end_inset
9149
9150
9151 \series default
9152 \size large
9153  
9154 \size default
9155 Will not do loop reversal 
9156 \begin_inset LatexCommand \index{Loop reversing}
9157
9158 \end_inset
9159
9160 optimization.
9161 \end_layout
9162
9163 \begin_layout List
9164 \labelwidthstring 00.00.0000
9165 -
9166 \begin_inset ERT
9167 status collapsed
9168
9169 \begin_layout Standard
9170
9171
9172 \backslash
9173 /
9174 \end_layout
9175
9176 \end_inset
9177
9178 -
9179 \series bold
9180 nolabelopt
9181 \series default
9182  
9183 \begin_inset LatexCommand \index{-\/-nolabelopt }
9184
9185 \end_inset
9186
9187 Will not optimize labels (makes the dumpfiles more readable).
9188 \end_layout
9189
9190 \begin_layout List
9191 \labelwidthstring 00.00.0000
9192
9193 \series bold
9194 -
9195 \begin_inset ERT
9196 status collapsed
9197
9198 \begin_layout Standard
9199
9200
9201 \backslash
9202 /
9203 \end_layout
9204
9205 \end_inset
9206
9207 -no-xinit-opt
9208 \begin_inset LatexCommand \index{-\/-no-xinit-opt}
9209
9210 \end_inset
9211
9212
9213 \series default
9214  Will not memcpy initialized data from code space into xdata space.
9215  This saves a few bytes in code space if you don't have initialized data
9216 \begin_inset LatexCommand \index{Variable initialization}
9217
9218 \end_inset
9219
9220 .
9221 \end_layout
9222
9223 \begin_layout List
9224 \labelwidthstring 00.00.0000
9225
9226 \series bold
9227 -
9228 \begin_inset ERT
9229 status collapsed
9230
9231 \begin_layout Standard
9232
9233
9234 \backslash
9235 /
9236 \end_layout
9237
9238 \end_inset
9239
9240 -nooverlay
9241 \begin_inset LatexCommand \index{-\/-nooverlay}
9242
9243 \end_inset
9244
9245
9246 \series default
9247   The compiler will not overlay parameters and local variables of any function,
9248  see section Parameters and local variables for more details.
9249 \end_layout
9250
9251 \begin_layout List
9252 \labelwidthstring 00.00.0000
9253
9254 \series bold
9255 -
9256 \begin_inset ERT
9257 status collapsed
9258
9259 \begin_layout Standard
9260
9261
9262 \backslash
9263 /
9264 \end_layout
9265
9266 \end_inset
9267
9268 -no-peep
9269 \begin_inset LatexCommand \index{-\/-no-peep}
9270
9271 \end_inset
9272
9273
9274 \series default
9275  Disable peep-hole optimization with built-in rules.
9276 \end_layout
9277
9278 \begin_layout List
9279 \labelwidthstring 00.00.0000
9280
9281 \series bold
9282 -
9283 \begin_inset ERT
9284 status collapsed
9285
9286 \begin_layout Standard
9287
9288
9289 \backslash
9290 /
9291 \end_layout
9292
9293 \end_inset
9294
9295 -peep-file
9296 \series default
9297
9298 \begin_inset LatexCommand \index{-\/-peep-file}
9299
9300 \end_inset
9301
9302 \InsetSpace ~
9303 <filename> This option can be used to use additional rules to be used by
9304  the peep hole optimizer.
9305  See section 
9306 \begin_inset LatexCommand \ref{sub:Peephole-Optimizer}
9307
9308 \end_inset
9309
9310 \InsetSpace ~
9311 Peep Hole optimizations for details on how to write these rules.
9312 \end_layout
9313
9314 \begin_layout List
9315 \labelwidthstring 00.00.0000
9316
9317 \series bold
9318 -
9319 \begin_inset ERT
9320 status collapsed
9321
9322 \begin_layout Standard
9323
9324
9325 \backslash
9326 /
9327 \end_layout
9328
9329 \end_inset
9330
9331 -peep-asm
9332 \begin_inset LatexCommand \index{-\/-peep-asm}
9333
9334 \end_inset
9335
9336
9337 \series default
9338  Pass the inline assembler code through the peep hole optimizer.
9339  This can cause unexpected changes to inline assembler code, please go through
9340  the peephole optimizer
9341 \begin_inset LatexCommand \index{Peephole optimizer}
9342
9343 \end_inset
9344
9345  rules defined in the source file tree '<target>/peeph.def' before using
9346  this option.
9347 \end_layout
9348
9349 \begin_layout List
9350 \labelwidthstring 00.00.0000
9351
9352 \series bold
9353 -
9354 \begin_inset ERT
9355 status collapsed
9356
9357 \begin_layout Standard
9358
9359
9360 \backslash
9361 /
9362 \end_layout
9363
9364 \end_inset
9365
9366 -opt-code-speed
9367 \begin_inset LatexCommand \index{-\/-opt-code-speed}
9368
9369 \end_inset
9370
9371
9372 \series default
9373  The compiler will optimize code generation towards fast code, possibly
9374  at the expense of code size.
9375 \end_layout
9376
9377 \begin_layout List
9378 \labelwidthstring 00.00.0000
9379
9380 \series bold
9381 -
9382 \begin_inset ERT
9383 status collapsed
9384
9385 \begin_layout Standard
9386
9387
9388 \backslash
9389 /
9390 \end_layout
9391
9392 \end_inset
9393
9394 -opt-code-size
9395 \begin_inset LatexCommand \index{-\/-opt-code-size}
9396
9397 \end_inset
9398
9399
9400 \series default
9401  The compiler will optimize code generation towards compact code, possibly
9402  at the expense of code speed.
9403 \end_layout
9404
9405 \begin_layout Standard
9406 \begin_inset VSpace bigskip
9407 \end_inset
9408
9409
9410 \end_layout
9411
9412 \begin_layout Subsection
9413 Other Options
9414 \begin_inset LatexCommand \index{Options other}
9415
9416 \end_inset
9417
9418
9419 \end_layout
9420
9421 \begin_layout List
9422 \labelwidthstring 00.00.0000
9423
9424 \series bold
9425 -c\InsetSpace ~
9426 -
9427 \begin_inset ERT
9428 status collapsed
9429
9430 \begin_layout Standard
9431
9432
9433 \backslash
9434 /
9435 \end_layout
9436
9437 \end_inset
9438
9439 -compile-only
9440 \begin_inset LatexCommand \index{-\/-compile-only}
9441
9442 \end_inset
9443
9444
9445 \begin_inset LatexCommand \index{-c -\/-compile-only}
9446
9447 \end_inset
9448
9449
9450 \series default
9451  will compile and assemble the source, but will not call the linkage editor.
9452 \end_layout
9453
9454 \begin_layout List
9455 \labelwidthstring 00.00.0000
9456
9457 \series bold
9458 -
9459 \series default
9460
9461 \begin_inset ERT
9462 status collapsed
9463
9464 \begin_layout Standard
9465
9466
9467 \backslash
9468 /
9469 \end_layout
9470
9471 \end_inset
9472
9473
9474 \series bold
9475 -c1mode
9476 \begin_inset LatexCommand \index{-\/-c1mode}
9477
9478 \end_inset
9479
9480
9481 \series default
9482  reads the preprocessed source from standard input and compiles it.
9483  The file name for the assembler output must be specified using the -o option.
9484 \end_layout
9485
9486 \begin_layout List
9487 \labelwidthstring 00.00.0000
9488
9489 \series bold
9490 -E
9491 \begin_inset LatexCommand \index{-E}
9492
9493 \end_inset
9494
9495
9496 \series default
9497  Run only the C preprocessor.
9498  Preprocess all the C source files specified and output the results to standard
9499  output.
9500 \end_layout
9501
9502 \begin_layout List
9503 \labelwidthstring 00.00.0000
9504
9505 \series bold
9506 -o\InsetSpace ~
9507 <path/file>
9508 \begin_inset LatexCommand \index{-o <path/file>}
9509
9510 \end_inset
9511
9512  
9513 \series default
9514 The output path where everything will be placed or the file name used for
9515  all generated output files.
9516  If the parameter is a path, it must have a trailing slash (or backslash
9517  for the Windows binaries) to be recognized as a path.
9518
9519 \emph on
9520  
9521 \emph default
9522 Note for Windows users: if the path contains spaces, it should be surrounded
9523  by quotes.
9524  The trailing backslash should be doubled in order to prevent escaping the
9525  final quote, for example: 
9526 \emph on
9527 -o 
9528 \begin_inset Quotes sld
9529 \end_inset
9530
9531 F:
9532 \backslash
9533 Projects
9534 \backslash
9535 test3
9536 \backslash
9537 output 1
9538 \backslash
9539
9540 \backslash
9541
9542 \begin_inset Quotes srd
9543 \end_inset
9544
9545
9546 \emph default
9547  or put after the final quote, for example: 
9548 \emph on
9549 -o 
9550 \begin_inset Quotes sld
9551 \end_inset
9552
9553 F:
9554 \backslash
9555 Projects
9556 \backslash
9557 test3
9558 \backslash
9559 output 1
9560 \begin_inset Quotes srd
9561 \end_inset
9562
9563
9564 \backslash
9565
9566 \emph default
9567 .
9568  The path using slashes for directory delimiters can be used too, for example:
9569  
9570 \emph on
9571 -o 
9572 \begin_inset Quotes sld
9573 \end_inset
9574
9575 F:/Projects/test3/output 1/
9576 \begin_inset Quotes srd
9577 \end_inset
9578
9579
9580 \emph default
9581 .
9582 \end_layout
9583
9584 \begin_layout List
9585 \labelwidthstring 00.00.0000
9586
9587 \series bold
9588 -
9589 \begin_inset ERT
9590 status collapsed
9591
9592 \begin_layout Standard
9593
9594
9595 \backslash
9596 /
9597 \end_layout
9598
9599 \end_inset
9600
9601 -stack-auto
9602 \begin_inset LatexCommand \index{-\/-stack-auto}
9603
9604 \end_inset
9605
9606
9607 \series default
9608 \size large
9609 \emph on
9610  
9611 \size default
9612 \emph default
9613 All functions in the source file will be compiled as 
9614 \emph on
9615 reentrant
9616 \emph default
9617
9618 \begin_inset LatexCommand \index{reentrant}
9619
9620 \end_inset
9621
9622 , i.e.
9623  the parameters and local variables will be allocated on the stack
9624 \begin_inset LatexCommand \index{stack}
9625
9626 \end_inset
9627
9628 .
9629  See section 
9630 \begin_inset LatexCommand \ref{sec:Parameters-and-Local-Variables}
9631
9632 \end_inset
9633
9634  Parameters and Local Variables for more details.
9635  If this option is used all source files in the project should be compiled
9636  with this option.
9637  It automatically implies -
9638 \series bold
9639
9640 \begin_inset ERT
9641 status open
9642
9643 \begin_layout Standard
9644
9645
9646 \backslash
9647 /
9648 \end_layout
9649
9650 \end_inset
9651
9652
9653 \series default
9654 -int-long-reent and -
9655 \series bold
9656
9657 \begin_inset ERT
9658 status open
9659
9660 \begin_layout Standard
9661
9662
9663 \backslash
9664 /
9665 \end_layout
9666
9667 \end_inset
9668
9669
9670 \series default
9671 -float-reent.
9672  
9673 \end_layout
9674
9675 \begin_layout List
9676 \labelwidthstring 00.00.0000
9677
9678 \series bold
9679 -
9680 \begin_inset ERT
9681 status collapsed
9682
9683 \begin_layout Standard
9684
9685
9686 \backslash
9687 /
9688 \end_layout
9689
9690 \end_inset
9691
9692 -callee-saves
9693 \begin_inset LatexCommand \index{-\/-callee-saves}
9694
9695 \end_inset
9696
9697  
9698 \begin_inset LatexCommand \label{lyx:--callee-saves-function1[,function2][,function3]...}
9699
9700 \end_inset
9701
9702 function1[,function2][,function3]....
9703
9704 \series default
9705  The compiler by default uses a caller saves convention for register saving
9706  across function calls, however this can cause unnecessary register pushing
9707  and popping when calling small functions from larger functions.
9708  This option can be used to switch the register saving convention for the
9709  function names specified.
9710  The compiler will not save registers when calling these functions, no extra
9711  code will be generated at the entry and exit (function prologue
9712 \series bold
9713
9714 \begin_inset LatexCommand \index{function prologue}
9715
9716 \end_inset
9717
9718
9719 \series default
9720  and epilogue
9721 \series bold
9722
9723 \begin_inset LatexCommand \index{function epilogue}
9724
9725 \end_inset
9726
9727
9728 \series default
9729 ) for these functions to save and restore the registers used by these functions,
9730  this can SUBSTANTIALLY reduce code and improve run time performance of
9731  the generated code.
9732  In the future the compiler (with inter procedural analysis) will be able
9733  to determine the appropriate scheme to use for each function call.
9734  DO NOT use this option for built-in functions such as _mulint..., if this
9735  option is used for a library function the appropriate library function
9736  needs to be recompiled with the same option.
9737  If the project consists of multiple source files then all the source file
9738  should be compiled with the same -
9739 \begin_inset ERT
9740 status collapsed
9741
9742 \begin_layout Standard
9743
9744
9745 \backslash
9746 /
9747 \end_layout
9748
9749 \end_inset
9750
9751 -callee-saves option string.
9752  Also see #pragma\InsetSpace ~
9753 callee_saves 
9754 \begin_inset LatexCommand \index{\#pragma callee\_saves}
9755
9756 \end_inset
9757
9758  
9759 \begin_inset LatexCommand \vpageref{ite:callee_saves-function1[,function2[,function3...]]--}
9760
9761 \end_inset
9762
9763 .
9764 \end_layout
9765
9766 \begin_layout List
9767 \labelwidthstring 00.00.0000
9768
9769 \series bold
9770 -
9771 \begin_inset ERT
9772 status collapsed
9773
9774 \begin_layout Standard
9775
9776
9777 \backslash
9778 /
9779 \end_layout
9780
9781 \end_inset
9782
9783 -all-callee-saves
9784 \begin_inset LatexCommand \index{-\/-all-callee-saves}
9785
9786 \end_inset
9787
9788  
9789 \series default
9790 Function of
9791 \series bold
9792  
9793 \series default
9794 -
9795 \begin_inset ERT
9796 status collapsed
9797
9798 \begin_layout Standard
9799
9800
9801 \backslash
9802 /
9803 \end_layout
9804
9805 \end_inset
9806
9807 -callee-saves will be applied to all functions by default.
9808 \end_layout
9809
9810 \begin_layout List
9811 \labelwidthstring 00.00.0000
9812
9813 \series bold
9814 -
9815 \begin_inset ERT
9816 status collapsed
9817
9818 \begin_layout Standard
9819
9820
9821 \backslash
9822 /
9823 \end_layout
9824
9825 \end_inset
9826
9827 -debug
9828 \begin_inset LatexCommand \index{-\/-debug}
9829
9830 \end_inset
9831
9832
9833 \bar under
9834  
9835 \series default
9836 \bar default
9837 When this option is used the compiler will generate debug information.
9838  The debug information collected in a file with .cdb extension can be used
9839  with the SDCDB.
9840  For more information see documentation for SDCDB.
9841  Another file with no extension contains debug information in AOMF or AOMF51
9842 \begin_inset LatexCommand \index{AOMF, AOMF51}
9843
9844 \end_inset
9845
9846  format which is commonly used by third party tools.
9847 \end_layout
9848
9849 \begin_layout List
9850 \labelwidthstring 00.00.0000
9851
9852 \series bold
9853 -S
9854 \begin_inset LatexCommand \index{-S}
9855
9856 \end_inset
9857
9858
9859 \size large
9860 \bar under
9861  
9862 \series default
9863 \size default
9864 \bar default
9865 Stop after the stage of compilation proper; do not assemble.
9866  The output is an assembler code file for the input file specified.
9867 \end_layout
9868
9869 \begin_layout List
9870 \labelwidthstring 00.00.0000
9871
9872 \series bold
9873 -
9874 \begin_inset ERT
9875 status collapsed
9876
9877 \begin_layout Standard
9878
9879
9880 \backslash
9881 /
9882 \end_layout
9883
9884 \end_inset
9885
9886 -int-long-reent
9887 \begin_inset LatexCommand \index{-\/-int-long-reent}
9888
9889 \end_inset
9890
9891
9892 \series default
9893  Integer (16 bit) and long (32 bit) libraries have been compiled as reentrant.
9894  Note by default these libraries are compiled as non-reentrant.
9895  See section Installation for more details.
9896 \end_layout
9897
9898 \begin_layout List
9899 \labelwidthstring 00.00.0000
9900
9901 \series bold
9902 -
9903 \begin_inset ERT
9904 status collapsed
9905
9906 \begin_layout Standard
9907
9908
9909 \backslash
9910 /
9911 \end_layout
9912
9913 \end_inset
9914
9915 -cyclomatic
9916 \begin_inset LatexCommand \index{-\/-cyclomatic}
9917
9918 \end_inset
9919
9920
9921 \bar under
9922  
9923 \series default
9924 \bar default
9925 This option will cause the compiler to generate an information message for
9926  each function in the source file.
9927  The message contains some 
9928 \emph on
9929 important
9930 \emph default
9931  information about the function.
9932  The number of edges and nodes the compiler detected in the control flow
9933  graph of the function, and most importantly the 
9934 \emph on
9935 cyclomatic complexity
9936 \begin_inset LatexCommand \index{Cyclomatic complexity}
9937
9938 \end_inset
9939
9940
9941 \emph default
9942  see section on Cyclomatic Complexity for more details.
9943 \end_layout
9944
9945 \begin_layout List
9946 \labelwidthstring 00.00.0000
9947
9948 \series bold
9949 -
9950 \begin_inset ERT
9951 status collapsed
9952
9953 \begin_layout Standard
9954
9955
9956 \backslash
9957 /
9958 \end_layout
9959
9960 \end_inset
9961
9962 -float-reent
9963 \begin_inset LatexCommand \index{-\/-float-reent}
9964
9965 \end_inset
9966
9967
9968 \series default
9969  Floating point library is compiled as reentrant
9970 \begin_inset LatexCommand \index{reentrant}
9971
9972 \end_inset
9973
9974 .
9975  See section Installation for more details.
9976 \end_layout
9977
9978 \begin_layout List
9979 \labelwidthstring 00.00.0000
9980
9981 \series bold
9982 -
9983 \begin_inset ERT
9984 status collapsed
9985
9986 \begin_layout Standard
9987
9988
9989 \backslash
9990 /
9991 \end_layout
9992
9993 \end_inset
9994
9995 -funsigned-char
9996 \begin_inset LatexCommand \index{-\/-funsigned-char}
9997
9998 \end_inset
9999
10000
10001 \series default
10002  The default signedness for every type is
10003 \family typewriter
10004  signed
10005 \family default
10006 .
10007  In some embedded environments the default signedness of
10008 \family typewriter
10009  char
10010 \family default
10011  is
10012 \family typewriter
10013  unsigned
10014 \family default
10015 .
10016  To set the signess for characters to unsigned, use the option -
10017 \series bold
10018
10019 \begin_inset ERT
10020 status open
10021
10022 \begin_layout Standard
10023
10024
10025 \backslash
10026 /
10027 \end_layout
10028
10029 \end_inset
10030
10031
10032 \series default
10033 -funsigned-char.
10034  If this option is set and no signedness keyword (unsigned/signed) is given,
10035  a char will be signed.
10036  All other types are unaffected.
10037 \end_layout
10038
10039 \begin_layout List
10040 \labelwidthstring 00.00.0000
10041
10042 \series bold
10043 -
10044 \begin_inset ERT
10045 status collapsed
10046
10047 \begin_layout Standard
10048
10049
10050 \backslash
10051 /
10052 \end_layout
10053
10054 \end_inset
10055
10056 -main-return
10057 \begin_inset LatexCommand \index{-\/-main-return}
10058
10059 \end_inset
10060
10061
10062 \series default
10063  This option can be used if the code generated is called by a monitor program
10064  or if the main routine includes an endless loop.
10065  This option results in slightly smaller code and saves two bytes of stack
10066  space.
10067  The return from the 'main'
10068 \begin_inset LatexCommand \index{main return}
10069
10070 \end_inset
10071
10072  function will return to the function calling main.
10073  The default setting is to lock up i.e.
10074  generate a '
10075 \family typewriter
10076 sjmp .
10077 \family default
10078 '.
10079 \end_layout
10080
10081 \begin_layout List
10082 \labelwidthstring 00.00.0000
10083
10084 \series bold
10085 -
10086 \begin_inset ERT
10087 status collapsed
10088
10089 \begin_layout Standard
10090
10091
10092 \backslash
10093 /
10094 \end_layout
10095
10096 \end_inset
10097
10098 -nostdinc
10099 \begin_inset LatexCommand \index{-\/-nostdinc}
10100
10101 \end_inset
10102
10103
10104 \series default
10105  This will prevent the compiler from passing on the default include path
10106  to the preprocessor.
10107 \end_layout
10108
10109 \begin_layout List
10110 \labelwidthstring 00.00.0000
10111
10112 \series bold
10113 -
10114 \begin_inset ERT
10115 status collapsed
10116
10117 \begin_layout Standard
10118
10119
10120 \backslash
10121 /
10122 \end_layout
10123
10124 \end_inset
10125
10126 -nostdlib
10127 \begin_inset LatexCommand \index{-\/-nostdlib}
10128
10129 \end_inset
10130
10131
10132 \series default
10133  This will prevent the compiler from passing on the default library
10134 \begin_inset LatexCommand \index{Libraries}
10135
10136 \end_inset
10137
10138  path to the linker.
10139 \end_layout
10140
10141 \begin_layout List
10142 \labelwidthstring 00.00.0000
10143
10144 \series bold
10145 -
10146 \begin_inset ERT
10147 status collapsed
10148
10149 \begin_layout Standard
10150
10151
10152 \backslash
10153 /
10154 \end_layout
10155
10156 \end_inset
10157
10158 -verbose
10159 \begin_inset LatexCommand \index{-\/-verbose}
10160
10161 \end_inset
10162
10163
10164 \series default
10165  Shows the various actions the compiler is performing.
10166 \end_layout
10167
10168 \begin_layout List
10169 \labelwidthstring 00.00.0000
10170
10171 \series bold
10172 -V
10173 \begin_inset LatexCommand \index{-V}
10174
10175 \end_inset
10176
10177
10178 \series default
10179  Shows the actual commands the compiler is executing.
10180 \end_layout
10181
10182 \begin_layout List
10183 \labelwidthstring 00.00.0000
10184
10185 \series bold
10186 -
10187 \begin_inset ERT
10188 status collapsed
10189
10190 \begin_layout Standard
10191
10192
10193 \backslash
10194 /
10195 \end_layout
10196
10197 \end_inset
10198
10199 -no-c-code-in-asm
10200 \begin_inset LatexCommand \index{-\/-no-c-code-in-asm}
10201
10202 \end_inset
10203
10204
10205 \series default
10206  Hides your ugly and inefficient c-code from the asm file, so you can always
10207  blame the compiler :)
10208 \end_layout
10209
10210 \begin_layout List
10211 \labelwidthstring 00.00.0000
10212
10213 \series bold
10214 -
10215 \begin_inset ERT
10216 status collapsed
10217
10218 \begin_layout Standard
10219
10220
10221 \backslash
10222 /
10223 \end_layout
10224
10225 \end_inset
10226
10227 -fverbose-asm
10228 \begin_inset LatexCommand \index{-\/-no-gen-comments}
10229
10230 \end_inset
10231
10232
10233 \series default
10234  Include code generator and peep-hole comments in the generated asm files.
10235 \end_layout
10236
10237 \begin_layout List
10238 \labelwidthstring 00.00.0000
10239
10240 \series bold
10241 -
10242 \begin_inset ERT
10243 status collapsed
10244
10245 \begin_layout Standard
10246
10247
10248 \backslash
10249 /
10250 \end_layout
10251
10252 \end_inset
10253
10254 -no-peep-comments
10255 \begin_inset LatexCommand \index{-\/-no-peep-comments}
10256
10257 \end_inset
10258
10259
10260 \series default
10261  Don't include peep-hole comments in the generated asm files even if -
10262 \series bold
10263
10264 \begin_inset ERT
10265 status open
10266
10267 \begin_layout Standard
10268
10269
10270 \backslash
10271 /
10272 \end_layout
10273
10274 \end_inset
10275
10276
10277 \series default
10278 -fverbose-asm option is specified.
10279 \end_layout
10280
10281 \begin_layout List
10282 \labelwidthstring 00.00.0000
10283
10284 \series bold
10285 -
10286 \begin_inset ERT
10287 status collapsed
10288
10289 \begin_layout Standard
10290
10291
10292 \backslash
10293 /
10294 \end_layout
10295
10296 \end_inset
10297
10298 -i-code-in-asm
10299 \begin_inset LatexCommand \index{-\/-i-code-in-asm}
10300
10301 \end_inset
10302
10303
10304 \series default
10305  Include i-codes in the asm file.
10306  Sounds like noise but is most helpful for debugging the compiler itself.
10307 \end_layout
10308
10309 \begin_layout List
10310 \labelwidthstring 00.00.0000
10311
10312 \series bold
10313 -
10314 \begin_inset ERT
10315 status collapsed
10316
10317 \begin_layout Standard
10318
10319
10320 \backslash
10321 /
10322 \end_layout
10323
10324 \end_inset
10325
10326 -less-pedantic
10327 \begin_inset LatexCommand \index{pedantic}
10328
10329 \end_inset
10330
10331
10332 \begin_inset LatexCommand \index{-\/-less-pedantic}
10333
10334 \end_inset
10335
10336
10337 \series default
10338
10339 \begin_inset LatexCommand \label{lyx:--less-pedantic}
10340
10341 \end_inset
10342
10343  Disable some of the more pedantic warnings
10344 \begin_inset LatexCommand \index{Warnings}
10345
10346 \end_inset
10347
10348 .
10349  For more details, see the less_pedantic pragma 
10350 \begin_inset LatexCommand \vpageref{ite:less_pedantic}
10351
10352 \end_inset
10353
10354 .
10355 \end_layout
10356
10357 \begin_layout List
10358 \labelwidthstring 00.00.0000
10359
10360 \series bold
10361 -
10362 \begin_inset ERT
10363 status collapsed
10364
10365 \begin_layout Standard
10366
10367
10368 \backslash
10369 /
10370 \end_layout
10371
10372 \end_inset
10373
10374 -disable-warning\InsetSpace ~
10375 <nnnn>
10376 \begin_inset LatexCommand \index{-\/-disable-warning}
10377
10378 \end_inset
10379
10380
10381 \series default
10382  Disable specific warning with number <nnnn>.
10383 \end_layout
10384
10385 \begin_layout List
10386 \labelwidthstring 00.00.0000
10387
10388 \series bold
10389 -
10390 \begin_inset ERT
10391 status collapsed
10392
10393 \begin_layout Standard
10394
10395
10396 \backslash
10397 /
10398 \end_layout
10399
10400 \end_inset
10401
10402 -print-search-dirs
10403 \begin_inset LatexCommand \index{-\/-print-search-dirs}
10404
10405 \end_inset
10406
10407
10408 \series default
10409  Display the directories in the compiler's search path
10410 \end_layout
10411
10412 \begin_layout List
10413 \labelwidthstring 00.00.0000
10414
10415 \series bold
10416 -
10417 \begin_inset ERT
10418 status collapsed
10419
10420 \begin_layout Standard
10421
10422
10423 \backslash
10424 /
10425 \end_layout
10426
10427 \end_inset
10428
10429 -vc
10430 \begin_inset LatexCommand \index{-\/-vc}
10431
10432 \end_inset
10433
10434
10435 \series default
10436  Display errors and warnings using MSVC style, so you can use SDCC with
10437  the visual studio IDE
10438 \begin_inset LatexCommand \index{IDE}
10439
10440 \end_inset
10441
10442 .
10443  With SDCC both offering a GCC-like (the default) and a MSVC-like
10444 \begin_inset LatexCommand \index{MSVC output style}
10445
10446 \end_inset
10447
10448  output style, integration into most programming editors should be straightforwa
10449 rd.
10450 \end_layout
10451
10452 \begin_layout List
10453 \labelwidthstring 00.00.0000
10454
10455 \series bold
10456 -
10457 \begin_inset ERT
10458 status collapsed
10459
10460 \begin_layout Standard
10461
10462
10463 \backslash
10464 /
10465 \end_layout
10466
10467 \end_inset
10468
10469 -use-stdout
10470 \begin_inset LatexCommand \index{-\/-use-stdout}
10471
10472 \end_inset
10473
10474
10475 \series default
10476  Send errors and warnings to stdout instead of stderr.
10477 \end_layout
10478
10479 \begin_layout List
10480 \labelwidthstring 00.00.0000
10481
10482 \series bold
10483 -Wa\InsetSpace ~
10484 asmOption[,asmOption]
10485 \series default
10486
10487 \begin_inset LatexCommand \index{-Wa asmOption[,asmOption]}
10488
10489 \end_inset
10490
10491 ...
10492  Pass the asmOption to the assembler
10493 \begin_inset LatexCommand \index{Options assembler}
10494
10495 \end_inset
10496
10497
10498 \begin_inset LatexCommand \index{Assembler options}
10499
10500 \end_inset
10501
10502 .
10503  See file sdcc/as/doc/asxhtm.html for assembler options.cd
10504 \end_layout
10505
10506 \begin_layout List
10507 \labelwidthstring 00.00.0000
10508
10509 \series bold
10510 -
10511 \begin_inset ERT
10512 status collapsed
10513
10514 \begin_layout Standard
10515
10516
10517 \backslash
10518 /
10519 \end_layout
10520
10521 \end_inset
10522
10523 -std-sdcc89
10524 \begin_inset LatexCommand \index{-\/-std-sdcc89}
10525
10526 \end_inset
10527
10528
10529 \series default
10530  Generally follow the C89 standard, but allow SDCC features that conflict
10531  with the standard (default).
10532 \end_layout
10533
10534 \begin_layout List
10535 \labelwidthstring 00.00.0000
10536
10537 \series bold
10538 -
10539 \begin_inset ERT
10540 status collapsed
10541
10542 \begin_layout Standard
10543
10544
10545 \backslash
10546 /
10547 \end_layout
10548
10549 \end_inset
10550
10551 -std-c89
10552 \begin_inset LatexCommand \index{-\/-std-c89}
10553
10554 \end_inset
10555
10556
10557 \series default
10558  Follow the C89 standard and disable SDCC features that conflict with the
10559  standard.
10560 \end_layout
10561
10562 \begin_layout List
10563 \labelwidthstring 00.00.0000
10564
10565 \series bold
10566 -
10567 \begin_inset ERT
10568 status collapsed
10569
10570 \begin_layout Standard
10571
10572
10573 \backslash
10574 /
10575 \end_layout
10576
10577 \end_inset
10578
10579 -std-sdcc99
10580 \begin_inset LatexCommand \index{-\/-std-sdcc99}
10581
10582 \end_inset
10583
10584
10585 \series default
10586  Generally follow the C99 standard, but allow SDCC features that conflict
10587  with the standard (incomplete support).
10588 \end_layout
10589
10590 \begin_layout List
10591 \labelwidthstring 00.00.0000
10592
10593 \series bold
10594 -
10595 \begin_inset ERT
10596 status collapsed
10597
10598 \begin_layout Standard
10599
10600
10601 \backslash
10602 /
10603 \end_layout
10604
10605 \end_inset
10606
10607 -std-c99
10608 \begin_inset LatexCommand \index{-\/-std-sdcc99}
10609
10610 \end_inset
10611
10612
10613 \series default
10614  Follow the C99 standard and disable SDCC features that conflict with the
10615  standard (incomplete support).
10616 \end_layout
10617
10618 \begin_layout List
10619 \labelwidthstring 00.00.0000
10620
10621 \series bold
10622 -
10623 \begin_inset ERT
10624 status collapsed
10625
10626 \begin_layout Standard
10627
10628
10629 \backslash
10630 /
10631 \end_layout
10632
10633 \end_inset
10634
10635 -codeseg
10636 \series default
10637
10638 \begin_inset LatexCommand \index{-\/-codeseg <Value>}
10639
10640 \end_inset
10641
10642 \InsetSpace ~
10643 <Name> The name to be used for the code
10644 \begin_inset LatexCommand \index{code}
10645
10646 \end_inset
10647
10648  segment, default CSEG.
10649  This is useful if you need to tell the compiler to put the code in a special
10650  segment so you can later on tell the linker to put this segment in a special
10651  place in memory.
10652  Can be used for instance when using bank switching to put the code in a
10653  bank.
10654 \end_layout
10655
10656 \begin_layout List
10657 \labelwidthstring 00.00.0000
10658
10659 \series bold
10660 -
10661 \begin_inset ERT
10662 status collapsed
10663
10664 \begin_layout Standard
10665
10666
10667 \backslash
10668 /
10669 \end_layout
10670
10671 \end_inset
10672
10673 -constseg
10674 \series default
10675
10676 \begin_inset LatexCommand \index{-\/-constseg <Value>}
10677
10678 \end_inset
10679
10680 \InsetSpace ~
10681 <Name> The name to be used for the const
10682 \begin_inset LatexCommand \index{const}
10683
10684 \end_inset
10685
10686  segment, default CONST.
10687  This is useful if you need to tell the compiler to put the const data in
10688  a special segment so you can later on tell the linker to put this segment
10689  in a special place in memory.
10690  Can be used for instance when using bank switching to put the const data
10691  in a bank.
10692 \end_layout
10693
10694 \begin_layout List
10695 \labelwidthstring 00.00.0000
10696
10697 \series bold
10698 -
10699 \begin_inset ERT
10700 status collapsed
10701
10702 \begin_layout Standard
10703
10704
10705 \backslash
10706 /
10707 \end_layout
10708
10709 \end_inset
10710
10711 -fdollars-in-identifiers
10712 \begin_inset LatexCommand \index{-\/-fdollars-in-identifiers}
10713
10714 \end_inset
10715
10716
10717 \series default
10718  Permit '$' as an identifier character.
10719 \end_layout
10720
10721 \begin_layout List
10722 \labelwidthstring 00.00.0000
10723
10724 \series bold
10725 -
10726 \begin_inset ERT
10727 status collapsed
10728
10729 \begin_layout Standard
10730
10731
10732 \backslash
10733 /
10734 \end_layout
10735
10736 \end_inset
10737
10738 -more-pedantic
10739 \series default
10740
10741 \begin_inset LatexCommand \index{-\/-more-pedantic}
10742
10743 \end_inset
10744
10745
10746 \begin_inset LatexCommand \index{pedantic}
10747
10748 \end_inset
10749
10750  Actually this is 
10751 \series bold
10752 \emph on
10753 not
10754 \series default
10755 \emph default
10756  a SDCC compiler option but if you want 
10757 \emph on
10758 more
10759 \emph default
10760  warnings you can use a separate tool dedicated to syntax checking like
10761  splint
10762 \begin_inset LatexCommand \label{lyx:more-pedantic-SPLINT}
10763
10764 \end_inset
10765
10766
10767 \begin_inset LatexCommand \index{lint (syntax checking tool)}
10768
10769 \end_inset
10770
10771  
10772 \begin_inset LatexCommand \url{http://www.splint.org}
10773
10774 \end_inset
10775
10776 .
10777  To make your source files parseable by splint you will have to include
10778  
10779 \family sans
10780 lint.h
10781 \family default
10782
10783 \begin_inset LatexCommand \index{splint (syntax checking tool)}
10784
10785 \end_inset
10786
10787  in your source file and add brackets around extended keywords (like 
10788 \family sans
10789
10790 \begin_inset Quotes sld
10791 \end_inset
10792
10793 __at\InsetSpace ~
10794
10795 \series bold
10796 (
10797 \series default
10798 0xab
10799 \series bold
10800 )
10801 \series default
10802
10803 \begin_inset Quotes srd
10804 \end_inset
10805
10806
10807 \family default
10808  and 
10809 \family sans
10810
10811 \begin_inset Quotes sld
10812 \end_inset
10813
10814 __interrupt\InsetSpace ~
10815 (2)
10816 \begin_inset Quotes srd
10817 \end_inset
10818
10819
10820 \family default
10821 ).
10822  
10823 \newline
10824 Splint has an excellent on line manual at 
10825 \begin_inset LatexCommand \url{http://www.splint.org/manual/}
10826
10827 \end_inset
10828
10829  and it's capabilities go beyond pure syntax checking.
10830  You'll need to tell splint the location of SDCC's include files so a typical
10831  command line could look like this: 
10832 \newline
10833
10834 \family sans
10835 splint\InsetSpace ~
10836 -I\InsetSpace ~
10837 /usr/local/share/sdcc/include/mcs51/\InsetSpace ~
10838 \InsetSpace ~
10839 myprogram.c
10840 \end_layout
10841
10842 \begin_layout List
10843 \labelwidthstring 00.00.0000
10844
10845 \series bold
10846 -
10847 \begin_inset ERT
10848 status collapsed
10849
10850 \begin_layout Standard
10851
10852
10853 \backslash
10854 /
10855 \end_layout
10856
10857 \end_inset
10858
10859 -short-is-8bits
10860 \series default
10861
10862 \begin_inset LatexCommand \index{-\/-short-is-8bits}
10863
10864 \end_inset
10865
10866
10867 \begin_inset LatexCommand \label{lyx:--short-is-8bits}
10868
10869 \end_inset
10870
10871  Treat short as 8-bit (for backward compatibility with older versions of
10872  compiler - see section 
10873 \begin_inset LatexCommand \ref{sec:Compatibility-with-previous}
10874
10875 \end_inset
10876
10877 )
10878 \end_layout
10879
10880 \begin_layout Standard
10881 \begin_inset VSpace bigskip
10882 \end_inset
10883
10884
10885 \end_layout
10886
10887 \begin_layout Subsection
10888 Intermediate Dump Options
10889 \begin_inset LatexCommand \label{sub:Intermediate-Dump-Options}
10890
10891 \end_inset
10892
10893
10894 \begin_inset LatexCommand \index{Options intermediate dump}
10895
10896 \end_inset
10897
10898
10899 \begin_inset LatexCommand \index{Intermediate dump options}
10900
10901 \end_inset
10902
10903
10904 \end_layout
10905
10906 \begin_layout Standard
10907 The following options are provided for the purpose of retargetting and debugging
10908  the compiler.
10909  They provide a means to dump the intermediate code (iCode
10910 \begin_inset LatexCommand \index{iCode}
10911
10912 \end_inset
10913
10914 ) generated by the compiler in human readable form at various stages of
10915  the compilation process.
10916  More on iCodes see chapter 
10917 \begin_inset LatexCommand \ref{sub:The-anatomy-of}
10918
10919 \end_inset
10920
10921  
10922 \begin_inset Quotes srd
10923 \end_inset
10924
10925 The anatomy of the compiler
10926 \begin_inset Quotes srd
10927 \end_inset
10928
10929 .
10930 \end_layout
10931
10932 \begin_layout List
10933 \labelwidthstring 00.00.0000
10934
10935 \series bold
10936 -
10937 \begin_inset ERT
10938 status collapsed
10939
10940 \begin_layout Standard
10941
10942
10943 \backslash
10944 /
10945 \end_layout
10946
10947 \end_inset
10948
10949 -dumpraw
10950 \begin_inset LatexCommand \index{-\/-dumpraw}
10951
10952 \end_inset
10953
10954
10955 \series default
10956  This option will cause the compiler to dump the intermediate code into
10957  a file of named 
10958 \emph on
10959 <source filename>.dumpraw
10960 \emph default
10961  just after the intermediate code has been generated for a function, i.e.
10962  before any optimizations are done.
10963  The basic blocks
10964 \begin_inset LatexCommand \index{Basic blocks}
10965
10966 \end_inset
10967
10968  at this stage ordered in the depth first number, so they may not be in
10969  sequence of execution.
10970 \end_layout
10971
10972 \begin_layout List
10973 \labelwidthstring 00.00.0000
10974
10975 \series bold
10976 -
10977 \begin_inset ERT
10978 status collapsed
10979
10980 \begin_layout Standard
10981
10982
10983 \backslash
10984 /
10985 \end_layout
10986
10987 \end_inset
10988
10989 -dumpgcse
10990 \begin_inset LatexCommand \index{-\/-dumpgcse}
10991
10992 \end_inset
10993
10994
10995 \series default
10996  Will create a dump of iCodes, after global subexpression elimination
10997 \begin_inset LatexCommand \index{Global subexpression elimination}
10998
10999 \end_inset
11000
11001 , into a file named 
11002 \emph on
11003 <source filename>.dumpgcse.
11004 \end_layout
11005
11006 \begin_layout List
11007 \labelwidthstring 00.00.0000
11008
11009 \series bold
11010 -
11011 \begin_inset ERT
11012 status collapsed
11013
11014 \begin_layout Standard
11015
11016
11017 \backslash
11018 /
11019 \end_layout
11020
11021 \end_inset
11022
11023 -dumpdeadcode
11024 \begin_inset LatexCommand \index{-\/-dumpdeadcode}
11025
11026 \end_inset
11027
11028
11029 \series default
11030  Will create a dump of iCodes, after deadcode elimination
11031 \begin_inset LatexCommand \index{Dead-code elimination}
11032
11033 \end_inset
11034
11035 , into a file named 
11036 \emph on
11037 <source filename>.dumpdeadcode.
11038 \end_layout
11039
11040 \begin_layout List
11041 \labelwidthstring 00.00.0000
11042
11043 \series bold
11044 -
11045 \begin_inset ERT
11046 status collapsed
11047
11048 \begin_layout Standard
11049
11050
11051 \backslash
11052 /
11053 \end_layout
11054
11055 \end_inset
11056
11057 -dumploop
11058 \begin_inset LatexCommand \index{-\/-dumploop}
11059
11060 \end_inset
11061
11062
11063 \series default
11064 \size large
11065  
11066 \size default
11067 Will create a dump of iCodes, after loop optimizations
11068 \begin_inset LatexCommand \index{Loop optimization}
11069
11070 \end_inset
11071
11072 , into a file named 
11073 \emph on
11074 <source filename>.dumploop.
11075 \end_layout
11076
11077 \begin_layout List
11078 \labelwidthstring 00.00.0000
11079
11080 \series bold
11081 -
11082 \begin_inset ERT
11083 status collapsed
11084
11085 \begin_layout Standard
11086
11087
11088 \backslash
11089 /
11090 \end_layout
11091
11092 \end_inset
11093
11094 -dumprange
11095 \begin_inset LatexCommand \index{-\/-dumprange}
11096
11097 \end_inset
11098
11099
11100 \series default
11101 \size large
11102  
11103 \size default
11104 Will create a dump of iCodes, after live range analysis
11105 \begin_inset LatexCommand \index{Live range analysis}
11106
11107 \end_inset
11108
11109 , into a file named 
11110 \emph on
11111 <source filename>.dumprange.
11112 \end_layout
11113
11114 \begin_layout List
11115 \labelwidthstring 00.00.0000
11116
11117 \series bold
11118 -
11119 \begin_inset ERT
11120 status collapsed
11121
11122 \begin_layout Standard
11123
11124
11125 \backslash
11126 /
11127 \end_layout
11128
11129 \end_inset
11130
11131 -dumlrange
11132 \begin_inset LatexCommand \index{-\/-dumlrange}
11133
11134 \end_inset
11135
11136
11137 \series default
11138  Will dump the life ranges
11139 \begin_inset LatexCommand \index{Live range analysis}
11140
11141 \end_inset
11142
11143  for all symbols.
11144 \end_layout
11145
11146 \begin_layout List
11147 \labelwidthstring 00.00.0000
11148
11149 \series bold
11150 -
11151 \begin_inset ERT
11152 status collapsed
11153
11154 \begin_layout Standard
11155
11156
11157 \backslash
11158 /
11159 \end_layout
11160
11161 \end_inset
11162
11163 -dumpregassign
11164 \begin_inset LatexCommand \index{-\/-dumpregassign}
11165
11166 \end_inset
11167
11168
11169 \bar under
11170  
11171 \series default
11172 \bar default
11173 Will create a dump of iCodes, after register assignment
11174 \begin_inset LatexCommand \index{Register assignment}
11175
11176 \end_inset
11177
11178 , into a file named 
11179 \emph on
11180 <source filename>.dumprassgn.
11181 \end_layout
11182
11183 \begin_layout List
11184 \labelwidthstring 00.00.0000
11185
11186 \series bold
11187 -
11188 \begin_inset ERT
11189 status collapsed
11190
11191 \begin_layout Standard
11192
11193
11194 \backslash
11195 /
11196 \end_layout
11197
11198 \end_inset
11199
11200 -dumplrange
11201 \begin_inset LatexCommand \index{-\/-dumplrange}
11202
11203 \end_inset
11204
11205
11206 \series default
11207  Will create a dump of the live ranges of iTemp's
11208 \end_layout
11209
11210 \begin_layout List
11211 \labelwidthstring 00.00.0000
11212
11213 \series bold
11214 -
11215 \begin_inset ERT
11216 status collapsed
11217
11218 \begin_layout Standard
11219
11220
11221 \backslash
11222 /
11223 \end_layout
11224
11225 \end_inset
11226
11227 -dumpall
11228 \begin_inset LatexCommand \index{-\/-dumpall}
11229
11230 \end_inset
11231
11232
11233 \size large
11234 \bar under
11235  
11236 \series default
11237 \size default
11238 \bar default
11239 Will cause all the above mentioned dumps to be created.
11240 \end_layout
11241
11242 \begin_layout Standard
11243 \begin_inset VSpace bigskip
11244 \end_inset
11245
11246
11247 \end_layout
11248
11249 \begin_layout Subsection
11250 Redirecting output on Windows Shells
11251 \end_layout
11252
11253 \begin_layout Standard
11254 By default SDCC writes its error messages to 
11255 \begin_inset Quotes sld
11256 \end_inset
11257
11258 standard error
11259 \begin_inset Quotes srd
11260 \end_inset
11261
11262 .
11263  To force all messages to 
11264 \begin_inset Quotes sld
11265 \end_inset
11266
11267 standard output
11268 \begin_inset Quotes srd
11269 \end_inset
11270
11271  use 
11272 \series bold
11273 -
11274 \series default
11275 \emph on
11276
11277 \begin_inset ERT
11278 status collapsed
11279
11280 \begin_layout Standard
11281
11282
11283 \backslash
11284 /
11285 \end_layout
11286
11287 \end_inset
11288
11289
11290 \series bold
11291 \emph default
11292 -
11293 \series default
11294 use-stdout
11295 \begin_inset LatexCommand \index{-\/-use-stdout}
11296
11297 \end_inset
11298
11299 .
11300  Additionally, if you happen to have visual studio installed in your windows
11301  machine, you can use it to compile your sources using a custom build and
11302  the SDCC -
11303 \emph on
11304
11305 \begin_inset ERT
11306 status collapsed
11307
11308 \begin_layout Standard
11309
11310
11311 \backslash
11312 /
11313 \end_layout
11314
11315 \end_inset
11316
11317
11318 \emph default
11319 -vc
11320 \begin_inset LatexCommand \index{-\/-vc}
11321
11322 \end_inset
11323
11324  option.
11325  Something like this should work:
11326 \newline
11327
11328 \newline
11329
11330 \series bold
11331 c:
11332 \backslash
11333 sdcc
11334 \backslash
11335 bin
11336 \backslash
11337 sdcc.exe -
11338 \series default
11339 \emph on
11340
11341 \begin_inset ERT
11342 status collapsed
11343
11344 \begin_layout Standard
11345
11346
11347 \backslash
11348 /
11349 \end_layout
11350
11351 \end_inset
11352
11353
11354 \series bold
11355 \emph default
11356 -vc -
11357 \series default
11358 \emph on
11359
11360 \begin_inset ERT
11361 status collapsed
11362
11363 \begin_layout Standard
11364
11365
11366 \backslash
11367 /
11368 \end_layout
11369
11370 \end_inset
11371
11372
11373 \series bold
11374 \emph default
11375 -model-large -c $(InputPath)
11376 \series default
11377
11378 \begin_inset VSpace bigskip
11379 \end_inset
11380
11381
11382 \end_layout
11383
11384 \begin_layout Section
11385 Environment variables
11386 \begin_inset LatexCommand \index{Environment variables}
11387
11388 \end_inset
11389
11390
11391 \end_layout
11392
11393 \begin_layout Standard
11394 SDCC recognizes the following environment variables:
11395 \end_layout
11396
11397 \begin_layout List
11398 \labelwidthstring 00.00.0000
11399
11400 \series bold
11401 SDCC_LEAVE_SIGNALS
11402 \begin_inset LatexCommand \index{SDCC\_LEAVE\_SIGNALS}
11403
11404 \end_inset
11405
11406
11407 \series default
11408  SDCC installs a signal handler
11409 \begin_inset LatexCommand \index{signal handler}
11410
11411 \end_inset
11412
11413  to be able to delete temporary files after an user break (^C) or an exception.
11414  If this environment variable is set, SDCC won't install the signal handler
11415  in order to be able to debug SDCC.
11416 \end_layout
11417
11418 \begin_layout List
11419 \labelwidthstring 00.00.0000
11420
11421 \series bold
11422 TMP,\InsetSpace ~
11423 TEMP,\InsetSpace ~
11424 TMPDIR
11425 \begin_inset LatexCommand \index{TMP, TEMP, TMPDIR}
11426
11427 \end_inset
11428
11429
11430 \series default
11431  Path, where temporary files will be created.
11432  The order of the variables is the search order.
11433  In a standard *nix environment these variables are not set, and there's
11434  no need to set them.
11435  On Windows it's recommended to set one of them.
11436 \end_layout
11437
11438 \begin_layout List
11439 \labelwidthstring 00.00.0000
11440
11441 \series bold
11442 SDCC_HOME
11443 \begin_inset LatexCommand \index{SDCC\_HOME}
11444
11445 \end_inset
11446
11447
11448 \series default
11449  Path, see section 
11450 \begin_inset LatexCommand \ref{sub:Install-paths}
11451
11452 \end_inset
11453
11454 \InsetSpace ~
11455
11456 \begin_inset Quotes sld
11457 \end_inset
11458
11459  Install Paths
11460 \begin_inset Quotes srd
11461 \end_inset
11462
11463 .
11464 \end_layout
11465
11466 \begin_layout List
11467 \labelwidthstring 00.00.0000
11468
11469 \series bold
11470 SDCC_INCLUDE
11471 \begin_inset LatexCommand \index{SDCC\_INCLUDE}
11472
11473 \end_inset
11474
11475
11476 \series default
11477  Path, see section 
11478 \begin_inset LatexCommand \ref{sub:Search-Paths}
11479
11480 \end_inset
11481
11482 \InsetSpace ~
11483
11484 \begin_inset Quotes sld
11485 \end_inset
11486
11487 Search Paths
11488 \begin_inset Quotes srd
11489 \end_inset
11490
11491 .
11492 \end_layout
11493
11494 \begin_layout List
11495 \labelwidthstring 00.00.0000
11496
11497 \series bold
11498 SDCC_LIB
11499 \begin_inset LatexCommand \index{SDCC\_LIB}
11500
11501 \end_inset
11502
11503
11504 \series default
11505  Path, see section 
11506 \begin_inset LatexCommand \ref{sub:Search-Paths}
11507
11508 \end_inset
11509
11510 \InsetSpace ~
11511
11512 \begin_inset Quotes sld
11513 \end_inset
11514
11515 Search Paths
11516 \begin_inset Quotes srd
11517 \end_inset
11518
11519 ..
11520 \end_layout
11521
11522 \begin_layout Standard
11523 There are some more environment variables recognized by SDCC, but these
11524  are solely used for debugging purposes.
11525  They can change or disappear very quickly, and will never be documented.
11526 \begin_inset VSpace bigskip
11527 \end_inset
11528
11529
11530 \end_layout
11531
11532 \begin_layout Section
11533 Storage Class Language Extensions
11534 \end_layout
11535
11536 \begin_layout Subsection
11537 MCS51/DS390 Storage Class
11538 \begin_inset LatexCommand \index{Storage class}
11539
11540 \end_inset
11541
11542  Language Extensions
11543 \end_layout
11544
11545 \begin_layout Standard
11546 In addition to the ANSI storage classes SDCC allows the following MCS51
11547  specific storage classes:
11548 \end_layout
11549
11550 \begin_layout Subsubsection
11551 data
11552 \begin_inset LatexCommand \index{data (mcs51, ds390 storage class)}
11553
11554 \end_inset
11555
11556
11557 \begin_inset LatexCommand \index{\_\_data (mcs51, ds390 storage class)}
11558
11559 \end_inset
11560
11561  / near
11562 \begin_inset LatexCommand \index{near (storage class)}
11563
11564 \end_inset
11565
11566
11567 \begin_inset LatexCommand \index{\_\_near (storage class)}
11568
11569 \end_inset
11570
11571
11572 \end_layout
11573
11574 \begin_layout Standard
11575 This is the 
11576 \series bold
11577 default
11578 \series default
11579  storage class for the Small Memory model (
11580 \emph on
11581 data
11582 \emph default
11583  and 
11584 \emph on
11585 near
11586 \emph default
11587  or the more ANSI-C compliant forms 
11588 \emph on
11589 __data
11590 \emph default
11591  and 
11592 \emph on
11593 __near
11594 \emph default
11595  can be used synonymously).
11596  Variables declared with this storage class will be allocated in the directly
11597  addressable portion of the internal RAM of a 8051, e.g.:
11598 \end_layout
11599
11600 \begin_layout Verse
11601
11602 \family typewriter
11603 __data unsigned char test_data;
11604 \end_layout
11605
11606 \begin_layout Standard
11607 Writing 0x01 to this variable generates the assembly code:
11608 \end_layout
11609
11610 \begin_layout Verse
11611
11612 \family typewriter
11613 75*00 01\InsetSpace ~
11614 \InsetSpace ~
11615 \InsetSpace ~
11616 mov\InsetSpace ~
11617 \InsetSpace ~
11618 _test_data,#0x01
11619 \end_layout
11620
11621 \begin_layout Subsubsection
11622 xdata
11623 \begin_inset LatexCommand \index{xdata (mcs51, ds390 storage class)}
11624
11625 \end_inset
11626
11627
11628 \begin_inset LatexCommand \index{\_\_xdata (mcs51, ds390 storage class)}
11629
11630 \end_inset
11631
11632  / far
11633 \begin_inset LatexCommand \index{far (storage class)}
11634
11635 \end_inset
11636
11637
11638 \begin_inset LatexCommand \index{\_\_far (storage class)}
11639
11640 \end_inset
11641
11642
11643 \end_layout
11644
11645 \begin_layout Standard
11646 Variables declared with this storage class will be placed in the external
11647  RAM.
11648  This is the 
11649 \series bold
11650 default
11651 \series default
11652  storage class for the Large Memory model, e.g.:
11653 \end_layout
11654
11655 \begin_layout Verse
11656
11657 \family typewriter
11658 __xdata unsigned char test_xdata;
11659 \end_layout
11660
11661 \begin_layout Standard
11662 Writing 0x01 to this variable generates the assembly code:
11663 \end_layout
11664
11665 \begin_layout Verse
11666
11667 \family typewriter
11668 90s00r00\InsetSpace ~
11669 \InsetSpace ~
11670 \InsetSpace ~
11671 mov\InsetSpace ~
11672 \InsetSpace ~
11673 dptr,#_test_xdata 
11674 \newline
11675 74\InsetSpace ~
11676 01\InsetSpace ~
11677 \InsetSpace ~
11678 \InsetSpace ~
11679 \InsetSpace ~
11680 \InsetSpace ~
11681 \InsetSpace ~
11682 mov\InsetSpace ~
11683 \InsetSpace ~
11684 a,#0x01 
11685 \newline
11686 F0\InsetSpace ~
11687 \InsetSpace ~
11688 \InsetSpace ~
11689 \InsetSpace ~
11690 \InsetSpace ~
11691 \InsetSpace ~
11692 \InsetSpace ~
11693 \InsetSpace ~
11694 \InsetSpace ~
11695 movx\InsetSpace ~
11696 @dptr,a 
11697 \end_layout
11698
11699 \begin_layout Subsubsection
11700 idata
11701 \begin_inset LatexCommand \index{idata (mcs51, ds390 storage class)}
11702
11703 \end_inset
11704
11705
11706 \begin_inset LatexCommand \index{\_\_idata (mcs51, ds390 storage class)}
11707
11708 \end_inset
11709
11710
11711 \end_layout
11712
11713 \begin_layout Standard
11714 Variables declared with this storage class will be allocated into the indirectly
11715  addressable portion of the internal ram of a 8051, e.g.:
11716 \end_layout
11717
11718 \begin_layout Verse
11719
11720 \family typewriter
11721 __idata unsigned char test_idata;
11722 \end_layout
11723
11724 \begin_layout Standard
11725 Writing 0x01 to this variable generates the assembly code:
11726 \end_layout
11727
11728 \begin_layout Verse
11729
11730 \family typewriter
11731 78r00\InsetSpace ~
11732 \InsetSpace ~
11733 \InsetSpace ~
11734 \InsetSpace ~
11735 \InsetSpace ~
11736 \InsetSpace ~
11737 \InsetSpace ~
11738 mov\InsetSpace ~
11739 \InsetSpace ~
11740 r0,#_test_idata
11741 \newline
11742 76\InsetSpace ~
11743 01\InsetSpace ~
11744 \InsetSpace ~
11745 \InsetSpace ~
11746 \InsetSpace ~
11747 \InsetSpace ~
11748 \InsetSpace ~
11749 \InsetSpace ~
11750 mov\InsetSpace ~
11751 \InsetSpace ~
11752 @r0,#0x01
11753 \end_layout
11754
11755 \begin_layout Standard
11756 Please note, the first 128 byte of idata physically access the same RAM
11757  as the data memory.
11758  The original 8051 had 128 byte idata memory, nowadays most devices have
11759  256 byte idata memory.
11760  The stack
11761 \begin_inset LatexCommand \index{stack}
11762
11763 \end_inset
11764
11765  is located in idata memory.
11766 \end_layout
11767
11768 \begin_layout Subsubsection
11769 pdata
11770 \begin_inset LatexCommand \index{pdata (mcs51, ds390 storage class)}
11771
11772 \end_inset
11773
11774
11775 \begin_inset LatexCommand \index{\_\_pdata (mcs51, ds390 storage class)}
11776
11777 \end_inset
11778
11779
11780 \end_layout
11781
11782 \begin_layout Standard
11783 Paged xdata access is just as straightforward as using the other addressing
11784  modes of a 8051.
11785  It is typically located at the start of xdata and has a maximum size of
11786  256 bytes.
11787  The following example writes 0x01 to the pdata variable.
11788  Please note, pdata access physically accesses xdata memory.
11789  The high byte of the address is determined by port P2 
11790 \begin_inset LatexCommand \index{P2 (mcs51 sfr)}
11791
11792 \end_inset
11793
11794 (or in case of some 8051 variants by a separate Special Function Register,
11795  see section 
11796 \begin_inset LatexCommand \ref{sub:MCS51-variants}
11797
11798 \end_inset
11799
11800 ).
11801  This is the 
11802 \series bold
11803 default
11804 \series default
11805  storage class for the Medium Memory model, e.g.:
11806 \end_layout
11807
11808 \begin_layout Verse
11809
11810 \family typewriter
11811 __pdata unsigned char test_pdata;
11812 \end_layout
11813
11814 \begin_layout Standard
11815 Writing 0x01 to this variable generates the assembly code:
11816 \end_layout
11817
11818 \begin_layout Verse
11819
11820 \family typewriter
11821 78r00\InsetSpace ~
11822 \InsetSpace ~
11823 \InsetSpace ~
11824 \InsetSpace ~
11825 \InsetSpace ~
11826 \InsetSpace ~
11827 mov r0,#_test_pdata
11828 \newline
11829 74 01\InsetSpace ~
11830 \InsetSpace ~
11831 \InsetSpace ~
11832 \InsetSpace ~
11833 \InsetSpace ~
11834 \InsetSpace ~
11835 mov a,#0x01 
11836 \newline
11837 F2\InsetSpace ~
11838 \InsetSpace ~
11839 \InsetSpace ~
11840 \InsetSpace ~
11841 \InsetSpace ~
11842 \InsetSpace ~
11843 \InsetSpace ~
11844 \InsetSpace ~
11845 \InsetSpace ~
11846 movx @r0,a
11847 \end_layout
11848
11849 \begin_layout Standard
11850 If the -
11851 \begin_inset ERT
11852 status collapsed
11853
11854 \begin_layout Standard
11855
11856
11857 \backslash
11858 /
11859 \end_layout
11860
11861 \end_inset
11862
11863 -xstack
11864 \begin_inset LatexCommand \index{-\/-xstack}
11865
11866 \end_inset
11867
11868  option is used the pdata memory area is followed by the xstack memory area
11869  and the sum of their sizes is limited to 256 bytes.
11870 \end_layout
11871
11872 \begin_layout Subsubsection
11873 code
11874 \begin_inset LatexCommand \index{code}
11875
11876 \end_inset
11877
11878
11879 \begin_inset LatexCommand \index{\_\_code}
11880
11881 \end_inset
11882
11883
11884 \end_layout
11885
11886 \begin_layout Standard
11887 'Variables' declared with this storage class will be placed in the code
11888  memory:
11889 \end_layout
11890
11891 \begin_layout Verse
11892
11893 \family typewriter
11894 __code unsigned char test_code;
11895 \end_layout
11896
11897 \begin_layout Standard
11898 Read access to this variable generates the assembly code:
11899 \end_layout
11900
11901 \begin_layout Verse
11902
11903 \family typewriter
11904 90s00r6F\InsetSpace ~
11905 \InsetSpace ~
11906 \InsetSpace ~
11907 mov dptr,#_test_code
11908 \newline
11909 E4\InsetSpace ~
11910 \InsetSpace ~
11911 \InsetSpace ~
11912 \InsetSpace ~
11913 \InsetSpace ~
11914 \InsetSpace ~
11915 \InsetSpace ~
11916 \InsetSpace ~
11917 \InsetSpace ~
11918 clr a
11919 \newline
11920 93\InsetSpace ~
11921 \InsetSpace ~
11922 \InsetSpace ~
11923 \InsetSpace ~
11924 \InsetSpace ~
11925 \InsetSpace ~
11926 \InsetSpace ~
11927 \InsetSpace ~
11928 \InsetSpace ~
11929 movc a,@a+dptr 
11930 \end_layout
11931
11932 \begin_layout Standard
11933
11934 \family typewriter
11935 char
11936 \family default
11937  indexed arrays of characters in code memory can be accessed efficiently:
11938 \end_layout
11939
11940 \begin_layout Verse
11941
11942 \family typewriter
11943 __code char test_array[] = {'c','h','e','a','p'}; 
11944 \end_layout
11945
11946 \begin_layout Standard
11947 Read access to this array using an 8-bit unsigned index generates the assembly
11948  code:
11949 \end_layout
11950
11951 \begin_layout Verse
11952
11953 \family typewriter
11954 E5*00\InsetSpace ~
11955 \InsetSpace ~
11956 \InsetSpace ~
11957 \InsetSpace ~
11958 \InsetSpace ~
11959 \InsetSpace ~
11960 mov a,_index 
11961 \end_layout
11962
11963 \begin_layout Verse
11964
11965 \family typewriter
11966 90s00r41\InsetSpace ~
11967 \InsetSpace ~
11968 \InsetSpace ~
11969 mov dptr,#_test_array
11970 \end_layout
11971
11972 \begin_layout Verse
11973
11974 \family typewriter
11975 93\InsetSpace ~
11976 \InsetSpace ~
11977 \InsetSpace ~
11978 \InsetSpace ~
11979 \InsetSpace ~
11980 \InsetSpace ~
11981 \InsetSpace ~
11982 \InsetSpace ~
11983 \InsetSpace ~
11984 movc a,@a+dptr 
11985 \end_layout
11986
11987 \begin_layout Subsubsection
11988 bit
11989 \begin_inset LatexCommand \index{bit}
11990
11991 \end_inset
11992
11993
11994 \begin_inset LatexCommand \index{\_\_bit}
11995
11996 \end_inset
11997
11998
11999 \end_layout
12000
12001 \begin_layout Standard
12002 This is a data-type and a storage class specifier.
12003  When a variable is declared as a bit, it is allocated into the bit addressable
12004  memory of 8051, e.g.:
12005 \end_layout
12006
12007 \begin_layout Verse
12008
12009 \family typewriter
12010 __bit test_bit;
12011 \end_layout
12012
12013 \begin_layout Standard
12014 Writing 1 to this variable generates the assembly code:
12015 \end_layout
12016
12017 \begin_layout Verse
12018
12019 \family typewriter
12020 D2*00\InsetSpace ~
12021 \InsetSpace ~
12022 \InsetSpace ~
12023 \InsetSpace ~
12024 \InsetSpace ~
12025 \InsetSpace ~
12026 \InsetSpace ~
12027 setb\InsetSpace ~
12028 _test_bit
12029 \end_layout
12030
12031 \begin_layout Standard
12032 The bit addressable memory consists of 128 bits which are located from 0x20
12033  to 0x2f in data memory.
12034  
12035 \newline
12036 Apart from this 8051 specific storage class most architectures support
12037  ANSI-C bitfields
12038 \begin_inset LatexCommand \index{bitfields}
12039
12040 \end_inset
12041
12042
12043 \begin_inset Foot
12044 status open
12045
12046 \begin_layout Standard
12047 Not really meant as examples, but nevertheless showing what bitfields are
12048  about: device/include/mc68hc908qy.h and support/regression/tests/bitfields.c
12049 \end_layout
12050
12051 \end_inset
12052
12053 .
12054  In accordance with ISO/IEC 9899 bits and bitfields without an explicit
12055  signed modifier are implemented as unsigned.
12056 \end_layout
12057
12058 \begin_layout Subsubsection
12059 sfr
12060 \begin_inset LatexCommand \index{sfr}
12061
12062 \end_inset
12063
12064
12065 \begin_inset LatexCommand \index{\_\_sfr}
12066
12067 \end_inset
12068
12069  / sfr16
12070 \begin_inset LatexCommand \index{sfr16}
12071
12072 \end_inset
12073
12074
12075 \begin_inset LatexCommand \index{\_\_sfr16}
12076
12077 \end_inset
12078
12079  / sfr32
12080 \begin_inset LatexCommand \index{sfr32}
12081
12082 \end_inset
12083
12084
12085 \begin_inset LatexCommand \index{\_\_sfr32}
12086
12087 \end_inset
12088
12089  / sbit
12090 \begin_inset LatexCommand \index{\_\_sbit}
12091
12092 \end_inset
12093
12094
12095 \begin_inset LatexCommand \index{sbit}
12096
12097 \end_inset
12098
12099
12100 \end_layout
12101
12102 \begin_layout Standard
12103 Like the bit keyword, 
12104 \emph on
12105 sfr / sfr16 / sfr32 / sbit 
12106 \emph default
12107 signify both a data-type and storage class, they are used to describe the
12108  
12109 \emph on
12110 s
12111 \emph default
12112 pecial 
12113 \emph on
12114 f
12115 \emph default
12116 unction 
12117 \emph on
12118 r
12119 \emph default
12120 egisters and 
12121 \emph on
12122 s
12123 \emph default
12124 pecial 
12125 \emph on
12126 bit
12127 \emph default
12128  variables of a 8051, eg:
12129 \end_layout
12130
12131 \begin_layout Verse
12132
12133 \family typewriter
12134 __sfr __at
12135 \begin_inset LatexCommand \index{at}
12136
12137 \end_inset
12138
12139
12140 \begin_inset LatexCommand \index{\_\_at}
12141
12142 \end_inset
12143
12144  (0x80) P0;\InsetSpace ~
12145  /* special function register P0 at location 0x80 */
12146 \newline
12147
12148 \newline
12149 /* 16 bit
12150  special function register combination for timer 0
12151 \newline
12152 \InsetSpace ~
12153 \InsetSpace ~
12154  with the high byte at
12155  location 0x8C and the low byte at location 0x8A */
12156 \newline
12157 __sfr16 __at (0x8C8A)
12158  TMR0;
12159 \newline
12160
12161 \newline
12162 __sbit __at
12163 \begin_inset LatexCommand \index{at}
12164
12165 \end_inset
12166
12167
12168 \begin_inset LatexCommand \index{\_\_at}
12169
12170 \end_inset
12171
12172  (0xd7) CY;\InsetSpace ~
12173  /* CY (Carry Flag
12174 \begin_inset LatexCommand \index{Flags}
12175
12176 \end_inset
12177
12178
12179 \begin_inset LatexCommand \index{Carry flag}
12180
12181 \end_inset
12182
12183 ) */
12184 \end_layout
12185
12186 \begin_layout Standard
12187 Special function registers which are located on an address dividable by
12188  8 are bit-addressable, an
12189 \emph on
12190  sbit
12191 \emph default
12192  addresses a specific bit within these sfr.
12193 \newline
12194 16 Bit and 32 bit special function
12195  register combinations which require a certain access order are better not
12196  declared using 
12197 \emph on
12198 sfr16
12199 \emph default
12200  or 
12201 \emph on
12202 sfr32.
12203
12204 \emph default
12205  Allthough SDCC usually accesses them Least Significant Byte (LSB) first,
12206  this is not guaranteed.
12207 \newline
12208
12209 \end_layout
12210
12211 \begin_layout Standard
12212 Please note, if you use a header file which was written for another compiler
12213  then the sfr / sfr16 / sfr32 / sbit Storage Class extensions will most
12214  likely be 
12215 \emph on
12216 not 
12217 \emph default
12218 compatible.
12219  Specifically the syntax 
12220 \family typewriter
12221 \InsetSpace ~
12222 sfr P0 = 0x80;\InsetSpace ~
12223
12224 \family default
12225  is compiled 
12226 \emph on
12227 without warning
12228 \emph default
12229  by SDCC to an assignment of 0x80 to a variable called P0 
12230 \family typewriter
12231
12232 \begin_inset Marginal
12233 status collapsed
12234
12235 \begin_layout Standard
12236
12237 \series bold
12238 \InsetSpace ~
12239 !
12240 \end_layout
12241
12242 \end_inset
12243
12244 .
12245  
12246 \family default
12247 Nevertheless it is possible to write header files
12248 \begin_inset LatexCommand \index{Header files}
12249
12250 \end_inset
12251
12252
12253 \begin_inset LatexCommand \index{Include files}
12254
12255 \end_inset
12256
12257  which can be shared among different compilers (see section 
12258 \begin_inset LatexCommand \ref{sec:Porting-code-to-other-compilers}
12259
12260 \end_inset
12261
12262 ).
12263  
12264 \end_layout
12265
12266 \begin_layout Subsubsection
12267 Pointers
12268 \begin_inset LatexCommand \index{Pointer}
12269
12270 \end_inset
12271
12272  to MCS51/DS390 specific memory spaces
12273 \end_layout
12274
12275 \begin_layout Standard
12276 SDCC allows (via language extensions) pointers to explicitly point to any
12277  of the memory spaces
12278 \begin_inset LatexCommand \index{Memory model}
12279
12280 \end_inset
12281
12282  of the 8051.
12283  In addition to the explicit pointers, the compiler uses (by default) generic
12284  pointers which can be used to point to any of the memory spaces.
12285 \newline
12286
12287 \newline
12288 Pointer
12289  declaration examples:
12290 \end_layout
12291
12292 \begin_layout Verse
12293
12294 \family typewriter
12295 /* pointer physically in internal ram pointing to object in external ram
12296  */ 
12297 \newline
12298 __xdata unsigned char * __data p;
12299 \newline
12300
12301 \newline
12302 /* pointer physically in external ram
12303  pointing to object in internal ram */ 
12304 \newline
12305 __data unsigned char * __xdata p;
12306 \newline
12307
12308 \newline
12309 /*
12310  pointer physically in code rom pointing to data in xdata space */ 
12311 \newline
12312 __xdata
12313  unsigned char * __code p;
12314 \newline
12315
12316 \newline
12317 /* pointer physically in code space pointing to
12318  data in code space */ 
12319 \newline
12320 __code unsigned char * __code p;
12321 \newline
12322
12323 \newline
12324 /* generic pointer
12325  physically located in xdata space */
12326 \newline
12327 unsigned char * __xdata p;
12328 \newline
12329
12330 \newline
12331 /* generic
12332  pointer physically located in default memory space */
12333 \newline
12334 unsigned char * p;
12335 \newline
12336
12337 \newline
12338 /*
12339  the following is a function pointer
12340 \begin_inset LatexCommand \index{function pointer}
12341
12342 \end_inset
12343
12344  physically located in data space */
12345 \newline
12346 char (* __data fp)(void);
12347 \end_layout
12348
12349 \begin_layout Standard
12350 Well you get the idea.
12351  
12352 \newline
12353
12354 \newline
12355 All unqualified pointers are treated as 3-byte (4-byte for the ds390) 
12356 \emph on
12357 generic
12358 \emph default
12359  pointers.
12360  
12361 \size small
12362
12363 \newline
12364
12365 \newline
12366
12367 \size default
12368 The highest order byte of the 
12369 \emph on
12370 generic
12371 \emph default
12372  pointers contains the data space information.
12373  Assembler support routines are called whenever data is stored or retrieved
12374  using 
12375 \emph on
12376 generic
12377 \emph default
12378  pointers.
12379  These are useful for developing reusable library
12380 \begin_inset LatexCommand \index{Libraries}
12381
12382 \end_inset
12383
12384  routines.
12385  Explicitly specifying the pointer
12386 \begin_inset LatexCommand \index{pointer}
12387
12388 \end_inset
12389
12390  type will generate the most efficient code.
12391 \end_layout
12392
12393 \begin_layout Subsubsection
12394 Notes on MCS51 memory
12395 \begin_inset LatexCommand \index{MCS51 memory}
12396
12397 \end_inset
12398
12399  layout
12400 \end_layout
12401
12402 \begin_layout Standard
12403 The 8051 family of microcontrollers have a minimum of 128 bytes of internal
12404  RAM memory which is structured as follows:
12405 \newline
12406
12407 \newline
12408 - Bytes 00-1F - 32 bytes to hold
12409  up to 4 banks of the registers R0 to R7, 
12410 \newline
12411 - Bytes 20-2F - 16 bytes to hold
12412  128 bit
12413 \begin_inset LatexCommand \index{bit}
12414
12415 \end_inset
12416
12417  variables and, 
12418 \newline
12419 - Bytes 30-7F - 80 bytes for general purpose use.
12420 \newline
12421
12422 \end_layout
12423
12424 \begin_layout Standard
12425 Additionally some members of the MCS51 family may have up to 128 bytes of
12426  additional, indirectly addressable, internal RAM memory (
12427 \emph on
12428 idata
12429 \emph default
12430
12431 \begin_inset LatexCommand \index{idata (mcs51, ds390 storage class)}
12432
12433 \end_inset
12434
12435
12436 \begin_inset LatexCommand \index{\_\_idata (mcs51, ds390 storage class)}
12437
12438 \end_inset
12439
12440 ).
12441  Furthermore, some chips may have some built in external memory (
12442 \emph on
12443 xdata
12444 \emph default
12445
12446 \begin_inset LatexCommand \index{xdata (mcs51, ds390 storage class)}
12447
12448 \end_inset
12449
12450
12451 \begin_inset LatexCommand \index{\_\_xdata (mcs51, ds390 storage class)}
12452
12453 \end_inset
12454
12455 ) which should not be confused with the internal, directly addressable RAM
12456  memory (
12457 \emph on
12458 data
12459 \emph default
12460
12461 \begin_inset LatexCommand \index{data (mcs51, ds390 storage class)}
12462
12463 \end_inset
12464
12465
12466 \begin_inset LatexCommand \index{\_\_data (mcs51, ds390 storage class)}
12467
12468 \end_inset
12469
12470 ).
12471  Sometimes this built in 
12472 \emph on
12473 xdata
12474 \emph default
12475  memory has to be activated before using it (you can probably find this
12476  information on the datasheet of the microcontroller your are using, see
12477  also section 
12478 \begin_inset LatexCommand \ref{sub:Startup-Code}
12479
12480 \end_inset
12481
12482 \InsetSpace ~
12483 Startup-Code).
12484 \end_layout
12485
12486 \begin_layout Standard
12487 Normally SDCC will only use the first bank
12488 \begin_inset LatexCommand \index{register bank (mcs51, ds390)}
12489
12490 \end_inset
12491
12492  of registers (register bank 0), but it is possible to specify that other
12493  banks of registers (keyword 
12494 \emph on
12495 using
12496 \emph default
12497  
12498 \emph on
12499
12500 \begin_inset LatexCommand \index{using (mcs51, ds390 register bank)}
12501
12502 \end_inset
12503
12504
12505 \begin_inset LatexCommand \index{\_\_using (mcs51, ds390 register bank)}
12506
12507 \end_inset
12508
12509
12510 \emph default
12511 ) should be used for example in interrupt
12512 \begin_inset LatexCommand \index{interrupt}
12513
12514 \end_inset
12515
12516
12517 \begin_inset LatexCommand \index{\_\_interrupt}
12518
12519 \end_inset
12520
12521  routines.
12522  By default, the compiler will place the stack after the last byte of allocated
12523  memory for variables.
12524  For example, if the first 2 banks of registers are used, and only four
12525  bytes are used for 
12526 \emph on
12527 data
12528 \emph default
12529  variables, it will position the base of the internal stack at address 20
12530  (0x14).
12531  This implies that as the stack
12532 \begin_inset LatexCommand \index{stack}
12533
12534 \end_inset
12535
12536  grows, it will use up the remaining register banks, and the 16 bytes used
12537  by the 128 bit variables, and 80 bytes for general purpose use.
12538  If any bit variables are used, the data variables will be placed in unused
12539  register banks and after the byte holding the last bit variable.
12540  For example, if register banks 0 and 1 are used, and there are 9 bit variables
12541  (two bytes used), 
12542 \emph on
12543 data
12544 \emph default
12545  variables will be placed starting from address 0x10 to 0x20 and continue
12546  at address 0x22.
12547  You can also use -
12548 \begin_inset ERT
12549 status collapsed
12550
12551 \begin_layout Standard
12552
12553
12554 \backslash
12555 /
12556 \end_layout
12557
12558 \end_inset
12559
12560 -data-loc
12561 \begin_inset LatexCommand \index{-\/-data-loc <Value>}
12562
12563 \end_inset
12564
12565  to specify the start address of the 
12566 \emph on
12567 data
12568 \emph default
12569  and -
12570 \begin_inset ERT
12571 status collapsed
12572
12573 \begin_layout Standard
12574
12575
12576 \backslash
12577 /
12578 \end_layout
12579
12580 \end_inset
12581
12582 -iram-size
12583 \begin_inset LatexCommand \index{-\/-iram-size <Value>}
12584
12585 \end_inset
12586
12587  to specify the size of the total internal RAM (
12588 \emph on
12589 data
12590 \emph default
12591 +
12592 \emph on
12593 idata
12594 \emph default
12595 ).
12596  
12597 \newline
12598
12599 \end_layout
12600
12601 \begin_layout Standard
12602 By default the 8051 linker will place the stack after the last byte of (i)data
12603  variables.
12604  Option -
12605 \begin_inset ERT
12606 status collapsed
12607
12608 \begin_layout Standard
12609
12610
12611 \backslash
12612 /
12613 \end_layout
12614
12615 \end_inset
12616
12617 -stack-loc
12618 \begin_inset LatexCommand \index{-\/-stack-loc <Value>}
12619
12620 \end_inset
12621
12622  allows you to specify the start of the stack, i.e.
12623  you could start it after any data in the general purpose area.
12624  If your microcontroller has additional indirectly addressable internal
12625  RAM (
12626 \emph on
12627 idata
12628 \emph default
12629 ) you can place the stack on it.
12630  You may also need to use -
12631 \begin_inset ERT
12632 status collapsed
12633
12634 \begin_layout Standard
12635
12636
12637 \backslash
12638 /
12639 \end_layout
12640
12641 \end_inset
12642
12643 -xdata-loc
12644 \begin_inset LatexCommand \index{-\/-xdata-loc<Value>}
12645
12646 \end_inset
12647
12648  to set the start address of the external RAM (
12649 \emph on
12650 xdata
12651 \emph default
12652 ) and -
12653 \begin_inset ERT
12654 status collapsed
12655
12656 \begin_layout Standard
12657
12658
12659 \backslash
12660 /
12661 \end_layout
12662
12663 \end_inset
12664
12665 -xram-size
12666 \begin_inset LatexCommand \index{-\/-xram-size <Value>}
12667
12668 \end_inset
12669
12670  to specify its size.
12671  Same goes for the code memory, using -
12672 \begin_inset ERT
12673 status collapsed
12674
12675 \begin_layout Standard
12676
12677
12678 \backslash
12679 /
12680 \end_layout
12681
12682 \end_inset
12683
12684 -code-loc
12685 \begin_inset LatexCommand \index{-\/-code-loc <Value>}
12686
12687 \end_inset
12688
12689  and -
12690 \begin_inset ERT
12691 status collapsed
12692
12693 \begin_layout Standard
12694
12695
12696 \backslash
12697 /
12698 \end_layout
12699
12700 \end_inset
12701
12702 -code-size
12703 \begin_inset LatexCommand \index{-\/-code-size <Value>}
12704
12705 \end_inset
12706
12707 .
12708  If in doubt, don't specify any options and see if the resulting memory
12709  layout is appropriate, then you can adjust it.
12710 \end_layout
12711
12712 \begin_layout Standard
12713 The linker generates two files with memory allocation information.
12714  The first, with extension .map
12715 \begin_inset LatexCommand \index{<file>.map}
12716
12717 \end_inset
12718
12719  shows all the variables and segments.
12720  The second with extension .mem
12721 \begin_inset LatexCommand \index{<file>.mem}
12722
12723 \end_inset
12724
12725  shows the final memory layout.
12726  The linker will complain either if memory segments overlap, there is not
12727  enough memory, or there is not enough space for stack.
12728  If you get any linking warnings and/or errors related to stack or segments
12729  allocation, take a look at either the .map or .mem files to find out what
12730  the problem is.
12731  The .mem file may even suggest a solution to the problem.
12732 \begin_inset VSpace bigskip
12733 \end_inset
12734
12735
12736 \end_layout
12737
12738 \begin_layout Subsection
12739 Z80/Z180 Storage Class
12740 \begin_inset LatexCommand \index{Z80!Storage class}
12741
12742 \end_inset
12743
12744  Language Extensions
12745 \end_layout
12746
12747 \begin_layout Subsubsection
12748 sfr
12749 \begin_inset LatexCommand \index{sfr}
12750
12751 \end_inset
12752
12753
12754 \begin_inset LatexCommand \index{\_\_sfr}
12755
12756 \end_inset
12757
12758  (in/out to 8-bit addresses)
12759 \end_layout
12760
12761 \begin_layout Standard
12762 The Z80
12763 \begin_inset LatexCommand \index{Z80}
12764
12765 \end_inset
12766
12767  family has separate address spaces for memory and 
12768 \emph on
12769 i
12770 \emph default
12771 nput/
12772 \emph on
12773 o
12774 \emph default
12775 utput memory.
12776  I/O memory
12777 \begin_inset LatexCommand \index{I/O memory (Z80, Z180)}
12778
12779 \end_inset
12780
12781
12782 \begin_inset LatexCommand \index{Z80!I/O memory}
12783
12784 \end_inset
12785
12786
12787 \begin_inset LatexCommand \index{Z180!I/O memory}
12788
12789 \end_inset
12790
12791  is accessed with special instructions, e.g.:
12792 \end_layout
12793
12794 \begin_layout Verse
12795
12796 \family typewriter
12797 sfr at 0x78 IoPort;\InsetSpace ~
12798 \InsetSpace ~
12799 /* define a var in I/O space at 78h called IoPort */
12800  
12801 \end_layout
12802
12803 \begin_layout Standard
12804 Writing 0x01 to this variable generates the assembly code:
12805 \end_layout
12806
12807 \begin_layout Verse
12808
12809 \family typewriter
12810 3E 01\InsetSpace ~
12811 \InsetSpace ~
12812 \InsetSpace ~
12813 \InsetSpace ~
12814 \InsetSpace ~
12815 \InsetSpace ~
12816 ld a,#0x01
12817 \newline
12818 D3 78\InsetSpace ~
12819 \InsetSpace ~
12820 \InsetSpace ~
12821 \InsetSpace ~
12822 \InsetSpace ~
12823 \InsetSpace ~
12824 out (_IoPort),a 
12825 \end_layout
12826
12827 \begin_layout Subsubsection
12828 banked sfr
12829 \begin_inset LatexCommand \index{sfr}
12830
12831 \end_inset
12832
12833
12834 \begin_inset LatexCommand \index{\_\_sfr}
12835
12836 \end_inset
12837
12838  (in/out to 16-bit addresses)
12839 \end_layout
12840
12841 \begin_layout Standard
12842 The keyword 
12843 \emph on
12844 banked
12845 \emph default
12846  is used to support 16 bit addresses in I/O memory e.g.:
12847 \end_layout
12848
12849 \begin_layout Verse
12850
12851 \family typewriter
12852 sfr banked at
12853 \begin_inset LatexCommand \index{at}
12854
12855 \end_inset
12856
12857
12858 \begin_inset LatexCommand \index{\_\_at}
12859
12860 \end_inset
12861
12862  0x123 IoPort; 
12863 \end_layout
12864
12865 \begin_layout Standard
12866 Writing 0x01 to this variable generates the assembly code:
12867 \end_layout
12868
12869 \begin_layout Verse
12870
12871 \family typewriter
12872 01 23 01\InsetSpace ~
12873 \InsetSpace ~
12874 \InsetSpace ~
12875 ld bc,#_IoPort
12876 \newline
12877 3E 01\InsetSpace ~
12878 \InsetSpace ~
12879 \InsetSpace ~
12880 \InsetSpace ~
12881 \InsetSpace ~
12882 \InsetSpace ~
12883 ld a,#0x01 
12884 \newline
12885 ED 79\InsetSpace ~
12886 \InsetSpace ~
12887 \InsetSpace ~
12888 \InsetSpace ~
12889 \InsetSpace ~
12890 \InsetSpace ~
12891 out (c),a 
12892 \end_layout
12893
12894 \begin_layout Subsubsection
12895 sfr
12896 \begin_inset LatexCommand \index{sfr}
12897
12898 \end_inset
12899
12900
12901 \begin_inset LatexCommand \index{\_\_sfr}
12902
12903 \end_inset
12904
12905  (in0/out0 to 8 bit addresses on Z180
12906 \begin_inset LatexCommand \index{Z180}
12907
12908 \end_inset
12909
12910 /HD64180
12911 \begin_inset LatexCommand \index{HD64180 (see Z180)}
12912
12913 \end_inset
12914
12915 )
12916 \end_layout
12917
12918 \begin_layout Standard
12919 The compiler option -
12920 \begin_inset ERT
12921 status collapsed
12922
12923 \begin_layout Standard
12924
12925
12926 \backslash
12927 /
12928 \end_layout
12929
12930 \end_inset
12931
12932 -portmode
12933 \begin_inset LatexCommand \index{Z180!Options!-\/-portmode}
12934
12935 \end_inset
12936
12937 =180 (80) and a compiler #pragma\InsetSpace ~
12938 portmode
12939 \begin_inset LatexCommand \index{Z180!Pragmas!\#pragma portmode}
12940
12941 \end_inset
12942
12943  z180 (z80) is used to turn on (off) the Z180/HD64180 port addressing instructio
12944 ns 
12945 \family typewriter
12946 in0/out0
12947 \family default
12948  instead of 
12949 \family typewriter
12950 in/out
12951 \family default
12952 .
12953  If you include the file z180.h this will be set automatically.
12954 \begin_inset VSpace bigskip
12955 \end_inset
12956
12957
12958 \end_layout
12959
12960 \begin_layout Subsection
12961 HC08 Storage Class
12962 \begin_inset LatexCommand \index{HC08!Storage class}
12963
12964 \end_inset
12965
12966  Language Extensions
12967 \end_layout
12968
12969 \begin_layout Subsubsection
12970 data
12971 \begin_inset LatexCommand \index{data (hc08 storage class)}
12972
12973 \end_inset
12974
12975
12976 \begin_inset LatexCommand \index{\_\_data (hc08 storage class)}
12977
12978 \end_inset
12979
12980  
12981 \end_layout
12982
12983 \begin_layout Standard
12984 The data storage class declares a variable that resides in the first 256
12985  bytes of memory (the direct page).
12986  The HC08
12987 \begin_inset LatexCommand \index{HC08}
12988
12989 \end_inset
12990
12991  is most efficient at accessing variables (especially pointers) stored here.
12992 \end_layout
12993
12994 \begin_layout Subsubsection
12995 xdata
12996 \begin_inset LatexCommand \index{xdata (hc08 storage class)}
12997
12998 \end_inset
12999
13000
13001 \begin_inset LatexCommand \index{\_\_xdata (hc08 storage class)}
13002
13003 \end_inset
13004
13005  
13006 \end_layout
13007
13008 \begin_layout Standard
13009 The xdata storage class declares a variable that can reside anywhere in
13010  memory.
13011  This is the default if no storage class is specified.
13012  
13013 \begin_inset VSpace bigskip
13014 \end_inset
13015
13016
13017 \end_layout
13018
13019 \begin_layout Section
13020 Absolute Addressing
13021 \begin_inset LatexCommand \index{Absolute addressing}
13022
13023 \end_inset
13024
13025
13026 \end_layout
13027
13028 \begin_layout Standard
13029 Data items can be assigned an absolute address with the 
13030 \emph on
13031 at
13032 \begin_inset LatexCommand \index{at}
13033
13034 \end_inset
13035
13036
13037 \begin_inset LatexCommand \index{\_\_at}
13038
13039 \end_inset
13040
13041  <address>
13042 \emph default
13043  keyword, in addition to a storage class, e.g.:
13044 \end_layout
13045
13046 \begin_layout Verse
13047
13048 \family typewriter
13049 xdata
13050 \begin_inset LatexCommand \index{xdata (mcs51, ds390 storage class)}
13051
13052 \end_inset
13053
13054
13055 \begin_inset LatexCommand \index{\_\_xdata (mcs51, ds390 storage class)}
13056
13057 \end_inset
13058
13059  at
13060 \begin_inset LatexCommand \index{at}
13061
13062 \end_inset
13063
13064
13065 \begin_inset LatexCommand \index{\_\_at}
13066
13067 \end_inset
13068
13069  0x7ffe unsigned int chksum;
13070 \end_layout
13071
13072 \begin_layout Standard
13073 or, better conforming to ISO/IEC 9899 C:
13074 \end_layout
13075
13076 \begin_layout Verse
13077
13078 \family typewriter
13079 __xdata __at (0x7ffe) unsigned int chksum;
13080 \end_layout
13081
13082 \begin_layout Standard
13083 In the above example the variable chksum will be located at 0x7ffe and 0x7fff
13084  of the external ram.
13085  The compiler does 
13086 \emph on
13087 not
13088 \emph default
13089  reserve any space for variables declared in this way
13090 \begin_inset Marginal
13091 status collapsed
13092
13093 \begin_layout Standard
13094
13095 \series bold
13096 \InsetSpace ~
13097 !
13098 \end_layout
13099
13100 \end_inset
13101
13102  (they are implemented with an equate in the assembler).
13103  Thus it is left to the programmer to make sure there are no overlaps with
13104  other variables that are declared without the absolute address.
13105  The assembler listing file (.lst
13106 \begin_inset LatexCommand \index{<file>.lst}
13107
13108 \end_inset
13109
13110 ) and the linker output files (.rst
13111 \begin_inset LatexCommand \index{<file>.rst}
13112
13113 \end_inset
13114
13115 ) and (.map
13116 \begin_inset LatexCommand \index{<file>.map}
13117
13118 \end_inset
13119
13120 ) are good places to look for such overlaps.
13121 \end_layout
13122
13123 \begin_layout Standard
13124 If however you provide an initializer
13125 \begin_inset LatexCommand \index{Variable initialization}
13126
13127 \end_inset
13128
13129  actual memory allocation will take place and overlaps will be detected
13130  by the linker.
13131  E.g.:
13132 \end_layout
13133
13134 \begin_layout Verse
13135
13136 \family typewriter
13137 __code __at (0x7ff0) char Id[5] = 
13138 \begin_inset Quotes sld
13139 \end_inset
13140
13141 SDCC
13142 \begin_inset Quotes srd
13143 \end_inset
13144
13145 ;
13146 \end_layout
13147
13148 \begin_layout Standard
13149 In the above example the variable Id will be located from 0x7ff0 to 0x7ff4
13150  in code memory.
13151 \end_layout
13152
13153 \begin_layout Standard
13154 In case of memory mapped I/O devices the keyword 
13155 \emph on
13156 volatile
13157 \emph default
13158  has to be used to tell the compiler that accesses might not be removed:
13159 \end_layout
13160
13161 \begin_layout Verse
13162
13163 \family typewriter
13164 volatile
13165 \begin_inset LatexCommand \index{volatile}
13166
13167 \end_inset
13168
13169  __xdata
13170 \begin_inset LatexCommand \index{xdata (mcs51, ds390 storage class)}
13171
13172 \end_inset
13173
13174  __at
13175 \begin_inset LatexCommand \index{at}
13176
13177 \end_inset
13178
13179  (0x8000) unsigned char PORTA_8255;
13180 \end_layout
13181
13182 \begin_layout Standard
13183 For some architectures (mcs51) array accesses are more efficient if an (xdata/fa
13184 r) array
13185 \family typewriter
13186 \size footnotesize
13187
13188 \begin_inset LatexCommand \index{Aligned array}
13189
13190 \end_inset
13191
13192
13193 \family default
13194 \size default
13195  starts at a block (256 byte) boundary
13196 \begin_inset LatexCommand \index{block boundary}
13197
13198 \end_inset
13199
13200  (section 
13201 \begin_inset LatexCommand \ref{sub:A-Step-by Assembler Introduction}
13202
13203 \end_inset
13204
13205  has an example).
13206 \newline
13207 Absolute addresses can be specified for variables in all
13208  storage classes, e.g.:
13209 \end_layout
13210
13211 \begin_layout Verse
13212
13213 \family typewriter
13214 __bit
13215 \begin_inset LatexCommand \index{bit}
13216
13217 \end_inset
13218
13219  __at
13220 \begin_inset LatexCommand \index{at}
13221
13222 \end_inset
13223
13224  (0x02) bvar;
13225 \end_layout
13226
13227 \begin_layout Standard
13228 The above example will allocate the variable at offset 0x02 in the bit-addressab
13229 le space.
13230  There is no real advantage to assigning absolute addresses to variables
13231  in this manner, unless you want strict control over all the variables allocated.
13232  One possible use would be to write hardware portable code.
13233  For example, if you have a routine that uses one or more of the microcontroller
13234  I/O pins, and such pins are different for two different hardwares, you
13235  can declare the I/O pins in your routine using:
13236 \end_layout
13237
13238 \begin_layout Verse
13239
13240 \family typewriter
13241 extern volatile
13242 \begin_inset LatexCommand \index{volatile}
13243
13244 \end_inset
13245
13246  __bit MOSI;\InsetSpace ~
13247 \InsetSpace ~
13248 \InsetSpace ~
13249 \InsetSpace ~
13250 /* master out, slave in */
13251 \newline
13252 extern volatile __bit MISO;\InsetSpace ~
13253 \InsetSpace ~
13254 \InsetSpace ~
13255 \InsetSpace ~
13256 /* master
13257  in, slave out */
13258 \newline
13259 extern volatile __bit MCLK;\InsetSpace ~
13260 \InsetSpace ~
13261 \InsetSpace ~
13262 \InsetSpace ~
13263 /* master clock */
13264 \newline
13265
13266 \newline
13267 /* Input and
13268  Output of a byte on a 3-wire serial bus.
13269 \newline
13270 \InsetSpace ~
13271 \InsetSpace ~
13272 \InsetSpace ~
13273 If needed adapt polarity of clock,
13274  polarity of data and bit order
13275 \newline
13276 \InsetSpace ~
13277 */
13278 \newline
13279 unsigned char spi_io(unsigned char out_byte)
13280  
13281 \newline
13282
13283 \newline
13284 \InsetSpace ~
13285 \InsetSpace ~
13286 \InsetSpace ~
13287 \InsetSpace ~
13288 unsigned char i=8;
13289 \newline
13290 \InsetSpace ~
13291 \InsetSpace ~
13292 \InsetSpace ~
13293 \InsetSpace ~
13294 do { 
13295 \newline
13296 \InsetSpace ~
13297 \InsetSpace ~
13298 \InsetSpace ~
13299 \InsetSpace ~
13300 \InsetSpace ~
13301 \InsetSpace ~
13302 \InsetSpace ~
13303 \InsetSpace ~
13304 MOSI = out_byte & 0x80; 
13305 \newline
13306 \InsetSpace ~
13307 \InsetSpace ~
13308 \InsetSpace ~
13309 \InsetSpace ~
13310 \InsetSpace ~
13311 \InsetSpace ~
13312 \InsetSpace ~
13313 \InsetSpace ~
13314 out_byte <<= 1;
13315 \newline
13316 \InsetSpace ~
13317 \InsetSpace ~
13318 \InsetSpace ~
13319 \InsetSpace ~
13320 \InsetSpace ~
13321 \InsetSpace ~
13322 \InsetSpace ~
13323 \InsetSpace ~
13324 MCLK =
13325  1; 
13326 \newline
13327 \InsetSpace ~
13328 \InsetSpace ~
13329 \InsetSpace ~
13330 \InsetSpace ~
13331 \InsetSpace ~
13332 \InsetSpace ~
13333 \InsetSpace ~
13334 \InsetSpace ~
13335 /* _asm nop _endasm; */\InsetSpace ~
13336 \InsetSpace ~
13337 \InsetSpace ~
13338 \InsetSpace ~
13339 \InsetSpace ~
13340 \InsetSpace ~
13341 \InsetSpace ~
13342 \InsetSpace ~
13343 /* for slow peripherals */
13344 \newline
13345 \InsetSpace ~
13346 \InsetSpace ~
13347 \InsetSpace ~
13348 \InsetSpace ~
13349 \InsetSpace ~
13350 \InsetSpace ~
13351 \InsetSpace ~
13352 \InsetSpace ~
13353 if(MISO) 
13354 \newline
13355 \InsetSpace ~
13356 \InsetSpace ~
13357 \InsetSpace ~
13358 \InsetSpace ~
13359 \InsetSpace ~
13360 \InsetSpace ~
13361 \InsetSpace ~
13362 \InsetSpace ~
13363 \InsetSpace ~
13364 \InsetSpace ~
13365 \InsetSpace ~
13366 \InsetSpace ~
13367 out_byte +=
13368  1; 
13369 \newline
13370 \InsetSpace ~
13371 \InsetSpace ~
13372 \InsetSpace ~
13373 \InsetSpace ~
13374 \InsetSpace ~
13375 \InsetSpace ~
13376 \InsetSpace ~
13377 \InsetSpace ~
13378 MCLK = 0; 
13379 \newline
13380 \InsetSpace ~
13381 \InsetSpace ~
13382 \InsetSpace ~
13383 \InsetSpace ~
13384 } while(--i);
13385 \newline
13386 \InsetSpace ~
13387 \InsetSpace ~
13388 \InsetSpace ~
13389 \InsetSpace ~
13390 return out_byte; 
13391 \newline
13392 }
13393 \end_layout
13394
13395 \begin_layout Standard
13396 Then, someplace in the code for the first hardware you would use
13397 \end_layout
13398
13399 \begin_layout Verse
13400
13401 \family typewriter
13402 __bit __at
13403 \begin_inset LatexCommand \index{at}
13404
13405 \end_inset
13406
13407
13408 \begin_inset LatexCommand \index{\_\_at}
13409
13410 \end_inset
13411
13412  (0x80) MOSI;\InsetSpace ~
13413 \InsetSpace ~
13414 \InsetSpace ~
13415 \InsetSpace ~
13416 /* I/O port 0, bit 0 */
13417 \newline
13418 __bit __at (0x81) MISO;\InsetSpace ~
13419 \InsetSpace ~
13420 \InsetSpace ~
13421 \InsetSpace ~
13422 /* I/O port 0,
13423  bit 1 */
13424 \newline
13425 __bit __at (0x82) MCLK;\InsetSpace ~
13426 \InsetSpace ~
13427 \InsetSpace ~
13428 \InsetSpace ~
13429 /* I/O port 0, bit 2 */
13430 \end_layout
13431
13432 \begin_layout Standard
13433 Similarly, for the second hardware you would use
13434 \end_layout
13435
13436 \begin_layout Verse
13437
13438 \family typewriter
13439 __bit __at (0x83) MOSI;\InsetSpace ~
13440 \InsetSpace ~
13441 \InsetSpace ~
13442 \InsetSpace ~
13443 /* I/O port 0, bit 3 */
13444 \newline
13445 __bit __at (0x91) MISO;\InsetSpace ~
13446 \InsetSpace ~
13447 \InsetSpace ~
13448 \InsetSpace ~
13449 /*
13450  I/O port 1, bit 1 */
13451 \newline
13452 __bit
13453 \begin_inset LatexCommand \index{bit}
13454
13455 \end_inset
13456
13457  __at (0x92) MCLK;\InsetSpace ~
13458 \InsetSpace ~
13459 \InsetSpace ~
13460 \InsetSpace ~
13461 /* I/O port 1, bit 2 */
13462 \end_layout
13463
13464 \begin_layout Standard
13465 and you can use the same hardware dependent routine without changes, as
13466  for example in a library.
13467  This is somehow similar to sbit, but only one absolute address has to be
13468  specified in the whole project.
13469 \begin_inset VSpace bigskip
13470 \end_inset
13471
13472
13473 \end_layout
13474
13475 \begin_layout Section
13476 Parameters
13477 \begin_inset LatexCommand \index{Parameters}
13478
13479 \end_inset
13480
13481
13482 \begin_inset LatexCommand \index{function parameter}
13483
13484 \end_inset
13485
13486  & Local Variables
13487 \begin_inset LatexCommand \index{local variables}
13488
13489 \end_inset
13490
13491
13492 \begin_inset LatexCommand \label{sec:Parameters-and-Local-Variables}
13493
13494 \end_inset
13495
13496
13497 \end_layout
13498
13499 \begin_layout Standard
13500 Automatic (local) variables and parameters to functions can either be placed
13501  on the stack or in data-space.
13502  The default action of the compiler is to place these variables in the internal
13503  RAM (for small model) or external RAM (for medium or large model).
13504  This in fact makes them similar to 
13505 \emph on
13506 static
13507 \begin_inset LatexCommand \index{static}
13508
13509 \end_inset
13510
13511
13512 \emph default
13513  so by default functions are non-reentrant
13514 \begin_inset LatexCommand \index{reentrant}
13515
13516 \end_inset
13517
13518 .
13519  
13520 \newline
13521
13522 \newline
13523 They can be placed on the stack
13524 \begin_inset LatexCommand \index{stack}
13525
13526 \end_inset
13527
13528  by using the
13529 \emph on
13530  -
13531 \begin_inset ERT
13532 status collapsed
13533
13534 \begin_layout Standard
13535
13536
13537 \backslash
13538 /
13539 \end_layout
13540
13541 \end_inset
13542
13543 -stack-auto
13544 \begin_inset LatexCommand \index{-\/-stack-auto}
13545
13546 \end_inset
13547
13548
13549 \emph default
13550  option, by using 
13551 \emph on
13552 #pragma\InsetSpace ~
13553 stackauto
13554 \emph default
13555
13556 \begin_inset LatexCommand \index{\#pragma stackauto}
13557
13558 \end_inset
13559
13560  or by using the 
13561 \emph on
13562 reentrant
13563 \begin_inset LatexCommand \index{reentrant}
13564
13565 \end_inset
13566
13567
13568 \emph default
13569  keyword in the function declaration, e.g.:
13570 \end_layout
13571
13572 \begin_layout Verse
13573
13574 \family typewriter
13575 unsigned char foo(char i) __reentrant 
13576 \newline
13577
13578 \newline
13579 \InsetSpace ~
13580 \InsetSpace ~
13581 \InsetSpace ~
13582 \InsetSpace ~
13583 ...
13584  
13585 \newline
13586 }
13587 \end_layout
13588
13589 \begin_layout Standard
13590 Since stack space on 8051 is limited, the 
13591 \emph on
13592 reentrant 
13593 \emph default
13594 keyword or the
13595 \emph on
13596  -
13597 \begin_inset ERT
13598 status collapsed
13599
13600 \begin_layout Standard
13601
13602
13603 \backslash
13604 /
13605 \end_layout
13606
13607 \end_inset
13608
13609 -stack-auto
13610 \emph default
13611  option should be used sparingly.
13612  Note that the reentrant keyword just means that the parameters & local
13613  variables will be allocated to the stack, it 
13614 \emph on
13615 does not
13616 \emph default
13617  mean that the function is register bank
13618 \begin_inset LatexCommand \index{register bank (mcs51, ds390)}
13619
13620 \end_inset
13621
13622  independent.
13623 \newline
13624
13625 \newline
13626 Local variables
13627 \begin_inset LatexCommand \index{local variables}
13628
13629 \end_inset
13630
13631  can be assigned storage classes and absolute
13632 \begin_inset LatexCommand \index{Absolute addressing}
13633
13634 \end_inset
13635
13636  addresses, e.g.: 
13637 \end_layout
13638
13639 \begin_layout Verse
13640
13641 \family typewriter
13642 unsigned char foo() 
13643 \newline
13644 {
13645 \newline
13646 \InsetSpace ~
13647 \InsetSpace ~
13648 \InsetSpace ~
13649 \InsetSpace ~
13650 __xdata unsigned char i;
13651 \newline
13652 \InsetSpace ~
13653 \InsetSpace ~
13654 \InsetSpace ~
13655 \InsetSpace ~
13656 __bit bvar;
13657 \newline
13658 \InsetSpace ~
13659 \InsetSpace ~
13660 \InsetSpace ~
13661 \InsetSpace ~
13662 __data __at
13663 \begin_inset LatexCommand \index{at}
13664
13665 \end_inset
13666
13667  (0x31) unsigned char j;
13668 \newline
13669 \InsetSpace ~
13670 \InsetSpace ~
13671 \InsetSpace ~
13672 \InsetSpace ~
13673 ...
13674  
13675 \newline
13676 }
13677 \end_layout
13678
13679 \begin_layout Standard
13680 In the above example the variable 
13681 \emph on
13682 i
13683 \emph default
13684  will be allocated in the external ram, 
13685 \emph on
13686 bvar
13687 \emph default
13688  in bit addressable space and
13689 \emph on
13690  j
13691 \emph default
13692  in internal ram.
13693  When compiled with 
13694 \emph on
13695 -
13696 \begin_inset ERT
13697 status collapsed
13698
13699 \begin_layout Standard
13700
13701
13702 \backslash
13703 /
13704 \end_layout
13705
13706 \end_inset
13707
13708 -stack-auto
13709 \emph default
13710  or when a function is declared as 
13711 \emph on
13712 reentrant
13713 \emph default
13714  this should only be done for static variables.
13715 \end_layout
13716
13717 \begin_layout Standard
13718 Parameters
13719 \begin_inset LatexCommand \index{function parameter}
13720
13721 \end_inset
13722
13723  however are not allowed any storage class
13724 \begin_inset LatexCommand \index{Storage class}
13725
13726 \end_inset
13727
13728 , (storage classes for parameters will be ignored), their allocation is
13729  governed by the memory model in use, and the reentrancy options.
13730 \end_layout
13731
13732 \begin_layout Standard
13733 It is however allowed to use bit parameters in reentrant functions and also
13734  non-static local bit variables are supported.
13735  Efficient use is limited to 8 semi-bitregisters in bit space.
13736  They are pushed and popped to stack
13737 \begin_inset LatexCommand \index{stack}
13738
13739 \end_inset
13740
13741  as a single byte just like the normal registers.
13742 \end_layout
13743
13744 \begin_layout Section
13745 Overlaying
13746 \begin_inset LatexCommand \label{sub:Overlaying}
13747
13748 \end_inset
13749
13750
13751 \begin_inset LatexCommand \index{Overlaying}
13752
13753 \end_inset
13754
13755
13756 \end_layout
13757
13758 \begin_layout Standard
13759 For non-reentrant
13760 \begin_inset LatexCommand \index{reentrant}
13761
13762 \end_inset
13763
13764  functions SDCC will try to reduce internal ram space usage by overlaying
13765  parameters and local variables of a function (if possible).
13766  Parameters and local variables
13767 \begin_inset LatexCommand \index{local variables}
13768
13769 \end_inset
13770
13771  of a function will be allocated to an overlayable segment if the function
13772  has 
13773 \emph on
13774 no other function calls and the function is non-reentrant and the memory
13775  model
13776 \begin_inset LatexCommand \index{Memory model}
13777
13778 \end_inset
13779
13780  is small.
13781
13782 \emph default
13783  If an explicit storage class
13784 \begin_inset LatexCommand \index{Storage class}
13785
13786 \end_inset
13787
13788  is specified for a local variable, it will NOT be overlayed.
13789 \end_layout
13790
13791 \begin_layout Standard
13792 Note that the compiler (not the linkage editor) makes the decision for overlayin
13793 g the data items.
13794  Functions that are called from an interrupt service routine
13795 \begin_inset Marginal
13796 status collapsed
13797
13798 \begin_layout Standard
13799
13800 \series bold
13801 !
13802 \end_layout
13803
13804 \end_inset
13805
13806  should be preceded by a #pragma\InsetSpace ~
13807 nooverlay
13808 \begin_inset LatexCommand \index{\#pragma nooverlay}
13809
13810 \end_inset
13811
13812  if they are not reentrant.
13813 \end_layout
13814
13815 \begin_layout Standard
13816 Also note that the compiler does not do any processing of inline assembler
13817  code, so the compiler might incorrectly assign local variables and parameters
13818  of a function into the overlay segment if the inline assembler code calls
13819  other c-functions that might use the overlay.
13820  In that case the #pragma\InsetSpace ~
13821 nooverlay should be used.
13822 \end_layout
13823
13824 \begin_layout Standard
13825 Parameters and local variables of functions that contain 16 or 32 bit multiplica
13826 tion
13827 \begin_inset LatexCommand \index{Multiplication}
13828
13829 \end_inset
13830
13831  or division
13832 \begin_inset LatexCommand \index{Division}
13833
13834 \end_inset
13835
13836  will NOT be overlayed since these are implemented using external functions,
13837  e.g.:
13838 \end_layout
13839
13840 \begin_layout Verse
13841
13842 \family typewriter
13843 #pragma save 
13844 \newline
13845 #pragma nooverlay
13846 \begin_inset LatexCommand \index{\#pragma nooverlay}
13847
13848 \end_inset
13849
13850  
13851 \newline
13852 void set_error(unsigned char errcd) 
13853 \newline
13854 {
13855 \newline
13856 \InsetSpace ~
13857 \InsetSpace ~
13858 \InsetSpace ~
13859 \InsetSpace ~
13860 P3 = errcd;
13861 \newline
13862
13863 \newline
13864 #pragma restore 
13865 \newline
13866
13867 \newline
13868 void
13869  some_isr () __interrupt
13870 \begin_inset LatexCommand \index{interrupt}
13871
13872 \end_inset
13873
13874  (2)
13875 \newline
13876 {
13877 \newline
13878 \InsetSpace ~
13879 \InsetSpace ~
13880 \InsetSpace ~
13881 \InsetSpace ~
13882 ...
13883 \newline
13884 \InsetSpace ~
13885 \InsetSpace ~
13886 \InsetSpace ~
13887 \InsetSpace ~
13888 set_error(10);
13889 \newline
13890 \InsetSpace ~
13891 \InsetSpace ~
13892 \InsetSpace ~
13893 \InsetSpace ~
13894 ...
13895  
13896 \newline
13897 }
13898 \end_layout
13899
13900 \begin_layout Standard
13901 In the above example the parameter 
13902 \emph on
13903 errcd
13904 \emph default
13905  for the function 
13906 \emph on
13907 set_error
13908 \emph default
13909  would be assigned to the overlayable segment if the #pragma\InsetSpace ~
13910 nooverlay was
13911  not present, this could cause unpredictable runtime behavior when called
13912  from an interrupt service routine.
13913  The #pragma\InsetSpace ~
13914 nooverlay ensures that the parameters and local variables for
13915  the function are NOT overlayed.
13916 \begin_inset VSpace bigskip
13917 \end_inset
13918
13919
13920 \end_layout
13921
13922 \begin_layout Section
13923 Interrupt Service Routines
13924 \begin_inset LatexCommand \label{sub:Interrupt-Service-Routines}
13925
13926 \end_inset
13927
13928
13929 \end_layout
13930
13931 \begin_layout Subsection
13932 General Information
13933 \end_layout
13934
13935 \begin_layout Standard
13936 SDCC allows 
13937 \emph on
13938 i
13939 \emph default
13940 nterrupt 
13941 \emph on
13942 s
13943 \emph default
13944 ervice 
13945 \emph on
13946 r
13947 \emph default
13948 outines to be coded in C, with some extended keywords.
13949 \end_layout
13950
13951 \begin_layout Verse
13952
13953 \family typewriter
13954 void timer_isr (void) __interrupt (1) __using (1) 
13955 \newline
13956
13957 \newline
13958 \InsetSpace ~
13959 \InsetSpace ~
13960 \InsetSpace ~
13961 \InsetSpace ~
13962 ...
13963  
13964 \newline
13965 }
13966 \end_layout
13967
13968 \begin_layout Standard
13969 The optional number following the 
13970 \emph on
13971 interrupt
13972 \begin_inset LatexCommand \index{interrupt}
13973
13974 \end_inset
13975
13976
13977 \begin_inset LatexCommand \index{\_\_interrupt}
13978
13979 \end_inset
13980
13981
13982 \emph default
13983  keyword is the interrupt number this routine will service.
13984  When present, the compiler will insert a call to this routine in the interrupt
13985  vector table
13986 \begin_inset LatexCommand \index{interrupt vector table}
13987
13988 \end_inset
13989
13990  for the interrupt number specified.
13991  If you have multiple source files in your project, interrupt service routines
13992  can be present in any of them, but a prototype of the isr MUST be present
13993  or included in the file that contains the function 
13994 \emph on
13995 main
13996 \emph default
13997 .
13998  The optional (8051 specific) keyword 
13999 \emph on
14000 using
14001 \begin_inset LatexCommand \index{using (mcs51, ds390 register bank)}
14002
14003 \end_inset
14004
14005
14006 \begin_inset LatexCommand \index{\_\_using (mcs51, ds390 register bank)}
14007
14008 \end_inset
14009
14010
14011 \emph default
14012  can be used to tell the compiler to use the specified register bank when
14013  generating code for this function.
14014  
14015 \newline
14016 Interrupt service routines open the door for some very interesting bugs:
14017 \end_layout
14018
14019 \begin_layout Subsubsection
14020 \begin_inset LatexCommand \label{sub:Common-interrupt-pitfall-volatile}
14021
14022 \end_inset
14023
14024 Common interrupt pitfall: variable not declared 
14025 \emph on
14026 volatile
14027 \end_layout
14028
14029 \begin_layout Standard
14030 If an interrupt service routine changes variables which are accessed by
14031  other functions these variables have to be declared 
14032 \emph on
14033 volatile
14034 \emph default
14035
14036 \begin_inset LatexCommand \index{volatile}
14037
14038 \end_inset
14039
14040 .
14041  See 
14042 \begin_inset LatexCommand \url{http://en.wikipedia.org/wiki/Volatile_variable}
14043
14044 \end_inset
14045
14046  .
14047 \end_layout
14048
14049 \begin_layout Subsubsection
14050 \begin_inset LatexCommand \label{sub:Common-interrupt-pitfall-non-atomic}
14051
14052 \end_inset
14053
14054 Common interrupt pitfall: 
14055 \emph on
14056 non-atomic access
14057 \end_layout
14058
14059 \begin_layout Standard
14060 If the access to these variables is not 
14061 \emph on
14062 atomic
14063 \begin_inset LatexCommand \index{atomic}
14064
14065 \end_inset
14066
14067
14068 \emph default
14069  (i.e.
14070  the processor needs more than one instruction for the access and could
14071  be interrupted while accessing the variable) the interrupt must be disabled
14072  during the access to avoid inconsistent data.
14073  
14074 \newline
14075 Access to 16 or 32 bit variables is obviously not atomic on 8 bit CPUs
14076  and should be protected by disabling interrupts.
14077  You're not automatically on the safe side if you use 8 bit variables though.
14078  We need an example here: f.e.
14079  on the 8051 the harmless looking 
14080 \begin_inset Quotes srd
14081 \end_inset
14082
14083
14084 \family typewriter
14085 flags\InsetSpace ~
14086 |=\InsetSpace ~
14087 0x80;
14088 \family default
14089
14090 \begin_inset Quotes sld
14091 \end_inset
14092
14093  is not atomic if 
14094 \family typewriter
14095 flags
14096 \family default
14097  resides in xdata.
14098  Setting 
14099 \begin_inset Quotes srd
14100 \end_inset
14101
14102
14103 \family typewriter
14104 flags\InsetSpace ~
14105 |=\InsetSpace ~
14106 0x40;
14107 \family default
14108
14109 \begin_inset Quotes sld
14110 \end_inset
14111
14112  from within an interrupt routine might get lost if the interrupt occurs
14113  at the wrong time.
14114  
14115 \begin_inset Quotes sld
14116 \end_inset
14117
14118
14119 \family typewriter
14120 counter\InsetSpace ~
14121 +=\InsetSpace ~
14122 8;
14123 \family default
14124
14125 \begin_inset Quotes srd
14126 \end_inset
14127
14128  is not atomic on the 8051 even if 
14129 \family typewriter
14130 counter
14131 \family default
14132  is located in data memory.
14133 \newline
14134 Bugs like these are hard to reproduce and can
14135  cause a lot of trouble.
14136  
14137 \end_layout
14138
14139 \begin_layout Subsubsection
14140 \begin_inset LatexCommand \label{sub:Common-interrupt-pitfall-stack-overflow}
14141
14142 \end_inset
14143
14144 Common interrupt pitfall: 
14145 \emph on
14146 stack overflow
14147 \end_layout
14148
14149 \begin_layout Standard
14150 The return address and the registers used in the interrupt service routine
14151  are saved on the stack
14152 \begin_inset LatexCommand \index{stack}
14153
14154 \end_inset
14155
14156  so there must be sufficient stack space.
14157  If there isn't variables or registers (or even the return address itself)
14158  will be corrupted.
14159  This 
14160 \emph on
14161 stack overflow
14162 \emph default
14163
14164 \begin_inset LatexCommand \index{stack overflow}
14165
14166 \end_inset
14167
14168  is most likely to happen if the interrupt occurs during the 
14169 \begin_inset Quotes sld
14170 \end_inset
14171
14172 deepest
14173 \begin_inset Quotes srd
14174 \end_inset
14175
14176  subroutine when the stack is already in use for f.e.
14177  many return addresses.
14178 \end_layout
14179
14180 \begin_layout Subsubsection
14181 \begin_inset LatexCommand \label{sub:Common-interrupt-pitfall-non-reentrant}
14182
14183 \end_inset
14184
14185 Common interrupt pitfall: 
14186 \emph on
14187 use of non-reentrant functions
14188 \end_layout
14189
14190 \begin_layout Standard
14191 A special note here, int (16 bit) and long (32 bit) integer division
14192 \begin_inset LatexCommand \index{Division}
14193
14194 \end_inset
14195
14196 , multiplication
14197 \begin_inset LatexCommand \index{Multiplication}
14198
14199 \end_inset
14200
14201  & modulus
14202 \begin_inset LatexCommand \index{Modulus}
14203
14204 \end_inset
14205
14206  and floating-point
14207 \begin_inset LatexCommand \index{Floating point support}
14208
14209 \end_inset
14210
14211  operations are implemented using external support routines.
14212  If an interrupt service routine needs to do any of these operations then
14213  the support routines (as mentioned in a following section) will have to
14214  be recompiled using the
14215 \emph on
14216  -
14217 \begin_inset ERT
14218 status collapsed
14219
14220 \begin_layout Standard
14221
14222
14223 \backslash
14224 /
14225 \end_layout
14226
14227 \end_inset
14228
14229 -stack-auto
14230 \begin_inset LatexCommand \index{-\/-stack-auto}
14231
14232 \end_inset
14233
14234
14235 \emph default
14236  option and the source file will need to be compiled using the 
14237 \emph on
14238 -
14239 \begin_inset ERT
14240 status collapsed
14241
14242 \begin_layout Standard
14243
14244
14245 \backslash
14246 /
14247 \end_layout
14248
14249 \end_inset
14250
14251 -int-long-reent
14252 \emph default
14253
14254 \begin_inset LatexCommand \index{-\/-int-long-reent}
14255
14256 \end_inset
14257
14258  compiler option.
14259  
14260 \newline
14261 Note, the type promotion
14262 \begin_inset LatexCommand \index{type promotion}
14263
14264 \end_inset
14265
14266  required by ANSI C can cause 16 bit routines to be used
14267 \begin_inset Marginal
14268 status collapsed
14269
14270 \begin_layout Standard
14271
14272 \series bold
14273 \InsetSpace ~
14274 !
14275 \end_layout
14276
14277 \end_inset
14278
14279  without the programmer being aware of it.
14280  See f.e.
14281  the cast 
14282 \family typewriter
14283 (unsigned char)(tail-1)
14284 \family default
14285  within the if clause in section 
14286 \begin_inset LatexCommand \ref{sub:A-Step-by Assembler Introduction}
14287
14288 \end_inset
14289
14290 .
14291 \end_layout
14292
14293 \begin_layout Standard
14294 Calling other functions from an interrupt service routine is not recommended,
14295  avoid it if possible.
14296  Note that when some function is called from an interrupt service routine
14297  it should be preceded by a #pragma\InsetSpace ~
14298 nooverlay
14299 \begin_inset LatexCommand \index{\#pragma nooverlay}
14300
14301 \end_inset
14302
14303  if it is not reentrant.
14304  Furthermore nonreentrant functions should not be called from the main program
14305  while the interrupt service routine might be active.
14306  They also must not be called from low priority interrupt service routines
14307  while a high priority interrupt service routine might be active.
14308  You could use semaphores or make the function
14309 \emph on
14310  critical
14311 \emph default
14312  if all parameters are passed in registers.
14313 \newline
14314  Also see section 
14315 \begin_inset LatexCommand \ref{sub:Overlaying}
14316
14317 \end_inset
14318
14319 \InsetSpace ~
14320 about Overlaying and section 
14321 \begin_inset LatexCommand \ref{sub:Functions-using-private-banks}
14322
14323 \end_inset
14324
14325 \InsetSpace ~
14326 about Functions using private register banks.
14327 \begin_inset VSpace bigskip
14328 \end_inset
14329
14330
14331 \end_layout
14332
14333 \begin_layout Subsection
14334 MCS51/DS390 Interrupt Service Routines
14335 \end_layout
14336
14337 \begin_layout Standard
14338 Interrupt
14339 \begin_inset LatexCommand \index{interrupt}
14340
14341 \end_inset
14342
14343  numbers and the corresponding address & descriptions for the Standard 8051/8052
14344  are listed below.
14345  SDCC will automatically adjust the 
14346 \begin_inset LatexCommand \index{interrupt vector table}
14347
14348 \end_inset
14349
14350  to the maximum interrupt number specified.
14351 \newline
14352
14353 \end_layout
14354
14355 \begin_layout Standard
14356 \align center
14357 \begin_inset Tabular
14358 <lyxtabular version="3" rows="9" columns="3">
14359 <features>
14360 <column alignment="center" valignment="top" leftline="true" width="0in">
14361 <column alignment="left" valignment="top" leftline="true" width="0in">
14362 <column alignment="left" valignment="top" leftline="true" rightline="true" width="0in">
14363 <row topline="true" bottomline="true">
14364 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14365 \begin_inset Text
14366
14367 \begin_layout Standard
14368 Interrupt #
14369 \end_layout
14370
14371 \end_inset
14372 </cell>
14373 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14374 \begin_inset Text
14375
14376 \begin_layout Standard
14377 Description
14378 \end_layout
14379
14380 \end_inset
14381 </cell>
14382 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
14383 \begin_inset Text
14384
14385 \begin_layout Standard
14386 Vector Address
14387 \end_layout
14388
14389 \end_inset
14390 </cell>
14391 </row>
14392 <row topline="true">
14393 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14394 \begin_inset Text
14395
14396 \begin_layout Standard
14397 0
14398 \end_layout
14399
14400 \end_inset
14401 </cell>
14402 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14403 \begin_inset Text
14404
14405 \begin_layout Standard
14406 External 0
14407 \end_layout
14408
14409 \end_inset
14410 </cell>
14411 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
14412 \begin_inset Text
14413
14414 \begin_layout Standard
14415 0x0003
14416 \end_layout
14417
14418 \end_inset
14419 </cell>
14420 </row>
14421 <row topline="true">
14422 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14423 \begin_inset Text
14424
14425 \begin_layout Standard
14426 1
14427 \end_layout
14428
14429 \end_inset
14430 </cell>
14431 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14432 \begin_inset Text
14433
14434 \begin_layout Standard
14435 Timer 0
14436 \end_layout
14437
14438 \end_inset
14439 </cell>
14440 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
14441 \begin_inset Text
14442
14443 \begin_layout Standard
14444 0x000b
14445 \end_layout
14446
14447 \end_inset
14448 </cell>
14449 </row>
14450 <row topline="true">
14451 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14452 \begin_inset Text
14453
14454 \begin_layout Standard
14455 2
14456 \end_layout
14457
14458 \end_inset
14459 </cell>
14460 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14461 \begin_inset Text
14462
14463 \begin_layout Standard
14464 External 1
14465 \end_layout
14466
14467 \end_inset
14468 </cell>
14469 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
14470 \begin_inset Text
14471
14472 \begin_layout Standard
14473 0x0013
14474 \end_layout
14475
14476 \end_inset
14477 </cell>
14478 </row>
14479 <row topline="true">
14480 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14481 \begin_inset Text
14482
14483 \begin_layout Standard
14484 3
14485 \end_layout
14486
14487 \end_inset
14488 </cell>
14489 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14490 \begin_inset Text
14491
14492 \begin_layout Standard
14493 Timer 1
14494 \end_layout
14495
14496 \end_inset
14497 </cell>
14498 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
14499 \begin_inset Text
14500
14501 \begin_layout Standard
14502 0x001b
14503 \end_layout
14504
14505 \end_inset
14506 </cell>
14507 </row>
14508 <row topline="true">
14509 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14510 \begin_inset Text
14511
14512 \begin_layout Standard
14513 4
14514 \end_layout
14515
14516 \end_inset
14517 </cell>
14518 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14519 \begin_inset Text
14520
14521 \begin_layout Standard
14522 Serial
14523 \end_layout
14524
14525 \end_inset
14526 </cell>
14527 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
14528 \begin_inset Text
14529
14530 \begin_layout Standard
14531 0x0023
14532 \end_layout
14533
14534 \end_inset
14535 </cell>
14536 </row>
14537 <row topline="true">
14538 <cell multicolumn="1" alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14539 \begin_inset Text
14540
14541 \begin_layout Standard
14542 5
14543 \end_layout
14544
14545 \end_inset
14546 </cell>
14547 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14548 \begin_inset Text
14549
14550 \begin_layout Standard
14551 Timer 2 (8052)
14552 \end_layout
14553
14554 \end_inset
14555 </cell>
14556 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
14557 \begin_inset Text
14558
14559 \begin_layout Standard
14560 0x002b
14561 \end_layout
14562
14563 \end_inset
14564 </cell>
14565 </row>
14566 <row topline="true">
14567 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14568 \begin_inset Text
14569
14570 \begin_layout Standard
14571 ...
14572 \end_layout
14573
14574 \end_inset
14575 </cell>
14576 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14577 \begin_inset Text
14578
14579 \begin_layout Standard
14580
14581 \end_layout
14582
14583 \end_inset
14584 </cell>
14585 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
14586 \begin_inset Text
14587
14588 \begin_layout Standard
14589 ...
14590 \end_layout
14591
14592 \end_inset
14593 </cell>
14594 </row>
14595 <row topline="true" bottomline="true">
14596 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14597 \begin_inset Text
14598
14599 \begin_layout Standard
14600 n
14601 \end_layout
14602
14603 \end_inset
14604 </cell>
14605 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14606 \begin_inset Text
14607
14608 \begin_layout Standard
14609
14610 \end_layout
14611
14612 \end_inset
14613 </cell>
14614 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
14615 \begin_inset Text
14616
14617 \begin_layout Standard
14618 0x0003 + 8*n
14619 \end_layout
14620
14621 \end_inset
14622 </cell>
14623 </row>
14624 </lyxtabular>
14625
14626 \end_inset
14627
14628
14629 \newline
14630
14631 \end_layout
14632
14633 \begin_layout Standard
14634 If the interrupt service routine is defined without 
14635 \emph on
14636 using
14637 \begin_inset LatexCommand \index{using (mcs51, ds390 register bank)}
14638
14639 \end_inset
14640
14641
14642 \begin_inset LatexCommand \index{\_\_using (mcs51, ds390 register bank)}
14643
14644 \end_inset
14645
14646
14647 \emph default
14648  a register bank or with register bank 0 (
14649 \emph on
14650 using
14651 \emph default
14652  0), the compiler will save the registers used by itself on the stack upon
14653  entry and restore them at exit, however if such an interrupt service routine
14654  calls another function then the entire register bank will be saved on the
14655  stack.
14656  This scheme may be advantageous for small interrupt service routines which
14657  have low register usage.
14658 \end_layout
14659
14660 \begin_layout Standard
14661 If the interrupt service routine is defined to be using a specific register
14662  bank then only 
14663 \emph on
14664 a, b, dptr
14665 \emph default
14666  & psw are saved and restored, if such an interrupt service routine calls
14667  another function (using another register bank) then the entire register
14668  bank of the called function will be saved on the stack
14669 \begin_inset LatexCommand \index{stack}
14670
14671 \end_inset
14672
14673 .
14674  This scheme is recommended for larger interrupt service routines.
14675 \begin_inset VSpace bigskip
14676 \end_inset
14677
14678
14679 \end_layout
14680
14681 \begin_layout Subsection
14682 HC08
14683 \begin_inset LatexCommand \index{HC08}
14684
14685 \end_inset
14686
14687  Interrupt Service Routines
14688 \end_layout
14689
14690 \begin_layout Standard
14691 Since the number of interrupts
14692 \begin_inset LatexCommand \index{HC08!interrupt}
14693
14694 \end_inset
14695
14696  available is chip specific and the interrupt vector table always ends at
14697  the last byte of memory, the interrupt numbers corresponds to the interrupt
14698  vectors in reverse order of address.
14699  For example, interrupt 1 will use the interrupt vector at 0xfffc, interrupt
14700  2 will use the interrupt vector at 0xfffa, and so on.
14701  However, interrupt 0 (the reset vector at 0xfffe) is not redefinable in
14702  this way; instead see section 
14703 \begin_inset LatexCommand \ref{sub:Startup-Code}
14704
14705 \end_inset
14706
14707  for details on customizing startup.
14708 \begin_inset VSpace bigskip
14709 \end_inset
14710
14711
14712 \end_layout
14713
14714 \begin_layout Subsection
14715 Z80 Interrupt Service Routines
14716 \end_layout
14717
14718 \begin_layout Standard
14719 The Z80
14720 \begin_inset LatexCommand \index{Z80}
14721
14722 \end_inset
14723
14724  uses several different methods for determining the correct interrupt
14725 \begin_inset LatexCommand \index{Z80!interrupt}
14726
14727 \end_inset
14728
14729  vector depending on the hardware implementation.
14730  Therefore, SDCC ignores the optional interrupt number and does not attempt
14731  to generate an interrupt vector table.
14732 \end_layout
14733
14734 \begin_layout Standard
14735 By default, SDCC generates code for a maskable interrupt, which uses a RETI
14736  instruction to return from the interrupt.
14737  To write an interrupt handler for the non-maskable interrupt, which needs
14738  a RETN instruction instead, add the 
14739 \emph on
14740 critical
14741 \emph default
14742  keyword:
14743 \end_layout
14744
14745 \begin_layout Verse
14746
14747 \family typewriter
14748 void nmi_isr (void) critical interrupt
14749 \newline
14750
14751 \newline
14752 \InsetSpace ~
14753 \InsetSpace ~
14754 \InsetSpace ~
14755 \InsetSpace ~
14756 ...
14757  
14758 \newline
14759 }
14760 \end_layout
14761
14762 \begin_layout Standard
14763 However if you need to create a non-interruptable interrupt service routine
14764  you would also require the 
14765 \emph on
14766 critical
14767 \emph default
14768  keyword.
14769  To distinguish between this and an nmi_isr you must provide an interrupt
14770  number.
14771 \begin_inset VSpace bigskip
14772 \end_inset
14773
14774
14775 \end_layout
14776
14777 \begin_layout Section
14778 Enabling and Disabling Interrupts
14779 \end_layout
14780
14781 \begin_layout Subsection
14782 Critical Functions and Critical Statements
14783 \end_layout
14784
14785 \begin_layout Standard
14786 A special keyword may be associated with a block or a function declaring
14787  it as 
14788 \emph on
14789 critical
14790 \emph default
14791 .
14792  SDCC will generate code to disable all interrupts
14793 \begin_inset LatexCommand \index{interrupt}
14794
14795 \end_inset
14796
14797  upon entry to a critical function and restore the interrupt enable to the
14798  previous state before returning.
14799  Nesting critical functions will need one additional byte on the stack
14800 \begin_inset LatexCommand \index{stack}
14801
14802 \end_inset
14803
14804  for each call.
14805 \end_layout
14806
14807 \begin_layout Verse
14808
14809 \family typewriter
14810 int foo () __critical
14811 \begin_inset LatexCommand \index{critical}
14812
14813 \end_inset
14814
14815
14816 \begin_inset LatexCommand \index{\_\_critical}
14817
14818 \end_inset
14819
14820  
14821 \newline
14822
14823 \newline
14824 \InsetSpace ~
14825 \InsetSpace ~
14826 \InsetSpace ~
14827 \InsetSpace ~
14828 ...
14829  
14830 \newline
14831 \InsetSpace ~
14832 \InsetSpace ~
14833 \InsetSpace ~
14834 \InsetSpace ~
14835 ...
14836  
14837 \newline
14838 }
14839 \end_layout
14840
14841 \begin_layout Standard
14842 The critical attribute maybe used with other attributes like 
14843 \emph on
14844 reentrant.
14845 \emph default
14846
14847 \newline
14848 The keyword 
14849 \emph on
14850 critical
14851 \emph default
14852  may also be used to disable interrupts more locally:
14853 \end_layout
14854
14855 \begin_layout Verse
14856
14857 \family typewriter
14858 __critical{ i++; }
14859 \end_layout
14860
14861 \begin_layout Standard
14862 More than one statement could have been included in the block.
14863 \end_layout
14864
14865 \begin_layout Subsection
14866 Enabling and Disabling Interrupts directly
14867 \end_layout
14868
14869 \begin_layout Standard
14870 Interrupts
14871 \begin_inset LatexCommand \index{interrupt}
14872
14873 \end_inset
14874
14875  can also be disabled and enabled directly (8051):
14876 \end_layout
14877
14878 \begin_layout Verse
14879
14880 \family typewriter
14881 EA = 0;\InsetSpace ~
14882 \InsetSpace ~
14883 \InsetSpace ~
14884 \InsetSpace ~
14885 \InsetSpace ~
14886 \InsetSpace ~
14887 \InsetSpace ~
14888 \InsetSpace ~
14889 \InsetSpace ~
14890 \InsetSpace ~
14891 \InsetSpace ~
14892 \InsetSpace ~
14893 or:\InsetSpace ~
14894 \InsetSpace ~
14895 \InsetSpace ~
14896 \InsetSpace ~
14897 \InsetSpace ~
14898 \InsetSpace ~
14899 \InsetSpace ~
14900 \InsetSpace ~
14901 \InsetSpace ~
14902 \InsetSpace ~
14903 \InsetSpace ~
14904 EA_SAVE = EA;
14905 \end_layout
14906
14907 \begin_layout Verse
14908
14909 \family typewriter
14910 ...\InsetSpace ~
14911 \InsetSpace ~
14912 \InsetSpace ~
14913 \InsetSpace ~
14914 \InsetSpace ~
14915 \InsetSpace ~
14916 \InsetSpace ~
14917 \InsetSpace ~
14918 \InsetSpace ~
14919 \InsetSpace ~
14920 \InsetSpace ~
14921 \InsetSpace ~
14922 \InsetSpace ~
14923 \InsetSpace ~
14924 \InsetSpace ~
14925 \InsetSpace ~
14926 \InsetSpace ~
14927 \InsetSpace ~
14928 \InsetSpace ~
14929 \InsetSpace ~
14930 \InsetSpace ~
14931 \InsetSpace ~
14932 \InsetSpace ~
14933 \InsetSpace ~
14934 \InsetSpace ~
14935 \InsetSpace ~
14936 \InsetSpace ~
14937 \InsetSpace ~
14938 \InsetSpace ~
14939 \InsetSpace ~
14940 EA = 0;
14941 \end_layout
14942
14943 \begin_layout Verse
14944
14945 \family typewriter
14946 EA = 1;\InsetSpace ~
14947 \InsetSpace ~
14948 \InsetSpace ~
14949 \InsetSpace ~
14950 \InsetSpace ~
14951 \InsetSpace ~
14952 \InsetSpace ~
14953 \InsetSpace ~
14954 \InsetSpace ~
14955 \InsetSpace ~
14956 \InsetSpace ~
14957 \InsetSpace ~
14958 \InsetSpace ~
14959 \InsetSpace ~
14960 \InsetSpace ~
14961 \InsetSpace ~
14962 \InsetSpace ~
14963 \InsetSpace ~
14964 \InsetSpace ~
14965 \InsetSpace ~
14966 \InsetSpace ~
14967 \InsetSpace ~
14968 \InsetSpace ~
14969 \InsetSpace ~
14970 \InsetSpace ~
14971 \InsetSpace ~
14972 ...
14973 \end_layout
14974
14975 \begin_layout Verse
14976
14977 \family typewriter
14978 \InsetSpace ~
14979 \InsetSpace ~
14980 \InsetSpace ~
14981 \InsetSpace ~
14982 \InsetSpace ~
14983 \InsetSpace ~
14984 \InsetSpace ~
14985 \InsetSpace ~
14986 \InsetSpace ~
14987 \InsetSpace ~
14988 \InsetSpace ~
14989 \InsetSpace ~
14990 \InsetSpace ~
14991 \InsetSpace ~
14992 \InsetSpace ~
14993 \InsetSpace ~
14994 \InsetSpace ~
14995 \InsetSpace ~
14996 \InsetSpace ~
14997 \InsetSpace ~
14998 \InsetSpace ~
14999 \InsetSpace ~
15000 \InsetSpace ~
15001 \InsetSpace ~
15002 \InsetSpace ~
15003 \InsetSpace ~
15004 \InsetSpace ~
15005 \InsetSpace ~
15006 \InsetSpace ~
15007 \InsetSpace ~
15008 \InsetSpace ~
15009 \InsetSpace ~
15010 \InsetSpace ~
15011 EA = EA_SAVE;
15012 \end_layout
15013
15014 \begin_layout Standard
15015 On other architectures which have seperate opcodes for enabling and disabling
15016  interrupts you might want to make use of defines with inline assembly
15017 \begin_inset LatexCommand \index{Assembler routines}
15018
15019 \end_inset
15020
15021  (HC08
15022 \begin_inset LatexCommand \index{HC08!interrupt}
15023
15024 \end_inset
15025
15026 ):
15027 \end_layout
15028
15029 \begin_layout Verse
15030
15031 \family typewriter
15032 #define CLI _asm
15033 \begin_inset LatexCommand \index{\_asm}
15034
15035 \end_inset
15036
15037 \InsetSpace ~
15038 \InsetSpace ~
15039 cli\InsetSpace ~
15040 \InsetSpace ~
15041 _endasm
15042 \begin_inset LatexCommand \index{\_endasm}
15043
15044 \end_inset
15045
15046
15047 \end_layout
15048
15049 \begin_layout Verse
15050
15051 \family typewriter
15052 #define SEI _asm\InsetSpace ~
15053 \InsetSpace ~
15054 sei\InsetSpace ~
15055 \InsetSpace ~
15056 _endasm; 
15057 \end_layout
15058
15059 \begin_layout Verse
15060
15061 \family typewriter
15062 ...
15063 \end_layout
15064
15065 \begin_layout Standard
15066 Note: it is sometimes sufficient to disable only a specific interrupt source
15067  like f.e.
15068  a timer or serial interrupt by manipulating an 
15069 \emph on
15070 interrupt mask
15071 \begin_inset LatexCommand \index{interrupt mask}
15072
15073 \end_inset
15074
15075
15076 \emph default
15077  register.
15078  
15079 \end_layout
15080
15081 \begin_layout Standard
15082 Usually the time during which interrupts are disabled should be kept as
15083  short as possible.
15084  This minimizes both 
15085 \emph on
15086 interrupt latency
15087 \emph default
15088
15089 \begin_inset LatexCommand \index{interrupt latency}
15090
15091 \end_inset
15092
15093  (the time between the occurrence of the interrupt and the execution of
15094  the first code in the interrupt routine) and 
15095 \emph on
15096 interrupt jitter
15097 \emph default
15098
15099 \begin_inset LatexCommand \index{interrupt jitter}
15100
15101 \end_inset
15102
15103  (the difference between the shortest and the longest interrupt latency).
15104  These really are something different, f.e.
15105  a serial interrupt has to be served before its buffer overruns so it cares
15106  for the maximum interrupt latency, whereas it does not care about jitter.
15107  On a loudspeaker driven via a digital to analog converter which is fed
15108  by an interrupt a latency of a few milliseconds might be tolerable, whereas
15109  a much smaller jitter will be very audible.
15110 \end_layout
15111
15112 \begin_layout Standard
15113 You can reenable interrupts within an interrupt routine and on some architecture
15114 s you can make use of two (or more) levels of 
15115 \emph on
15116 interrupt priorities
15117 \emph default
15118
15119 \begin_inset LatexCommand \index{interrupt priority}
15120
15121 \end_inset
15122
15123 .
15124  On some architectures which don't support interrupt priorities these can
15125  be implemented by manipulating the interrupt mask and reenabling interrupts
15126  within the interrupt routine.
15127  Check there is sufficient space on the stack
15128 \begin_inset LatexCommand \index{stack}
15129
15130 \end_inset
15131
15132  and don't add complexity unless you have to.
15133  
15134 \end_layout
15135
15136 \begin_layout Subsection
15137 Semaphore
15138 \begin_inset LatexCommand \index{semaphore}
15139
15140 \end_inset
15141
15142  locking (mcs51/ds390)
15143 \end_layout
15144
15145 \begin_layout Standard
15146 Some architectures (mcs51/ds390) have an atomic
15147 \begin_inset LatexCommand \index{atomic}
15148
15149 \end_inset
15150
15151  bit test and
15152 \emph on
15153  
15154 \emph default
15155 clear
15156 \emph on
15157  
15158 \emph default
15159 instruction.
15160  These type of instructions are typically used in preemptive multitasking
15161  systems, where a routine f.e.
15162  claims the use of a data structure ('acquires a lock
15163 \begin_inset LatexCommand \index{lock}
15164
15165 \end_inset
15166
15167  on it'), makes some modifications and then releases the lock when the data
15168  structure is consistent again.
15169  The instruction may also be used if interrupt and non-interrupt code have
15170  to compete for a resource.
15171  With the atomic bit test and clear instruction interrupts
15172 \begin_inset LatexCommand \index{interrupt}
15173
15174 \end_inset
15175
15176  don't have to be disabled for the locking operation.
15177  
15178 \end_layout
15179
15180 \begin_layout Standard
15181 SDCC generates this instruction if the source follows this pattern:
15182 \end_layout
15183
15184 \begin_layout Verse
15185
15186 \family typewriter
15187 volatile
15188 \begin_inset LatexCommand \index{volatile}
15189
15190 \end_inset
15191
15192  bit resource_is_free; 
15193 \newline
15194
15195 \newline
15196 if (resource_is_free) 
15197 \newline
15198 \InsetSpace ~
15199 \InsetSpace ~
15200
15201 \newline
15202 \InsetSpace ~
15203 \InsetSpace ~
15204 \InsetSpace ~
15205 \InsetSpace ~
15206 resource_is_free=0; 
15207 \newline
15208 \InsetSpace ~
15209 \InsetSpace ~
15210 \InsetSpace ~
15211 \InsetSpace ~
15212 ...
15213  
15214 \newline
15215 \InsetSpace ~
15216 \InsetSpace ~
15217 \InsetSpace ~
15218 \InsetSpace ~
15219 resource_is_free=1;
15220 \newline
15221 \InsetSpace ~
15222 \InsetSpace ~
15223
15224 \end_layout
15225
15226 \begin_layout Standard
15227 Note, mcs51 and ds390 support only an atomic
15228 \begin_inset LatexCommand \index{atomic}
15229
15230 \end_inset
15231
15232  bit test and 
15233 \emph on
15234 clear
15235 \emph default
15236  instruction (as opposed to atomic bit test and 
15237 \emph on
15238 set).
15239 \end_layout
15240
15241 \begin_layout Section
15242 Functions using private register banks
15243 \begin_inset LatexCommand \label{sub:Functions-using-private-banks}
15244
15245 \end_inset
15246
15247  (mcs51/ds390)
15248 \end_layout
15249
15250 \begin_layout Standard
15251 Some architectures have support for quickly changing register sets.
15252  SDCC supports this feature with the 
15253 \emph on
15254 using
15255 \begin_inset LatexCommand \index{using (mcs51, ds390 register bank)}
15256
15257 \end_inset
15258
15259
15260 \begin_inset LatexCommand \index{\_\_using (mcs51, ds390 register bank)}
15261
15262 \end_inset
15263
15264
15265 \emph default
15266  attribute (which tells the compiler to use a register bank
15267 \begin_inset LatexCommand \index{register bank (mcs51, ds390)}
15268
15269 \end_inset
15270
15271  other than the default bank zero).
15272  It should only be applied to 
15273 \emph on
15274 interrupt
15275 \begin_inset LatexCommand \index{interrupt}
15276
15277 \end_inset
15278
15279
15280 \emph default
15281  functions (see footnote below).
15282  This will in most circumstances make the generated ISR code more efficient
15283  since it will not have to save registers on the stack.
15284 \end_layout
15285
15286 \begin_layout Standard
15287 The 
15288 \emph on
15289 using
15290 \emph default
15291  attribute will have no effect on the generated code for a 
15292 \emph on
15293 non-interrupt
15294 \emph default
15295  function (but may occasionally be useful anyway
15296 \begin_inset Foot
15297 status open
15298
15299 \begin_layout Standard
15300 possible exception: if a function is called ONLY from 'interrupt' functions
15301  using a particular bank, it can be declared with the same 'using' attribute
15302  as the calling 'interrupt' functions.
15303  For instance, if you have several ISRs using bank one, and all of them
15304  call memcpy(), it might make sense to create a specialized version of memcpy()
15305  'using 1', since this would prevent the ISR from having to save bank zero
15306  to the stack on entry and switch to bank zero before calling the function
15307 \end_layout
15308
15309 \end_inset
15310
15311 ).
15312 \newline
15313
15314 \emph on
15315 (pending: Note, nowadays the 
15316 \emph default
15317 using
15318 \emph on
15319  attribute has an effect on
15320 \emph default
15321  
15322 \emph on
15323 the generated code for a 
15324 \emph default
15325 non-interrupt
15326 \emph on
15327  function
15328 \emph default
15329 .
15330 \emph on
15331 )
15332 \end_layout
15333
15334 \begin_layout Standard
15335 An 
15336 \emph on
15337 interrupt
15338 \emph default
15339  function using a non-zero bank will assume that it can trash that register
15340  bank, and will not save it.
15341  Since high-priority interrupts
15342 \begin_inset LatexCommand \index{interrupts}
15343
15344 \end_inset
15345
15346
15347 \begin_inset LatexCommand \index{interrupt priority}
15348
15349 \end_inset
15350
15351  can interrupt low-priority ones on the 8051 and friends, this means that
15352  if a high-priority ISR 
15353 \emph on
15354 using
15355 \emph default
15356  a particular bank occurs while processing a low-priority ISR 
15357 \emph on
15358 using
15359 \emph default
15360  the same bank, terrible and bad things can happen.
15361  To prevent this, no single register bank should be 
15362 \emph on
15363 used
15364 \emph default
15365  by both a high priority and a low priority ISR.
15366  This is probably most easily done by having all high priority ISRs use
15367  one bank and all low priority ISRs use another.
15368  If you have an ISR which can change priority at runtime, you're on your
15369  own: I suggest using the default bank zero and taking the small performance
15370  hit.
15371 \end_layout
15372
15373 \begin_layout Standard
15374 It is most efficient if your ISR calls no other functions.
15375  If your ISR must call other functions, it is most efficient if those functions
15376  use the same bank as the ISR (see note 1 below); the next best is if the
15377  called functions use bank zero.
15378  It is very inefficient to call a function using a different, non-zero bank
15379  from an ISR.
15380  
15381 \begin_inset VSpace bigskip
15382 \end_inset
15383
15384
15385 \end_layout
15386
15387 \begin_layout Section
15388 Startup Code
15389 \begin_inset LatexCommand \label{sub:Startup-Code}
15390
15391 \end_inset
15392
15393
15394 \begin_inset LatexCommand \index{Startup code}
15395
15396 \end_inset
15397
15398
15399 \end_layout
15400
15401 \begin_layout Subsection
15402 MCS51/DS390 Startup Code
15403 \end_layout
15404
15405 \begin_layout Standard
15406 The compiler triggers the linker to link certain initialization modules
15407  from the runtime library
15408 \begin_inset LatexCommand \index{Runtime library}
15409
15410 \end_inset
15411
15412  called crt<something>.
15413  Only the necessary ones are linked, for instance crtxstack.asm (GSINIT1,
15414  GSINIT5) is not linked unless the -
15415 \series bold
15416
15417 \begin_inset ERT
15418 status open
15419
15420 \begin_layout Standard
15421
15422
15423 \backslash
15424 /
15425 \end_layout
15426
15427 \end_inset
15428
15429
15430 \series default
15431 -xstack option is used.
15432  These modules are highly entangled by the use of special segments/areas,
15433  but a common layout is shown below:
15434 \end_layout
15435
15436 \begin_layout Verse
15437
15438 \family typewriter
15439 \series bold
15440 \size footnotesize
15441 (main.asm)
15442 \end_layout
15443
15444 \begin_layout Verse
15445
15446 \family typewriter
15447 \size footnotesize
15448 \InsetSpace ~
15449 \InsetSpace ~
15450 \InsetSpace ~
15451 \InsetSpace ~
15452 \InsetSpace ~
15453 \InsetSpace ~
15454 \InsetSpace ~
15455 \InsetSpace ~
15456 .area HOME (CODE)
15457 \newline
15458 __interrupt_vect:
15459 \newline
15460 \InsetSpace ~
15461 \InsetSpace ~
15462 \InsetSpace ~
15463 \InsetSpace ~
15464 \InsetSpace ~
15465 \InsetSpace ~
15466 \InsetSpace ~
15467 \InsetSpace ~
15468 ljmp __sdcc_gsinit_startup
15469 \end_layout
15470
15471 \begin_layout Verse
15472
15473 \family typewriter
15474 \series bold
15475 \size footnotesize
15476 (crtstart.asm)
15477 \end_layout
15478
15479 \begin_layout Verse
15480
15481 \family typewriter
15482 \size footnotesize
15483 \InsetSpace ~
15484 \InsetSpace ~
15485 \InsetSpace ~
15486 \InsetSpace ~
15487 \InsetSpace ~
15488 \InsetSpace ~
15489 \InsetSpace ~
15490 \InsetSpace ~
15491 .area GSINIT0 (CODE)
15492 \newline
15493 __sdcc_gsinit_startup::
15494 \newline
15495 \InsetSpace ~
15496 \InsetSpace ~
15497 \InsetSpace ~
15498 \InsetSpace ~
15499 \InsetSpace ~
15500 \InsetSpace ~
15501 \InsetSpace ~
15502 \InsetSpace ~
15503 mov sp,#__start__stack - 1
15504 \end_layout
15505
15506 \begin_layout Verse
15507
15508 \family typewriter
15509 \series bold
15510 \size footnotesize
15511 (crtxstack.asm)
15512 \end_layout
15513
15514 \begin_layout Verse
15515
15516 \family typewriter
15517 \size footnotesize
15518 \InsetSpace ~
15519 \InsetSpace ~
15520 \InsetSpace ~
15521 \InsetSpace ~
15522 \InsetSpace ~
15523 \InsetSpace ~
15524 \InsetSpace ~
15525 \InsetSpace ~
15526 .area GSINIT1 (CODE)
15527 \newline
15528 __sdcc_init_xstack::
15529 \newline
15530 ; Need to initialize in GSINIT1 in
15531  case the user's __sdcc_external_startup uses the xstack.
15532 \newline
15533 \InsetSpace ~
15534 \InsetSpace ~
15535 \InsetSpace ~
15536 \InsetSpace ~
15537 \InsetSpace ~
15538 \InsetSpace ~
15539 \InsetSpace ~
15540 \InsetSpace ~
15541 mov __XPAGE,#(__start__x
15542 stack >> 8)
15543 \newline
15544 \InsetSpace ~
15545 \InsetSpace ~
15546 \InsetSpace ~
15547 \InsetSpace ~
15548 \InsetSpace ~
15549 \InsetSpace ~
15550 \InsetSpace ~
15551 \InsetSpace ~
15552 mov _spx,#__start__xstack
15553 \end_layout
15554
15555 \begin_layout Verse
15556
15557 \family typewriter
15558 \series bold
15559 \size footnotesize
15560 (crtstart.asm)
15561 \end_layout
15562
15563 \begin_layout Verse
15564
15565 \family typewriter
15566 \size footnotesize
15567 \InsetSpace ~
15568 \InsetSpace ~
15569 \InsetSpace ~
15570 \InsetSpace ~
15571 \InsetSpace ~
15572 \InsetSpace ~
15573 \InsetSpace ~
15574 \InsetSpace ~
15575 .area GSINIT2 (CODE)
15576 \newline
15577 \InsetSpace ~
15578 \InsetSpace ~
15579 \InsetSpace ~
15580 \InsetSpace ~
15581 \InsetSpace ~
15582 \InsetSpace ~
15583 \InsetSpace ~
15584 \InsetSpace ~
15585 lcall __sdcc_external_startup
15586 \newline
15587 \InsetSpace ~
15588 \InsetSpace ~
15589 \InsetSpace ~
15590 \InsetSpace ~
15591 \InsetSpace ~
15592 \InsetSpace ~
15593 \InsetSpace ~
15594 \InsetSpace ~
15595 mov a,dpl
15596 \newline
15597 \InsetSpace ~
15598 \InsetSpace ~
15599 \InsetSpace ~
15600 \InsetSpace ~
15601 \InsetSpace ~
15602 \InsetSpace ~
15603 \InsetSpace ~
15604 \InsetSpace ~
15605 jz __sdcc_init_data
15606 \newline
15607 \InsetSpace ~
15608 \InsetSpace ~
15609 \InsetSpace ~
15610 \InsetSpace ~
15611 \InsetSpace ~
15612 \InsetSpace ~
15613 \InsetSpace ~
15614 \InsetSpace ~
15615 ljmp
15616  __sdcc_program_startup
15617 \newline
15618 __sdcc_init_data:
15619 \end_layout
15620
15621 \begin_layout Verse
15622
15623 \family typewriter
15624 \series bold
15625 \size footnotesize
15626 (crtxinit.asm)
15627 \end_layout
15628
15629 \begin_layout Verse
15630
15631 \family typewriter
15632 \size footnotesize
15633 \InsetSpace ~
15634 \InsetSpace ~
15635 \InsetSpace ~
15636 \InsetSpace ~
15637 \InsetSpace ~
15638 \InsetSpace ~
15639 \InsetSpace ~
15640 \InsetSpace ~
15641 .area GSINIT3 (CODE)
15642 \newline
15643 __mcs51_genXINIT::
15644 \newline
15645 \InsetSpace ~
15646 \InsetSpace ~
15647 \InsetSpace ~
15648 \InsetSpace ~
15649 \InsetSpace ~
15650 \InsetSpace ~
15651 \InsetSpace ~
15652 \InsetSpace ~
15653 mov r1,#l_XINIT
15654 \newline
15655 \InsetSpace ~
15656 \InsetSpace ~
15657 \InsetSpace ~
15658 \InsetSpace ~
15659 \InsetSpace ~
15660 \InsetSpace ~
15661 \InsetSpace ~
15662 \InsetSpace ~
15663 mov a,r1
15664 \newline
15665 \InsetSpace ~
15666 \InsetSpace ~
15667 \InsetSpace ~
15668 \InsetSpace ~
15669 \InsetSpace ~
15670 \InsetSpace ~
15671 \InsetSpace ~
15672 \InsetSpace ~
15673 orl a,#(l_XINIT
15674  >> 8)
15675 \newline
15676 \InsetSpace ~
15677 \InsetSpace ~
15678 \InsetSpace ~
15679 \InsetSpace ~
15680 \InsetSpace ~
15681 \InsetSpace ~
15682 \InsetSpace ~
15683 \InsetSpace ~
15684 jz 00003$
15685 \newline
15686 \InsetSpace ~
15687 \InsetSpace ~
15688 \InsetSpace ~
15689 \InsetSpace ~
15690 \InsetSpace ~
15691 \InsetSpace ~
15692 \InsetSpace ~
15693 \InsetSpace ~
15694 mov r2,#((l_XINIT+255) >> 8)
15695 \newline
15696 \InsetSpace ~
15697 \InsetSpace ~
15698 \InsetSpace ~
15699 \InsetSpace ~
15700 \InsetSpace ~
15701 \InsetSpace ~
15702 \InsetSpace ~
15703 \InsetSpace ~
15704 mov dptr,#s_XINIT
15705 \newline
15706 \InsetSpace ~
15707 \InsetSpace ~
15708 \InsetSpace ~
15709 \InsetSpace ~
15710 \InsetSpace ~
15711 \InsetSpace ~
15712 \InsetSpace ~
15713 \InsetSpace ~
15714 mov r0,#s_XISEG
15715 \newline
15716 \InsetSpace ~
15717 \InsetSpace ~
15718 \InsetSpace ~
15719 \InsetSpace ~
15720 \InsetSpace ~
15721 \InsetSpace ~
15722 \InsetSpace ~
15723 \InsetSpace ~
15724 mov
15725  __XPAGE,#(s_XISEG >> 8)
15726 \newline
15727 00001$:\InsetSpace ~
15728 clr a
15729 \newline
15730 \InsetSpace ~
15731 \InsetSpace ~
15732 \InsetSpace ~
15733 \InsetSpace ~
15734 \InsetSpace ~
15735 \InsetSpace ~
15736 \InsetSpace ~
15737 \InsetSpace ~
15738 movc a,@a+dptr
15739 \newline
15740 \InsetSpace ~
15741 \InsetSpace ~
15742 \InsetSpace ~
15743 \InsetSpace ~
15744 \InsetSpace ~
15745 \InsetSpace ~
15746 \InsetSpace ~
15747 \InsetSpace ~
15748 movx @r0,a
15749 \newline
15750 \InsetSpace ~
15751 \InsetSpace ~
15752 \InsetSpace ~
15753 \InsetSpace ~
15754 \InsetSpace ~
15755 \InsetSpace ~
15756 \InsetSpace ~
15757 \InsetSpace ~
15758 inc dptr
15759 \newline
15760 \InsetSpace ~
15761 \InsetSpace ~
15762 \InsetSpace ~
15763 \InsetSpace ~
15764 \InsetSpace ~
15765 \InsetSpace ~
15766 \InsetSpace ~
15767 \InsetSpace ~
15768 inc
15769  r0
15770 \newline
15771 \InsetSpace ~
15772 \InsetSpace ~
15773 \InsetSpace ~
15774 \InsetSpace ~
15775 \InsetSpace ~
15776 \InsetSpace ~
15777 \InsetSpace ~
15778 \InsetSpace ~
15779 cjne r0,#0,00002$
15780 \newline
15781 \InsetSpace ~
15782 \InsetSpace ~
15783 \InsetSpace ~
15784 \InsetSpace ~
15785 \InsetSpace ~
15786 \InsetSpace ~
15787 \InsetSpace ~
15788 \InsetSpace ~
15789 inc __XPAGE
15790 \newline
15791 00002$:\InsetSpace ~
15792 djnz r1,00001$
15793 \newline
15794 \InsetSpace ~
15795 \InsetSpace ~
15796 \InsetSpace ~
15797 \InsetSpace ~
15798 \InsetSpace ~
15799 \InsetSpace ~
15800 \InsetSpace ~
15801 \InsetSpace ~
15802 djnz r2,00001$
15803 \newline
15804 \InsetSpace ~
15805 \InsetSpace ~
15806 \InsetSpace ~
15807 \InsetSpace ~
15808 \InsetSpace ~
15809 \InsetSpace ~
15810 \InsetSpace ~
15811 \InsetSpace ~
15812 mov __XPAGE,#0
15813 xFF
15814 \newline
15815 00003$:
15816 \end_layout
15817
15818 \begin_layout Verse
15819
15820 \family typewriter
15821 \series bold
15822 \size footnotesize
15823 (crtclear.asm)
15824 \end_layout
15825
15826 \begin_layout Verse
15827
15828 \family typewriter
15829 \size footnotesize
15830 \InsetSpace ~
15831 \InsetSpace ~
15832 \InsetSpace ~
15833 \InsetSpace ~
15834 \InsetSpace ~
15835 \InsetSpace ~
15836 \InsetSpace ~
15837 \InsetSpace ~
15838 .area GSINIT4 (CODE)
15839 \newline
15840 __mcs51_genRAMCLEAR::
15841 \newline
15842 \InsetSpace ~
15843 \InsetSpace ~
15844 \InsetSpace ~
15845 \InsetSpace ~
15846 \InsetSpace ~
15847 \InsetSpace ~
15848 \InsetSpace ~
15849 \InsetSpace ~
15850 clr a
15851 \newline
15852 \InsetSpace ~
15853 \InsetSpace ~
15854 \InsetSpace ~
15855 \InsetSpace ~
15856 \InsetSpace ~
15857 \InsetSpace ~
15858 \InsetSpace ~
15859 \InsetSpace ~
15860 mov r0,#(l_IRAM-1)
15861 \newline
15862 00004$:\InsetSpace ~
15863 mov
15864  @r0,a
15865 \newline
15866 \InsetSpace ~
15867 \InsetSpace ~
15868 \InsetSpace ~
15869 \InsetSpace ~
15870 \InsetSpace ~
15871 \InsetSpace ~
15872 \InsetSpace ~
15873 \InsetSpace ~
15874 djnz r0,00004$
15875 \newline
15876 ; _mcs51_genRAMCLEAR() end
15877 \end_layout
15878
15879 \begin_layout Verse
15880
15881 \family typewriter
15882 \series bold
15883 \size footnotesize
15884 (crtxclear.asm)
15885 \end_layout
15886
15887 \begin_layout Verse
15888
15889 \family typewriter
15890 \size footnotesize
15891 \InsetSpace ~
15892 \InsetSpace ~
15893 \InsetSpace ~
15894 \InsetSpace ~
15895 \InsetSpace ~
15896 \InsetSpace ~
15897 \InsetSpace ~
15898 \InsetSpace ~
15899 .area GSINIT4 (CODE)
15900 \newline
15901 __mcs51_genXRAMCLEAR::
15902 \newline
15903 \InsetSpace ~
15904 \InsetSpace ~
15905 \InsetSpace ~
15906 \InsetSpace ~
15907 \InsetSpace ~
15908 \InsetSpace ~
15909 \InsetSpace ~
15910 \InsetSpace ~
15911 mov r0,#l_PSEG
15912 \newline
15913 \InsetSpace ~
15914 \InsetSpace ~
15915 \InsetSpace ~
15916 \InsetSpace ~
15917 \InsetSpace ~
15918 \InsetSpace ~
15919 \InsetSpace ~
15920 \InsetSpace ~
15921 mov a,r0
15922 \newline
15923 \InsetSpace ~
15924 \InsetSpace ~
15925 \InsetSpace ~
15926 \InsetSpace ~
15927 \InsetSpace ~
15928 \InsetSpace ~
15929 \InsetSpace ~
15930 \InsetSpace ~
15931 orl a,#(l_PSEG
15932  >> 8)
15933 \newline
15934 \InsetSpace ~
15935 \InsetSpace ~
15936 \InsetSpace ~
15937 \InsetSpace ~
15938 \InsetSpace ~
15939 \InsetSpace ~
15940 \InsetSpace ~
15941 \InsetSpace ~
15942 jz 00006$
15943 \newline
15944 \InsetSpace ~
15945 \InsetSpace ~
15946 \InsetSpace ~
15947 \InsetSpace ~
15948 \InsetSpace ~
15949 \InsetSpace ~
15950 \InsetSpace ~
15951 \InsetSpace ~
15952 mov r1,#s_PSEG
15953 \newline
15954 \InsetSpace ~
15955 \InsetSpace ~
15956 \InsetSpace ~
15957 \InsetSpace ~
15958 \InsetSpace ~
15959 \InsetSpace ~
15960 \InsetSpace ~
15961 \InsetSpace ~
15962 mov __XPAGE,#(s_PSEG >> 8)
15963 \newline
15964 \InsetSpace ~
15965 \InsetSpace ~
15966 \InsetSpace ~
15967 \InsetSpace ~
15968 \InsetSpace ~
15969 \InsetSpace ~
15970 \InsetSpace ~
15971 \InsetSpace ~
15972 clr a
15973 \newline
15974 00005$:\InsetSpace ~
15975 movx
15976  @r1,a
15977 \newline
15978 \InsetSpace ~
15979 \InsetSpace ~
15980 \InsetSpace ~
15981 \InsetSpace ~
15982 \InsetSpace ~
15983 \InsetSpace ~
15984 \InsetSpace ~
15985 \InsetSpace ~
15986 inc r1
15987 \newline
15988 \InsetSpace ~
15989 \InsetSpace ~
15990 \InsetSpace ~
15991 \InsetSpace ~
15992 \InsetSpace ~
15993 \InsetSpace ~
15994 \InsetSpace ~
15995 \InsetSpace ~
15996 djnz r0,00005$
15997 \newline
15998 00006$:
15999 \newline
16000 \InsetSpace ~
16001 \InsetSpace ~
16002 \InsetSpace ~
16003 \InsetSpace ~
16004 \InsetSpace ~
16005 \InsetSpace ~
16006 \InsetSpace ~
16007 \InsetSpace ~
16008 mov r0,#l_XSEG
16009 \newline
16010 \InsetSpace ~
16011 \InsetSpace ~
16012 \InsetSpace ~
16013 \InsetSpace ~
16014 \InsetSpace ~
16015 \InsetSpace ~
16016 \InsetSpace ~
16017 \InsetSpace ~
16018 mov a,r0
16019 \newline
16020 \InsetSpace ~
16021 \InsetSpace ~
16022 \InsetSpace ~
16023 \InsetSpace ~
16024 \InsetSpace ~
16025 \InsetSpace ~
16026 \InsetSpace ~
16027 \InsetSpace ~
16028 orl a,#(l_XSEG >>
16029  8)
16030 \newline
16031 \InsetSpace ~
16032 \InsetSpace ~
16033 \InsetSpace ~
16034 \InsetSpace ~
16035 \InsetSpace ~
16036 \InsetSpace ~
16037 \InsetSpace ~
16038 \InsetSpace ~
16039 jz 00008$
16040 \newline
16041 \InsetSpace ~
16042 \InsetSpace ~
16043 \InsetSpace ~
16044 \InsetSpace ~
16045 \InsetSpace ~
16046 \InsetSpace ~
16047 \InsetSpace ~
16048 \InsetSpace ~
16049 mov r1,#((l_XSEG + 255) >> 8)
16050 \newline
16051 \InsetSpace ~
16052 \InsetSpace ~
16053 \InsetSpace ~
16054 \InsetSpace ~
16055 \InsetSpace ~
16056 \InsetSpace ~
16057 \InsetSpace ~
16058 \InsetSpace ~
16059 mov dptr,#s_XSEG
16060 \newline
16061 \InsetSpace ~
16062 \InsetSpace ~
16063 \InsetSpace ~
16064 \InsetSpace ~
16065 \InsetSpace ~
16066 \InsetSpace ~
16067 \InsetSpace ~
16068 \InsetSpace ~
16069 clr a
16070 \newline
16071 00007$:\InsetSpace ~
16072 movx
16073  @dptr,a
16074 \newline
16075 \InsetSpace ~
16076 \InsetSpace ~
16077 \InsetSpace ~
16078 \InsetSpace ~
16079 \InsetSpace ~
16080 \InsetSpace ~
16081 \InsetSpace ~
16082 \InsetSpace ~
16083 inc dptr
16084 \newline
16085 \InsetSpace ~
16086 \InsetSpace ~
16087 \InsetSpace ~
16088 \InsetSpace ~
16089 \InsetSpace ~
16090 \InsetSpace ~
16091 \InsetSpace ~
16092 \InsetSpace ~
16093 djnz r0,00007$
16094 \newline
16095 \InsetSpace ~
16096 \InsetSpace ~
16097 \InsetSpace ~
16098 \InsetSpace ~
16099 \InsetSpace ~
16100 \InsetSpace ~
16101 \InsetSpace ~
16102 \InsetSpace ~
16103 djnz r1,00007$
16104 \newline
16105 00008$:
16106 \end_layout
16107
16108 \begin_layout Verse
16109
16110 \family typewriter
16111 \series bold
16112 \size footnotesize
16113 (crtxstack.asm)
16114 \end_layout
16115
16116 \begin_layout Verse
16117
16118 \family typewriter
16119 \size footnotesize
16120 \InsetSpace ~
16121 \InsetSpace ~
16122 \InsetSpace ~
16123 \InsetSpace ~
16124 \InsetSpace ~
16125 \InsetSpace ~
16126 \InsetSpace ~
16127 \InsetSpace ~
16128 .area GSINIT5 (CODE)
16129 \newline
16130 ; Need to initialize in GSINIT5 because __mcs51_genXINIT
16131  modifies __XPAGE
16132 \newline
16133 ; and __mcs51_genRAMCLEAR modifies _spx.
16134 \newline
16135 \InsetSpace ~
16136 \InsetSpace ~
16137 \InsetSpace ~
16138 \InsetSpace ~
16139 \InsetSpace ~
16140 \InsetSpace ~
16141 \InsetSpace ~
16142 \InsetSpace ~
16143 mov __XPAGE,#(__start__x
16144 stack >> 8)
16145 \newline
16146 \InsetSpace ~
16147 \InsetSpace ~
16148 \InsetSpace ~
16149 \InsetSpace ~
16150 \InsetSpace ~
16151 \InsetSpace ~
16152 \InsetSpace ~
16153 \InsetSpace ~
16154 mov _spx,#__start__xstack
16155 \end_layout
16156
16157 \begin_layout Verse
16158
16159 \family typewriter
16160 \series bold
16161 \size footnotesize
16162 (application modules)
16163 \end_layout
16164
16165 \begin_layout Verse
16166
16167 \family typewriter
16168 \size footnotesize
16169 \InsetSpace ~
16170 \InsetSpace ~
16171 \InsetSpace ~
16172 \InsetSpace ~
16173 \InsetSpace ~
16174 \InsetSpace ~
16175 \InsetSpace ~
16176 \InsetSpace ~
16177 .area GSINIT (CODE)
16178 \end_layout
16179
16180 \begin_layout Verse
16181
16182 \family typewriter
16183 \series bold
16184 \size footnotesize
16185 (main.asm)
16186 \end_layout
16187
16188 \begin_layout Verse
16189
16190 \family typewriter
16191 \size footnotesize
16192 \InsetSpace ~
16193 \InsetSpace ~
16194 \InsetSpace ~
16195 \InsetSpace ~
16196 \InsetSpace ~
16197 \InsetSpace ~
16198 \InsetSpace ~
16199 \InsetSpace ~
16200 .area GSFINAL (CODE)
16201 \newline
16202 \InsetSpace ~
16203 \InsetSpace ~
16204 \InsetSpace ~
16205 \InsetSpace ~
16206 \InsetSpace ~
16207 \InsetSpace ~
16208 \InsetSpace ~
16209 \InsetSpace ~
16210 ljmp __sdcc_program_startup
16211 \newline
16212 ;---------------------------------
16213 -----------------------
16214 \newline
16215 ; Home
16216 \newline
16217 ;--------------------------------------------------
16218 ------
16219 \newline
16220 \InsetSpace ~
16221 \InsetSpace ~
16222 \InsetSpace ~
16223 \InsetSpace ~
16224 \InsetSpace ~
16225 \InsetSpace ~
16226 \InsetSpace ~
16227 \InsetSpace ~
16228 .area HOME (CODE)
16229 \newline
16230 \InsetSpace ~
16231 \InsetSpace ~
16232 \InsetSpace ~
16233 \InsetSpace ~
16234 \InsetSpace ~
16235 \InsetSpace ~
16236 \InsetSpace ~
16237 \InsetSpace ~
16238 .area CSEG (CODE)
16239 \newline
16240 __sdcc_program_startup:
16241 \newline
16242 \InsetSpace ~
16243 \InsetSpace ~
16244 \InsetSpace ~
16245 \InsetSpace ~
16246 \InsetSpace ~
16247 \InsetSpace ~
16248 \InsetSpace ~
16249 \InsetSpace ~
16250 lcall _main
16251 \newline
16252 ;
16253  return from main will lock up
16254 \newline
16255 \InsetSpace ~
16256 \InsetSpace ~
16257 \InsetSpace ~
16258 \InsetSpace ~
16259 \InsetSpace ~
16260 \InsetSpace ~
16261 \InsetSpace ~
16262 \InsetSpace ~
16263 sjmp .
16264 \end_layout
16265
16266 \begin_layout Standard
16267 One of these modules (crtstart.asm) contains a call to the C routine 
16268 \emph on
16269 _sdcc_external_startup()
16270 \begin_inset LatexCommand \index{\_sdcc\_external\_startup()}
16271
16272 \end_inset
16273
16274
16275 \series bold
16276 \emph default
16277  
16278 \series default
16279 at the start of the CODE area.
16280  This routine is also in the runtime library
16281 \begin_inset LatexCommand \index{Runtime library}
16282
16283 \end_inset
16284
16285  and returns 0 by default.
16286  If this routine returns a non-zero value, the static & global variable
16287  initialization will be skipped and the function main will be invoked.
16288  Otherwise static & global variables will be initialized before the function
16289  main is invoked.
16290  You could add an 
16291 \emph on
16292 _sdcc_external_startup()
16293 \emph default
16294  routine to your program to override the default if you need to setup hardware
16295  or perform some other critical operation prior to static & global variable
16296  initialization
16297 \begin_inset LatexCommand \index{Variable initialization}
16298
16299 \end_inset
16300
16301 .
16302  On some mcs51 variants xdata
16303 \begin_inset LatexCommand \index{xdata (mcs51, ds390 storage class)}
16304
16305 \end_inset
16306
16307  memory has to be explicitly enabled before it can be accessed or if the
16308  watchdog
16309 \begin_inset LatexCommand \index{watchdog}
16310
16311 \end_inset
16312
16313  needs to be disabled, this is the place to do it.
16314  The startup code clears all internal data memory, 256 bytes by default,
16315  but from 0 to n-1 if 
16316 \emph on
16317 -
16318 \begin_inset ERT
16319 status collapsed
16320
16321 \begin_layout Standard
16322
16323
16324 \backslash
16325 /
16326 \end_layout
16327
16328 \end_inset
16329
16330 -iram-size
16331 \begin_inset LatexCommand \index{-\/-iram-size <Value>}
16332
16333 \end_inset
16334
16335 n
16336 \emph default
16337  is used.
16338  (recommended for Chipcon CC1010).
16339 \end_layout
16340
16341 \begin_layout Standard
16342 See also the compiler options 
16343 \emph on
16344 -
16345 \begin_inset ERT
16346 status collapsed
16347
16348 \begin_layout Standard
16349
16350
16351 \backslash
16352 /
16353 \end_layout
16354
16355 \end_inset
16356
16357 -no-xinit
16358 \emph default
16359 -
16360 \emph on
16361 opt
16362 \emph default
16363
16364 \begin_inset LatexCommand \index{-\/-no-xinit-opt}
16365
16366 \end_inset
16367
16368
16369 \emph on
16370 -
16371 \begin_inset ERT
16372 status collapsed
16373
16374 \begin_layout Standard
16375
16376
16377 \backslash
16378 /
16379 \end_layout
16380
16381 \end_inset
16382
16383 -main-return
16384 \emph default
16385
16386 \begin_inset LatexCommand \index{-\/-main-return}
16387
16388 \end_inset
16389
16390  and section 
16391 \begin_inset LatexCommand \ref{sub:MCS51-variants}
16392
16393 \end_inset
16394
16395  about MCS51-variants.
16396 \newline
16397
16398 \end_layout
16399
16400 \begin_layout Standard
16401 While these initialization modules are meant as generic startup code there
16402  might be the need for customization.
16403  Let's assume the return value of 
16404 \emph on
16405 _sdcc_external_startup()
16406 \emph default
16407  in 
16408 \emph on
16409 crtstart.asm
16410 \emph default
16411  should not be checked (or 
16412 \emph on
16413 _sdcc_external_startup()
16414 \emph default
16415  should not be called at all).
16416  The recommended way would be to copy 
16417 \emph on
16418 crtstart.asm
16419 \emph default
16420  (f.e.
16421  from 
16422 \begin_inset LatexCommand \url{http://sdcc.svn.sourceforge.net/viewvc/*checkout*/sdcc/trunk/sdcc/device/lib/mcs51/crtstart.asm}
16423
16424 \end_inset
16425
16426 ) into the source directory, adapt it there, then assemble it with 
16427 \emph on
16428 asx8051 -plosgff
16429 \begin_inset Foot
16430 status open
16431
16432 \begin_layout Standard
16433 \begin_inset Quotes sld
16434 \end_inset
16435
16436 -plosgff
16437 \begin_inset Quotes srd
16438 \end_inset
16439
16440  are the assembler options used in 
16441 \begin_inset LatexCommand \url{http://sdcc.svn.sourceforge.net/viewvc/sdcc/trunk/sdcc/device/lib/mcs51/Makefile.in?view=markup }
16442
16443 \end_inset
16444
16445
16446 \end_layout
16447
16448 \end_inset
16449
16450  crtstart.asm
16451 \emph default
16452  and when linking your project explicitely specify 
16453 \emph on
16454 crtstart.rel
16455 \emph default
16456 .
16457  As a bonus a listing of the relocated object file 
16458 \emph on
16459 crtstart.rst
16460 \emph default
16461  is generated.
16462 \end_layout
16463
16464 \begin_layout Standard
16465 \begin_inset VSpace bigskip
16466 \end_inset
16467
16468
16469 \end_layout
16470
16471 \begin_layout Subsection
16472 HC08 Startup Code
16473 \end_layout
16474
16475 \begin_layout Standard
16476 The HC08
16477 \begin_inset LatexCommand \index{HC08}
16478
16479 \end_inset
16480
16481  startup code follows the same scheme as the MCS51 startup code.
16482 \begin_inset VSpace bigskip
16483 \end_inset
16484
16485
16486 \end_layout
16487
16488 \begin_layout Subsection
16489 Z80 Startup Code
16490 \end_layout
16491
16492 \begin_layout Standard
16493 On the Z80
16494 \begin_inset LatexCommand \index{Z80}
16495
16496 \end_inset
16497
16498  the startup code is inserted by linking with crt0.o which is generated from
16499  sdcc/device/lib/z80/crt0.s.
16500  If you need a different startup code you can use the compiler option 
16501 \emph on
16502 -
16503 \series bold
16504 \emph default
16505
16506 \begin_inset ERT
16507 status collapsed
16508
16509 \begin_layout Standard
16510
16511
16512 \backslash
16513 /
16514 \end_layout
16515
16516 \end_inset
16517
16518
16519 \series default
16520 \emph on
16521 -no-std-crt0
16522 \emph default
16523
16524 \begin_inset LatexCommand \index{-\/-no-std-crt0}
16525
16526 \end_inset
16527
16528  and provide your own crt0.o.
16529  
16530 \begin_inset VSpace bigskip
16531 \end_inset
16532
16533
16534 \end_layout
16535
16536 \begin_layout Section
16537 Inline Assembler Code
16538 \begin_inset LatexCommand \index{Assembler routines}
16539
16540 \end_inset
16541
16542
16543 \end_layout
16544
16545 \begin_layout Subsection
16546 A Step by Step Introduction
16547 \begin_inset LatexCommand \label{sub:A-Step-by Assembler Introduction}
16548
16549 \end_inset
16550
16551
16552 \end_layout
16553
16554 \begin_layout Standard
16555 Starting from a small snippet of c-code this example shows for the MCS51
16556  how to use inline assembly, access variables, a function parameter and
16557  an array in xdata memory.
16558  The example uses an MCS51 here but is easily adapted for other architectures.
16559  This is a buffer routine which should be optimized:
16560 \end_layout
16561
16562 \begin_layout Verse
16563
16564 \family typewriter
16565 \size footnotesize
16566 unsigned char __far
16567 \begin_inset LatexCommand \index{far (storage class)}
16568
16569 \end_inset
16570
16571
16572 \begin_inset LatexCommand \index{\_\_far (storage class)}
16573
16574 \end_inset
16575
16576  __at
16577 \begin_inset LatexCommand \index{at}
16578
16579 \end_inset
16580
16581
16582 \begin_inset LatexCommand \index{\_\_at}
16583
16584 \end_inset
16585
16586 (0x7f00) buf[0x100];
16587 \begin_inset LatexCommand \index{Aligned array}
16588
16589 \end_inset
16590
16591
16592 \newline
16593 unsigned char head, tail;\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 /* if interrupts
16611 \begin_inset LatexCommand \index{interrupt}
16612
16613 \end_inset
16614
16615  are involved see
16616 \newline
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 \InsetSpace ~
16633 \InsetSpace ~
16634 \InsetSpace ~
16635 \InsetSpace ~
16636 \InsetSpace ~
16637 \InsetSpace ~
16638 \InsetSpace ~
16639 \InsetSpace ~
16640 \InsetSpace ~
16641 \InsetSpace ~
16642 \InsetSpace ~
16643 \InsetSpace ~
16644 \InsetSpace ~
16645 \InsetSpace ~
16646 \InsetSpace ~
16647 \InsetSpace ~
16648 \InsetSpace ~
16649 \InsetSpace ~
16650 \InsetSpace ~
16651 \InsetSpace ~
16652 \InsetSpace ~
16653 \InsetSpace ~
16654 \InsetSpace ~
16655 \InsetSpace ~
16656 \InsetSpace ~
16657 \InsetSpace ~
16658 \InsetSpace ~
16659 \InsetSpace ~
16660 \InsetSpace ~
16661 \InsetSpace ~
16662 section 
16663 \begin_inset LatexCommand \ref{sub:Common-interrupt-pitfall-volatile}
16664
16665 \end_inset
16666
16667  about
16668 \series bold
16669  volatile
16670 \series default
16671  */
16672 \newline
16673
16674 \newline
16675 void to_buffer( unsigned char c ) 
16676 \newline
16677 {
16678 \newline
16679 \InsetSpace ~
16680 \InsetSpace ~
16681 \InsetSpace ~
16682 \InsetSpace ~
16683 if( head != (unsigned char)(tail-1)
16684  )\InsetSpace ~
16685 /* cast 
16686 \series bold
16687 needed
16688 \series default
16689  to avoid promotion
16690 \begin_inset LatexCommand \index{promotion to signed int}
16691
16692 \end_inset
16693
16694
16695 \begin_inset LatexCommand \index{type promotion}
16696
16697 \end_inset
16698
16699  to integer */
16700 \begin_inset Marginal
16701 status collapsed
16702
16703 \begin_layout Standard
16704
16705 \series bold
16706 \InsetSpace ~
16707 !
16708 \end_layout
16709
16710 \end_inset
16711
16712
16713 \newline
16714 \InsetSpace ~
16715 \InsetSpace ~
16716 \InsetSpace ~
16717 \InsetSpace ~
16718 \InsetSpace ~
16719 \InsetSpace ~
16720 \InsetSpace ~
16721 \InsetSpace ~
16722 buf[ head++ ] = c;\InsetSpace ~
16723 \InsetSpace ~
16724 \InsetSpace ~
16725 \InsetSpace ~
16726 \InsetSpace ~
16727 \InsetSpace ~
16728 \InsetSpace ~
16729 \InsetSpace ~
16730 \InsetSpace ~
16731 \InsetSpace ~
16732 \InsetSpace ~
16733 \InsetSpace ~
16734 \InsetSpace ~
16735 \InsetSpace ~
16736 \InsetSpace ~
16737 \InsetSpace ~
16738 /* access to a 256 byte aligned array */
16739 \newline
16740
16741 \end_layout
16742
16743 \begin_layout Standard
16744 If the code snippet (assume it is saved in buffer.c) is compiled with SDCC
16745  then a corresponding buffer.asm file is generated.
16746  We define a new function 
16747 \family typewriter
16748 to_buffer_asm()
16749 \family default
16750  in file buffer.c in which we cut and paste the generated code, removing
16751  unwanted comments and some ':'.
16752  Then add 
16753 \begin_inset Quotes sld
16754 \end_inset
16755
16756
16757 \series bold
16758 _asm
16759 \series default
16760
16761 \begin_inset Quotes srd
16762 \end_inset
16763
16764  and 
16765 \begin_inset Quotes sld
16766 \end_inset
16767
16768
16769 \series bold
16770 _endasm;
16771 \series default
16772
16773 \begin_inset Quotes srd
16774 \end_inset
16775
16776
16777 \begin_inset Foot
16778 status open
16779
16780 \begin_layout Standard
16781 Note, that the single underscore form (_asm and _endasm) are not C99-compatible,
16782  and for C-99 compatibility, the double-underscore form (__asm and __endasm)
16783  has to be used.
16784  The latter is also used in the library functions.
16785 \end_layout
16786
16787 \end_inset
16788
16789  to the beginning and the end of the function body:
16790 \end_layout
16791
16792 \begin_layout Verse
16793
16794 \family typewriter
16795 \size footnotesize
16796 /* With a cut and paste from the .asm file, we have something to start with.
16797 \newline
16798 \InsetSpace ~
16799 \InsetSpace ~
16800 \InsetSpace ~
16801 The
16802  function is not yet OK! (registers aren't saved) */ 
16803 \newline
16804 void to_buffer_asm(
16805  unsigned char c ) 
16806 \newline
16807
16808 \newline
16809 \InsetSpace ~
16810 \InsetSpace ~
16811 \InsetSpace ~
16812 \InsetSpace ~
16813 _asm
16814 \begin_inset LatexCommand \index{\_asm}
16815
16816 \end_inset
16817
16818
16819 \begin_inset LatexCommand \index{\_\_asm}
16820
16821 \end_inset
16822
16823
16824 \newline
16825 \InsetSpace ~
16826 \InsetSpace ~
16827 \InsetSpace ~
16828 \InsetSpace ~
16829 mov\InsetSpace ~
16830 \InsetSpace ~
16831 r2,dpl 
16832 \newline
16833 ;buffer.c if( head != (unsigned char)(tail-1) ) \InsetSpace ~
16834 /* cast 
16835 \series bold
16836 needed
16837 \series default
16838  to avoid promotion
16839 \begin_inset LatexCommand \index{promotion to signed int}
16840
16841 \end_inset
16842
16843
16844 \begin_inset LatexCommand \index{type promotion}
16845
16846 \end_inset
16847
16848  to integer */
16849 \newline
16850 \InsetSpace ~
16851 \InsetSpace ~
16852 \InsetSpace ~
16853 \InsetSpace ~
16854 mov\InsetSpace ~
16855 \InsetSpace ~
16856 a,_tail 
16857 \newline
16858 \InsetSpace ~
16859 \InsetSpace ~
16860 \InsetSpace ~
16861 \InsetSpace ~
16862 dec\InsetSpace ~
16863 \InsetSpace ~
16864
16865 \newline
16866 \InsetSpace ~
16867 \InsetSpace ~
16868 \InsetSpace ~
16869 \InsetSpace ~
16870 mov\InsetSpace ~
16871 \InsetSpace ~
16872 r3,a 
16873 \newline
16874 \InsetSpace ~
16875 \InsetSpace ~
16876 \InsetSpace ~
16877 \InsetSpace ~
16878 mov\InsetSpace ~
16879 \InsetSpace ~
16880 a,_head 
16881 \newline
16882 \InsetSpace ~
16883 \InsetSpace ~
16884 \InsetSpace ~
16885 \InsetSpace ~
16886 cjne a,ar3,00106$ 
16887 \newline
16888 \InsetSpace ~
16889 \InsetSpace ~
16890 \InsetSpace ~
16891 \InsetSpace ~
16892 ret
16893 \newline
16894 00106$:
16895  
16896 \newline
16897 ;buffer.c buf[ head++ ] = c; /* access to a 256 byte aligned array */
16898 \begin_inset LatexCommand \index{Aligned array}
16899
16900 \end_inset
16901
16902
16903 \newline
16904 \InsetSpace ~
16905 \InsetSpace ~
16906 \InsetSpace ~
16907 \InsetSpace ~
16908 mov\InsetSpace ~
16909 \InsetSpace ~
16910 r3,_head 
16911 \newline
16912 \InsetSpace ~
16913 \InsetSpace ~
16914 \InsetSpace ~
16915 \InsetSpace ~
16916 inc\InsetSpace ~
16917 \InsetSpace ~
16918 _head 
16919 \newline
16920 \InsetSpace ~
16921 \InsetSpace ~
16922 \InsetSpace ~
16923 \InsetSpace ~
16924 mov\InsetSpace ~
16925 \InsetSpace ~
16926 dpl,r3 
16927 \newline
16928 \InsetSpace ~
16929 \InsetSpace ~
16930 \InsetSpace ~
16931 \InsetSpace ~
16932 mov\InsetSpace ~
16933 \InsetSpace ~
16934 dph,#(_buf >> 8) 
16935 \newline
16936 \InsetSpace ~
16937 \InsetSpace ~
16938 \InsetSpace ~
16939 \InsetSpace ~
16940 mov\InsetSpace ~
16941 \InsetSpace ~
16942 a,r2 
16943 \newline
16944 \InsetSpace ~
16945 \InsetSpace ~
16946 \InsetSpace ~
16947 \InsetSpace ~
16948 movx @dptr,a
16949  
16950 \newline
16951 00103$: 
16952 \newline
16953 \InsetSpace ~
16954 \InsetSpace ~
16955 \InsetSpace ~
16956 \InsetSpace ~
16957 ret
16958 \newline
16959 \InsetSpace ~
16960 \InsetSpace ~
16961 \InsetSpace ~
16962 \InsetSpace ~
16963 _endasm
16964 \begin_inset LatexCommand \index{\_endasm}
16965
16966 \end_inset
16967
16968
16969 \begin_inset LatexCommand \index{\_\_endasm}
16970
16971 \end_inset
16972
16973 ;
16974 \newline
16975
16976 \end_layout
16977
16978 \begin_layout Standard
16979 The new file buffer.c should compile with only one warning about the unreferenced
16980  function argument 'c'.
16981  Now we hand-optimize the assembly code and insert an #define USE_ASSEMBLY
16982  (1) and finally have:
16983 \end_layout
16984
16985 \begin_layout Verse
16986
16987 \family typewriter
16988 \size footnotesize
16989 unsigned char __far __at(0x7f00) buf[0x100];
16990 \newline
16991 unsigned char head, tail;
16992 \newline
16993 #define
16994  USE_ASSEMBLY (1)
16995 \newline
16996
16997 \newline
16998 #if !USE_ASSEMBLY
16999 \newline
17000
17001 \newline
17002 void to_buffer( unsigned char c )
17003 \newline
17004 {
17005 \newline
17006 \InsetSpace ~
17007 \InsetSpace ~
17008 \InsetSpace ~
17009 \InsetSpace ~
17010 if(
17011  head != (unsigned char)(tail-1) )
17012 \newline
17013 \InsetSpace ~
17014 \InsetSpace ~
17015 \InsetSpace ~
17016 \InsetSpace ~
17017 \InsetSpace ~
17018 \InsetSpace ~
17019 \InsetSpace ~
17020 \InsetSpace ~
17021 buf[ head++ ] = c;
17022 \newline
17023 }
17024 \newline
17025
17026 \newline
17027 #else
17028 \newline
17029
17030 \newline
17031 void to_buffer(
17032  unsigned char c )
17033 \newline
17034 {
17035 \newline
17036 \InsetSpace ~
17037 \InsetSpace ~
17038 \InsetSpace ~
17039 \InsetSpace ~
17040 c; // to avoid warning: unreferenced function argument
17041 \newline
17042 \InsetSpace ~
17043 \InsetSpace ~
17044 \InsetSpace ~
17045 \InsetSpace ~
17046 _asm
17047 \begin_inset LatexCommand \index{\_asm}
17048
17049 \end_inset
17050
17051
17052 \begin_inset LatexCommand \index{\_\_asm}
17053
17054 \end_inset
17055
17056
17057 \newline
17058 \InsetSpace ~
17059 \InsetSpace ~
17060 \InsetSpace ~
17061 \InsetSpace ~
17062 \InsetSpace ~
17063 \InsetSpace ~
17064 \InsetSpace ~
17065 \InsetSpace ~
17066 ; save used registers here.
17067  
17068 \newline
17069 \InsetSpace ~
17070 \InsetSpace ~
17071 \InsetSpace ~
17072 \InsetSpace ~
17073 \InsetSpace ~
17074 \InsetSpace ~
17075 \InsetSpace ~
17076 \InsetSpace ~
17077 ; If we were still using r2,r3 we would have to push them here.
17078  
17079 \newline
17080 ; if( head != (unsigned char)(tail-1) )
17081 \newline
17082 \InsetSpace ~
17083 \InsetSpace ~
17084 \InsetSpace ~
17085 \InsetSpace ~
17086 \InsetSpace ~
17087 \InsetSpace ~
17088 \InsetSpace ~
17089 \InsetSpace ~
17090 mov\InsetSpace ~
17091  a,_tail
17092 \newline
17093 \InsetSpace ~
17094 \InsetSpace ~
17095 \InsetSpace ~
17096 \InsetSpace ~
17097 \InsetSpace ~
17098 \InsetSpace ~
17099 \InsetSpace ~
17100 \InsetSpace ~
17101 dec\InsetSpace ~
17102  a
17103 \newline
17104 \InsetSpace ~
17105 \InsetSpace ~
17106 \InsetSpace ~
17107 \InsetSpace ~
17108 \InsetSpace ~
17109 \InsetSpace ~
17110 \InsetSpace ~
17111 \InsetSpace ~
17112 xrl\InsetSpace ~
17113  a,_head
17114 \newline
17115 \InsetSpace ~
17116 \InsetSpace ~
17117 \InsetSpace ~
17118 \InsetSpace ~
17119 \InsetSpace ~
17120 \InsetSpace ~
17121 \InsetSpace ~
17122 \InsetSpace ~
17123 ; we
17124  could do an ANL a,#0x0f here to use a smaller buffer (see below)
17125 \newline
17126 \InsetSpace ~
17127 \InsetSpace ~
17128 \InsetSpace ~
17129 \InsetSpace ~
17130 \InsetSpace ~
17131 \InsetSpace ~
17132 \InsetSpace ~
17133 \InsetSpace ~
17134 jz\InsetSpace ~
17135 \InsetSpace ~
17136  t_b_end$
17137 \newline
17138 \InsetSpace ~
17139 \InsetSpace ~
17140 \InsetSpace ~
17141 \InsetSpace ~
17142 \InsetSpace ~
17143 \InsetSpace ~
17144 \InsetSpace ~
17145 \InsetSpace ~
17146 ;
17147 \newline
17148 ;
17149  buf[ head++ ] = c;
17150 \newline
17151 \InsetSpace ~
17152 \InsetSpace ~
17153 \InsetSpace ~
17154 \InsetSpace ~
17155 \InsetSpace ~
17156 \InsetSpace ~
17157 \InsetSpace ~
17158 \InsetSpace ~
17159 mov\InsetSpace ~
17160  a,dpl \InsetSpace ~
17161 \InsetSpace ~
17162 \InsetSpace ~
17163 \InsetSpace ~
17164 \InsetSpace ~
17165 \InsetSpace ~
17166 \InsetSpace ~
17167 ; dpl holds lower byte of function argument
17168 \newline
17169 \InsetSpace ~
17170 \InsetSpace ~
17171 \InsetSpace ~
17172 \InsetSpace ~
17173 \InsetSpace ~
17174 \InsetSpace ~
17175 \InsetSpace ~
17176 \InsetSpace ~
17177 mov\InsetSpace ~
17178
17179  dpl,_head \InsetSpace ~
17180 \InsetSpace ~
17181 \InsetSpace ~
17182 ; buf is 0x100 byte aligned so head can be used directly
17183 \newline
17184 \InsetSpace ~
17185 \InsetSpace ~
17186 \InsetSpace ~
17187 \InsetSpace ~
17188 \InsetSpace ~
17189 \InsetSpace ~
17190 \InsetSpace ~
17191 \InsetSpace ~
17192 mov\InsetSpace ~
17193  dph,#(_bu
17194 f>>8)
17195 \newline
17196 \InsetSpace ~
17197 \InsetSpace ~
17198 \InsetSpace ~
17199 \InsetSpace ~
17200 \InsetSpace ~
17201 \InsetSpace ~
17202 \InsetSpace ~
17203 \InsetSpace ~
17204 movx @dptr,a
17205 \newline
17206 \InsetSpace ~
17207 \InsetSpace ~
17208 \InsetSpace ~
17209 \InsetSpace ~
17210 \InsetSpace ~
17211 \InsetSpace ~
17212 \InsetSpace ~
17213 \InsetSpace ~
17214 inc \InsetSpace ~
17215 _head
17216 \newline
17217 \InsetSpace ~
17218 \InsetSpace ~
17219 \InsetSpace ~
17220 \InsetSpace ~
17221 \InsetSpace ~
17222 \InsetSpace ~
17223 \InsetSpace ~
17224 \InsetSpace ~
17225 ; we could do an ANL _head,#0x0f here to use a
17226  smaller buffer (see above)
17227 \newline
17228 t_b_end$:
17229 \newline
17230 \InsetSpace ~
17231 \InsetSpace ~
17232 \InsetSpace ~
17233 \InsetSpace ~
17234 \InsetSpace ~
17235 \InsetSpace ~
17236 \InsetSpace ~
17237 \InsetSpace ~
17238 ; restore used registers here 
17239 \newline
17240 \InsetSpace ~
17241 \InsetSpace ~
17242 \InsetSpace ~
17243 \InsetSpace ~
17244 _endasm
17245 \begin_inset LatexCommand \index{\_endasm}
17246
17247 \end_inset
17248
17249
17250 \begin_inset LatexCommand \index{\_\_endasm}
17251
17252 \end_inset
17253
17254 ;
17255 \newline
17256 }
17257 \newline
17258 #endif
17259 \end_layout
17260
17261 \begin_layout Standard
17262 The inline assembler code can contain any valid code understood by the assembler
17263 , this includes any assembler directives and comment lines.
17264  The assembler does not like some characters like ':' or ''' in comments.
17265  You'll find an 100+ pages assembler manual in sdcc/as/doc/asxhtm.html
17266 \begin_inset LatexCommand \index{asXXXX (as-gbz80, as-hc08, asx8051, as-z80)}
17267
17268 \end_inset
17269
17270
17271 \begin_inset LatexCommand \index{Assembler documentation}
17272
17273 \end_inset
17274
17275  or online at 
17276 \begin_inset LatexCommand \url{http://sdcc.svn.sourceforge.net/viewvc/*checkout*/sdcc/trunk/sdcc/as/doc/asxhtm.html}
17277
17278 \end_inset
17279
17280 \InsetSpace ~
17281 .
17282 \end_layout
17283
17284 \begin_layout Standard
17285 The compiler does not do any validation of the code within the 
17286 \family typewriter
17287 _asm
17288 \begin_inset LatexCommand \index{\_asm}
17289
17290 \end_inset
17291
17292
17293 \begin_inset LatexCommand \index{\_\_asm}
17294
17295 \end_inset
17296
17297  ...
17298  _endasm
17299 \size footnotesize
17300
17301 \begin_inset LatexCommand \index{\_endasm}
17302
17303 \end_inset
17304
17305
17306 \begin_inset LatexCommand \index{\_\_endasm}
17307
17308 \end_inset
17309
17310
17311 \size default
17312 ;
17313 \family default
17314  keyword pair.
17315  Specifically it will not know which registers are used and thus register
17316  pushing/popping
17317 \begin_inset LatexCommand \index{push/pop}
17318
17319 \end_inset
17320
17321  has to be done manually.
17322  
17323 \end_layout
17324
17325 \begin_layout Standard
17326 It is recommended that each assembly instruction (including labels) be placed
17327  in a separate line (as the example shows).
17328  When the -
17329 \begin_inset ERT
17330 status collapsed
17331
17332 \begin_layout Standard
17333
17334
17335 \backslash
17336 /
17337 \end_layout
17338
17339 \end_inset
17340
17341 -
17342 \emph on
17343 peep-asm
17344 \begin_inset LatexCommand \index{-\/-peep-asm}
17345
17346 \end_inset
17347
17348
17349 \emph default
17350  command line option is used, the inline assembler code will be passed through
17351  the peephole optimizer
17352 \begin_inset LatexCommand \index{Peephole optimizer}
17353
17354 \end_inset
17355
17356 .
17357  There are only a few (if any) cases where this option makes sense, it might
17358  cause some unexpected changes in the inline assembler code.
17359  Please go through the peephole optimizer rules defined in file 
17360 \emph on
17361 SDCCpeeph.def
17362 \emph default
17363  before using this option.
17364 \end_layout
17365
17366 \begin_layout Subsection
17367 Naked Functions
17368 \begin_inset LatexCommand \label{sub:Naked-Functions}
17369
17370 \end_inset
17371
17372
17373 \begin_inset LatexCommand \index{Naked functions}
17374
17375 \end_inset
17376
17377
17378 \end_layout
17379
17380 \begin_layout Standard
17381 A special keyword may be associated with a function declaring it as 
17382 \emph on
17383 _naked
17384 \begin_inset LatexCommand \index{\_naked}
17385
17386 \end_inset
17387
17388
17389 \begin_inset LatexCommand \index{\_\_naked}
17390
17391 \end_inset
17392
17393 .
17394  
17395 \emph default
17396 The 
17397 \emph on
17398 _naked
17399 \emph default
17400  function modifier attribute prevents the compiler from generating prologue
17401 \begin_inset LatexCommand \index{function prologue}
17402
17403 \end_inset
17404
17405  and epilogue
17406 \begin_inset LatexCommand \index{function epilogue}
17407
17408 \end_inset
17409
17410  code for that function.
17411  This means that the user is entirely responsible for such things as saving
17412  any registers that may need to be preserved, selecting the proper register
17413  bank, generating the 
17414 \emph on
17415 return
17416 \emph default
17417  instruction at the end, etc.
17418  Practically, this means that the contents of the function must be written
17419  in inline assembler.
17420  This is particularly useful for interrupt functions, which can have a large
17421  (and often unnecessary) prologue/epilogue.
17422  For example, compare the code generated by these two functions:
17423 \end_layout
17424
17425 \begin_layout Verse
17426
17427 \family typewriter
17428 volatile
17429 \begin_inset LatexCommand \index{volatile}
17430
17431 \end_inset
17432
17433  data unsigned char counter;
17434 \newline
17435
17436 \newline
17437 void simpleInterrupt(void) __interrupt
17438 \begin_inset LatexCommand \index{interrupt}
17439
17440 \end_inset
17441
17442
17443 \begin_inset LatexCommand \index{\_\_interrupt}
17444
17445 \end_inset
17446
17447  (1)
17448 \newline
17449 {
17450 \newline
17451 \InsetSpace ~
17452 \InsetSpace ~
17453 \InsetSpace ~
17454 \InsetSpace ~
17455 counter++;
17456 \newline
17457 }
17458 \newline
17459
17460 \newline
17461 void nakedInterrupt(void) __interrupt (2) __naked
17462 \newline
17463 {
17464 \newline
17465 \InsetSpace ~
17466 \InsetSpace ~
17467 \InsetSpace ~
17468 \InsetSpace ~
17469 _asm
17470 \begin_inset LatexCommand \index{\_asm}
17471
17472 \end_inset
17473
17474
17475 \begin_inset LatexCommand \index{\_\_asm}
17476
17477 \end_inset
17478
17479
17480 \newline
17481 \InsetSpace ~
17482 \InsetSpace ~
17483 \InsetSpace ~
17484 \InsetSpace ~
17485 \InsetSpace ~
17486 \InsetSpace ~
17487 inc\InsetSpace ~
17488 \InsetSpace ~
17489 \InsetSpace ~
17490 \InsetSpace ~
17491 \InsetSpace ~
17492 _counter ; does not change flags, no need to save psw
17493 \newline
17494 \InsetSpace ~
17495 \InsetSpace ~
17496 \InsetSpace ~
17497 \InsetSpace ~
17498 \InsetSpace ~
17499 \InsetSpace ~
17500 reti\InsetSpace ~
17501 \InsetSpace ~
17502 \InsetSpace ~
17503 \InsetSpace ~
17504 ; MUST explicitly
17505  include ret or reti in _naked function.
17506 \newline
17507 \InsetSpace ~
17508 \InsetSpace ~
17509 \InsetSpace ~
17510 \InsetSpace ~
17511 _endasm
17512 \begin_inset LatexCommand \index{\_endasm}
17513
17514 \end_inset
17515
17516
17517 \begin_inset LatexCommand \index{\_\_endasm}
17518
17519 \end_inset
17520
17521 ;
17522 \newline
17523 }
17524 \end_layout
17525
17526 \begin_layout Standard
17527 For an 8051 target, the generated simpleInterrupt looks like:
17528 \end_layout
17529
17530 \begin_layout Verse
17531
17532 \family typewriter
17533 Note, this is an 
17534 \emph on
17535 outdated
17536 \emph default
17537  example, recent versions of SDCC generate
17538 \newline
17539 the 
17540 \emph on
17541 same
17542 \emph default
17543  code for simpleInterrupt() and nakedInterrupt()!
17544 \newline
17545
17546 \newline
17547 _simpleInterrupt:
17548 \newline
17549 \InsetSpace ~
17550 \InsetSpace ~
17551 \InsetSpace ~
17552 \InsetSpace ~
17553 push\InsetSpace ~
17554 \InsetSpace ~
17555 \InsetSpace ~
17556 \InsetSpace ~
17557 acc
17558 \newline
17559 \InsetSpace ~
17560 \InsetSpace ~
17561 \InsetSpace ~
17562 \InsetSpace ~
17563 push\InsetSpace ~
17564 \InsetSpace ~
17565 \InsetSpace ~
17566 \InsetSpace ~
17567 b
17568 \newline
17569 \InsetSpace ~
17570 \InsetSpace ~
17571 \InsetSpace ~
17572 \InsetSpace ~
17573 pu
17574 sh\InsetSpace ~
17575 \InsetSpace ~
17576 \InsetSpace ~
17577 \InsetSpace ~
17578 dpl
17579 \newline
17580 \InsetSpace ~
17581 \InsetSpace ~
17582 \InsetSpace ~
17583 \InsetSpace ~
17584 push\InsetSpace ~
17585 \InsetSpace ~
17586 \InsetSpace ~
17587 \InsetSpace ~
17588 dph
17589 \newline
17590 \InsetSpace ~
17591 \InsetSpace ~
17592 \InsetSpace ~
17593 \InsetSpace ~
17594 push\InsetSpace ~
17595 \InsetSpace ~
17596 \InsetSpace ~
17597 \InsetSpace ~
17598 psw
17599 \newline
17600 \InsetSpace ~
17601 \InsetSpace ~
17602 \InsetSpace ~
17603 \InsetSpace ~
17604 mov\InsetSpace ~
17605 \InsetSpace ~
17606 \InsetSpace ~
17607 \InsetSpace ~
17608 \InsetSpace ~
17609 psw,#0x00
17610 \newline
17611 \InsetSpace ~
17612 \InsetSpace ~
17613 \InsetSpace ~
17614 \InsetSpace ~
17615 inc\InsetSpace ~
17616 \InsetSpace ~
17617 \InsetSpace ~
17618 \InsetSpace ~
17619 \InsetSpace ~
17620 _counter
17621 \newline
17622 \InsetSpace ~
17623 \InsetSpace ~
17624 \InsetSpace ~
17625 \InsetSpace ~
17626 pop\InsetSpace ~
17627 \InsetSpace ~
17628 \InsetSpace ~
17629 \InsetSpace ~
17630 \InsetSpace ~
17631 psw
17632 \newline
17633 \InsetSpace ~
17634 \InsetSpace ~
17635 \InsetSpace ~
17636 \InsetSpace ~
17637 pop\InsetSpace ~
17638 \InsetSpace ~
17639 \InsetSpace ~
17640 \InsetSpace ~
17641 \InsetSpace ~
17642 dph
17643 \newline
17644 \InsetSpace ~
17645 \InsetSpace ~
17646 \InsetSpace ~
17647 \InsetSpace ~
17648 pop\InsetSpace ~
17649 \InsetSpace ~
17650 \InsetSpace ~
17651 \InsetSpace ~
17652 \InsetSpace ~
17653 dpl
17654 \newline
17655 \InsetSpace ~
17656 \InsetSpace ~
17657 \InsetSpace ~
17658 \InsetSpace ~
17659 pop\InsetSpace ~
17660 \InsetSpace ~
17661 \InsetSpace ~
17662 \InsetSpace ~
17663 \InsetSpace ~
17664 b
17665 \newline
17666 \InsetSpace ~
17667 \InsetSpace ~
17668 \InsetSpace ~
17669 \InsetSpace ~
17670 pop\InsetSpace ~
17671 \InsetSpace ~
17672 \InsetSpace ~
17673 \InsetSpace ~
17674 \InsetSpace ~
17675 acc
17676 \newline
17677 \InsetSpace ~
17678 \InsetSpace ~
17679 \InsetSpace ~
17680 \InsetSpace ~
17681 reti
17682 \end_layout
17683
17684 \begin_layout Standard
17685 whereas nakedInterrupt looks like:
17686 \end_layout
17687
17688 \begin_layout Verse
17689
17690 \family typewriter
17691 _nakedInterrupt:
17692 \newline
17693 \InsetSpace ~
17694 \InsetSpace ~
17695 \InsetSpace ~
17696 \InsetSpace ~
17697 inc\InsetSpace ~
17698 \InsetSpace ~
17699 \InsetSpace ~
17700 \InsetSpace ~
17701 _counter ; does not change flags, no need to save psw
17702 \newline
17703 \InsetSpace ~
17704 \InsetSpace ~
17705 \InsetSpace ~
17706 \InsetSpace ~
17707 reti\InsetSpace ~
17708 \InsetSpace ~
17709 \InsetSpace ~
17710 \InsetSpace ~
17711 \InsetSpace ~
17712 \InsetSpace ~
17713 \InsetSpace ~
17714 \InsetSpace ~
17715 \InsetSpace ~
17716 \InsetSpace ~
17717 \InsetSpace ~
17718 \InsetSpace ~
17719 ;
17720  MUST explicitly include ret or reti in _naked function
17721 \end_layout
17722
17723 \begin_layout Standard
17724 The related directive #pragma exclude
17725 \begin_inset LatexCommand \index{\#pragma exclude}
17726
17727 \end_inset
17728
17729  allows a more fine grained control over pushing & popping
17730 \begin_inset LatexCommand \index{push/pop}
17731
17732 \end_inset
17733
17734  the registers.
17735 \end_layout
17736
17737 \begin_layout Standard
17738 While there is nothing preventing you from writing C code inside a 
17739 \family typewriter
17740 _naked
17741 \family default
17742  function, there are many ways to shoot yourself in the foot doing this,
17743  and it is recommended that you stick to inline assembler.
17744 \end_layout
17745
17746 \begin_layout Subsection
17747 Use of Labels within Inline Assembler
17748 \end_layout
17749
17750 \begin_layout Standard
17751 SDCC allows the use of in-line assembler with a few restrictions regarding
17752  labels.
17753  All labels defined within inline assembler code have to be of the form
17754  
17755 \emph on
17756 nnnnn$
17757 \emph default
17758  where nnnnn is a number less than 100 (which implies a limit of utmost
17759  100 inline assembler labels 
17760 \emph on
17761 per function
17762 \emph default
17763 \noun on
17764 )
17765 \noun default
17766 .
17767 \begin_inset Foot
17768 status open
17769
17770 \begin_layout Standard
17771 This is a slightly more stringent rule than absolutely necessary, but stays
17772  always on the safe side.
17773  Labels in the form of nnnnn$ are local labels in the assembler, locality
17774  of which is confined within two labels of the standard form.
17775  The compiler uses the same form for labels within a function (but starting
17776  from nnnnn=00100); and places always a standard label at the beginning
17777  of a function, thus limiting the locality of labels within the scope of
17778  the function.
17779  So, if the inline assembler part would be embedded into C-code, an improperly
17780  placed non-local label in the assembler would break up the reference space
17781  for labels created by the compiler for the C-code, leading to an assembling
17782  error.
17783 \end_layout
17784
17785 \begin_layout Standard
17786 The numeric part of local labels does not need to have 5 digits (although
17787  this is the form of labels output by the compiler), any valid integer will
17788  do.
17789  Please refer to the assemblers documentation for further details.
17790 \end_layout
17791
17792 \end_inset
17793
17794  
17795 \end_layout
17796
17797 \begin_layout Verse
17798
17799 \family typewriter
17800 _asm
17801 \begin_inset LatexCommand \index{\_asm}
17802
17803 \end_inset
17804
17805
17806 \begin_inset LatexCommand \index{\_\_asm}
17807
17808 \end_inset
17809
17810  
17811 \newline
17812 \InsetSpace ~
17813 \InsetSpace ~
17814 \InsetSpace ~
17815 \InsetSpace ~
17816 mov\InsetSpace ~
17817 \InsetSpace ~
17818 \InsetSpace ~
17819 \InsetSpace ~
17820 \InsetSpace ~
17821 b,#10 
17822 \newline
17823 00001$: 
17824 \newline
17825 \InsetSpace ~
17826 \InsetSpace ~
17827 \InsetSpace ~
17828 \InsetSpace ~
17829 djnz\InsetSpace ~
17830 \InsetSpace ~
17831 \InsetSpace ~
17832 \InsetSpace ~
17833 b,00001$ 
17834 \newline
17835 _endasm
17836 \begin_inset LatexCommand \index{\_endasm}
17837
17838 \end_inset
17839
17840
17841 \begin_inset LatexCommand \index{\_\_endasm}
17842
17843 \end_inset
17844
17845  ;
17846 \end_layout
17847
17848 \begin_layout Standard
17849 Inline assembler code cannot reference any C-labels, however it can reference
17850  labels
17851 \begin_inset LatexCommand \index{Labels}
17852
17853 \end_inset
17854
17855  defined by the inline assembler, e.g.:
17856 \end_layout
17857
17858 \begin_layout Verse
17859
17860 \family typewriter
17861 foo() { 
17862 \newline
17863 \InsetSpace ~
17864 \InsetSpace ~
17865 \InsetSpace ~
17866 \InsetSpace ~
17867 /* some c code */ 
17868 \newline
17869 \InsetSpace ~
17870 \InsetSpace ~
17871 \InsetSpace ~
17872 \InsetSpace ~
17873 _asm 
17874 \newline
17875 \InsetSpace ~
17876 \InsetSpace ~
17877 \InsetSpace ~
17878 \InsetSpace ~
17879 \InsetSpace ~
17880 \InsetSpace ~
17881 ; some assembler code 
17882 \newline
17883 \InsetSpace ~
17884 \InsetSpace ~
17885 \InsetSpace ~
17886 \InsetSpace ~
17887 \InsetSpace ~
17888 \InsetSpace ~
17889 ljmp 0003$ 
17890 \newline
17891 \InsetSpace ~
17892 \InsetSpace ~
17893 \InsetSpace ~
17894 \InsetSpace ~
17895 _endasm;
17896  
17897 \newline
17898 \InsetSpace ~
17899 \InsetSpace ~
17900 \InsetSpace ~
17901 \InsetSpace ~
17902 /* some more c code */ 
17903 \newline
17904 clabel:\InsetSpace ~
17905 \InsetSpace ~
17906 /* inline assembler cannot reference this
17907  label */ 
17908 \begin_inset Foot
17909 status open
17910
17911 \begin_layout Standard
17912 Here, the C-label 
17913 \family typewriter
17914 clabel
17915 \family default
17916  is translated by the compiler into a local label, so the locality of labels
17917  within the function is not broken.
17918 \end_layout
17919
17920 \end_inset
17921
17922
17923 \newline
17924 \InsetSpace ~
17925 \InsetSpace ~
17926 \InsetSpace ~
17927 \InsetSpace ~
17928 _asm
17929 \newline
17930 \InsetSpace ~
17931 \InsetSpace ~
17932 \InsetSpace ~
17933 \InsetSpace ~
17934 0003$: ;label (can be referenced by inline assembler only) 
17935 \newline
17936 \InsetSpace ~
17937 \InsetSpace ~
17938 \InsetSpace ~
17939 \InsetSpace ~
17940 _endasm
17941 \begin_inset LatexCommand \index{\_endasm}
17942
17943 \end_inset
17944
17945
17946 \begin_inset LatexCommand \index{\_\_endasm}
17947
17948 \end_inset
17949
17950  ; 
17951 \newline
17952 \InsetSpace ~
17953 \InsetSpace ~
17954 \InsetSpace ~
17955 \InsetSpace ~
17956 /* some more c code */
17957 \newline
17958 }
17959 \end_layout
17960
17961 \begin_layout Standard
17962 In other words inline assembly code can access labels defined in inline
17963  assembly within the scope of the function.
17964  The same goes the other way, i.e.
17965  labels defines in inline assembly can not be accessed by C statements.
17966 \end_layout
17967
17968 \begin_layout Section
17969 Interfacing with Assembler Code
17970 \begin_inset LatexCommand \index{Assembler routines}
17971
17972 \end_inset
17973
17974
17975 \end_layout
17976
17977 \begin_layout Subsection
17978 Global Registers used for Parameter Passing
17979 \begin_inset LatexCommand \index{Parameter passing}
17980
17981 \end_inset
17982
17983
17984 \end_layout
17985
17986 \begin_layout Standard
17987 The compiler always uses the global registers 
17988 \emph on
17989 DPL, DPH
17990 \begin_inset LatexCommand \index{DPTR, DPH, DPL}
17991
17992 \end_inset
17993
17994
17995 \begin_inset LatexCommand \index{DPTR}
17996
17997 \end_inset
17998
17999 , B
18000 \begin_inset LatexCommand \index{B (mcs51, ds390 register)}
18001
18002 \end_inset
18003
18004  
18005 \emph default
18006 and
18007 \emph on
18008  ACC
18009 \begin_inset LatexCommand \index{ACC (mcs51, ds390 register)}
18010
18011 \end_inset
18012
18013
18014 \emph default
18015  to pass the first (non-bit) parameter to a function, and also to pass the
18016  return value 
18017 \begin_inset LatexCommand \index{return value}
18018
18019 \end_inset
18020
18021 of function; according to the following scheme: one byte return value in
18022  
18023 \emph on
18024 DPL
18025 \emph default
18026 , two byte value in 
18027 \emph on
18028 DPL
18029 \emph default
18030  (LSB) and 
18031 \emph on
18032 DPH
18033 \emph default
18034  (MSB).
18035  three byte values (generic pointers) in 
18036 \emph on
18037 DPH
18038 \emph default
18039
18040 \emph on
18041 DPL
18042 \emph default
18043  and 
18044 \emph on
18045 B
18046 \emph default
18047 , and four byte values in 
18048 \emph on
18049 DPH
18050 \emph default
18051
18052 \emph on
18053 DPL
18054 \emph default
18055 ,
18056 \emph on
18057  B
18058 \emph default
18059  and 
18060 \emph on
18061 ACC
18062 \emph default
18063 .
18064  Generic pointers
18065 \begin_inset LatexCommand \index{generic pointer}
18066
18067 \end_inset
18068
18069  contain type of accessed memory in 
18070 \emph on
18071 B
18072 \emph default
18073
18074 \series bold
18075 0x00
18076 \series default
18077  -- xdata/far, 
18078 \series bold
18079 0x40
18080 \series default
18081  -- idata/near -- , 
18082 \series bold
18083 0x60
18084 \series default
18085  -- pdata, 
18086 \series bold
18087 0x80
18088 \series default
18089  -- code
18090 \begin_inset Note Note
18091 status collapsed
18092
18093 \begin_layout Standard
18094 This might not be the case of certain memory models (medium???)
18095 \end_layout
18096
18097 \end_inset
18098
18099 .
18100 \end_layout
18101
18102 \begin_layout Standard
18103 The second parameter onwards is either allocated on the stack (for reentrant
18104  routines or if -
18105 \begin_inset ERT
18106 status collapsed
18107
18108 \begin_layout Standard
18109
18110
18111 \backslash
18112 /
18113 \end_layout
18114
18115 \end_inset
18116
18117 -stack-auto is used) or in data/xdata memory (depending on the memory model).
18118 \end_layout
18119
18120 \begin_layout Standard
18121 Bit parameters are passed in a virtual register called 'bits' in bit-addressable
18122  space for reentrant functions or allocated directly in bit memory otherwise.
18123 \end_layout
18124
18125 \begin_layout Standard
18126 Functions (with two or more parameters or bit parameters) that are called
18127  through function pointers
18128 \begin_inset LatexCommand \index{function pointers}
18129
18130 \end_inset
18131
18132  must therefor be reentrant so the compiler knows how to pass the parameters.
18133 \end_layout
18134
18135 \begin_layout Subsection
18136 Registers usage
18137 \end_layout
18138
18139 \begin_layout Standard
18140 Unless the called function is declared as 
18141 \family typewriter
18142 _naked
18143 \family default
18144
18145 \begin_inset LatexCommand \index{naked}
18146
18147 \end_inset
18148
18149 , or the -
18150 \begin_inset ERT
18151 status collapsed
18152
18153 \begin_layout Standard
18154
18155
18156 \backslash
18157 /
18158 \end_layout
18159
18160 \end_inset
18161
18162 -callee-saves
18163 \begin_inset LatexCommand \index{-\/-callee-saves}
18164
18165 \end_inset
18166
18167 /-
18168 \begin_inset ERT
18169 status collapsed
18170
18171 \begin_layout Standard
18172
18173
18174 \backslash
18175 /
18176 \end_layout
18177
18178 \end_inset
18179
18180 -all-callee-saves command line option or the corresponding callee_saves
18181  pragma are used, the caller will save the registers (
18182 \emph on
18183 R0-R7
18184 \emph default
18185 ) around the call, so the called function can destroy they content freely.
18186 \end_layout
18187
18188 \begin_layout Standard
18189 If the called function is not declared as 
18190 \family typewriter
18191 _naked
18192 \family default
18193 , the caller will swap register banks around the call, if caller and callee
18194  use different register banks (having them defined by the 
18195 \family typewriter
18196 _using
18197 \family default
18198  modifier).
18199  
18200 \end_layout
18201
18202 \begin_layout Standard
18203 The called function can also use 
18204 \emph on
18205 DPL
18206 \emph default
18207
18208 \emph on
18209 DPH
18210 \emph default
18211
18212 \emph on
18213 B
18214 \emph default
18215  and 
18216 \emph on
18217 ACC
18218 \emph default
18219  observing that they are used for parameter/return value passing.
18220 \end_layout
18221
18222 \begin_layout Subsection
18223 Assembler Routine (non-reentrant)
18224 \end_layout
18225
18226 \begin_layout Standard
18227 In the following example
18228 \begin_inset LatexCommand \index{reentrant}
18229
18230 \end_inset
18231
18232
18233 \begin_inset LatexCommand \index{Assembler routines (non-reentrant)}
18234
18235 \end_inset
18236
18237  the function c_func calls an assembler routine asm_func, which takes two
18238  parameters
18239 \begin_inset LatexCommand \index{function parameter}
18240
18241 \end_inset
18242
18243 .
18244 \end_layout
18245
18246 \begin_layout Verse
18247
18248 \family typewriter
18249 extern int asm_func(unsigned char, unsigned char);
18250 \newline
18251
18252 \newline
18253 int c_func (unsigned char
18254  i, unsigned char j)
18255 \newline
18256 {
18257 \newline
18258 \InsetSpace ~
18259 \InsetSpace ~
18260 \InsetSpace ~
18261 \InsetSpace ~
18262 return asm_func(i,j);
18263 \newline
18264 }
18265 \newline
18266
18267 \newline
18268 int main()
18269 \newline
18270 {
18271 \newline
18272 \InsetSpace ~
18273 \InsetSpace ~
18274 \InsetSpace ~
18275 \InsetSpace ~
18276 return c_func(10,9);
18277 \newline
18278 }
18279 \end_layout
18280
18281 \begin_layout Standard
18282 The corresponding assembler function is:
18283 \end_layout
18284
18285 \begin_layout Verse
18286
18287 \family typewriter
18288 .globl _asm_func_PARM_2 
18289 \newline
18290 \InsetSpace ~
18291 \InsetSpace ~
18292 \InsetSpace ~
18293 \InsetSpace ~
18294 \InsetSpace ~
18295 \InsetSpace ~
18296 \InsetSpace ~
18297 \InsetSpace ~
18298 .globl _asm_func 
18299 \newline
18300 \InsetSpace ~
18301 \InsetSpace ~
18302 \InsetSpace ~
18303 \InsetSpace ~
18304 \InsetSpace ~
18305 \InsetSpace ~
18306 \InsetSpace ~
18307 \InsetSpace ~
18308 .area OSEG 
18309 \newline
18310 _asm_func_PARM_2:
18311 \newline
18312 \InsetSpace ~
18313 \InsetSpace ~
18314 \InsetSpace ~
18315 \InsetSpace ~
18316 \InsetSpace ~
18317 \InsetSpace ~
18318 \InsetSpace ~
18319 \InsetSpace ~
18320 .ds   
18321  1 
18322 \newline
18323 \InsetSpace ~
18324 \InsetSpace ~
18325 \InsetSpace ~
18326 \InsetSpace ~
18327 \InsetSpace ~
18328 \InsetSpace ~
18329 \InsetSpace ~
18330 \InsetSpace ~
18331 .area CSEG 
18332 \newline
18333 _asm_func: 
18334 \newline
18335 \InsetSpace ~
18336 \InsetSpace ~
18337 \InsetSpace ~
18338 \InsetSpace ~
18339 \InsetSpace ~
18340 \InsetSpace ~
18341 \InsetSpace ~
18342 \InsetSpace ~
18343 mov\InsetSpace ~
18344 \InsetSpace ~
18345 \InsetSpace ~
18346 \InsetSpace ~
18347 a,dpl 
18348 \newline
18349 \InsetSpace ~
18350 \InsetSpace ~
18351 \InsetSpace ~
18352 \InsetSpace ~
18353 \InsetSpace ~
18354 \InsetSpace ~
18355 \InsetSpace ~
18356 \InsetSpace ~
18357 add\InsetSpace ~
18358 \InsetSpace ~
18359 \InsetSpace ~
18360 \InsetSpace ~
18361 a,_asm_func_PARM_2 
18362 \newline
18363 \InsetSpace ~
18364 \InsetSpace ~
18365 \InsetSpace ~
18366 \InsetSpace ~
18367 \InsetSpace ~
18368 \InsetSpace ~
18369 \InsetSpace ~
18370 \InsetSpace ~
18371 mov\InsetSpace ~
18372 \InsetSpace ~
18373 \InsetSpace ~
18374 \InsetSpace ~
18375 dpl,a 
18376 \newline
18377 \InsetSpace ~
18378 \InsetSpace ~
18379 \InsetSpace ~
18380 \InsetSpace ~
18381 \InsetSpace ~
18382 \InsetSpace ~
18383 \InsetSpace ~
18384 \InsetSpace ~
18385 mov\InsetSpace ~
18386 \InsetSpace ~
18387 \InsetSpace ~
18388 \InsetSpace ~
18389 dph
18390 \begin_inset LatexCommand \index{DPTR, DPH, DPL}
18391
18392 \end_inset
18393
18394 ,#0x00 
18395 \newline
18396 \InsetSpace ~
18397 \InsetSpace ~
18398 \InsetSpace ~
18399 \InsetSpace ~
18400 \InsetSpace ~
18401 \InsetSpace ~
18402 \InsetSpace ~
18403 \InsetSpace ~
18404 ret
18405 \end_layout
18406
18407 \begin_layout Standard
18408 The parameter naming convention is _<function_name>_PARM_<n>, where n is
18409  the parameter number starting from 1, and counting from the left.
18410  The first parameter is passed in 
18411 \emph on
18412 DPH
18413 \emph default
18414
18415 \emph on
18416 DPL
18417 \emph default
18418
18419 \emph on
18420 B
18421 \emph default
18422  and 
18423 \emph on
18424 ACC
18425 \emph default
18426  according to the description above.
18427  The variable name for the second parameter will be _<function_name>_PARM_2.
18428 \newline
18429
18430 \newline
18431 Assem
18432 ble the assembler routine with the following command:
18433 \newline
18434
18435 \newline
18436
18437 \family sans
18438 \series bold
18439 asx8051 -losg asmfunc.asm
18440 \newline
18441
18442 \newline
18443
18444 \family default
18445 \series default
18446 Then compile and link the assembler routine to the C source file with the
18447  following command:
18448 \newline
18449
18450 \newline
18451
18452 \family sans
18453 \series bold
18454 sdcc cfunc.c asmfunc.rel
18455 \end_layout
18456
18457 \begin_layout Subsection
18458 Assembler Routine (reentrant)
18459 \end_layout
18460
18461 \begin_layout Standard
18462 In this case
18463 \begin_inset LatexCommand \index{reentrant}
18464
18465 \end_inset
18466
18467
18468 \begin_inset LatexCommand \index{Assembler routines (reentrant)}
18469
18470 \end_inset
18471
18472  the second parameter
18473 \begin_inset LatexCommand \index{function parameter}
18474
18475 \end_inset
18476
18477  onwards will be passed on the stack, the parameters are pushed from right
18478  to left i.e.
18479  before the call the second leftmost parameter will be on the top of the
18480  stack (the leftmost parameter is passed in registers).
18481  Here is an example:
18482 \end_layout
18483
18484 \begin_layout Verse
18485
18486 \family typewriter
18487 extern int asm_func(unsigned char, unsigned char, unsigned char) reentrant;
18488 \newline
18489
18490 \newline
18491 int
18492  c_func (unsigned char i, unsigned char j, unsigned char k) reentrant 
18493 \newline
18494 {
18495  
18496 \newline
18497 \InsetSpace ~
18498 \InsetSpace ~
18499 \InsetSpace ~
18500 \InsetSpace ~
18501 return asm_func(i,j,k); 
18502 \newline
18503
18504 \newline
18505
18506 \newline
18507 int main() 
18508 \newline
18509
18510 \newline
18511 \InsetSpace ~
18512 \InsetSpace ~
18513 \InsetSpace ~
18514 \InsetSpace ~
18515 return c_func(10,9,8); 
18516 \newline
18517 }
18518 \end_layout
18519
18520 \begin_layout Standard
18521 The corresponding (unoptimized) assembler routine is:
18522 \end_layout
18523
18524 \begin_layout Verse
18525
18526 \family typewriter
18527 .globl _asm_func 
18528 \newline
18529 _asm_func: 
18530 \newline
18531 \InsetSpace ~
18532 \InsetSpace ~
18533 \InsetSpace ~
18534 \InsetSpace ~
18535 push\InsetSpace ~
18536 _bp 
18537 \newline
18538 \InsetSpace ~
18539 \InsetSpace ~
18540 \InsetSpace ~
18541 \InsetSpace ~
18542 mov\InsetSpace ~
18543 \InsetSpace ~
18544 _bp,sp\InsetSpace ~
18545 \InsetSpace ~
18546 \InsetSpace ~
18547 \InsetSpace ~
18548 \InsetSpace ~
18549 \InsetSpace ~
18550 ;stack contains: _bp, return
18551  address, second parameter, third parameter
18552 \newline
18553 \InsetSpace ~
18554 \InsetSpace ~
18555 \InsetSpace ~
18556 \InsetSpace ~
18557 mov\InsetSpace ~
18558 \InsetSpace ~
18559 r2,dpl
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,#0xfd\InsetSpace ~
18576 \InsetSpace ~
18577 \InsetSpace ~
18578 \InsetSpace ~
18579 \InsetSpace ~
18580 ;calculate
18581  pointer to the second parameter
18582 \newline
18583 \InsetSpace ~
18584 \InsetSpace ~
18585 \InsetSpace ~
18586 \InsetSpace ~
18587 mov\InsetSpace ~
18588 \InsetSpace ~
18589 r0,a 
18590 \newline
18591 \InsetSpace ~
18592 \InsetSpace ~
18593 \InsetSpace ~
18594 \InsetSpace ~
18595 mov\InsetSpace ~
18596 \InsetSpace ~
18597 a,_bp 
18598 \newline
18599 \InsetSpace ~
18600 \InsetSpace ~
18601 \InsetSpace ~
18602 \InsetSpace ~
18603 add\InsetSpace ~
18604 \InsetSpace ~
18605 a,#0xfc\InsetSpace ~
18606 \InsetSpace ~
18607 \InsetSpace ~
18608 \InsetSpace ~
18609 \InsetSpace ~
18610 ;calculate pointer
18611  to the rightmost parameter
18612 \newline
18613 \InsetSpace ~
18614 \InsetSpace ~
18615 \InsetSpace ~
18616 \InsetSpace ~
18617 mov\InsetSpace ~
18618 \InsetSpace ~
18619 r1,a 
18620 \newline
18621 \InsetSpace ~
18622 \InsetSpace ~
18623 \InsetSpace ~
18624 \InsetSpace ~
18625 mov\InsetSpace ~
18626 \InsetSpace ~
18627 a,@r0
18628 \newline
18629 \InsetSpace ~
18630 \InsetSpace ~
18631 \InsetSpace ~
18632 \InsetSpace ~
18633 add\InsetSpace ~
18634 \InsetSpace ~
18635 a,@r1
18636 \newline
18637 \InsetSpace ~
18638 \InsetSpace ~
18639 \InsetSpace ~
18640 \InsetSpace ~
18641 add\InsetSpace ~
18642 \InsetSpace ~
18643 a,r2\InsetSpace ~
18644 \InsetSpace ~
18645 \InsetSpace ~
18646 \InsetSpace ~
18647 \InsetSpace ~
18648 \InsetSpace ~
18649 \InsetSpace ~
18650 \InsetSpace ~
18651 ;calculate the
18652  result (= sum of all three parameters)
18653 \newline
18654 \InsetSpace ~
18655 \InsetSpace ~
18656 \InsetSpace ~
18657 \InsetSpace ~
18658 mov\InsetSpace ~
18659 \InsetSpace ~
18660 dpl,a\InsetSpace ~
18661 \InsetSpace ~
18662 \InsetSpace ~
18663 \InsetSpace ~
18664 \InsetSpace ~
18665 \InsetSpace ~
18666 \InsetSpace ~
18667 ;return value goes into dptr
18668  (cast into int)
18669 \newline
18670 \InsetSpace ~
18671 \InsetSpace ~
18672 \InsetSpace ~
18673 \InsetSpace ~
18674 mov\InsetSpace ~
18675 \InsetSpace ~
18676 dph,#0x00 
18677 \newline
18678 \InsetSpace ~
18679 \InsetSpace ~
18680 \InsetSpace ~
18681 \InsetSpace ~
18682 mov\InsetSpace ~
18683 \InsetSpace ~
18684 sp,_bp 
18685 \newline
18686 \InsetSpace ~
18687 \InsetSpace ~
18688 \InsetSpace ~
18689 \InsetSpace ~
18690 pop\InsetSpace ~
18691 \InsetSpace ~
18692 _bp 
18693 \newline
18694 \InsetSpace ~
18695 \InsetSpace ~
18696 \InsetSpace ~
18697 \InsetSpace ~
18698 ret
18699 \end_layout
18700
18701 \begin_layout Standard
18702 The compiling and linking procedure remains the same, however note the extra
18703  entry & exit linkage required for the assembler code, _bp is the stack
18704  frame pointer and is used to compute the offset into the stack for parameters
18705  and local variables.
18706 \begin_inset VSpace bigskip
18707 \end_inset
18708
18709
18710 \end_layout
18711
18712 \begin_layout Section
18713 int (16 bit)
18714 \begin_inset LatexCommand \index{int (16 bit)}
18715
18716 \end_inset
18717
18718  and long (32 bit)
18719 \begin_inset LatexCommand \index{long (32 bit)}
18720
18721 \end_inset
18722
18723  Support
18724 \end_layout
18725
18726 \begin_layout Standard
18727 For signed & unsigned int (16 bit) and long (32 bit) variables, division,
18728  multiplication and modulus operations are implemented by support routines.
18729  These support routines are all developed in ANSI-C to facilitate porting
18730  to other MCUs, although some model specific assembler optimizations are
18731  used.
18732  The following files contain the described routines, all of them can be
18733  found in <installdir>/share/sdcc/lib.
18734 \newline
18735
18736 \end_layout
18737
18738 \begin_layout Standard
18739 \align center
18740 \begin_inset Tabular
18741 <lyxtabular version="3" rows="11" columns="2">
18742 <features>
18743 <column alignment="left" valignment="top" leftline="true" width="0">
18744 <column alignment="left" valignment="top" leftline="true" rightline="true" width="0">
18745 <row topline="true" bottomline="true">
18746 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
18747 \begin_inset Text
18748
18749 \begin_layout Standard
18750
18751 \series bold
18752 Function
18753 \end_layout
18754
18755 \end_inset
18756 </cell>
18757 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
18758 \begin_inset Text
18759
18760 \begin_layout Standard
18761
18762 \series bold
18763 Description
18764 \end_layout
18765
18766 \end_inset
18767 </cell>
18768 </row>
18769 <row topline="true">
18770 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
18771 \begin_inset Text
18772
18773 \begin_layout Standard
18774 _mulint.c 
18775 \end_layout
18776
18777 \end_inset
18778 </cell>
18779 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
18780 \begin_inset Text
18781
18782 \begin_layout Standard
18783 16 bit multiplication
18784 \end_layout
18785
18786 \end_inset
18787 </cell>
18788 </row>
18789 <row topline="true">
18790 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
18791 \begin_inset Text
18792
18793 \begin_layout Standard
18794 _divsint.c 
18795 \end_layout
18796
18797 \end_inset
18798 </cell>
18799 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
18800 \begin_inset Text
18801
18802 \begin_layout Standard
18803  signed 16 bit division (calls _divuint)
18804 \end_layout
18805
18806 \end_inset
18807 </cell>
18808 </row>
18809 <row topline="true">
18810 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
18811 \begin_inset Text
18812
18813 \begin_layout Standard
18814 _divuint.c 
18815 \end_layout
18816
18817 \end_inset
18818 </cell>
18819 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
18820 \begin_inset Text
18821
18822 \begin_layout Standard
18823  unsigned 16 bit division
18824 \end_layout
18825
18826 \end_inset
18827 </cell>
18828 </row>
18829 <row topline="true">
18830 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
18831 \begin_inset Text
18832
18833 \begin_layout Standard
18834 _modsint.c
18835 \end_layout
18836
18837 \end_inset
18838 </cell>
18839 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
18840 \begin_inset Text
18841
18842 \begin_layout Standard
18843 signed 16 bit modulus (calls _moduint)
18844 \end_layout
18845
18846 \end_inset
18847 </cell>
18848 </row>
18849 <row topline="true">
18850 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
18851 \begin_inset Text
18852
18853 \begin_layout Standard
18854 _moduint.c
18855 \end_layout
18856
18857 \end_inset
18858 </cell>
18859 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
18860 \begin_inset Text
18861
18862 \begin_layout Standard
18863 unsigned 16 bit modulus
18864 \end_layout
18865
18866 \end_inset
18867 </cell>
18868 </row>
18869 <row topline="true">
18870 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
18871 \begin_inset Text
18872
18873 \begin_layout Standard
18874 _mullong.c
18875 \end_layout
18876
18877 \end_inset
18878 </cell>
18879 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
18880 \begin_inset Text
18881
18882 \begin_layout Standard
18883 32 bit multiplication
18884 \end_layout
18885
18886 \end_inset
18887 </cell>
18888 </row>
18889 <row topline="true">
18890 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
18891 \begin_inset Text
18892
18893 \begin_layout Standard
18894 _divslong.c 
18895 \end_layout
18896
18897 \end_inset
18898 </cell>
18899 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
18900 \begin_inset Text
18901
18902 \begin_layout Standard
18903  signed 32 division (calls _divulong)
18904 \end_layout
18905
18906 \end_inset
18907 </cell>
18908 </row>
18909 <row topline="true">
18910 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
18911 \begin_inset Text
18912
18913 \begin_layout Standard
18914 _divulong.c 
18915 \end_layout
18916
18917 \end_inset
18918 </cell>
18919 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
18920 \begin_inset Text
18921
18922 \begin_layout Standard
18923 unsigned 32 division
18924 \end_layout
18925
18926 \end_inset
18927 </cell>
18928 </row>
18929 <row topline="true">
18930 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
18931 \begin_inset Text
18932
18933 \begin_layout Standard
18934 _modslong.c
18935 \end_layout
18936
18937 \end_inset
18938 </cell>
18939 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
18940 \begin_inset Text
18941
18942 \begin_layout Standard
18943  signed 32 bit modulus (calls _modulong)
18944 \end_layout
18945
18946 \end_inset
18947 </cell>
18948 </row>
18949 <row topline="true" bottomline="true">
18950 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
18951 \begin_inset Text
18952
18953 \begin_layout Standard
18954 _modulong.c
18955 \end_layout
18956
18957 \end_inset
18958 </cell>
18959 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
18960 \begin_inset Text
18961
18962 \begin_layout Standard
18963 unsigned 32 bit modulus
18964 \end_layout
18965
18966 \end_inset
18967 </cell>
18968 </row>
18969 </lyxtabular>
18970
18971 \end_inset
18972
18973
18974 \newline
18975
18976 \end_layout
18977
18978 \begin_layout Standard
18979 Since they are compiled as 
18980 \emph on
18981 non-reentrant
18982 \emph default
18983
18984 \begin_inset LatexCommand \index{reentrant}
18985
18986 \end_inset
18987
18988 , interrupt
18989 \begin_inset LatexCommand \index{interrupt}
18990
18991 \end_inset
18992
18993  service routines should not do any of the above operations.
18994  If this is unavoidable then the above routines will need to be compiled
18995  with the 
18996 \emph on
18997 -
18998 \begin_inset ERT
18999 status collapsed
19000
19001 \begin_layout Standard
19002
19003
19004 \backslash
19005 /
19006 \end_layout
19007
19008 \end_inset
19009
19010 -stack-auto
19011 \begin_inset LatexCommand \index{-\/-stack-auto}
19012
19013 \end_inset
19014
19015
19016 \emph default
19017  option, after which the source program will have to be compiled with 
19018 \emph on
19019 -
19020 \begin_inset ERT
19021 status collapsed
19022
19023 \begin_layout Standard
19024
19025
19026 \backslash
19027 /
19028 \end_layout
19029
19030 \end_inset
19031
19032 -int-long-reent
19033 \begin_inset LatexCommand \index{-\/-int-long-reent}
19034
19035 \end_inset
19036
19037
19038 \emph default
19039  option.
19040  Notice that you don't have to call these routines directly.
19041  The compiler will use them automatically every time an integer operation
19042  is required.
19043 \end_layout
19044
19045 \begin_layout Section
19046 Floating Point Support
19047 \begin_inset LatexCommand \index{Floating point support}
19048
19049 \end_inset
19050
19051
19052 \end_layout
19053
19054 \begin_layout Standard
19055 SDCC supports IEEE (single precision 4 bytes) floating point numbers.
19056  The floating point support routines are derived from gcc's floatlib.c and
19057  consist of the following routines:
19058 \newline
19059
19060 \end_layout
19061
19062 \begin_layout Standard
19063 \align center
19064
19065 \size footnotesize
19066 \begin_inset Tabular
19067 <lyxtabular version="3" rows="17" columns="2">
19068 <features>
19069 <column alignment="left" valignment="top" leftline="true" width="0">
19070 <column alignment="left" valignment="top" leftline="true" rightline="true" width="0">
19071 <row topline="true" bottomline="true">
19072 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19073 \begin_inset Text
19074
19075 \begin_layout Standard
19076
19077 \family roman
19078 \series medium
19079 \shape up
19080 \size normal
19081 \emph off
19082 \bar no
19083 \noun off
19084 \color none
19085 Function 
19086 \end_layout
19087
19088 \end_inset
19089 </cell>
19090 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19091 \begin_inset Text
19092
19093 \begin_layout Standard
19094 Description
19095 \end_layout
19096
19097 \end_inset
19098 </cell>
19099 </row>
19100 <row topline="true">
19101 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19102 \begin_inset Text
19103
19104 \begin_layout Standard
19105
19106 \family roman
19107 \series medium
19108 \shape up
19109 \size normal
19110 \emph off
19111 \bar no
19112 \noun off
19113 \color none
19114 _fsadd.c
19115 \end_layout
19116
19117 \end_inset
19118 </cell>
19119 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19120 \begin_inset Text
19121
19122 \begin_layout Standard
19123
19124 \family roman
19125 \series medium
19126 \shape up
19127 \size normal
19128 \emph off
19129 \bar no
19130 \noun off
19131 \color none
19132 add floating point numbers
19133 \end_layout
19134
19135 \end_inset
19136 </cell>
19137 </row>
19138 <row topline="true">
19139 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19140 \begin_inset Text
19141
19142 \begin_layout Standard
19143
19144 \family roman
19145 \series medium
19146 \shape up
19147 \size normal
19148 \emph off
19149 \bar no
19150 \noun off
19151 \color none
19152 _fssub.c 
19153 \end_layout
19154
19155 \end_inset
19156 </cell>
19157 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19158 \begin_inset Text
19159
19160 \begin_layout Standard
19161
19162 \family roman
19163 \series medium
19164 \shape up
19165 \size normal
19166 \emph off
19167 \bar no
19168 \noun off
19169 \color none
19170 subtract floating point numbers 
19171 \end_layout
19172
19173 \end_inset
19174 </cell>
19175 </row>
19176 <row topline="true">
19177 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19178 \begin_inset Text
19179
19180 \begin_layout Standard
19181
19182 \family roman
19183 \series medium
19184 \shape up
19185 \size normal
19186 \emph off
19187 \bar no
19188 \noun off
19189 \color none
19190 _fsdiv.c 
19191 \end_layout
19192
19193 \end_inset
19194 </cell>
19195 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19196 \begin_inset Text
19197
19198 \begin_layout Standard
19199
19200 \family roman
19201 \series medium
19202 \shape up
19203 \size normal
19204 \emph off
19205 \bar no
19206 \noun off
19207 \color none
19208 divide floating point numbers 
19209 \end_layout
19210
19211 \end_inset
19212 </cell>
19213 </row>
19214 <row topline="true">
19215 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19216 \begin_inset Text
19217
19218 \begin_layout Standard
19219
19220 \family roman
19221 \series medium
19222 \shape up
19223 \size normal
19224 \emph off
19225 \bar no
19226 \noun off
19227 \color none
19228 _fsmul.c 
19229 \end_layout
19230
19231 \end_inset
19232 </cell>
19233 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19234 \begin_inset Text
19235
19236 \begin_layout Standard
19237
19238 \family roman
19239 \series medium
19240 \shape up
19241 \size normal
19242 \emph off
19243 \bar no
19244 \noun off
19245 \color none
19246 multiply floating point numbers 
19247 \end_layout
19248
19249 \end_inset
19250 </cell>
19251 </row>
19252 <row topline="true">
19253 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19254 \begin_inset Text
19255
19256 \begin_layout Standard
19257
19258 \family roman
19259 \series medium
19260 \shape up
19261 \size normal
19262 \emph off
19263 \bar no
19264 \noun off
19265 \color none
19266 _fs2uchar.c
19267 \end_layout
19268
19269 \end_inset
19270 </cell>
19271 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19272 \begin_inset Text
19273
19274 \begin_layout Standard
19275
19276 \family roman
19277 \series medium
19278 \shape up
19279 \size normal
19280 \emph off
19281 \bar no
19282 \noun off
19283 \color none
19284 convert floating point to unsigned char
19285 \end_layout
19286
19287 \end_inset
19288 </cell>
19289 </row>
19290 <row topline="true">
19291 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19292 \begin_inset Text
19293
19294 \begin_layout Standard
19295
19296 \family roman
19297 \series medium
19298 \shape up
19299 \size normal
19300 \emph off
19301 \bar no
19302 \noun off
19303 \color none
19304 _fs2char.c
19305 \end_layout
19306
19307 \end_inset
19308 </cell>
19309 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19310 \begin_inset Text
19311
19312 \begin_layout Standard
19313
19314 \family roman
19315 \series medium
19316 \shape up
19317 \size normal
19318 \emph off
19319 \bar no
19320 \noun off
19321 \color none
19322 convert floating point to signed char
19323 \end_layout
19324
19325 \end_inset
19326 </cell>
19327 </row>
19328 <row topline="true">
19329 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19330 \begin_inset Text
19331
19332 \begin_layout Standard
19333
19334 \family roman
19335 \series medium
19336 \shape up
19337 \size normal
19338 \emph off
19339 \bar no
19340 \noun off
19341 \color none
19342 _fs2uint.c
19343 \end_layout
19344
19345 \end_inset
19346 </cell>
19347 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19348 \begin_inset Text
19349
19350 \begin_layout Standard
19351
19352 \family roman
19353 \series medium
19354 \shape up
19355 \size normal
19356 \emph off
19357 \bar no
19358 \noun off
19359 \color none
19360 convert floating point to unsigned int
19361 \end_layout
19362
19363 \end_inset
19364 </cell>
19365 </row>
19366 <row topline="true">
19367 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19368 \begin_inset Text
19369
19370 \begin_layout Standard
19371
19372 \family roman
19373 \series medium
19374 \shape up
19375 \size normal
19376 \emph off
19377 \bar no
19378 \noun off
19379 \color none
19380 _fs2int.c
19381 \end_layout
19382
19383 \end_inset
19384 </cell>
19385 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19386 \begin_inset Text
19387
19388 \begin_layout Standard
19389
19390 \family roman
19391 \series medium
19392 \shape up
19393 \size normal
19394 \emph off
19395 \bar no
19396 \noun off
19397 \color none
19398 convert floating point to signed int
19399 \end_layout
19400
19401 \end_inset
19402 </cell>
19403 </row>
19404 <row topline="true">
19405 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19406 \begin_inset Text
19407
19408 \begin_layout Standard
19409
19410 \family roman
19411 \series medium
19412 \shape up
19413 \size normal
19414 \emph off
19415 \bar no
19416 \noun off
19417 \color none
19418 _fs2ulong.
19419 \family default
19420 \series default
19421 \shape default
19422 \size default
19423 \emph default
19424 \bar default
19425 \noun default
19426 c
19427 \end_layout
19428
19429 \end_inset
19430 </cell>
19431 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19432 \begin_inset Text
19433
19434 \begin_layout Standard
19435
19436 \family roman
19437 \series medium
19438 \shape up
19439 \size normal
19440 \emph off
19441 \bar no
19442 \noun off
19443 \color none
19444 convert floating point to unsigned long
19445 \end_layout
19446
19447 \end_inset
19448 </cell>
19449 </row>
19450 <row topline="true">
19451 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19452 \begin_inset Text
19453
19454 \begin_layout Standard
19455
19456 \family roman
19457 \series medium
19458 \shape up
19459 \size normal
19460 \emph off
19461 \bar no
19462 \noun off
19463 \color none
19464 _fs2long.c
19465 \end_layout
19466
19467 \end_inset
19468 </cell>
19469 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19470 \begin_inset Text
19471
19472 \begin_layout Standard
19473
19474 \family roman
19475 \series medium
19476 \shape up
19477 \size normal
19478 \emph off
19479 \bar no
19480 \noun off
19481 \color none
19482 convert floating point to signed long
19483 \end_layout
19484
19485 \end_inset
19486 </cell>
19487 </row>
19488 <row topline="true">
19489 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19490 \begin_inset Text
19491
19492 \begin_layout Standard
19493
19494 \family roman
19495 \series medium
19496 \shape up
19497 \size normal
19498 \emph off
19499 \bar no
19500 \noun off
19501 \color none
19502 _uchar2fs.c
19503 \end_layout
19504
19505 \end_inset
19506 </cell>
19507 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19508 \begin_inset Text
19509
19510 \begin_layout Standard
19511
19512 \family roman
19513 \series medium
19514 \shape up
19515 \size normal
19516 \emph off
19517 \bar no
19518 \noun off
19519 \color none
19520 convert unsigned char to floating point
19521 \end_layout
19522
19523 \end_inset
19524 </cell>
19525 </row>
19526 <row topline="true">
19527 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19528 \begin_inset Text
19529
19530 \begin_layout Standard
19531
19532 \family roman
19533 \series medium
19534 \shape up
19535 \size normal
19536 \emph off
19537 \bar no
19538 \noun off
19539 \color none
19540 _char2fs.c
19541 \end_layout
19542
19543 \end_inset
19544 </cell>
19545 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19546 \begin_inset Text
19547
19548 \begin_layout Standard
19549
19550 \family roman
19551 \series medium
19552 \shape up
19553 \size normal
19554 \emph off
19555 \bar no
19556 \noun off
19557 \color none
19558 convert char to floating point number
19559 \end_layout
19560
19561 \end_inset
19562 </cell>
19563 </row>
19564 <row topline="true">
19565 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19566 \begin_inset Text
19567
19568 \begin_layout Standard
19569
19570 \family roman
19571 \series medium
19572 \shape up
19573 \size normal
19574 \emph off
19575 \bar no
19576 \noun off
19577 \color none
19578 _uint2fs.c
19579 \end_layout
19580
19581 \end_inset
19582 </cell>
19583 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19584 \begin_inset Text
19585
19586 \begin_layout Standard
19587
19588 \family roman
19589 \series medium
19590 \shape up
19591 \size normal
19592 \emph off
19593 \bar no
19594 \noun off
19595 \color none
19596 convert unsigned int to floating point
19597 \end_layout
19598
19599 \end_inset
19600 </cell>
19601 </row>
19602 <row topline="true">
19603 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19604 \begin_inset Text
19605
19606 \begin_layout Standard
19607
19608 \family roman
19609 \series medium
19610 \shape up
19611 \size normal
19612 \emph off
19613 \bar no
19614 \noun off
19615 \color none
19616 _int2fs.c
19617 \end_layout
19618
19619 \end_inset
19620 </cell>
19621 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19622 \begin_inset Text
19623
19624 \begin_layout Standard
19625
19626 \family roman
19627 \series medium
19628 \shape up
19629 \size normal
19630 \emph off
19631 \bar no
19632 \noun off
19633 \color none
19634 convert int to floating point numbers
19635 \end_layout
19636
19637 \end_inset
19638 </cell>
19639 </row>
19640 <row topline="true">
19641 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19642 \begin_inset Text
19643
19644 \begin_layout Standard
19645
19646 \family roman
19647 \series medium
19648 \shape up
19649 \size normal
19650 \emph off
19651 \bar no
19652 \noun off
19653 \color none
19654 _ulong2fs.c
19655 \end_layout
19656
19657 \end_inset
19658 </cell>
19659 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19660 \begin_inset Text
19661
19662 \begin_layout Standard
19663
19664 \family roman
19665 \series medium
19666 \shape up
19667 \size normal
19668 \emph off
19669 \bar no
19670 \noun off
19671 \color none
19672 convert unsigned long to floating point number
19673 \end_layout
19674
19675 \end_inset
19676 </cell>
19677 </row>
19678 <row topline="true" bottomline="true">
19679 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19680 \begin_inset Text
19681
19682 \begin_layout Standard
19683
19684 \family roman
19685 \series medium
19686 \shape up
19687 \size normal
19688 \emph off
19689 \bar no
19690 \noun off
19691 \color none
19692 _long2fs.c
19693 \end_layout
19694
19695 \end_inset
19696 </cell>
19697 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19698 \begin_inset Text
19699
19700 \begin_layout Standard
19701
19702 \family roman
19703 \series medium
19704 \shape up
19705 \size normal
19706 \emph off
19707 \bar no
19708 \noun off
19709 \color none
19710 convert long to floating point number
19711 \end_layout
19712
19713 \end_inset
19714 </cell>
19715 </row>
19716 </lyxtabular>
19717
19718 \end_inset
19719
19720
19721 \newline
19722
19723 \end_layout
19724
19725 \begin_layout Standard
19726 These support routines are developed in ANSI-C so there is room for space
19727  and speed improvement
19728 \begin_inset Foot
19729 status open
19730
19731 \begin_layout Standard
19732 These floating point routines (
19733 \emph on
19734 not
19735 \emph default
19736  sinf(), cosf(), ...) for the mcs51 are implemented in assembler.
19737  
19738 \end_layout
19739
19740 \end_inset
19741
19742 .
19743  Note if all these routines are used simultaneously the data space might
19744  overflow.
19745  For serious floating point usage the large model might be needed.
19746  Also notice that you don't have to call this routines directly.
19747  The compiler will use them automatically every time a floating point operation
19748  is required.
19749 \begin_inset VSpace bigskip
19750 \end_inset
19751
19752
19753 \end_layout
19754
19755 \begin_layout Section
19756 Library Routines
19757 \begin_inset LatexCommand \index{Libraries}
19758
19759 \end_inset
19760
19761
19762 \end_layout
19763
19764 \begin_layout Standard
19765
19766 \emph on
19767 <pending: this is messy and incomplete - a little more information is in
19768  sdcc/doc/libdoc.txt
19769 \emph default
19770  >
19771 \end_layout
19772
19773 \begin_layout Subsection
19774 Compiler support routines (_gptrget, _mulint etc.)
19775 \end_layout
19776
19777 \begin_layout Subsection
19778 Stdclib functions (puts, printf, strcat etc.)
19779 \end_layout
19780
19781 \begin_layout Subsubsection
19782 <stdio.h>
19783 \end_layout
19784
19785 \begin_layout Paragraph
19786 getchar(), putchar()
19787 \end_layout
19788
19789 \begin_layout Standard
19790 \begin_inset LatexCommand \index{<stdio.h>}
19791
19792 \end_inset
19793
19794 As usual on embedded systems you have to provide your own 
19795 \family typewriter
19796 getchar()
19797 \begin_inset LatexCommand \index{getchar()}
19798
19799 \end_inset
19800
19801  
19802 \family default
19803 and 
19804 \family typewriter
19805 putchar()
19806 \begin_inset LatexCommand \index{putchar()}
19807
19808 \end_inset
19809
19810
19811 \family default
19812  routines.
19813  SDCC does not know whether the system connects to a serial line with or
19814  without handshake, LCD, keyboard or other device.
19815  And whether a 
19816 \family typewriter
19817 lf
19818 \family default
19819  to 
19820 \family typewriter
19821 crlf
19822 \family default
19823  conversion within 
19824 \family typewriter
19825 putchar()
19826 \family default
19827  is intended.
19828  You'll find examples for serial routines f.e.
19829  in sdcc/device/lib.
19830  For the mcs51 this minimalistic polling 
19831 \family typewriter
19832 putchar()
19833 \family default
19834  routine might be a start:
19835 \end_layout
19836
19837 \begin_layout Verse
19838
19839 \family typewriter
19840 void putchar (char c) { 
19841 \newline
19842 \InsetSpace ~
19843 \InsetSpace ~
19844 \InsetSpace ~
19845 \InsetSpace ~
19846 while (!TI)\InsetSpace ~
19847 \InsetSpace ~
19848 \InsetSpace ~
19849  /* assumes UART is initialized */
19850 \newline
19851 \InsetSpace ~
19852 \InsetSpace ~
19853 \InsetSpace ~
19854 \InsetSpace ~
19855 \InsetSpace ~
19856 \InsetSpace ~
19857 \InsetSpace ~
19858 \InsetSpace ~
19859 ;
19860 \newline
19861 \InsetSpace ~
19862 \InsetSpace ~
19863 \InsetSpace ~
19864 \InsetSpace ~
19865 TI
19866  = 0;
19867 \newline
19868 \InsetSpace ~
19869 \InsetSpace ~
19870 \InsetSpace ~
19871 \InsetSpace ~
19872 SBUF = c;
19873 \newline
19874 }
19875 \end_layout
19876
19877 \begin_layout Paragraph
19878 printf()
19879 \end_layout
19880
19881 \begin_layout Standard
19882 The default
19883 \family typewriter
19884  printf()
19885 \begin_inset LatexCommand \index{printf()}
19886
19887 \end_inset
19888
19889
19890 \family default
19891  implementation in
19892 \family typewriter
19893  printf_large.c
19894 \family default
19895  does not support float (except on ds390).
19896  To enable this recompile it with the option 
19897 \emph on
19898 -
19899 \begin_inset ERT
19900 status collapsed
19901
19902 \begin_layout Standard
19903
19904
19905 \backslash
19906 /
19907 \end_layout
19908
19909 \end_inset
19910
19911 DUSE_FLOATS=1
19912 \begin_inset LatexCommand \index{USE\_FLOATS}
19913
19914 \end_inset
19915
19916
19917 \emph default
19918  on the command line.
19919  Use
19920 \emph on
19921  -
19922 \begin_inset ERT
19923 status collapsed
19924
19925 \begin_layout Standard
19926
19927
19928 \backslash
19929 /
19930 \end_layout
19931
19932 \end_inset
19933
19934 -model-large
19935 \begin_inset LatexCommand \index{-\/-model-large}
19936
19937 \end_inset
19938
19939
19940 \emph default
19941  for the mcs51 port, since this uses a lot of memory.
19942 \end_layout
19943
19944 \begin_layout Standard
19945 If you're short on code memory you might want to use 
19946 \family typewriter
19947 printf_small()
19948 \begin_inset LatexCommand \index{printf\_small()}
19949
19950 \end_inset
19951
19952
19953 \family default
19954  
19955 \emph on
19956 instead
19957 \emph default
19958  of
19959 \family typewriter
19960  printf().
19961
19962 \family default
19963  For the mcs51 there additionally are assembly versions 
19964 \family typewriter
19965 printf_tiny()
19966 \begin_inset LatexCommand \index{printf\_tiny() (mcs51)}
19967
19968 \end_inset
19969
19970
19971 \family default
19972  (subset of printf using less than 270 bytes) and 
19973 \family typewriter
19974 printf_fast()
19975 \begin_inset LatexCommand \index{printf\_fast() (mcs51)}
19976
19977 \end_inset
19978
19979  
19980 \family default
19981 and
19982 \family typewriter
19983  printf_fast_f()
19984 \begin_inset LatexCommand \index{printf\_fast\_f() (mcs51)}
19985
19986 \end_inset
19987
19988
19989 \family default
19990  (floating-point aware version of printf_fast) which should fit the requirements
19991  of many embedded systems (printf_fast() can be customized by unsetting
19992  #defines to 
19993 \emph on
19994 not
19995 \emph default
19996  support long variables and field widths).
19997  Be sure to use only one of these printf options within a project.
19998 \newline
19999
20000 \end_layout
20001
20002 \begin_layout Standard
20003 Feature matrix of different 
20004 \emph on
20005 printf
20006 \emph default
20007  options on mcs51.
20008 \end_layout
20009
20010 \begin_layout Standard
20011 \begin_inset Tabular
20012 <lyxtabular version="3" rows="14" columns="7">
20013 <features islongtable="true">
20014 <column alignment="left" valignment="middle" leftline="true" width="14col%">
20015 <column alignment="center" valignment="top" leftline="true" width="0">
20016 <column alignment="center" valignment="top" leftline="true" width="12col%">
20017 <column alignment="center" valignment="top" leftline="true" width="10col%">
20018 <column alignment="center" valignment="top" leftline="true" width="0">
20019 <column alignment="center" valignment="top" leftline="true" rightline="true" width="12col%">
20020 <column alignment="center" valignment="top" rightline="true" width="0">
20021 <row topline="true" bottomline="true" endhead="true">
20022 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20023 \begin_inset Text
20024
20025 \begin_layout Standard
20026
20027 \series bold
20028 \size large
20029 mcs51
20030 \end_layout
20031
20032 \end_inset
20033 </cell>
20034 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20035 \begin_inset Text
20036
20037 \begin_layout Standard
20038 printf
20039 \begin_inset LatexCommand \index{printf}
20040
20041 \end_inset
20042
20043
20044 \end_layout
20045
20046 \end_inset
20047 </cell>
20048 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20049 \begin_inset Text
20050
20051 \begin_layout Standard
20052 printf 
20053 \size scriptsize
20054 USE_FLOATS=1
20055 \end_layout
20056
20057 \end_inset
20058 </cell>
20059 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20060 \begin_inset Text
20061
20062 \begin_layout Standard
20063 printf_small
20064 \end_layout
20065
20066 \end_inset
20067 </cell>
20068 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20069 \begin_inset Text
20070
20071 \begin_layout Standard
20072 printf_fast
20073 \end_layout
20074
20075 \end_inset
20076 </cell>
20077 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20078 \begin_inset Text
20079
20080 \begin_layout Standard
20081 printf_fast_f
20082 \end_layout
20083
20084 \end_inset
20085 </cell>
20086 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20087 \begin_inset Text
20088
20089 \begin_layout Standard
20090 printf_tiny
20091 \end_layout
20092
20093 \end_inset
20094 </cell>
20095 </row>
20096 <row topline="true" endhead="true">
20097 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20098 \begin_inset Text
20099
20100 \begin_layout Standard
20101 filename
20102 \end_layout
20103
20104 \end_inset
20105 </cell>
20106 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20107 \begin_inset Text
20108
20109 \begin_layout Standard
20110
20111 \size scriptsize
20112 printf_large.c
20113 \end_layout
20114
20115 \end_inset
20116 </cell>
20117 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20118 \begin_inset Text
20119
20120 \begin_layout Standard
20121
20122 \size scriptsize
20123 printf_large.c
20124 \end_layout
20125
20126 \end_inset
20127 </cell>
20128 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20129 \begin_inset Text
20130
20131 \begin_layout Standard
20132
20133 \size scriptsize
20134 printfl.c
20135 \end_layout
20136
20137 \end_inset
20138 </cell>
20139 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20140 \begin_inset Text
20141
20142 \begin_layout Standard
20143
20144 \size scriptsize
20145 printf_fast.c
20146 \end_layout
20147
20148 \end_inset
20149 </cell>
20150 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20151 \begin_inset Text
20152
20153 \begin_layout Standard
20154
20155 \size scriptsize
20156 printf_fast_f.c
20157 \end_layout
20158
20159 \end_inset
20160 </cell>
20161 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20162 \begin_inset Text
20163
20164 \begin_layout Standard
20165
20166 \size scriptsize
20167 printf_tiny.c
20168 \end_layout
20169
20170 \end_inset
20171 </cell>
20172 </row>
20173 <row topline="true" endhead="true">
20174 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20175 \begin_inset Text
20176
20177 \begin_layout Standard
20178 \begin_inset Quotes sld
20179 \end_inset
20180
20181 Hello World
20182 \begin_inset Quotes srd
20183 \end_inset
20184
20185  size
20186 \end_layout
20187
20188 \begin_layout Standard
20189 small / large
20190 \end_layout
20191
20192 \end_inset
20193 </cell>
20194 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20195 \begin_inset Text
20196
20197 \begin_layout Standard
20198 1.7k / 2.4k
20199 \end_layout
20200
20201 \end_inset
20202 </cell>
20203 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20204 \begin_inset Text
20205
20206 \begin_layout Standard
20207 4.3k / 5.6k
20208 \end_layout
20209
20210 \end_inset
20211 </cell>
20212 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20213 \begin_inset Text
20214
20215 \begin_layout Standard
20216 1.2k / 1.8k
20217 \end_layout
20218
20219 \end_inset
20220 </cell>
20221 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20222 \begin_inset Text
20223
20224 \begin_layout Standard
20225 1.3k / 1.3k
20226 \end_layout
20227
20228 \end_inset
20229 </cell>
20230 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20231 \begin_inset Text
20232
20233 \begin_layout Standard
20234 1.9k / 1.9k
20235 \end_layout
20236
20237 \end_inset
20238 </cell>
20239 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20240 \begin_inset Text
20241
20242 \begin_layout Standard
20243 0.44k / 0.44k
20244 \end_layout
20245
20246 \end_inset
20247 </cell>
20248 </row>
20249 <row topline="true" endhead="true">
20250 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20251 \begin_inset Text
20252
20253 \begin_layout Standard
20254 code size
20255 \end_layout
20256
20257 \begin_layout Standard
20258 small / large
20259 \end_layout
20260
20261 \end_inset
20262 </cell>
20263 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20264 \begin_inset Text
20265
20266 \begin_layout Standard
20267 1.4k / 2.0k
20268 \end_layout
20269
20270 \end_inset
20271 </cell>
20272 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20273 \begin_inset Text
20274
20275 \begin_layout Standard
20276 2.8k / 3.7k
20277 \end_layout
20278
20279 \end_inset
20280 </cell>
20281 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20282 \begin_inset Text
20283
20284 \begin_layout Standard
20285 0.45k / 0.47k (+ _ltoa)
20286 \end_layout
20287
20288 \end_inset
20289 </cell>
20290 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20291 \begin_inset Text
20292
20293 \begin_layout Standard
20294 1.2k / 1.2k
20295 \end_layout
20296
20297 \end_inset
20298 </cell>
20299 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20300 \begin_inset Text
20301
20302 \begin_layout Standard
20303 1.6k / 1.6k
20304 \end_layout
20305
20306 \end_inset
20307 </cell>
20308 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20309 \begin_inset Text
20310
20311 \begin_layout Standard
20312 0.26k / 0.26k
20313 \end_layout
20314
20315 \end_inset
20316 </cell>
20317 </row>
20318 <row topline="true">
20319 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20320 \begin_inset Text
20321
20322 \begin_layout Standard
20323 formats
20324 \end_layout
20325
20326 \end_inset
20327 </cell>
20328 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20329 \begin_inset Text
20330
20331 \begin_layout Standard
20332 cdi
20333 \emph on
20334 o
20335 \emph default
20336 psux
20337 \end_layout
20338
20339 \end_inset
20340 </cell>
20341 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20342 \begin_inset Text
20343
20344 \begin_layout Standard
20345
20346 \family roman
20347 \series medium
20348 \shape up
20349 \size normal
20350 \emph off
20351 \bar no
20352 \noun off
20353 \color none
20354 cd
20355 \family default
20356 \series default
20357 \shape default
20358 \size default
20359 \emph default
20360 \bar default
20361 \noun default
20362 f
20363 \family roman
20364 \series medium
20365 \shape up
20366 \size normal
20367 \emph off
20368 \bar no
20369 \noun off
20370 i
20371 \family default
20372 \series default
20373 \shape default
20374 \size default
20375 \emph on
20376 \bar default
20377 \noun default
20378 o
20379 \family roman
20380 \series medium
20381 \shape up
20382 \size normal
20383 \emph off
20384 \bar no
20385 \noun off
20386 psux
20387 \end_layout
20388
20389 \end_inset
20390 </cell>
20391 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20392 \begin_inset Text
20393
20394 \begin_layout Standard
20395 c
20396 \family roman
20397 \series medium
20398 \shape up
20399 \size normal
20400 \emph off
20401 \bar no
20402 \noun off
20403 \color none
20404 d
20405 \family default
20406 \series default
20407 \shape default
20408 \size default
20409 \emph on
20410 \bar default
20411 \noun default
20412 o
20413 \family roman
20414 \series medium
20415 \shape up
20416 \size normal
20417 \emph off
20418 \bar no
20419 \noun off
20420 s
20421 \family default
20422 \series default
20423 \shape default
20424 \size default
20425 \emph default
20426 \bar default
20427 \noun default
20428 x
20429 \end_layout
20430
20431 \end_inset
20432 </cell>
20433 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20434 \begin_inset Text
20435
20436 \begin_layout Standard
20437 cdsux
20438 \end_layout
20439
20440 \end_inset
20441 </cell>
20442 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20443 \begin_inset Text
20444
20445 \begin_layout Standard
20446 cdfsux
20447 \end_layout
20448
20449 \end_inset
20450 </cell>
20451 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20452 \begin_inset Text
20453
20454 \begin_layout Standard
20455 cdsux
20456 \end_layout
20457
20458 \end_inset
20459 </cell>
20460 </row>
20461 <row topline="true">
20462 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20463 \begin_inset Text
20464
20465 \begin_layout Standard
20466 long (32 bit) support
20467 \end_layout
20468
20469 \end_inset
20470 </cell>
20471 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20472 \begin_inset Text
20473
20474 \begin_layout Standard
20475 x
20476 \end_layout
20477
20478 \end_inset
20479 </cell>
20480 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20481 \begin_inset Text
20482
20483 \begin_layout Standard
20484 x
20485 \end_layout
20486
20487 \end_inset
20488 </cell>
20489 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20490 \begin_inset Text
20491
20492 \begin_layout Standard
20493 x
20494 \end_layout
20495
20496 \end_inset
20497 </cell>
20498 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20499 \begin_inset Text
20500
20501 \begin_layout Standard
20502 x
20503 \end_layout
20504
20505 \end_inset
20506 </cell>
20507 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20508 \begin_inset Text
20509
20510 \begin_layout Standard
20511
20512 \family roman
20513 \series medium
20514 \shape up
20515 \size normal
20516 \emph off
20517 \bar no
20518 \noun off
20519 \color none
20520 x
20521 \end_layout
20522
20523 \end_inset
20524 </cell>
20525 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20526 \begin_inset Text
20527
20528 \begin_layout Standard
20529 -
20530 \end_layout
20531
20532 \end_inset
20533 </cell>
20534 </row>
20535 <row topline="true">
20536 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20537 \begin_inset Text
20538
20539 \begin_layout Standard
20540 byte arguments on stack
20541 \end_layout
20542
20543 \end_inset
20544 </cell>
20545 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20546 \begin_inset Text
20547
20548 \begin_layout Standard
20549 b
20550 \end_layout
20551
20552 \end_inset
20553 </cell>
20554 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20555 \begin_inset Text
20556
20557 \begin_layout Standard
20558 b
20559 \end_layout
20560
20561 \end_inset
20562 </cell>
20563 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20564 \begin_inset Text
20565
20566 \begin_layout Standard
20567 -
20568 \end_layout
20569
20570 \end_inset
20571 </cell>
20572 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20573 \begin_inset Text
20574
20575 \begin_layout Standard
20576 -
20577 \end_layout
20578
20579 \end_inset
20580 </cell>
20581 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20582 \begin_inset Text
20583
20584 \begin_layout Standard
20585 -
20586 \end_layout
20587
20588 \end_inset
20589 </cell>
20590 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20591 \begin_inset Text
20592
20593 \begin_layout Standard
20594 -
20595 \end_layout
20596
20597 \end_inset
20598 </cell>
20599 </row>
20600 <row topline="true">
20601 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20602 \begin_inset Text
20603
20604 \begin_layout Standard
20605 float format
20606 \begin_inset LatexCommand \index{Floating point support}
20607
20608 \end_inset
20609
20610
20611 \end_layout
20612
20613 \end_inset
20614 </cell>
20615 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20616 \begin_inset Text
20617
20618 \begin_layout Standard
20619 -
20620 \end_layout
20621
20622 \end_inset
20623 </cell>
20624 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20625 \begin_inset Text
20626
20627 \begin_layout Standard
20628 %f
20629 \end_layout
20630
20631 \end_inset
20632 </cell>
20633 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20634 \begin_inset Text
20635
20636 \begin_layout Standard
20637 -
20638 \end_layout
20639
20640 \end_inset
20641 </cell>
20642 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20643 \begin_inset Text
20644
20645 \begin_layout Standard
20646 -
20647 \end_layout
20648
20649 \end_inset
20650 </cell>
20651 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20652 \begin_inset Text
20653
20654 \begin_layout Standard
20655 %f
20656 \begin_inset Foot
20657 status collapsed
20658
20659 \begin_layout Standard
20660 Range limited to +/- 4294967040, precision limited to 8 digits past decimal
20661 \end_layout
20662
20663 \end_inset
20664
20665
20666 \end_layout
20667
20668 \end_inset
20669 </cell>
20670 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20671 \begin_inset Text
20672
20673 \begin_layout Standard
20674 -
20675 \end_layout
20676
20677 \end_inset
20678 </cell>
20679 </row>
20680 <row topline="true">
20681 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20682 \begin_inset Text
20683
20684 \begin_layout Standard
20685 float formats %e %g
20686 \end_layout
20687
20688 \end_inset
20689 </cell>
20690 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20691 \begin_inset Text
20692
20693 \begin_layout Standard
20694 -
20695 \end_layout
20696
20697 \end_inset
20698 </cell>
20699 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20700 \begin_inset Text
20701
20702 \begin_layout Standard
20703 -
20704 \end_layout
20705
20706 \end_inset
20707 </cell>
20708 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20709 \begin_inset Text
20710
20711 \begin_layout Standard
20712 -
20713 \end_layout
20714
20715 \end_inset
20716 </cell>
20717 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20718 \begin_inset Text
20719
20720 \begin_layout Standard
20721 -
20722 \end_layout
20723
20724 \end_inset
20725 </cell>
20726 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20727 \begin_inset Text
20728
20729 \begin_layout Standard
20730 -
20731 \end_layout
20732
20733 \end_inset
20734 </cell>
20735 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20736 \begin_inset Text
20737
20738 \begin_layout Standard
20739 -
20740 \end_layout
20741
20742 \end_inset
20743 </cell>
20744 </row>
20745 <row topline="true" bottomline="true">
20746 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20747 \begin_inset Text
20748
20749 \begin_layout Standard
20750 field width
20751 \end_layout
20752
20753 \end_inset
20754 </cell>
20755 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20756 \begin_inset Text
20757
20758 \begin_layout Standard
20759 x
20760 \end_layout
20761
20762 \end_inset
20763 </cell>
20764 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20765 \begin_inset Text
20766
20767 \begin_layout Standard
20768 x
20769 \end_layout
20770
20771 \end_inset
20772 </cell>
20773 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20774 \begin_inset Text
20775
20776 \begin_layout Standard
20777 -
20778 \end_layout
20779
20780 \end_inset
20781 </cell>
20782 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20783 \begin_inset Text
20784
20785 \begin_layout Standard
20786 x
20787 \end_layout
20788
20789 \end_inset
20790 </cell>
20791 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20792 \begin_inset Text
20793
20794 \begin_layout Standard
20795 x
20796 \end_layout
20797
20798 \end_inset
20799 </cell>
20800 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20801 \begin_inset Text
20802
20803 \begin_layout Standard
20804 -
20805 \end_layout
20806
20807 \end_inset
20808 </cell>
20809 </row>
20810 <row bottomline="true">
20811 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20812 \begin_inset Text
20813
20814 \begin_layout Standard
20815 string speed
20816 \begin_inset Foot
20817 status collapsed
20818
20819 \begin_layout Standard
20820 Execution time of printf("%s%c%s%c%c%c", "Hello", ' ', "World", '!', '
20821 \backslash
20822 r', '
20823 \backslash
20824 n'); standard 8051 @ 22.1184 MHz, empty putchar()
20825 \end_layout
20826
20827 \end_inset
20828
20829 ,
20830 \end_layout
20831
20832 \begin_layout Standard
20833 small / large
20834 \end_layout
20835
20836 \end_inset
20837 </cell>
20838 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20839 \begin_inset Text
20840
20841 \begin_layout Standard
20842 1.52 / 2.59 ms
20843 \end_layout
20844
20845 \end_inset
20846 </cell>
20847 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20848 \begin_inset Text
20849
20850 \begin_layout Standard
20851 1.53 / 2.62 ms
20852 \end_layout
20853
20854 \end_inset
20855 </cell>
20856 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20857 \begin_inset Text
20858
20859 \begin_layout Standard
20860 0.92 / 0.93 ms
20861 \end_layout
20862
20863 \end_inset
20864 </cell>
20865 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20866 \begin_inset Text
20867
20868 \begin_layout Standard
20869 0.45 / 0.45 ms
20870 \end_layout
20871
20872 \end_inset
20873 </cell>
20874 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20875 \begin_inset Text
20876
20877 \begin_layout Standard
20878 0.46 / 0.46 ms
20879 \end_layout
20880
20881 \end_inset
20882 </cell>
20883 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20884 \begin_inset Text
20885
20886 \begin_layout Standard
20887 0.45 / 0.45 ms
20888 \end_layout
20889
20890 \end_inset
20891 </cell>
20892 </row>
20893 <row bottomline="true">
20894 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20895 \begin_inset Text
20896
20897 \begin_layout Standard
20898 int speed
20899 \begin_inset Foot
20900 status collapsed
20901
20902 \begin_layout Standard
20903 Execution time of printf("%d", -12345); standard 8051 @ 22.1184 MHz, empty
20904  putchar()
20905 \end_layout
20906
20907 \end_inset
20908
20909 ,
20910 \end_layout
20911
20912 \begin_layout Standard
20913 small / large
20914 \end_layout
20915
20916 \end_inset
20917 </cell>
20918 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20919 \begin_inset Text
20920
20921 \begin_layout Standard
20922 3.01 / 3.61 ms
20923 \end_layout
20924
20925 \end_inset
20926 </cell>
20927 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20928 \begin_inset Text
20929
20930 \begin_layout Standard
20931 3.01 / 3.61 ms
20932 \end_layout
20933
20934 \end_inset
20935 </cell>
20936 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20937 \begin_inset Text
20938
20939 \begin_layout Standard
20940 3.51 / 18.13 ms
20941 \end_layout
20942
20943 \end_inset
20944 </cell>
20945 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20946 \begin_inset Text
20947
20948 \begin_layout Standard
20949 0.22 / 0.22 ms
20950 \end_layout
20951
20952 \end_inset
20953 </cell>
20954 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20955 \begin_inset Text
20956
20957 \begin_layout Standard
20958 0.23 / 0.23 ms
20959 \end_layout
20960
20961 \end_inset
20962 </cell>
20963 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20964 \begin_inset Text
20965
20966 \begin_layout Standard
20967 0.25 / 0.25 ms
20968 \begin_inset Foot
20969 status collapsed
20970
20971 \begin_layout Standard
20972 printf_tiny integer speed is data dependent, worst case is 0.33 ms
20973 \end_layout
20974
20975 \end_inset
20976
20977
20978 \end_layout
20979
20980 \end_inset
20981 </cell>
20982 </row>
20983 <row bottomline="true">
20984 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20985 \begin_inset Text
20986
20987 \begin_layout Standard
20988 long speed
20989 \begin_inset Foot
20990 status collapsed
20991
20992 \begin_layout Standard
20993 Execution time of printf("%ld", -123456789); standard 8051 @ 22.1184 MHz,
20994  empty putchar()
20995 \end_layout
20996
20997 \end_inset
20998
20999 ,
21000 \end_layout
21001
21002 \begin_layout Standard
21003 small / large
21004 \end_layout
21005
21006 \end_inset
21007 </cell>
21008 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21009 \begin_inset Text
21010
21011 \begin_layout Standard
21012 5.37 / 6.31 ms
21013 \end_layout
21014
21015 \end_inset
21016 </cell>
21017 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21018 \begin_inset Text
21019
21020 \begin_layout Standard
21021 5.37 / 6.31 ms
21022 \end_layout
21023
21024 \end_inset
21025 </cell>
21026 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21027 \begin_inset Text
21028
21029 \begin_layout Standard
21030 8.71 / 40.65 ms
21031 \end_layout
21032
21033 \end_inset
21034 </cell>
21035 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21036 \begin_inset Text
21037
21038 \begin_layout Standard
21039 0.40 / 0.40 ms
21040 \end_layout
21041
21042 \end_inset
21043 </cell>
21044 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21045 \begin_inset Text
21046
21047 \begin_layout Standard
21048 0.40 / 0.40 ms
21049 \end_layout
21050
21051 \end_inset
21052 </cell>
21053 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
21054 \begin_inset Text
21055
21056 \begin_layout Standard
21057 -
21058 \end_layout
21059
21060 \end_inset
21061 </cell>
21062 </row>
21063 <row bottomline="true">
21064 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21065 \begin_inset Text
21066
21067 \begin_layout Standard
21068 float speed
21069 \begin_inset Foot
21070 status collapsed
21071
21072 \begin_layout Standard
21073 Execution time of printf("%.3f", -12345.678); standard 8051 @ 22.1184 MHz,
21074  empty putchar()
21075 \end_layout
21076
21077 \end_inset
21078
21079 ,
21080 \end_layout
21081
21082 \begin_layout Standard
21083 small / large
21084 \end_layout
21085
21086 \end_inset
21087 </cell>
21088 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21089 \begin_inset Text
21090
21091 \begin_layout Standard
21092 -
21093 \end_layout
21094
21095 \end_inset
21096 </cell>
21097 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21098 \begin_inset Text
21099
21100 \begin_layout Standard
21101 7.49 / 22.47 ms
21102 \end_layout
21103
21104 \end_inset
21105 </cell>
21106 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21107 \begin_inset Text
21108
21109 \begin_layout Standard
21110 -
21111 \end_layout
21112
21113 \end_inset
21114 </cell>
21115 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21116 \begin_inset Text
21117
21118 \begin_layout Standard
21119 -
21120 \end_layout
21121
21122 \end_inset
21123 </cell>
21124 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21125 \begin_inset Text
21126
21127 \begin_layout Standard
21128 1.04 / 1.04 ms
21129 \end_layout
21130
21131 \end_inset
21132 </cell>
21133 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
21134 \begin_inset Text
21135
21136 \begin_layout Standard
21137 -
21138 \end_layout
21139
21140 \end_inset
21141 </cell>
21142 </row>
21143 </lyxtabular>
21144
21145 \end_inset
21146
21147
21148 \end_layout
21149
21150 \begin_layout Subsubsection
21151 <malloc.h>
21152 \begin_inset LatexCommand \index{malloc.h}
21153
21154 \end_inset
21155
21156
21157 \end_layout
21158
21159 \begin_layout Standard
21160 As of SDCC 2.6.2 you no longer need to call an initialization routine before
21161  using dynamic memory allocation
21162 \begin_inset LatexCommand \index{dynamic memory allocation (malloc)}
21163
21164 \end_inset
21165
21166  and a default heap
21167 \begin_inset LatexCommand \index{heap (malloc)}
21168
21169 \end_inset
21170
21171  space of 1024 bytes is provided for malloc to allocate memory from.
21172  If you need a different heap size you need to recompile _heap.c with the
21173  required size defined in HEAP_SIZE.
21174  It is recommended to make a copy of this file into your project directory
21175  and compile it there with:
21176 \end_layout
21177
21178 \begin_layout Verse
21179
21180 \family typewriter
21181 sdcc -c _heap.c -D HEAD_SIZE=2048
21182 \end_layout
21183
21184 \begin_layout Standard
21185 And then link it with:
21186 \end_layout
21187
21188 \begin_layout Verse
21189
21190 \family typewriter
21191 sdcc main.rel _heap.rel
21192 \end_layout
21193
21194 \begin_layout Subsection
21195 Math functions (sinf, powf, sqrtf etc.)
21196 \end_layout
21197
21198 \begin_layout Subsubsection
21199 <math.h>
21200 \end_layout
21201
21202 \begin_layout Standard
21203 See definitions in file <math.h>.
21204 \end_layout
21205
21206 \begin_layout Subsection
21207 Other libraries
21208 \end_layout
21209
21210 \begin_layout Standard
21211 Libraries
21212 \begin_inset LatexCommand \index{Libraries}
21213
21214 \end_inset
21215
21216  included in SDCC should have a license at least as liberal as the GNU Lesser
21217  General Public License
21218 \begin_inset LatexCommand \index{GNU Lesser General Public License, LGPL}
21219
21220 \end_inset
21221
21222  
21223 \emph on
21224 LGPL
21225 \emph default
21226 .
21227 \end_layout
21228
21229 \begin_layout Standard
21230 \begin_inset Note Note
21231 status collapsed
21232
21233 \begin_layout Standard
21234 license statements for the libraries are missing.
21235  sdcc/device/lib/ser_ir.c
21236 \end_layout
21237
21238 \begin_layout Standard
21239 or _decdptr f.e.
21240  come with a GPL (as opposed to LGPL) License - this will not be liberal
21241  enough for many embedded programmers.
21242 \end_layout
21243
21244 \end_inset
21245
21246
21247 \end_layout
21248
21249 \begin_layout Standard
21250 If you have ported some library or want to share experience about some code
21251  which f.e.
21252  falls into any of these categories Busses (I
21253 \begin_inset Formula $^{\textrm{2}}$
21254 \end_inset
21255
21256 C, CAN, Ethernet, Profibus, Modbus, USB, SPI, JTAG ...), Media (IDE, Memory
21257  cards, eeprom, flash...), En-/Decryption, Remote debugging, Realtime kernel,
21258  Keyboard, LCD, RTC, FPGA, PID then the sdcc-user mailing list 
21259 \begin_inset LatexCommand \url{http://sourceforge.net/mail/?group_id=599}
21260
21261 \end_inset
21262
21263 \InsetSpace ~
21264 would certainly like to hear about it.
21265 \end_layout
21266
21267 \begin_layout Standard
21268 Programmers coding for embedded systems are not especially famous for being
21269  enthusiastic, so don't expect a big hurray but as the mailing list is searchabl
21270 e these references are very valuable.
21271  Let's help to create a climate where information is shared.
21272 \begin_inset VSpace bigskip
21273 \end_inset
21274
21275
21276 \end_layout
21277
21278 \begin_layout Section
21279 Memory Models
21280 \end_layout
21281
21282 \begin_layout Subsection
21283 MCS51 Memory Models
21284 \begin_inset LatexCommand \index{Memory model}
21285
21286 \end_inset
21287
21288
21289 \begin_inset LatexCommand \index{MCS51 memory model}
21290
21291 \end_inset
21292
21293
21294 \end_layout
21295
21296 \begin_layout Subsubsection
21297 Small, Medium and Large
21298 \end_layout
21299
21300 \begin_layout Standard
21301 SDCC allows three memory models for MCS51 code, 
21302 \shape slanted
21303 small, medium
21304 \shape default
21305  and 
21306 \shape slanted
21307 large
21308 \shape default
21309 .
21310  Modules compiled with different memory models should 
21311 \emph on
21312 never
21313 \emph default
21314  be combined together or the results would be unpredictable.
21315  The library routines supplied with the compiler are compiled as small,
21316  medium and large.
21317  The compiled library modules are contained in separate directories as small,
21318  medium and large so that you can link to the appropriate set.
21319 \end_layout
21320
21321 \begin_layout Standard
21322 When the medium or large model is used all variables declared without a
21323  storage class will be allocated into the external ram, this includes all
21324  parameters and local variables (for non-reentrant
21325 \begin_inset LatexCommand \index{reentrant}
21326
21327 \end_inset
21328
21329  functions).
21330  When the small model is used variables without storage class are allocated
21331  in the internal ram.
21332 \end_layout
21333
21334 \begin_layout Standard
21335 Judicious usage of the processor specific storage classes
21336 \begin_inset LatexCommand \index{Storage class}
21337
21338 \end_inset
21339
21340  and the 'reentrant' function type will yield much more efficient code,
21341  than using the large model.
21342  Several optimizations are disabled when the program is compiled using the
21343  large model, it is therefore recommended that the small model be used unless
21344  absolutely required.
21345 \end_layout
21346
21347 \begin_layout Subsubsection
21348 External Stack
21349 \begin_inset LatexCommand \label{sub:External-Stack}
21350
21351 \end_inset
21352
21353
21354 \begin_inset LatexCommand \index{stack}
21355
21356 \end_inset
21357
21358
21359 \begin_inset LatexCommand \index{External stack (mcs51)}
21360
21361 \end_inset
21362
21363
21364 \end_layout
21365
21366 \begin_layout Standard
21367 The external stack (-
21368 \begin_inset ERT
21369 status collapsed
21370
21371 \begin_layout Standard
21372
21373
21374 \backslash
21375 /
21376 \end_layout
21377
21378 \end_inset
21379
21380 -xstack option
21381 \begin_inset LatexCommand \index{-\/-xstack}
21382
21383 \end_inset
21384
21385 ) is located in pdata
21386 \begin_inset LatexCommand \index{pdata (mcs51, ds390 storage class)}
21387
21388 \end_inset
21389
21390  memory (usually at the start of the external ram segment) and uses all
21391  unused space in pdata (max.
21392  256 bytes).
21393  When -
21394 \begin_inset ERT
21395 status collapsed
21396
21397 \begin_layout Standard
21398
21399
21400 \backslash
21401 /
21402 \end_layout
21403
21404 \end_inset
21405
21406 -xstack option is used to compile the program, the parameters and local
21407  variables
21408 \begin_inset LatexCommand \index{local variables}
21409
21410 \end_inset
21411
21412  of all reentrant functions are allocated in this area.
21413  This option is provided for programs with large stack space requirements.
21414  When used with the -
21415 \begin_inset ERT
21416 status collapsed
21417
21418 \begin_layout Standard
21419
21420
21421 \backslash
21422 /
21423 \end_layout
21424
21425 \end_inset
21426
21427 -stack-auto
21428 \begin_inset LatexCommand \index{-\/-stack-auto}
21429
21430 \end_inset
21431
21432  option, all parameters and local variables are allocated on the external
21433  stack (note: support libraries will need to be recompiled with the same
21434  options.
21435  There is a predefined target in the library makefile).
21436 \end_layout
21437
21438 \begin_layout Standard
21439 The compiler outputs the higher order address byte of the external ram segment
21440  into port P2
21441 \begin_inset LatexCommand \index{P2 (mcs51 sfr)}
21442
21443 \end_inset
21444
21445  (see also section 
21446 \begin_inset LatexCommand \ref{sub:MCS51-variants}
21447
21448 \end_inset
21449
21450 ), therefore when using the External Stack option, this port 
21451 \emph on
21452 may not
21453 \emph default
21454  be used by the application program.
21455 \end_layout
21456
21457 \begin_layout Subsection
21458 DS390 Memory Model
21459 \begin_inset LatexCommand \index{Memory model}
21460
21461 \end_inset
21462
21463
21464 \begin_inset LatexCommand \index{DS390 memory model}
21465
21466 \end_inset
21467
21468
21469 \end_layout
21470
21471 \begin_layout Standard
21472 The only model supported is Flat 24
21473 \begin_inset LatexCommand \index{Flat 24 (DS390 memory model)}
21474
21475 \end_inset
21476
21477 .
21478  This generates code for the 24 bit contiguous addressing mode of the Dallas
21479  DS80C390 part.
21480  In this mode, up to four meg of external RAM or code space can be directly
21481  addressed.
21482  See the data sheets at www.dalsemi.com for further information on this part.
21483 \newline
21484
21485 \newline
21486 Note
21487  that the compiler does not generate any code to place the processor into
21488  24 bitmode (although 
21489 \emph on
21490 tinibios
21491 \emph default
21492  in the ds390 libraries will do that for you).
21493  If you don't use 
21494 \emph on
21495 tinibios
21496 \emph default
21497
21498 \begin_inset LatexCommand \index{Tinibios (DS390)}
21499
21500 \end_inset
21501
21502 , the boot loader or similar code must ensure that the processor is in 24
21503  bit contiguous addressing mode before calling the SDCC startup code.
21504 \newline
21505
21506 \newline
21507 Like
21508  the 
21509 \emph on
21510 -
21511 \begin_inset ERT
21512 status collapsed
21513
21514 \begin_layout Standard
21515
21516
21517 \backslash
21518 /
21519 \end_layout
21520
21521 \end_inset
21522
21523 -model-large
21524 \emph default
21525  option, variables will by default be placed into the XDATA segment.
21526  
21527 \newline
21528
21529 \newline
21530 Segments may be placed anywhere in the 4 meg address space using the usual
21531  -
21532 \begin_inset ERT
21533 status collapsed
21534
21535 \begin_layout Standard
21536
21537
21538 \backslash
21539 /
21540 \end_layout
21541
21542 \end_inset
21543
21544 -*-loc options.
21545  Note that if any segments are located above 64K, the -r flag must be passed
21546  to the linker to generate the proper segment relocations, and the Intel
21547  HEX output format must be used.
21548  The -r flag can be passed to the linker by using the option 
21549 \emph on
21550 -Wl-r
21551 \emph default
21552  on the SDCC command line.
21553  However, currently the linker can not handle code segments > 64k.
21554 \end_layout
21555
21556 \begin_layout Section
21557 Pragmas
21558 \begin_inset LatexCommand \label{sec:Pragmas}
21559
21560 \end_inset
21561
21562
21563 \begin_inset LatexCommand \index{Pragmas}
21564
21565 \end_inset
21566
21567
21568 \end_layout
21569
21570 \begin_layout Standard
21571 Pragmas are used to turn on and/or off certain compiler options.
21572  Some of them are closely related to corresponding command-line options
21573  (see section 
21574 \begin_inset LatexCommand \vref{sec:Command-Line-Options}
21575
21576 \end_inset
21577
21578 ).
21579 \newline
21580 Pragmas should be placed before and/or after a function, placing pragmas
21581  inside a function body could have unpredictable results.
21582 \newline
21583
21584 \newline
21585 SDCC supports the
21586  following #pragma directives:
21587 \end_layout
21588
21589 \begin_layout Itemize
21590
21591 \series bold
21592 save
21593 \series default
21594
21595 \begin_inset LatexCommand \index{\#pragma save}
21596
21597 \end_inset
21598
21599  - this will save most current options to the save/restore stack.
21600  See #pragma\InsetSpace ~
21601 restore.
21602 \end_layout
21603
21604 \begin_layout Itemize
21605
21606 \series bold
21607 restore
21608 \series default
21609
21610 \begin_inset LatexCommand \index{\#pragma restore}
21611
21612 \end_inset
21613
21614  - will restore saved options from the last save.
21615  saves & restores can be nested.
21616  SDCC uses a save/restore stack: save pushes current options to the stack,
21617  restore pulls current options from the stack.
21618  See #pragma\InsetSpace ~
21619 save.
21620 \newline
21621
21622 \end_layout
21623
21624 \begin_layout Itemize
21625
21626 \series bold
21627 callee_saves
21628 \series default
21629
21630 \begin_inset LatexCommand \index{\#pragma callee\_saves}
21631
21632 \end_inset
21633
21634
21635 \begin_inset LatexCommand \index{function prologue}
21636
21637 \end_inset
21638
21639  function1[,function2[,function3...]] 
21640 \begin_inset LatexCommand \label{ite:callee_saves-function1[,function2[,function3...]]--}
21641
21642 \end_inset
21643
21644 - The compiler by default uses a caller saves convention for register saving
21645  across function calls, however this can cause unnecessary register pushing
21646  and popping
21647 \begin_inset LatexCommand \index{push/pop}
21648
21649 \end_inset
21650
21651  when calling small functions from larger functions.
21652  This option can be used to switch off the register saving convention for
21653  the function names specified.
21654  The compiler will not save registers when calling these functions, extra
21655  code need to be manually inserted at the entry and exit for these functions
21656  to save and restore the registers used by these functions, this can SUBSTANTIAL
21657 LY reduce code and improve run time performance of the generated code.
21658  In the future the compiler (with inter procedural analysis) may be able
21659  to determine the appropriate scheme to use for each function call.
21660  If -
21661 \begin_inset ERT
21662 status collapsed
21663
21664 \begin_layout Standard
21665
21666
21667 \backslash
21668 /
21669 \end_layout
21670
21671 \end_inset
21672
21673 -callee-saves command line option is used (see page 
21674 \begin_inset LatexCommand \vpageref{lyx:--callee-saves-function1[,function2][,function3]...}
21675
21676 \end_inset
21677
21678 ), the function names specified in #pragma\InsetSpace ~
21679 callee_saves
21680 \begin_inset LatexCommand \index{\#pragma callee\_saves}
21681
21682 \end_inset
21683
21684  is appended to the list of functions specified in the command line.
21685 \end_layout
21686
21687 \begin_layout Itemize
21688
21689 \series bold
21690 exclude
21691 \series default
21692
21693 \begin_inset LatexCommand \index{\#pragma exclude}
21694
21695 \end_inset
21696
21697  none | {acc[,b[,dpl[,dph]]] - The exclude pragma disables the generation
21698  of pairs of push/pop
21699 \begin_inset LatexCommand \index{push/pop}
21700
21701 \end_inset
21702
21703  instructions in 
21704 \emph on
21705 I
21706 \emph default
21707 nterrupt
21708 \begin_inset LatexCommand \index{interrupt}
21709
21710 \end_inset
21711
21712  
21713 \emph on
21714 S
21715 \emph default
21716 ervice 
21717 \emph on
21718 R
21719 \emph default
21720 outines.
21721  The directive should be placed immediately before the ISR function definition
21722  and it affects ALL ISR functions following it.
21723  To enable the normal register saving for ISR functions use #pragma\InsetSpace ~
21724 exclude\InsetSpace ~
21725 none
21726 \begin_inset LatexCommand \index{\#pragma exclude}
21727
21728 \end_inset
21729
21730 .
21731  See also the related keyword _naked
21732 \begin_inset LatexCommand \index{\_naked}
21733
21734 \end_inset
21735
21736
21737 \begin_inset LatexCommand \index{\_\_naked}
21738
21739 \end_inset
21740
21741 .
21742 \end_layout
21743
21744 \begin_layout Itemize
21745
21746 \series bold
21747 less_pedantic
21748 \series default
21749
21750 \begin_inset LatexCommand \index{pedantic}
21751
21752 \end_inset
21753
21754
21755 \begin_inset LatexCommand \index{\#pragma less\_pedantic}
21756
21757 \end_inset
21758
21759  
21760 \begin_inset LatexCommand \label{ite:less_pedantic}
21761
21762 \end_inset
21763
21764 - the compiler will not warn you anymore for obvious mistakes, you're on
21765  your own now ;-( .
21766  See also the command line option -
21767 \begin_inset ERT
21768 status collapsed
21769
21770 \begin_layout Standard
21771
21772
21773 \backslash
21774 /
21775 \end_layout
21776
21777 \end_inset
21778
21779 -less-pedantic 
21780 \begin_inset LatexCommand \vpageref{lyx:--less-pedantic}
21781
21782 \end_inset
21783
21784 .
21785  
21786 \newline
21787 More specifically, the following warnings will be disabled: 
21788 \shape italic
21789 comparison is always [true/false] due to limited range of data type
21790 \shape default
21791  (94); 
21792 \shape italic
21793 overflow in implicit constant conversion
21794 \shape default
21795  (158); [the (in)famous] 
21796 \shape italic
21797 conditional flow changed by optimizer: so said EVELYN the modified DOG
21798 \shape default
21799  (110); 
21800 \shape italic
21801 function '[function name]' must return value
21802 \shape default
21803  (59).
21804  
21805 \newline
21806 Furthermore, warnings of less importance (of PEDANTIC and INFO warning
21807  level) are disabled, too, namely: 
21808 \shape italic
21809 constant value '[
21810 \begin_inset Note Note
21811 status collapsed
21812
21813 \begin_layout Standard
21814 dunno what comes here - this warning appears to be unused altogether
21815 \end_layout
21816
21817 \end_inset
21818
21819 ]', out of range
21820 \shape default
21821  (81); 
21822 \shape italic
21823 [left/right] shifting more than size of object changed to zero
21824 \shape default
21825  (116); 
21826 \shape italic
21827 unreachable code
21828 \shape default
21829  (126); 
21830 \shape italic
21831 integer overflow in expression
21832 \shape default
21833  (165); 
21834 \shape italic
21835 unmatched #pragma save and #pragma restore
21836 \shape default
21837  (170); 
21838 \shape italic
21839 comparison of 'signed char' with 'unsigned char' requires promotion to int
21840 \shape default
21841  (185); 
21842 \shape italic
21843 ISO C90 does not support flexible array members
21844 \shape default
21845  (187); 
21846 \shape italic
21847 extended stack by [number] bytes for compiler temp(s) :in function '[function\InsetSpace ~
21848 nam
21849 e]':\InsetSpace ~
21850 [
21851 \begin_inset Note Note
21852 status collapsed
21853
21854 \begin_layout Standard
21855 appears to be always blank - what was supposed to be here?
21856 \end_layout
21857
21858 \end_inset
21859
21860 ]
21861 \shape default
21862  (114); 
21863 \shape italic
21864 function '[function name]', # edges [number] , # nodes [number] , cyclomatic
21865  complexity [number]
21866 \shape default
21867  (121).
21868 \end_layout
21869
21870 \begin_layout Itemize
21871
21872 \series bold
21873 disable_warning
21874 \series default
21875  <nnnn>
21876 \begin_inset LatexCommand \index{\#pragma disable\_warning}
21877
21878 \end_inset
21879
21880  - the compiler will not warn you anymore about warning number <nnnn>.
21881 \end_layout
21882
21883 \begin_layout Itemize
21884
21885 \series bold
21886 nogcse
21887 \series default
21888
21889 \begin_inset LatexCommand \index{\#pragma nogcse}
21890
21891 \end_inset
21892
21893  - will stop global common subexpression elimination.
21894 \end_layout
21895
21896 \begin_layout Itemize
21897
21898 \series bold
21899 noinduction
21900 \series default
21901
21902 \begin_inset LatexCommand \index{\#pragma noinduction}
21903
21904 \end_inset
21905
21906  - will stop loop induction optimizations.
21907 \end_layout
21908
21909 \begin_layout Itemize
21910
21911 \series bold
21912 noinvariant
21913 \series default
21914
21915 \begin_inset LatexCommand \index{\#pragma noinvariant}
21916
21917 \end_inset
21918
21919  - will not do loop invariant optimizations.
21920  For more details see Loop Invariants in section
21921 \begin_inset LatexCommand \ref{sub:Loop-Optimizations}
21922
21923 \end_inset
21924
21925 .
21926 \end_layout
21927
21928 \begin_layout Itemize
21929
21930 \series bold
21931 noiv
21932 \series default
21933
21934 \begin_inset LatexCommand \index{\#pragma noiv}
21935
21936 \end_inset
21937
21938  - Do not generate interrupt
21939 \begin_inset LatexCommand \index{interrupt}
21940
21941 \end_inset
21942
21943  vector table
21944 \begin_inset LatexCommand \index{interrupt vector table}
21945
21946 \end_inset
21947
21948  entries for all ISR functions defined after the pragma.
21949  This is useful in cases where the interrupt vector table must be defined
21950  manually, or when there is a secondary, manually defined interrupt vector
21951  table (e.g.
21952  for the autovector feature of the Cypress EZ-USB FX2).
21953  More elegantly this can be achieved by obmitting the optional interrupt
21954  number after the interrupt keyword, see section 
21955 \begin_inset LatexCommand \ref{sub:Interrupt-Service-Routines}
21956
21957 \end_inset
21958
21959 \InsetSpace ~
21960 about interrupts.
21961 \end_layout
21962
21963 \begin_layout Itemize
21964
21965 \series bold
21966 nojtbound
21967 \series default
21968
21969 \begin_inset LatexCommand \index{\#pragma nojtbound}
21970
21971 \end_inset
21972
21973  - will not generate code for boundary value checking, when switch statements
21974  are turned into jump-tables (dangerous).
21975  For more details see section 
21976 \begin_inset LatexCommand \ref{sub:'switch'-Statements}
21977
21978 \end_inset
21979
21980 .
21981 \end_layout
21982
21983 \begin_layout Itemize
21984
21985 \series bold
21986 noloopreverse
21987 \series default
21988
21989 \begin_inset LatexCommand \index{\#pragma noloopreverse}
21990
21991 \end_inset
21992
21993  - Will not do loop reversal optimization
21994 \end_layout
21995
21996 \begin_layout Itemize
21997
21998 \series bold
21999 nooverlay
22000 \series default
22001
22002 \begin_inset LatexCommand \index{\#pragma nooverlay}
22003
22004 \end_inset
22005
22006  - the compiler will not overlay the parameters and local variables of a
22007  function.
22008 \end_layout
22009
22010 \begin_layout Itemize
22011
22012 \series bold
22013 stackauto
22014 \series default
22015
22016 \begin_inset LatexCommand \index{\#pragma stackauto}
22017
22018 \end_inset
22019
22020 - See option -
22021 \begin_inset ERT
22022 status collapsed
22023
22024 \begin_layout Standard
22025
22026
22027 \backslash
22028 /
22029 \end_layout
22030
22031 \end_inset
22032
22033 -stack-auto
22034 \begin_inset LatexCommand \index{-\/-stack-auto}
22035
22036 \end_inset
22037
22038  and section 
22039 \begin_inset LatexCommand \ref{sec:Parameters-and-Local-Variables}
22040
22041 \end_inset
22042
22043  Parameters and Local Variables.
22044 \end_layout
22045
22046 \begin_layout Itemize
22047
22048 \series bold
22049 opt_code_speed
22050 \series default
22051  
22052 \begin_inset LatexCommand \index{\#pragma opt\_code\_speed}
22053
22054 \end_inset
22055
22056 - The compiler will optimize code generation towards fast code, possibly
22057  at the expense of code size.
22058  Currently this has little effect.
22059 \end_layout
22060
22061 \begin_layout Itemize
22062
22063 \series bold
22064 opt_code_size
22065 \series default
22066  
22067 \begin_inset LatexCommand \index{\#pragma opt\_code\_size}
22068
22069 \end_inset
22070
22071 - The compiler will optimize code generation towards compact code, possibly
22072  at the expense of code speed.
22073  Currently this has little effect.
22074 \end_layout
22075
22076 \begin_layout Itemize
22077
22078 \series bold
22079 opt_code_balanced
22080 \series default
22081  
22082 \begin_inset LatexCommand \index{\#pragma opt\_code\_balanced}
22083
22084 \end_inset
22085
22086 - The compiler will attempt to generate code that is both compact and fast,
22087  as long as meeting one goal is not a detriment to the other (this is the
22088  default).
22089  
22090 \end_layout
22091
22092 \begin_layout Itemize
22093
22094 \series bold
22095 std_sdcc89
22096 \series default
22097  
22098 \begin_inset LatexCommand \index{\#pragma std\_sdcc89}
22099
22100 \end_inset
22101
22102 - Generally follow the C89 standard, but allow SDCC features that conflict
22103  with the standard (default).
22104 \end_layout
22105
22106 \begin_layout Itemize
22107
22108 \series bold
22109 std_c89
22110 \series default
22111  
22112 \begin_inset LatexCommand \index{\#pragma std\_c89}
22113
22114 \end_inset
22115
22116 - Follow the C89 standard and disable SDCC features that conflict with the
22117  standard.
22118 \end_layout
22119
22120 \begin_layout Itemize
22121
22122 \series bold
22123 std_sdcc99
22124 \series default
22125  
22126 \begin_inset LatexCommand \index{\#pragma std\_sdcc99}
22127
22128 \end_inset
22129
22130 - Generally follow the C99 standard, but allow SDCC features that conflict
22131  with the standard (incomplete support).
22132 \end_layout
22133
22134 \begin_layout Itemize
22135
22136 \series bold
22137 std_c99
22138 \series default
22139  
22140 \begin_inset LatexCommand \index{\#pragma std\_c99}
22141
22142 \end_inset
22143
22144 - Follow the C99 standard and disable SDCC features that conflict with the
22145  standard (incomplete support).
22146 \end_layout
22147
22148 \begin_layout Itemize
22149
22150 \series bold
22151 codeseg
22152 \series default
22153  <name>
22154 \begin_inset LatexCommand \index{\#pragma codeseg}
22155
22156 \end_inset
22157
22158 - Use this name (max.
22159  8 characters) for the code segment.
22160  See option -
22161 \begin_inset ERT
22162 status collapsed
22163
22164 \begin_layout Standard
22165
22166
22167 \backslash
22168 /
22169 \end_layout
22170
22171 \end_inset
22172
22173 -codeseg.
22174 \end_layout
22175
22176 \begin_layout Itemize
22177
22178 \series bold
22179 constseg
22180 \series default
22181  <name>
22182 \begin_inset LatexCommand \index{\#pragma constseg}
22183
22184 \end_inset
22185
22186 - Use this name (max.
22187  8 characters) for the const segment.
22188  See option -
22189 \begin_inset ERT
22190 status collapsed
22191
22192 \begin_layout Standard
22193
22194
22195 \backslash
22196 /
22197 \end_layout
22198
22199 \end_inset
22200
22201 -constseg.
22202 \end_layout
22203
22204 \begin_layout Standard
22205 The preprocessor SDCPP
22206 \begin_inset LatexCommand \index{sdcpp (preprocessor)}
22207
22208 \end_inset
22209
22210  supports the following #pragma directives:
22211 \end_layout
22212
22213 \begin_layout Itemize
22214
22215 \series bold
22216 pedantic_parse_number
22217 \series default
22218
22219 \begin_inset LatexCommand \index{pedantic}
22220
22221 \end_inset
22222
22223
22224 \begin_inset LatexCommand \index{\#pragma pedantic\_parse\_number}
22225
22226 \end_inset
22227
22228  (+ | -) 
22229 \begin_inset LatexCommand \label{ite:pedantic_parse_number}
22230
22231 \end_inset
22232
22233 - Pedantic parse numbers so that situations like 0xfe-LO_B(3) are parsed
22234  properly and the macro LO_B(3) gets expanded.
22235  Default is off.
22236  See also the -
22237 \begin_inset ERT
22238 status collapsed
22239
22240 \begin_layout Standard
22241
22242
22243 \backslash
22244 /
22245 \end_layout
22246
22247 \end_inset
22248
22249 -pedantic-parse-number command line option 
22250 \begin_inset LatexCommand \vpageref{lyx:-pedantic-parse-number}
22251
22252 \end_inset
22253
22254 .
22255  
22256 \newline
22257 Below is an example on how to use this pragma.
22258
22259 \emph on
22260  Note: this functionality is not in conformance with standard!
22261 \end_layout
22262
22263 \begin_layout Verse
22264
22265 \family typewriter
22266 #pragma pedantic_parse_number +
22267 \begin_inset LatexCommand \index{\#pragma pedantic\_parse\_number}
22268
22269 \end_inset
22270
22271
22272 \newline
22273
22274 \newline
22275 #define LO_B(x) ((x) & 0xff)
22276 \newline
22277
22278 \newline
22279 unsigned char foo(void)
22280 \newline
22281 {
22282 \newline
22283 \InsetSpace ~
22284 \InsetSpace ~
22285 \InsetSpace ~
22286 unsigned char c=0xfe-LO_B(3)
22287 ;
22288 \newline
22289
22290 \newline
22291 \InsetSpace ~
22292 \InsetSpace ~
22293 \InsetSpace ~
22294 return c;
22295 \newline
22296 }
22297 \newline
22298
22299 \end_layout
22300
22301 \begin_layout Itemize
22302
22303 \series bold
22304 preproc_asm
22305 \series default
22306
22307 \begin_inset LatexCommand \index{\#pragma preproc\_asm}
22308
22309 \end_inset
22310
22311  (+ | -) - switch _asm _endasm block preprocessing on / off.
22312  Default is on.
22313  You use this prama to define multilines of assembly code.
22314  This will prevent the preprocessor from changing the formating required
22315  by assembly code.
22316  Below is an example on how to use this pragma.
22317 \end_layout
22318
22319 \begin_layout Verse
22320
22321 \family typewriter
22322 #pragma preproc_asm -
22323 \begin_inset LatexCommand \index{\#pragma preproc\_asm}
22324
22325 \end_inset
22326
22327
22328 \newline
22329 #define MYDELAY _asm
22330 \newline
22331 \InsetSpace ~
22332 \InsetSpace ~
22333 \InsetSpace ~
22334 nop ;my assembly comment...
22335 \newline
22336 \InsetSpace ~
22337 \InsetSpace ~
22338 \InsetSpace ~
22339 nop
22340 \newline
22341 \InsetSpace ~
22342 \InsetSpace ~
22343 \InsetSpace ~
22344 nop
22345 \newline
22346 _endasm
22347 \newline
22348 #pragma preproc_asm
22349  +
22350 \newline
22351
22352 \newline
22353 void foo (void) 
22354 \newline
22355
22356 \newline
22357 \InsetSpace ~
22358 \InsetSpace ~
22359 \InsetSpace ~
22360  ...
22361  
22362 \newline
22363 \InsetSpace ~
22364 \InsetSpace ~
22365 \InsetSpace ~
22366  MYDELAY;
22367 \newline
22368 \InsetSpace ~
22369 \InsetSpace ~
22370 \InsetSpace ~
22371  ...
22372  
22373 \newline
22374
22375 \newline
22376
22377 \end_layout
22378
22379 \begin_layout Itemize
22380
22381 \series bold
22382 sdcc_hash
22383 \series default
22384
22385 \begin_inset LatexCommand \index{\#pragma sdcc\_hash}
22386
22387 \end_inset
22388
22389  (+ | -) - Allow "naked" hash in macro definition, for example:
22390 \newline
22391
22392 \family typewriter
22393 #define DIR_LO(x) #(x & 0xff)
22394 \family default
22395
22396 \newline
22397 Default is off.
22398  Below is an example on how to use this pragma.
22399 \end_layout
22400
22401 \begin_layout Verse
22402
22403 \family typewriter
22404 #pragma preproc_asm +
22405 \newline
22406 #pragma sdcc_hash +
22407 \begin_inset LatexCommand \index{\#pragma sdcc\_hash}
22408
22409 \end_inset
22410
22411
22412 \newline
22413
22414 \newline
22415 #define ROMCALL(x) 
22416 \backslash
22417
22418 \newline
22419 \InsetSpace ~
22420 \InsetSpace ~
22421 \InsetSpace ~
22422 mov R6_B3, #(x & 0xff) 
22423 \backslash
22424
22425 \newline
22426 \InsetSpace ~
22427 \InsetSpace ~
22428 \InsetSpace ~
22429 mov R7_B3, #((x >> 8) & 0xff) 
22430 \backslash
22431
22432 \newline
22433 \InsetSpace ~
22434 \InsetSpace ~
22435 \InsetSpace ~
22436 lcall __romcall
22437 \newline
22438
22439 \newline
22440 ...
22441 \newline
22442 _asm
22443 \newline
22444 ROMCALL(72)
22445 \newline
22446 _endasm;
22447 \newline
22448 ...
22449 \newline
22450
22451 \end_layout
22452
22453 \begin_layout Standard
22454 Some of the pragmas are intended to be used to turn-on or off certain optimizati
22455 ons which might cause the compiler to generate extra stack and/or data space
22456  to store compiler generated temporary variables.
22457  This usually happens in large functions.
22458  Pragma directives should be used as shown in the following example, they
22459  are used to control options and optimizations for a given function.
22460  
22461 \end_layout
22462
22463 \begin_layout Verse
22464
22465 \family typewriter
22466 #pragma save
22467 \begin_inset LatexCommand \index{\#pragma save}
22468
22469 \end_inset
22470
22471  \InsetSpace ~
22472 \InsetSpace ~
22473 \InsetSpace ~
22474 \InsetSpace ~
22475 \InsetSpace ~
22476 \InsetSpace ~
22477 \InsetSpace ~
22478 /* save the current settings */ 
22479 \newline
22480 #pragma nogcse
22481 \begin_inset LatexCommand \index{\#pragma nogcse}
22482
22483 \end_inset
22484
22485  \InsetSpace ~
22486 \InsetSpace ~
22487 \InsetSpace ~
22488 \InsetSpace ~
22489 \InsetSpace ~
22490 /* turnoff global subexpression elimination */ 
22491 \newline
22492 #pragma noinduction
22493 \begin_inset LatexCommand \index{\#pragma noinduction}
22494
22495 \end_inset
22496
22497  /* turn off induction optimizations */ 
22498 \newline
22499 int foo () 
22500 \newline
22501
22502 \newline
22503 \InsetSpace ~
22504  \InsetSpace ~
22505  ...
22506  
22507 \newline
22508 \InsetSpace ~
22509  \InsetSpace ~
22510  /* large code */ 
22511 \newline
22512 \InsetSpace ~
22513  \InsetSpace ~
22514  ...
22515  
22516 \newline
22517
22518 \newline
22519 #pragma restore
22520 \begin_inset LatexCommand \index{\#pragma restore}
22521
22522 \end_inset
22523
22524  /* turn the optimizations back on */
22525 \end_layout
22526
22527 \begin_layout Standard
22528 The compiler will generate a warning message when extra space is allocated.
22529  It is strongly recommended that the save and restore pragmas be used when
22530  changing options for a function.
22531 \newline
22532
22533 \newline
22534
22535 \newline
22536
22537 \end_layout
22538
22539 \begin_layout Section
22540 Defines Created by the Compiler
22541 \end_layout
22542
22543 \begin_layout Standard
22544 The compiler creates the following #defines
22545 \begin_inset LatexCommand \index{\#defines}
22546
22547 \end_inset
22548
22549
22550 \begin_inset LatexCommand \index{Defines created by the compiler}
22551
22552 \end_inset
22553
22554 :
22555 \newline
22556
22557 \end_layout
22558
22559 \begin_layout Standard
22560 \begin_inset Tabular
22561 <lyxtabular version="3" rows="11" columns="2">
22562 <features>
22563 <column alignment="left" valignment="top" leftline="true" width="3in">
22564 <column alignment="left" valignment="top" leftline="true" rightline="true" width="3in">
22565 <row topline="true" bottomline="true">
22566 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
22567 \begin_inset Text
22568
22569 \begin_layout Standard
22570
22571 \series bold
22572 #define
22573 \end_layout
22574
22575 \end_inset
22576 </cell>
22577 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
22578 \begin_inset Text
22579
22580 \begin_layout Standard
22581
22582 \series bold
22583 Description
22584 \end_layout
22585
22586 \end_inset
22587 </cell>
22588 </row>
22589 <row topline="true">
22590 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
22591 \begin_inset Text
22592
22593 \begin_layout Standard
22594 SDCC
22595 \begin_inset LatexCommand \index{SDCC}
22596
22597 \end_inset
22598
22599  
22600 \end_layout
22601
22602 \end_inset
22603 </cell>
22604 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
22605 \begin_inset Text
22606
22607 \begin_layout Standard
22608 Always defined.
22609  Since version 2.5.6 the version number as an int (ex.
22610  256)
22611 \end_layout
22612
22613 \end_inset
22614 </cell>
22615 </row>
22616 <row topline="true">
22617 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
22618 \begin_inset Text
22619
22620 \begin_layout Standard
22621 SDCC_mcs51
22622 \begin_inset LatexCommand \index{SDCC\_mcs51}
22623
22624 \end_inset
22625
22626  or SDCC_ds390
22627 \begin_inset LatexCommand \index{SDCC\_ds390}
22628
22629 \end_inset
22630
22631  or SDCC_z80
22632 \begin_inset LatexCommand \index{SDCC\_z80}
22633
22634 \end_inset
22635
22636 , etc.
22637 \end_layout
22638
22639 \end_inset
22640 </cell>
22641 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
22642 \begin_inset Text
22643
22644 \begin_layout Standard
22645 depending on the model used (e.g.: -mds390)
22646 \end_layout
22647
22648 \end_inset
22649 </cell>
22650 </row>
22651 <row topline="true">
22652 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
22653 \begin_inset Text
22654
22655 \begin_layout Standard
22656 __mcs51
22657 \begin_inset LatexCommand \index{\_\_mcs51}
22658
22659 \end_inset
22660
22661 , __ds390
22662 \begin_inset LatexCommand \index{\_\_ds390}
22663
22664 \end_inset
22665
22666 , __hc08
22667 \begin_inset LatexCommand \index{\_\_hc08}
22668
22669 \end_inset
22670
22671 , __z80
22672 \begin_inset LatexCommand \index{\_\_z80}
22673
22674 \end_inset
22675
22676 , etc
22677 \end_layout
22678
22679 \end_inset
22680 </cell>
22681 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
22682 \begin_inset Text
22683
22684 \begin_layout Standard
22685 depending on the model used (e.g.
22686  -mz80)
22687 \end_layout
22688
22689 \end_inset
22690 </cell>
22691 </row>
22692 <row topline="true">
22693 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
22694 \begin_inset Text
22695
22696 \begin_layout Standard
22697 SDCC_STACK_AUTO
22698 \begin_inset LatexCommand \index{SDCC\_STACK\_AUTO}
22699
22700 \end_inset
22701
22702
22703 \end_layout
22704
22705 \end_inset
22706 </cell>
22707 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
22708 \begin_inset Text
22709
22710 \begin_layout Standard
22711 when 
22712 \emph on
22713 -
22714 \begin_inset ERT
22715 status collapsed
22716
22717 \begin_layout Standard
22718
22719
22720 \backslash
22721 /
22722 \end_layout
22723
22724 \end_inset
22725
22726 -stack-auto
22727 \emph default
22728  option is used
22729 \end_layout
22730
22731 \end_inset
22732 </cell>
22733 </row>
22734 <row topline="true">
22735 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
22736 \begin_inset Text
22737
22738 \begin_layout Standard
22739 SDCC_MODEL_SMALL
22740 \begin_inset LatexCommand \index{SDCC\_MODEL\_SMALL}
22741
22742 \end_inset
22743
22744
22745 \end_layout
22746
22747 \end_inset
22748 </cell>
22749 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
22750 \begin_inset Text
22751
22752 \begin_layout Standard
22753 when 
22754 \emph on
22755 -
22756 \begin_inset ERT
22757 status collapsed
22758
22759 \begin_layout Standard
22760
22761
22762 \backslash
22763 /
22764 \end_layout
22765
22766 \end_inset
22767
22768 -model-small
22769 \emph default
22770  is used
22771 \end_layout
22772
22773 \end_inset
22774 </cell>
22775 </row>
22776 <row topline="true">
22777 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
22778 \begin_inset Text
22779
22780 \begin_layout Standard
22781 SDCC_MODEL_MEDIUM
22782 \begin_inset LatexCommand \index{SDCC\_MODEL\_MEDIUM}
22783
22784 \end_inset
22785
22786
22787 \end_layout
22788
22789 \end_inset
22790 </cell>
22791 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
22792 \begin_inset Text
22793
22794 \begin_layout Standard
22795 when 
22796 \emph on
22797 -
22798 \begin_inset ERT
22799 status collapsed
22800
22801 \begin_layout Standard
22802
22803
22804 \backslash
22805 /
22806 \end_layout
22807
22808 \end_inset
22809
22810 -model-medium
22811 \emph default
22812  is used
22813 \end_layout
22814
22815 \end_inset
22816 </cell>
22817 </row>
22818 <row topline="true">
22819 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
22820 \begin_inset Text
22821
22822 \begin_layout Standard
22823 SDCC_MODEL_LARGE
22824 \begin_inset LatexCommand \index{SDCC\_MODEL\_LARGE}
22825
22826 \end_inset
22827
22828
22829 \end_layout
22830
22831 \end_inset
22832 </cell>
22833 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
22834 \begin_inset Text
22835
22836 \begin_layout Standard
22837 when 
22838 \emph on
22839 -
22840 \begin_inset ERT
22841 status collapsed
22842
22843 \begin_layout Standard
22844
22845
22846 \backslash
22847 /
22848 \end_layout
22849
22850 \end_inset
22851
22852 -model-large
22853 \emph default
22854  is used
22855 \end_layout
22856
22857 \end_inset
22858 </cell>
22859 </row>
22860 <row topline="true">
22861 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
22862 \begin_inset Text
22863
22864 \begin_layout Standard
22865 SDCC_USE_XSTACK
22866 \begin_inset LatexCommand \index{SDCC\_USE\_XSTACK}
22867
22868 \end_inset
22869
22870
22871 \end_layout
22872
22873 \end_inset
22874 </cell>
22875 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
22876 \begin_inset Text
22877
22878 \begin_layout Standard
22879 when 
22880 \emph on
22881 -
22882 \begin_inset ERT
22883 status collapsed
22884
22885 \begin_layout Standard
22886
22887
22888 \backslash
22889 /
22890 \end_layout
22891
22892 \end_inset
22893
22894 -xstack
22895 \emph default
22896  option is used
22897 \end_layout
22898
22899 \end_inset
22900 </cell>
22901 </row>
22902 <row topline="true">
22903 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
22904 \begin_inset Text
22905
22906 \begin_layout Standard
22907 SDCC_STACK_TENBIT
22908 \begin_inset LatexCommand \index{SDCC\_STACK\_TENBIT}
22909
22910 \end_inset
22911
22912  
22913 \end_layout
22914
22915 \end_inset
22916 </cell>
22917 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
22918 \begin_inset Text
22919
22920 \begin_layout Standard
22921 when 
22922 \emph on
22923 -mds390
22924 \emph default
22925  is used
22926 \end_layout
22927
22928 \end_inset
22929 </cell>
22930 </row>
22931 <row topline="true" bottomline="true">
22932 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
22933 \begin_inset Text
22934
22935 \begin_layout Standard
22936 SDCC_MODEL_FLAT24
22937 \begin_inset LatexCommand \index{SDCC\_MODEL\_FLAT24}
22938
22939 \end_inset
22940
22941
22942 \end_layout
22943
22944 \end_inset
22945 </cell>
22946 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
22947 \begin_inset Text
22948
22949 \begin_layout Standard
22950 when 
22951 \emph on
22952 -mds390
22953 \emph default
22954  is used
22955 \end_layout
22956
22957 \end_inset
22958 </cell>
22959 </row>
22960 </lyxtabular>
22961
22962 \end_inset
22963
22964
22965 \end_layout
22966
22967 \begin_layout Chapter
22968 Notes on supported Processors
22969 \end_layout
22970
22971 \begin_layout Section
22972 MCS51 variants
22973 \begin_inset LatexCommand \label{sub:MCS51-variants}
22974
22975 \end_inset
22976
22977
22978 \begin_inset LatexCommand \index{MCS51 variants}
22979
22980 \end_inset
22981
22982
22983 \end_layout
22984
22985 \begin_layout Standard
22986 MCS51 processors are available from many vendors and come in many different
22987  flavours.
22988  While they might differ considerably in respect to Special Function Registers
22989  the core MCS51 is usually not modified or is kept compatible.
22990  
22991 \end_layout
22992
22993 \begin_layout Subsection
22994 pdata access by SFR 
22995 \end_layout
22996
22997 \begin_layout Standard
22998 With the upcome of devices with internal xdata and flash memory devices
22999  using port P2
23000 \begin_inset LatexCommand \index{P2 (mcs51 sfr)}
23001
23002 \end_inset
23003
23004  as dedicated I/O port is becoming more popular.
23005  Switching the high byte for pdata
23006 \begin_inset LatexCommand \index{pdata (mcs51, ds390 storage class)}
23007
23008 \end_inset
23009
23010  access which was formerly done by port P2 is then achieved by a Special
23011  Function Register
23012 \begin_inset LatexCommand \index{sfr}
23013
23014 \end_inset
23015
23016 .
23017  In well-established MCS51 tradition the address of this 
23018 \emph on
23019 sfr
23020 \emph default
23021  is where the chip designers decided to put it.
23022  Needless to say that they didn't agree on a common name either.
23023  So that the startup code can correctly initialize xdata variables, you
23024  should define an sfr with the name _XPAGE
23025 \family typewriter
23026
23027 \begin_inset LatexCommand \index{\_XPAGE (mcs51)}
23028
23029 \end_inset
23030
23031
23032 \family default
23033  at the appropriate location if the default, port P2, is not used for this.
23034  Some examples are:
23035 \end_layout
23036
23037 \begin_layout Verse
23038
23039 \family typewriter
23040 __sfr __at (0x85) _XPAGE; /* Ramtron VRS51 family a.k.a.
23041  MPAGE */
23042 \end_layout
23043
23044 \begin_layout Verse
23045
23046 \family typewriter
23047 __sfr __at (0x92) _XPAGE; /* Cypress EZ-USB family, Texas Instruments (Chipcon)
23048  a.k.a.
23049  MPAGE */
23050 \end_layout
23051
23052 \begin_layout Verse
23053
23054 \family typewriter
23055 __sfr __at (0x91) _XPAGE; /* Infineon (Siemens) C500 family a.k.a.
23056  XPAGE */
23057 \end_layout
23058
23059 \begin_layout Verse
23060
23061 \family typewriter
23062 __sfr __at (0xaf) _XPAGE; /* some Silicon Labs (Cygnal) chips a.k.a.
23063  EMI0CN */
23064 \end_layout
23065
23066 \begin_layout Verse
23067
23068 \family typewriter
23069 __sfr __at (0xaa) _XPAGE; /* some Silicon Labs (Cygnal) chips a.k.a.
23070  EMI0CN */
23071 \end_layout
23072
23073 \begin_layout Standard
23074 For more exotic implementations further customizations may be needed.
23075  See section 
23076 \begin_inset LatexCommand \ref{sub:Startup-Code}
23077
23078 \end_inset
23079
23080  for other possibilities.
23081 \end_layout
23082
23083 \begin_layout Subsection
23084 Other Features available by SFR
23085 \end_layout
23086
23087 \begin_layout Standard
23088 Some MCS51 variants offer features like Double DPTR
23089 \begin_inset LatexCommand \index{DPTR}
23090
23091 \end_inset
23092
23093 , multiple DPTR, decrementing DPTR, 16x16 Multiply.
23094  These are currently not used for the MCS51 port.
23095  If you absolutely need them you can fall back to inline assembly or submit
23096  a patch to SDCC.
23097 \begin_inset VSpace bigskip
23098 \end_inset
23099
23100
23101 \end_layout
23102
23103 \begin_layout Section
23104 DS400 port
23105 \end_layout
23106
23107 \begin_layout Standard
23108 The DS80C400
23109 \begin_inset LatexCommand \index{DS80C400}
23110
23111 \end_inset
23112
23113
23114 \begin_inset LatexCommand \index{DS400}
23115
23116 \end_inset
23117
23118  microcontroller has a rich set of peripherals.
23119  In its built-in ROM library it includes functions to access some of the
23120  features, among them is a TCP stack with IP4 and IP6 support.
23121  Library headers (currently in beta status) and other files are provided
23122  at 
23123 \size footnotesize
23124
23125 \begin_inset LatexCommand \url{ftp://ftp.dalsemi.com/pub/tini/ds80c400/c_libraries/sdcc/index.html}
23126
23127 \end_inset
23128
23129 .
23130  
23131 \begin_inset VSpace bigskip
23132 \end_inset
23133
23134
23135 \end_layout
23136
23137 \begin_layout Section
23138 The Z80 and gbz80 port
23139 \end_layout
23140
23141 \begin_layout Standard
23142 SDCC can target both the Zilog Z80
23143 \begin_inset LatexCommand \index{Z80}
23144
23145 \end_inset
23146
23147  and the Nintendo Gameboy's Z80-like gbz80
23148 \begin_inset LatexCommand \index{gbz80 (GameBoy Z80)}
23149
23150 \end_inset
23151
23152 .
23153  The Z80 port is passed through the same 
23154 \emph on
23155 regressions tests
23156 \begin_inset LatexCommand \index{Regression test}
23157
23158 \end_inset
23159
23160
23161 \emph default
23162  (see section 
23163 \begin_inset LatexCommand \ref{sec:Quality-control}
23164
23165 \end_inset
23166
23167 ) as the MCS51 and DS390 ports, so floating point support, support for long
23168  variables and bitfield support is fine.
23169  See mailing lists and forums about interrupt routines.
23170 \end_layout
23171
23172 \begin_layout Standard
23173 As always, the code is the authoritative reference - see z80/ralloc.c and
23174  z80/gen.c.
23175  The stack
23176 \begin_inset LatexCommand \index{Z80!stack}
23177
23178 \end_inset
23179
23180  frame is similar to that generated by the IAR Z80 compiler.
23181  IX is used as the base pointer, HL and IY are used as a temporary registers,
23182  and BC and DE are available for holding variables.
23183  Return values
23184 \begin_inset LatexCommand \index{Z80!return value}
23185
23186 \end_inset
23187
23188  for the Z80 port are stored in L (one byte), HL (two bytes), or DEHL (four
23189  bytes).
23190  The gbz80 port use the same set of registers for the return values, but
23191  in a different order of significance: E (one byte), DE (two bytes), or
23192  HLDE (four bytes).
23193 \begin_inset VSpace bigskip
23194 \end_inset
23195
23196
23197 \end_layout
23198
23199 \begin_layout Section
23200 The HC08 port
23201 \end_layout
23202
23203 \begin_layout Standard
23204 The port to the Freescale/Motorola HC08
23205 \begin_inset LatexCommand \index{HC08}
23206
23207 \end_inset
23208
23209  family has been added in October 2003, and is still undergoing some basic
23210  development.
23211  The code generator is complete, but the register allocation is still quite
23212  unoptimized.
23213  Some of the SDCC's standard C library functions have embedded non-HC08
23214  inline assembly and so are not yet usable.
23215 \end_layout
23216
23217 \begin_layout Standard
23218 The HC08 port passes the regression test suite (see section 
23219 \begin_inset LatexCommand \ref{sec:Quality-control}
23220
23221 \end_inset
23222
23223 ).
23224 \begin_inset VSpace bigskip
23225 \end_inset
23226
23227
23228 \newpage
23229
23230 \end_layout
23231
23232 \begin_layout Section
23233 The PIC14
23234 \begin_inset LatexCommand \index{PIC14}
23235
23236 \end_inset
23237
23238  port
23239 \end_layout
23240
23241 \begin_layout Standard
23242 The PIC14 port adds support for Microchip
23243 \begin_inset LatexCommand \index{Microchip}
23244
23245 \end_inset
23246
23247
23248 \begin_inset Formula $^{\text{TM}}$
23249 \end_inset
23250
23251  PIC
23252 \begin_inset LatexCommand \index{PIC14}
23253
23254 \end_inset
23255
23256
23257 \begin_inset Formula $^{\text{TM}}$
23258 \end_inset
23259
23260  MCUs with 14 bit wide instructions.
23261  This port is not yet mature and still lacks many features.
23262  However, it can work for simple code.
23263 \end_layout
23264
23265 \begin_layout Standard
23266 Currently supported devices include:
23267 \end_layout
23268
23269 \begin_layout Standard
23270 12F: 629, 635, 675, 683
23271 \end_layout
23272
23273 \begin_layout Standard
23274 16C: 432, 433
23275 \end_layout
23276
23277 \begin_layout Standard
23278 16C: 554, 557, 558
23279 \end_layout
23280
23281 \begin_layout Standard
23282 16C: 62, 620, 620a, 621, 621a, 622, 622a, 63a, 65b
23283 \end_layout
23284
23285 \begin_layout Standard
23286 16C: 71, 710, 711, 715, 717, 72, 73b, 745, 74b, 765, 770, 771, 773, 774,
23287  781, 782
23288 \end_layout
23289
23290 \begin_layout Standard
23291 16C: 925, 926
23292 \end_layout
23293
23294 \begin_layout Standard
23295 16F: 627, 627a, 628, 628a, 630, 636, 639, 648a, 676, 684, 685, 687, 688,
23296  689, 690
23297 \end_layout
23298
23299 \begin_layout Standard
23300 16F: 716, 72, 73, 737, 74, 76, 767, 77, 777, 785
23301 \end_layout
23302
23303 \begin_layout Standard
23304 16F: 818, 819, 84, 84a, 87, 870, 871, 872, 873, 873a, 874, 874a, 876, 876a,
23305  877, 877a, 88
23306 \end_layout
23307
23308 \begin_layout Standard
23309 16F: 913, 914, 916, 917
23310 \end_layout
23311
23312 \begin_layout Standard
23313 An up-to-date list of currently supported devices can be obtained via 
23314 \family typewriter
23315 sdcc -mpic14 -phelp foo.c
23316 \family default
23317  (foo.c must exist...).
23318 \end_layout
23319
23320 \begin_layout Subsection
23321 PIC Code Pages
23322 \begin_inset LatexCommand \index{code page (pic14)}
23323
23324 \end_inset
23325
23326  and Memory Banks
23327 \begin_inset LatexCommand \index{Memory bank (pic14)}
23328
23329 \end_inset
23330
23331
23332 \end_layout
23333
23334 \begin_layout Standard
23335 The linker organizes allocation for the code page and RAM banks.
23336  It does not have intimate knowledge of the code flow.
23337  It will put all the code section of a single .asm file into a single code
23338  page.
23339  In order to make use of multiple code pages, separate asm files must be
23340  used.
23341  The compiler assigns all 
23342 \emph on
23343 static
23344 \emph default
23345  functions of a single .c file into the same code page.
23346 \newline
23347
23348 \newline
23349 To get the best results,
23350  follow these guidelines:
23351 \end_layout
23352
23353 \begin_layout Enumerate
23354 Make local functions static, as non static functions require code page selection
23355  overhead.
23356 \newline
23357 Due to the way sdcc handles functions, place called functions prior
23358  to calling functions in the file wherever possible: Otherwise sdcc will
23359  insert unneccessary pagesel directives around the call, believing that
23360  the called function is externally defined.
23361 \end_layout
23362
23363 \begin_layout Enumerate
23364 For devices that have multiple code pages it is more efficient to use the
23365  same number of files as pages: Use up to 4 separate .c files for the 16F877,
23366  but only 2 files for the 16F874.
23367  This way the linker can put the code for each file into different code
23368  pages and there will be less page selection overhead.
23369 \end_layout
23370
23371 \begin_layout Enumerate
23372 And as for any 8 bit micro (especially for PIC14 as they have a very simple
23373  instruction set), use `unsigned char' wherever possible instead of `int'.
23374 \end_layout
23375
23376 \begin_layout Subsection
23377 Adding New Devices to the Port 
23378 \end_layout
23379
23380 \begin_layout Standard
23381 Adding support for a new 14
23382 \begin_inset ERT
23383 status open
23384
23385 \begin_layout Standard
23386
23387
23388 \backslash
23389 ,
23390 \end_layout
23391
23392 \end_inset
23393
23394 bit PIC MCU requires the following steps:
23395 \end_layout
23396
23397 \begin_layout Enumerate
23398 Create a new device description.
23399 \newline
23400 Each device is described in two files: pic16f*.h
23401  and pic16f*.c.
23402  These files primarily define SFRs, structs to access their bits, and symbolic
23403  configuration options.
23404  Both files can be generated from gputils' .inc files using the perl script
23405  
23406 \family typewriter
23407 support/scripts/inc2h.pl
23408 \family default
23409 .
23410  This file also contains further instructions on how to proceed.
23411 \end_layout
23412
23413 \begin_layout Enumerate
23414 Copy the .h file into SDCC's include path and either add the .c file to your
23415  project or copy it to 
23416 \family typewriter
23417 device/lib/pic/libdev
23418 \family default
23419 .
23420  Afterwards, rebuild and install the libraries.
23421 \end_layout
23422
23423 \begin_layout Enumerate
23424 Edit pic14devices.txt in SDCC's include path (
23425 \family typewriter
23426 device/include/pic/
23427 \family default
23428  in the source tree or 
23429 \family typewriter
23430 /usr/local/share/sdcc/include/pic
23431 \family default
23432  after installation).
23433 \newline
23434 You need to add a device specification here to make
23435  the memory layout (code banks, RAM, aliased memory regions, ...) known to
23436  the compiler.
23437  Probably you can copy and modify an existing entry.
23438  The file format is documented at the top of the file.
23439 \end_layout
23440
23441 \begin_layout Subsection
23442 Interrupt Code
23443 \end_layout
23444
23445 \begin_layout Standard
23446 For the interrupt function, use the keyword `__interrupt'
23447 \begin_inset LatexCommand \index{PIC14!interrupt}
23448
23449 \end_inset
23450
23451  with level number of 0 (PIC14 only has 1 interrupt so this number is only
23452  there to avoid a syntax error - it ought to be fixed).
23453  E.g.:
23454 \end_layout
23455
23456 \begin_layout Verse
23457
23458 \family typewriter
23459 void Intr(void) __interrupt 0
23460 \newline
23461 {
23462 \newline
23463 \InsetSpace ~
23464 \InsetSpace ~
23465 T0IF = 0; /* Clear timer interrupt */
23466 \newline
23467 }
23468 \end_layout
23469
23470 \begin_layout Subsection
23471 Linking and Assembling
23472 \end_layout
23473
23474 \begin_layout Standard
23475 For assembling you can use either GPUTILS'
23476 \begin_inset LatexCommand \index{gputils (pic tools)}
23477
23478 \end_inset
23479
23480  gpasm.exe or MPLAB's mpasmwin.exe.
23481  GPUTILS are available from 
23482 \begin_inset LatexCommand \url{http://sourceforge.net/projects/gputils}
23483
23484 \end_inset
23485
23486 .
23487  For linking you can use either GPUTILS' gplink or MPLAB's mplink.exe.
23488  If you use MPLAB and an interrupt function then the linker script file
23489  vectors section will need to be enlarged to link with mplink.
23490 \newline
23491
23492 \newline
23493 Here is a 
23494 \family typewriter
23495 Makefile
23496 \family default
23497  using GPUTILS:
23498 \end_layout
23499
23500 \begin_layout Verse
23501
23502 \family typewriter
23503 .c.o:
23504 \newline
23505 \InsetSpace ~
23506 \InsetSpace ~
23507 \InsetSpace ~
23508 \InsetSpace ~
23509 \InsetSpace ~
23510 \InsetSpace ~
23511 \InsetSpace ~
23512 \InsetSpace ~
23513 sdcc -V -mpic14 -p16f877 -c $< 
23514 \newline
23515
23516 \newline
23517 $(PRJ).hex: $(OBJS) 
23518 \newline
23519 \InsetSpace ~
23520 \InsetSpace ~
23521 \InsetSpace ~
23522 \InsetSpace ~
23523 \InsetSpace ~
23524 \InsetSpace ~
23525 \InsetSpace ~
23526 \InsetSpace ~
23527 gplink -m -s $(PRJ).lkr
23528  -o $(PRJ).hex $(OBJS) libsdcc.lib
23529 \end_layout
23530
23531 \begin_layout Standard
23532 Here is a 
23533 \family typewriter
23534 Makefile
23535 \family default
23536  using MPLAB:
23537 \end_layout
23538
23539 \begin_layout Verse
23540
23541 \family typewriter
23542 .c.o: 
23543 \newline
23544 \InsetSpace ~
23545 \InsetSpace ~
23546 \InsetSpace ~
23547 \InsetSpace ~
23548 \InsetSpace ~
23549 \InsetSpace ~
23550 \InsetSpace ~
23551 \InsetSpace ~
23552 sdcc -S -V -mpic14 -p16f877 $< 
23553 \newline
23554 \InsetSpace ~
23555 \InsetSpace ~
23556 \InsetSpace ~
23557 \InsetSpace ~
23558 \InsetSpace ~
23559 \InsetSpace ~
23560 \InsetSpace ~
23561 \InsetSpace ~
23562 mpasmwin /q /o $*.asm
23563 \newline
23564
23565 \newline
23566 $(PRJ).hex: $(OBJS)
23567  
23568 \newline
23569 \InsetSpace ~
23570 \InsetSpace ~
23571 \InsetSpace ~
23572 \InsetSpace ~
23573 \InsetSpace ~
23574 \InsetSpace ~
23575 \InsetSpace ~
23576 \InsetSpace ~
23577 mplink /v $(PRJ).lkr /m $(PRJ).map /o $(PRJ).hex $(OBJS) libsdcc.lib
23578 \end_layout
23579
23580 \begin_layout Standard
23581 Please note that indentations within a
23582 \family typewriter
23583  Makefile
23584 \family default
23585  have to be done with a tabulator character.
23586 \end_layout
23587
23588 \begin_layout Subsection
23589 Command-Line Options
23590 \end_layout
23591
23592 \begin_layout Standard
23593 Besides the switches common to all SDCC backends, the PIC14 port accepts
23594  the following options (for an updated list see sdcc -
23595 \begin_inset ERT
23596 status collapsed
23597
23598 \begin_layout Standard
23599
23600
23601 \backslash
23602 /
23603 \end_layout
23604
23605 \end_inset
23606
23607 -help):
23608 \end_layout
23609
23610 \begin_layout Description
23611 -
23612 \begin_inset ERT
23613 status collapsed
23614
23615 \begin_layout Standard
23616
23617
23618 \backslash
23619 /
23620 \end_layout
23621
23622 \end_inset
23623
23624 -debug-xtra
23625 \begin_inset LatexCommand \index{PIC14!Options!-\/-debug-extra}
23626
23627 \end_inset
23628
23629  emit debug info in assembly output
23630 \end_layout
23631
23632 \begin_layout Description
23633 -
23634 \begin_inset ERT
23635 status collapsed
23636
23637 \begin_layout Standard
23638
23639
23640 \backslash
23641 /
23642 \end_layout
23643
23644 \end_inset
23645
23646 -no-pcode-opt
23647 \begin_inset LatexCommand \index{PIC14!Options!-\/-no-pcode-opt}
23648
23649 \end_inset
23650
23651  disable (slightly faulty) optimization on pCode
23652 \end_layout
23653
23654 \begin_layout Description
23655 -
23656 \begin_inset ERT
23657 status collapsed
23658
23659 \begin_layout Standard
23660
23661
23662 \backslash
23663 /
23664 \end_layout
23665
23666 \end_inset
23667
23668 -stack-loc
23669 \begin_inset LatexCommand \index{PIC14!Options!-\/-stack-loc}
23670
23671 \end_inset
23672
23673  sets the lowest address of the argument passing stack (defaults to a suitably
23674  large shared databank to reduce BANKSEL overhead)
23675 \end_layout
23676
23677 \begin_layout Description
23678 -
23679 \begin_inset ERT
23680 status collapsed
23681
23682 \begin_layout Standard
23683
23684
23685 \backslash
23686 /
23687 \end_layout
23688
23689 \end_inset
23690
23691 -stack-size
23692 \begin_inset LatexCommand \index{PIC14!Options!-\/-stack-size}
23693
23694 \end_inset
23695
23696  sets the size if the argument passing stack (default: 16, minimum: 4)
23697 \end_layout
23698
23699 \begin_layout Subsection
23700 Environment Variables
23701 \end_layout
23702
23703 \begin_layout Standard
23704 The PIC14 port recognizes the following environment variables:
23705 \end_layout
23706
23707 \begin_layout Description
23708 SDCC_PIC14_SPLIT_LOCALS If set and not empty, sdcc will allocate each temporary
23709  register (the ones called r0xNNNN) in a section of its own.
23710  By default (if this variable is unset), sdcc tries to cluster registers
23711  in sections in order to reduce the BANKSEL overhead when accessing them.
23712 \end_layout
23713
23714 \begin_layout Subsection
23715 The Library
23716 \end_layout
23717
23718 \begin_layout Standard
23719 The PIC14 library currently only contains support routines required by the
23720  compiler to implement multiplication, division, and floating point support.
23721  No libc-like replacement is available at the moment, though many of the
23722  common sdcc library sources (in 
23723 \family typewriter
23724 device/lib
23725 \family default
23726 ) should also compile with the PIC14 port.
23727 \end_layout
23728
23729 \begin_layout Subsubsection
23730 error: missing definition for symbol ``__gptrget1''
23731 \end_layout
23732
23733 \begin_layout Standard
23734 The PIC14 port uses library routines to provide more complex operations
23735  like multiplication, division/modulus and (generic) pointer dereferencing.
23736  In order to add these routines to your project, you must link with PIC14's
23737  
23738 \family typewriter
23739 libsdcc.lib
23740 \family default
23741 .
23742  For single source file projects this is done automatically, more complex
23743  projects must add 
23744 \family typewriter
23745 libsdcc.lib
23746 \family default
23747  to the linker's arguments.
23748  Make sure you also add an include path for the library (using the -I switch
23749  to the linker)!
23750 \end_layout
23751
23752 \begin_layout Subsubsection
23753 Processor mismatch in file ``XXX''.
23754 \end_layout
23755
23756 \begin_layout Standard
23757 This warning can usually be ignored due to the very good compatibility amongst
23758  14
23759 \begin_inset ERT
23760 status open
23761
23762 \begin_layout Standard
23763
23764
23765 \backslash
23766 ,
23767 \end_layout
23768
23769 \end_inset
23770
23771 bit PIC
23772 \begin_inset LatexCommand \index{PIC14}
23773
23774 \end_inset
23775
23776  devices.
23777 \end_layout
23778
23779 \begin_layout Standard
23780 You might also consider recompiling the library for your specific device
23781  by changing the ARCH=p16f877 (default target) entry in 
23782 \family typewriter
23783 device/lib/pic/Makefile.in
23784 \family default
23785  and 
23786 \family typewriter
23787 device/lib/pic/Makefile
23788 \family default
23789  to reflect your device.
23790  This might even improve performance for smaller devices as unneccesary
23791  BANKSELs might be removed.
23792 \end_layout
23793
23794 \begin_layout Subsection
23795 Known Bugs
23796 \end_layout
23797
23798 \begin_layout Subsubsection
23799 Function arguments
23800 \end_layout
23801
23802 \begin_layout Standard
23803 Functions with variable argument lists (like printf) are not yet supported.
23804  Similarly, taking the argument of the first argument passed into a function
23805  does not work: It is currently passed in WREG and has no address...
23806 \end_layout
23807
23808 \begin_layout Subsubsection
23809 Regression tests fail
23810 \end_layout
23811
23812 \begin_layout Standard
23813 Though the small subset of regression tests in src/regression passes, SDCC
23814  regression test suite does not, indicating that there are still major bugs
23815  in the port.
23816  However, many smaller projects have successfully used SDCC in the past...
23817 \end_layout
23818
23819 \begin_layout Standard
23820
23821 \size footnotesize
23822
23823 \newpage
23824
23825 \end_layout
23826
23827 \begin_layout Section
23828 The PIC16
23829 \begin_inset LatexCommand \index{PIC16}
23830
23831 \end_inset
23832
23833  port
23834 \end_layout
23835
23836 \begin_layout Standard
23837 The PIC16 port adds support for Microchip
23838 \begin_inset LatexCommand \index{Microchip}
23839
23840 \end_inset
23841
23842
23843 \begin_inset Formula $^{\text{TM}}$
23844 \end_inset
23845
23846  PIC
23847 \begin_inset LatexCommand \index{PIC}
23848
23849 \end_inset
23850
23851
23852 \begin_inset Formula $^{\text{TM}}$
23853 \end_inset
23854
23855  MCUs with 16 bit wide instructions.
23856  Currently this family of microcontrollers contains the PIC18Fxxx and PIC18Fxxxx
23857 ; devices supported by the port include:
23858 \end_layout
23859
23860 \begin_layout Standard
23861 18F: 242, 248, 252, 258, 442, 448, 452, 458
23862 \end_layout
23863
23864 \begin_layout Standard
23865 18F: 1220, 1320
23866 \end_layout
23867
23868 \begin_layout Standard
23869 18F: 2220, 2221, 2320, 2321, 2331, 2431, 2455, 24j10, 2525, 2550, 25j10,
23870  2620
23871 \end_layout
23872
23873 \begin_layout Standard
23874 18F: 4220, 4221, 4320, 4321, 4331, 4431, 4455, 44j10, 4520, 4525, 4550,
23875  45j10, 4620
23876 \end_layout
23877
23878 \begin_layout Standard
23879 18F: 6520, 6620, 6680, 6720
23880 \end_layout
23881
23882 \begin_layout Standard
23883 18F: 8520, 8620, 8680, 8720
23884 \end_layout
23885
23886 \begin_layout Subsection
23887 Global Options
23888 \end_layout
23889
23890 \begin_layout Standard
23891 PIC16 port supports the standard command line arguments as supposed, with
23892  the exception of certain cases that will be mentioned in the following
23893  list:
23894 \end_layout
23895
23896 \begin_layout Description
23897 -
23898 \begin_inset ERT
23899 status collapsed
23900
23901 \begin_layout Standard
23902
23903
23904 \backslash
23905 /
23906 \end_layout
23907
23908 \end_inset
23909
23910 -callee-saves
23911 \begin_inset LatexCommand \index{PIC16!Options!-\/-callee-saves}
23912
23913 \end_inset
23914
23915  See -
23916 \begin_inset ERT
23917 status collapsed
23918
23919 \begin_layout Standard
23920
23921
23922 \backslash
23923 /
23924 \end_layout
23925
23926 \end_inset
23927
23928 -all-callee-saves
23929 \end_layout
23930
23931 \begin_layout Description
23932 -
23933 \begin_inset ERT
23934 status collapsed
23935
23936 \begin_layout Standard
23937
23938
23939 \backslash
23940 /
23941 \end_layout
23942
23943 \end_inset
23944
23945 -fommit-frame-pointer
23946 \begin_inset LatexCommand \index{PIC16!Options!-\/-fommit-frame-pointer}
23947
23948 \end_inset
23949
23950  Frame pointer will be omitted when the function uses no local variables.
23951 \end_layout
23952
23953 \begin_layout Subsection
23954 Port Specific Options
23955 \begin_inset LatexCommand \index{Options PIC16}
23956
23957 \end_inset
23958
23959
23960 \end_layout
23961
23962 \begin_layout Standard
23963 The port specific options appear after the global options in the sdcc -
23964 \begin_inset ERT
23965 status collapsed
23966
23967 \begin_layout Standard
23968
23969
23970 \backslash
23971 /
23972 \end_layout
23973
23974 \end_inset
23975
23976 -help output.
23977 \end_layout
23978
23979 \begin_layout Subsubsection
23980 Code Generation Options
23981 \end_layout
23982
23983 \begin_layout Standard
23984 These options influence the generated assembler code.
23985 \end_layout
23986
23987 \begin_layout Description
23988 -
23989 \begin_inset ERT
23990 status collapsed
23991
23992 \begin_layout Standard
23993
23994
23995 \backslash
23996 /
23997 \end_layout
23998
23999 \end_inset
24000
24001 -pstack-model=[model] Used in conjuction with the command above.
24002  Defines the stack model to be used, valid stack models are:
24003 \end_layout
24004
24005 \begin_deeper
24006 \begin_layout List
24007 \labelwidthstring 00.00.0000
24008
24009 \emph on
24010 small
24011 \emph default
24012  Selects small stack model.
24013  8 bit stack and frame pointers.
24014  Supports 256 bytes stack size.
24015 \end_layout
24016
24017 \begin_layout List
24018 \labelwidthstring 00.00.0000
24019
24020 \emph on
24021 large
24022 \emph default
24023  Selects large stack model.
24024  16 bit stack and frame pointers.
24025  Supports 65536 bytes stack size.
24026 \end_layout
24027
24028 \end_deeper
24029 \begin_layout Description
24030 -
24031 \begin_inset ERT
24032 status collapsed
24033
24034 \begin_layout Standard
24035
24036
24037 \backslash
24038 /
24039 \end_layout
24040
24041 \end_inset
24042
24043 -pno-banksel Do not generate BANKSEL assembler directives.
24044 \end_layout
24045
24046 \begin_layout Description
24047 -
24048 \begin_inset ERT
24049 status collapsed
24050
24051 \begin_layout Standard
24052
24053
24054 \backslash
24055 /
24056 \end_layout
24057
24058 \end_inset
24059
24060 -extended Enable extended instruction set/literal offset addressing mode.
24061  Use with care!
24062 \end_layout
24063
24064 \begin_layout Subsubsection
24065 Optimization Options
24066 \end_layout
24067
24068 \begin_layout Description
24069 -
24070 \begin_inset ERT
24071 status collapsed
24072
24073 \begin_layout Standard
24074
24075
24076 \backslash
24077 /
24078 \end_layout
24079
24080 \end_inset
24081
24082 -obanksel=n Set optimization level for inserting BANKSELs.
24083 \newline
24084
24085 \end_layout
24086
24087 \begin_deeper
24088 \begin_layout List
24089 \labelwidthstring 00.00.0000
24090 0 no optimization
24091 \end_layout
24092
24093 \begin_layout List
24094 \labelwidthstring 00.00.0000
24095 1 checks previous used register and if it is the same then does not emit
24096  BANKSEL, accounts only for labels.
24097 \end_layout
24098
24099 \begin_layout List
24100 \labelwidthstring 00.00.0000
24101 2 tries to check the location of (even different) symbols and removes BANKSELs
24102  if they are in the same bank.
24103  
24104 \newline
24105
24106 \emph on
24107 Important: There might be problems if the linker script has data sections
24108  across bank borders!
24109 \end_layout
24110
24111 \end_deeper
24112 \begin_layout Description
24113 -
24114 \begin_inset ERT
24115 status collapsed
24116
24117 \begin_layout Standard
24118
24119
24120 \backslash
24121 /
24122 \end_layout
24123
24124 \end_inset
24125
24126 -denable-peeps Force the usage of peepholes.
24127  Use with care.
24128 \end_layout
24129
24130 \begin_layout Description
24131 -
24132 \begin_inset ERT
24133 status collapsed
24134
24135 \begin_layout Standard
24136
24137
24138 \backslash
24139 /
24140 \end_layout
24141
24142 \end_inset
24143
24144 -optimize-goto Try to use (conditional) BRA instead of GOTO.
24145 \end_layout
24146
24147 \begin_layout Description
24148 -
24149 \begin_inset ERT
24150 status collapsed
24151
24152 \begin_layout Standard
24153
24154
24155 \backslash
24156 /
24157 \end_layout
24158
24159 \end_inset
24160
24161 -optimize-cmp Try to optimize some compares.
24162 \end_layout
24163
24164 \begin_layout Description
24165 -
24166 \begin_inset ERT
24167 status collapsed
24168
24169 \begin_layout Standard
24170
24171
24172 \backslash
24173 /
24174 \end_layout
24175
24176 \end_inset
24177
24178 -optimize-df Analyze the dataflow of the generated code and improve it.
24179 \end_layout
24180
24181 \begin_layout Subsubsection
24182 Assembling Options
24183 \end_layout
24184
24185 \begin_layout Description
24186 -
24187 \begin_inset ERT
24188 status collapsed
24189
24190 \begin_layout Standard
24191
24192
24193 \backslash
24194 /
24195 \end_layout
24196
24197 \end_inset
24198
24199 -asm= Sets the full path and name of an external assembler to call.
24200 \end_layout
24201
24202 \begin_layout Description
24203 -
24204 \begin_inset ERT
24205 status collapsed
24206
24207 \begin_layout Standard
24208
24209
24210 \backslash
24211 /
24212 \end_layout
24213
24214 \end_inset
24215
24216 -mplab-comp MPLAB
24217 \begin_inset LatexCommand \index{PIC16!MPLAB}
24218
24219 \end_inset
24220
24221  compatibility option.
24222  Currently only suppresses special gpasm directives.
24223 \end_layout
24224
24225 \begin_layout Subsubsection
24226 Linking Options
24227 \end_layout
24228
24229 \begin_layout Description
24230 -
24231 \begin_inset ERT
24232 status collapsed
24233
24234 \begin_layout Standard
24235
24236
24237 \backslash
24238 /
24239 \end_layout
24240
24241 \end_inset
24242
24243 -link= Sets the full path and name of an external linker to call.
24244 \end_layout
24245
24246 \begin_layout Description
24247 -
24248 \begin_inset ERT
24249 status collapsed
24250
24251 \begin_layout Standard
24252
24253
24254 \backslash
24255 /
24256 \end_layout
24257
24258 \end_inset
24259
24260 -preplace-udata-with=[kword] Replaces the default udata keyword for allocating
24261  unitialized data variables with [kword].
24262  Valid keywords are: "udata_acs", "udata_shr", "udata_ovr".
24263 \end_layout
24264
24265 \begin_layout Description
24266 -
24267 \begin_inset ERT
24268 status collapsed
24269
24270 \begin_layout Standard
24271
24272
24273 \backslash
24274 /
24275 \end_layout
24276
24277 \end_inset
24278
24279 -ivt-loc=n Place the interrupt vector table at address 
24280 \emph on
24281 n
24282 \emph default
24283 .
24284  Useful for bootloaders.
24285 \end_layout
24286
24287 \begin_layout Description
24288 -
24289 \begin_inset ERT
24290 status collapsed
24291
24292 \begin_layout Standard
24293
24294
24295 \backslash
24296 /
24297 \end_layout
24298
24299 \end_inset
24300
24301 -nodefaultlibs Do not link default libraries when linking.
24302 \end_layout
24303
24304 \begin_layout Description
24305 -
24306 \begin_inset ERT
24307 status collapsed
24308
24309 \begin_layout Standard
24310
24311
24312 \backslash
24313 /
24314 \end_layout
24315
24316 \end_inset
24317
24318 -use-crt= Use a custom run-time module instead of the defaults.
24319 \end_layout
24320
24321 \begin_layout Description
24322 -
24323 \begin_inset ERT
24324 status collapsed
24325
24326 \begin_layout Standard
24327
24328
24329 \backslash
24330 /
24331 \end_layout
24332
24333 \end_inset
24334
24335 -no-crt Don't link the default run-time modules
24336 \end_layout
24337
24338 \begin_layout Subsubsection
24339 Debugging Options
24340 \end_layout
24341
24342 \begin_layout Standard
24343 Debugging options enable extra debugging information in the output files.
24344 \end_layout
24345
24346 \begin_layout Description
24347 -
24348 \begin_inset ERT
24349 status collapsed
24350
24351 \begin_layout Standard
24352
24353
24354 \backslash
24355 /
24356 \end_layout
24357
24358 \end_inset
24359
24360 -debug-xtra Similar to -
24361 \begin_inset ERT
24362 status collapsed
24363
24364 \begin_layout Standard
24365
24366
24367 \backslash
24368 /
24369 \end_layout
24370
24371 \end_inset
24372
24373 -debug
24374 \begin_inset LatexCommand \index{-\/-debug}
24375
24376 \end_inset
24377
24378 , but dumps more information.
24379 \end_layout
24380
24381 \begin_layout Description
24382 -
24383 \begin_inset ERT
24384 status collapsed
24385
24386 \begin_layout Standard
24387
24388
24389 \backslash
24390 /
24391 \end_layout
24392
24393 \end_inset
24394
24395 -debug-ralloc Force register allocator to dump <source>.d file with debugging
24396  information.
24397  <source> is the name of the file being compiled.
24398 \end_layout
24399
24400 \begin_layout Description
24401 -
24402 \begin_inset ERT
24403 status collapsed
24404
24405 \begin_layout Standard
24406
24407
24408 \backslash
24409 /
24410 \end_layout
24411
24412 \end_inset
24413
24414 -pcode-verbose Enable pcode debugging information in translation.
24415 \end_layout
24416
24417 \begin_layout Description
24418 -
24419 \begin_inset ERT
24420 status collapsed
24421
24422 \begin_layout Standard
24423
24424
24425 \backslash
24426 /
24427 \end_layout
24428
24429 \end_inset
24430
24431 -calltree Dump call tree in .calltree file.
24432 \end_layout
24433
24434 \begin_layout Description
24435 -
24436 \begin_inset ERT
24437 status collapsed
24438
24439 \begin_layout Standard
24440
24441
24442 \backslash
24443 /
24444 \end_layout
24445
24446 \end_inset
24447
24448 -gstack Trace push/pops for stack pointer overflow.
24449 \end_layout
24450
24451 \begin_layout Subsection
24452 Enviroment Variables
24453 \end_layout
24454
24455 \begin_layout Standard
24456 There is a number of enviromental variables that can be used when running
24457  SDCC to enable certain optimizations or force a specific program behaviour.
24458  these variables are primarily for debugging purposes so they can be enabled/dis
24459 abled at will.
24460 \end_layout
24461
24462 \begin_layout Standard
24463 Currently there is only two such variables available:
24464 \end_layout
24465
24466 \begin_layout Description
24467 OPTIMIZE_BITFIELD_POINTER_GET When this variable exists, reading of structure
24468  bitfields is optimized by directly loading FSR0 with the address of the
24469  bitfield structure.
24470  Normally SDCC will cast the bitfield structure to a bitfield pointer and
24471  then load FSR0.
24472  This step saves data ram and code space for functions that make heavy use
24473  of bitfields.
24474  (i.e., 80 bytes of code space are saved when compiling malloc.c with this
24475  option).
24476  
24477 \end_layout
24478
24479 \begin_layout Description
24480 NO_REG_OPT Do not perform pCode registers optimization.
24481  This should be used for debugging purposes.
24482  If bugs in the pcode optimizer are found, users can benefit from temporarily
24483  disabling the optimizer until the bug is fixed.
24484 \end_layout
24485
24486 \begin_layout Subsection
24487 Preprocessor Macros
24488 \end_layout
24489
24490 \begin_layout Standard
24491 PIC16
24492 \begin_inset LatexCommand \index{PIC16}
24493
24494 \end_inset
24495
24496  port defines the following preprocessor macros while translating a source.
24497 \end_layout
24498
24499 \begin_layout Standard
24500 \align center
24501 \begin_inset Tabular
24502 <lyxtabular version="3" rows="6" columns="2">
24503 <features>
24504 <column alignment="center" valignment="top" leftline="true" width="0">
24505 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
24506 <row topline="true" bottomline="true">
24507 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
24508 \begin_inset Text
24509
24510 \begin_layout Standard
24511 Macro
24512 \end_layout
24513
24514 \end_inset
24515 </cell>
24516 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
24517 \begin_inset Text
24518
24519 \begin_layout Standard
24520 Description
24521 \end_layout
24522
24523 \end_inset
24524 </cell>
24525 </row>
24526 <row topline="true">
24527 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
24528 \begin_inset Text
24529
24530 \begin_layout Standard
24531 SDCC_pic16
24532 \end_layout
24533
24534 \end_inset
24535 </cell>
24536 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
24537 \begin_inset Text
24538
24539 \begin_layout Standard
24540 Port identification
24541 \end_layout
24542
24543 \end_inset
24544 </cell>
24545 </row>
24546 <row topline="true">
24547 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
24548 \begin_inset Text
24549
24550 \begin_layout Standard
24551 _
24552 \begin_inset ERT
24553 status collapsed
24554
24555 \begin_layout Standard
24556
24557
24558 \backslash
24559 /
24560 \end_layout
24561
24562 \end_inset
24563
24564 _pic16
24565 \end_layout
24566
24567 \end_inset
24568 </cell>
24569 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
24570 \begin_inset Text
24571
24572 \begin_layout Standard
24573 Port identification (same as above)
24574 \end_layout
24575
24576 \end_inset
24577 </cell>
24578 </row>
24579 <row topline="true">
24580 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
24581 \begin_inset Text
24582
24583 \begin_layout Standard
24584 pic18fxxxx
24585 \end_layout
24586
24587 \end_inset
24588 </cell>
24589 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
24590 \begin_inset Text
24591
24592 \begin_layout Standard
24593 MCU Identification.
24594  
24595 \emph on
24596 xxxx
24597 \emph default
24598  is the microcontrol identification number, i.e.
24599  452, 6620, etc
24600 \end_layout
24601
24602 \end_inset
24603 </cell>
24604 </row>
24605 <row topline="true">
24606 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
24607 \begin_inset Text
24608
24609 \begin_layout Standard
24610 _
24611 \begin_inset ERT
24612 status collapsed
24613
24614 \begin_layout Standard
24615
24616
24617 \backslash
24618 /
24619 \end_layout
24620
24621 \end_inset
24622
24623 _18Fxxxx
24624 \end_layout
24625
24626 \end_inset
24627 </cell>
24628 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
24629 \begin_inset Text
24630
24631 \begin_layout Standard
24632 MCU Identification (same as above)
24633 \end_layout
24634
24635 \end_inset
24636 </cell>
24637 </row>
24638 <row topline="true" bottomline="true">
24639 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
24640 \begin_inset Text
24641
24642 \begin_layout Standard
24643 STACK_MODEL_nnn
24644 \end_layout
24645
24646 \end_inset
24647 </cell>
24648 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
24649 \begin_inset Text
24650
24651 \begin_layout Standard
24652 nnn = SMALL or LARGE respectively according to the stack model used
24653 \end_layout
24654
24655 \end_inset
24656 </cell>
24657 </row>
24658 </lyxtabular>
24659
24660 \end_inset
24661
24662
24663 \end_layout
24664
24665 \begin_layout Standard
24666 In addition the following macros are defined when calling assembler:
24667 \end_layout
24668
24669 \begin_layout Standard
24670 \align center
24671 \begin_inset Tabular
24672 <lyxtabular version="3" rows="4" columns="2">
24673 <features>
24674 <column alignment="center" valignment="top" leftline="true" width="0">
24675 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
24676 <row topline="true" bottomline="true">
24677 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
24678 \begin_inset Text
24679
24680 \begin_layout Standard
24681 Macro
24682 \end_layout
24683
24684 \end_inset
24685 </cell>
24686 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
24687 \begin_inset Text
24688
24689 \begin_layout Standard
24690 Description
24691 \end_layout
24692
24693 \end_inset
24694 </cell>
24695 </row>
24696 <row topline="true">
24697 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
24698 \begin_inset Text
24699
24700 \begin_layout Standard
24701 __18Fxxxx
24702 \end_layout
24703
24704 \end_inset
24705 </cell>
24706 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
24707 \begin_inset Text
24708
24709 \begin_layout Standard
24710 MCU Identification.
24711  
24712 \emph on
24713 xxxx
24714 \emph default
24715  is the microcontrol identification number, i.e.
24716  452, 6620, etc
24717 \end_layout
24718
24719 \end_inset
24720 </cell>
24721 </row>
24722 <row topline="true">
24723 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
24724 \begin_inset Text
24725
24726 \begin_layout Standard
24727 SDCC_MODEL_nnn
24728 \end_layout
24729
24730 \end_inset
24731 </cell>
24732 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
24733 \begin_inset Text
24734
24735 \begin_layout Standard
24736 nnn = SMALL or LARGE respectively according to the memory model used for
24737  SDCC
24738 \end_layout
24739
24740 \end_inset
24741 </cell>
24742 </row>
24743 <row topline="true" bottomline="true">
24744 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
24745 \begin_inset Text
24746
24747 \begin_layout Standard
24748 STACK_MODEL_nnn
24749 \end_layout
24750
24751 \end_inset
24752 </cell>
24753 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
24754 \begin_inset Text
24755
24756 \begin_layout Standard
24757 nnn = SMALL or LARGE respectively according to the stack model used
24758 \end_layout
24759
24760 \end_inset
24761 </cell>
24762 </row>
24763 </lyxtabular>
24764
24765 \end_inset
24766
24767
24768 \end_layout
24769
24770 \begin_layout Subsection
24771 Directories
24772 \end_layout
24773
24774 \begin_layout Standard
24775 PIC16
24776 \begin_inset LatexCommand \index{PIC16}
24777
24778 \end_inset
24779
24780  port uses the following directories for searching header files and libraries.
24781 \end_layout
24782
24783 \begin_layout Standard
24784 \align center
24785 \begin_inset Tabular
24786 <lyxtabular version="3" rows="3" columns="4">
24787 <features>
24788 <column alignment="center" valignment="top" leftline="true" width="0">
24789 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
24790 <column alignment="center" valignment="top" width="0">
24791 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
24792 <row topline="true" bottomline="true">
24793 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
24794 \begin_inset Text
24795
24796 \begin_layout Standard
24797 Directory
24798 \end_layout
24799
24800 \end_inset
24801 </cell>
24802 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
24803 \begin_inset Text
24804
24805 \begin_layout Standard
24806 Description
24807 \end_layout
24808
24809 \end_inset
24810 </cell>
24811 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
24812 \begin_inset Text
24813
24814 \begin_layout Standard
24815 Target
24816 \end_layout
24817
24818 \end_inset
24819 </cell>
24820 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
24821 \begin_inset Text
24822
24823 \begin_layout Standard
24824 Command prefix
24825 \end_layout
24826
24827 \end_inset
24828 </cell>
24829 </row>
24830 <row topline="true">
24831 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
24832 \begin_inset Text
24833
24834 \begin_layout Standard
24835 PREFIX/sdcc/include/pic16
24836 \end_layout
24837
24838 \end_inset
24839 </cell>
24840 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
24841 \begin_inset Text
24842
24843 \begin_layout Standard
24844 PIC16 specific headers
24845 \end_layout
24846
24847 \end_inset
24848 </cell>
24849 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
24850 \begin_inset Text
24851
24852 \begin_layout Standard
24853 Compiler
24854 \end_layout
24855
24856 \end_inset
24857 </cell>
24858 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
24859 \begin_inset Text
24860
24861 \begin_layout Standard
24862 -I
24863 \end_layout
24864
24865 \end_inset
24866 </cell>
24867 </row>
24868 <row topline="true" bottomline="true">
24869 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
24870 \begin_inset Text
24871
24872 \begin_layout Standard
24873 PREFIX/sdcc/lib/pic16
24874 \end_layout
24875
24876 \end_inset
24877 </cell>
24878 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
24879 \begin_inset Text
24880
24881 \begin_layout Standard
24882 PIC16 specific libraries
24883 \end_layout
24884
24885 \end_inset
24886 </cell>
24887 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
24888 \begin_inset Text
24889
24890 \begin_layout Standard
24891 Linker
24892 \end_layout
24893
24894 \end_inset
24895 </cell>
24896 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
24897 \begin_inset Text
24898
24899 \begin_layout Standard
24900 -L
24901 \end_layout
24902
24903 \end_inset
24904 </cell>
24905 </row>
24906 </lyxtabular>
24907
24908 \end_inset
24909
24910
24911 \end_layout
24912
24913 \begin_layout Subsection
24914 Pragmas
24915 \begin_inset LatexCommand \label{sub:PIC16_Pragmas}
24916
24917 \end_inset
24918
24919
24920 \end_layout
24921
24922 \begin_layout Standard
24923 The PIC16
24924 \begin_inset LatexCommand \index{PIC16}
24925
24926 \end_inset
24927
24928  port currently supports the following pragmas:
24929 \end_layout
24930
24931 \begin_layout Description
24932 stack
24933 \begin_inset LatexCommand \index{PIC16!Pragmas!\#pragma stack}
24934
24935 \end_inset
24936
24937  This forces the code generator to initialize the stack & frame pointers
24938  at a specific address.
24939  This is an ad hoc solution for cases where no STACK directive is available
24940  in the linker script or gplink is not instructed to create a stack section.
24941 \newline
24942 The
24943  stack pragma should be used only once in a project.
24944  Multiple pragmas may result in indeterminate behaviour of the program.
24945 \begin_inset Foot
24946 status open
24947
24948 \begin_layout Standard
24949 The old format (ie.
24950  #pragma stack 0x5ff) is deprecated and will cause the stack pointer to
24951  cross page boundaries (or even exceed the available data RAM) and crash
24952  the program.
24953  Make sure that stack does not cross page boundaries when using the SMALL
24954  stack model.
24955 \end_layout
24956
24957 \end_inset
24958
24959
24960 \newline
24961 The format is as follows:
24962 \newline
24963
24964 \end_layout
24965
24966 \begin_layout LyX-Code
24967 #pragma stack bottom_address [stack_size]
24968 \newline
24969
24970 \end_layout
24971
24972 \begin_layout Standard
24973
24974 \emph on
24975 bottom_address
24976 \emph default
24977  is the lower bound of the stack section.
24978  The stack pointer initially will point at address (bottom_address+stack_size-1).
24979 \end_layout
24980
24981 \begin_layout LyX-Code
24982 Example:
24983 \end_layout
24984
24985 \begin_layout LyX-Code
24986
24987 \end_layout
24988
24989 \begin_layout LyX-Code
24990 /* initializes stack of 100 bytes at RAM address 0x200 */
24991 \end_layout
24992
24993 \begin_layout LyX-Code
24994 #pragma stack 0x200 100
24995 \end_layout
24996
24997 \begin_layout Standard
24998 If the stack_size field is omitted then a stack is created with the default
24999  size of 64.
25000  This size might be enough for most programs, but its not enough for operations
25001  with deep function nesting or excessive stack usage.
25002 \end_layout
25003
25004 \begin_layout Description
25005 code
25006 \begin_inset LatexCommand \index{PIC16!Pragmas!\#pragma code}
25007
25008 \end_inset
25009
25010  Force a function to a static FLASH address.
25011 \end_layout
25012
25013 \begin_layout LyX-Code
25014 Example:
25015 \end_layout
25016
25017 \begin_layout LyX-Code
25018
25019 \end_layout
25020
25021 \begin_layout LyX-Code
25022 /* place function test_func at 0x4000 */
25023 \end_layout
25024
25025 \begin_layout LyX-Code
25026 #pragma code test_func 0x4000
25027 \end_layout
25028
25029 \begin_layout LyX-Code
25030
25031 \end_layout
25032
25033 \begin_layout Description
25034 library instructs the linker to use a library module.
25035 \newline
25036 Usage:
25037 \end_layout
25038
25039 \begin_layout LyX-Code
25040 #pragma library module_name
25041 \end_layout
25042
25043 \begin_layout Standard
25044
25045 \emph on
25046 module_name
25047 \emph default
25048  can be any library or object file (including its path).
25049  Note that there are four reserved keywords which have special meaning.
25050  These are:
25051 \end_layout
25052
25053 \begin_layout Standard
25054 \align center
25055 \begin_inset Tabular
25056 <lyxtabular version="3" rows="6" columns="3">
25057 <features>
25058 <column alignment="center" valignment="top" leftline="true" width="0">
25059 <column alignment="block" valignment="top" leftline="true" width="20page%">
25060 <column alignment="left" valignment="top" leftline="true" rightline="true" width="0">
25061 <row topline="true" bottomline="true">
25062 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25063 \begin_inset Text
25064
25065 \begin_layout Standard
25066 Keyword
25067 \end_layout
25068
25069 \end_inset
25070 </cell>
25071 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25072 \begin_inset Text
25073
25074 \begin_layout Standard
25075 Description
25076 \end_layout
25077
25078 \end_inset
25079 </cell>
25080 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
25081 \begin_inset Text
25082
25083 \begin_layout Standard
25084 Module to link
25085 \end_layout
25086
25087 \end_inset
25088 </cell>
25089 </row>
25090 <row topline="true">
25091 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25092 \begin_inset Text
25093
25094 \begin_layout Standard
25095
25096 \series bold
25097 ignore
25098 \end_layout
25099
25100 \end_inset
25101 </cell>
25102 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25103 \begin_inset Text
25104
25105 \begin_layout Standard
25106 ignore all library pragmas
25107 \end_layout
25108
25109 \end_inset
25110 </cell>
25111 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
25112 \begin_inset Text
25113
25114 \begin_layout Standard
25115
25116 \emph on
25117 (none)
25118 \end_layout
25119
25120 \end_inset
25121 </cell>
25122 </row>
25123 <row topline="true">
25124 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25125 \begin_inset Text
25126
25127 \begin_layout Standard
25128
25129 \series bold
25130 c
25131 \end_layout
25132
25133 \end_inset
25134 </cell>
25135 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25136 \begin_inset Text
25137
25138 \begin_layout Standard
25139 link the C library
25140 \end_layout
25141
25142 \end_inset
25143 </cell>
25144 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
25145 \begin_inset Text
25146
25147 \begin_layout Standard
25148
25149 \emph on
25150 libc18f
25151 \emph default
25152 .lib
25153 \end_layout
25154
25155 \end_inset
25156 </cell>
25157 </row>
25158 <row topline="true">
25159 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25160 \begin_inset Text
25161
25162 \begin_layout Standard
25163
25164 \series bold
25165 math
25166 \end_layout
25167
25168 \end_inset
25169 </cell>
25170 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25171 \begin_inset Text
25172
25173 \begin_layout Standard
25174 link the Math libarary
25175 \end_layout
25176
25177 \end_inset
25178 </cell>
25179 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
25180 \begin_inset Text
25181
25182 \begin_layout Standard
25183
25184 \emph on
25185 libm18f
25186 \emph default
25187 .lib
25188 \end_layout
25189
25190 \end_inset
25191 </cell>
25192 </row>
25193 <row topline="true">
25194 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25195 \begin_inset Text
25196
25197 \begin_layout Standard
25198
25199 \series bold
25200 io
25201 \end_layout
25202
25203 \end_inset
25204 </cell>
25205 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25206 \begin_inset Text
25207
25208 \begin_layout Standard
25209 link the I/O library
25210 \end_layout
25211
25212 \end_inset
25213 </cell>
25214 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
25215 \begin_inset Text
25216
25217 \begin_layout Standard
25218
25219 \emph on
25220 libio18f*
25221 \emph default
25222 .lib
25223 \end_layout
25224
25225 \end_inset
25226 </cell>
25227 </row>
25228 <row topline="true" bottomline="true">
25229 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25230 \begin_inset Text
25231
25232 \begin_layout Standard
25233
25234 \series bold
25235 debug
25236 \end_layout
25237
25238 \end_inset
25239 </cell>
25240 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25241 \begin_inset Text
25242
25243 \begin_layout Standard
25244 link the debug library
25245 \end_layout
25246
25247 \end_inset
25248 </cell>
25249 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
25250 \begin_inset Text
25251
25252 \begin_layout Standard
25253
25254 \emph on
25255 libdebug
25256 \emph default
25257 .lib
25258 \end_layout
25259
25260 \end_inset
25261 </cell>
25262 </row>
25263 </lyxtabular>
25264
25265 \end_inset
25266
25267
25268 \newline
25269 * is the device number, i.e.
25270  452 for PIC18F452 MCU.
25271 \end_layout
25272
25273 \begin_layout Standard
25274 This feature allows for linking with specific libraries withoug having to
25275  explicit name them in the command line.
25276  Note that the 
25277 \noun on
25278 ignore
25279 \noun default
25280  keyword will reject all modules specified by the library pragma.
25281 \end_layout
25282
25283 \begin_layout Description
25284 udata The pragma udata instructs the compiler to emit code so that linker
25285  will place a variable at a specific memory bank.
25286 \end_layout
25287
25288 \begin_layout LyX-Code
25289 Example:
25290 \end_layout
25291
25292 \begin_layout LyX-Code
25293
25294 \end_layout
25295
25296 \begin_layout LyX-Code
25297 /* places variable foo at bank2 */
25298 \end_layout
25299
25300 \begin_layout LyX-Code
25301 #pragma udata bank2 foo
25302 \end_layout
25303
25304 \begin_layout LyX-Code
25305 char foo;
25306 \end_layout
25307
25308 \begin_layout Standard
25309 In order for this pragma to work extra SECTION directives should be added
25310  in the .lkr script.
25311  In the following example a sample .lkr file is shown:
25312 \end_layout
25313
25314 \begin_layout LyX-Code
25315
25316 \end_layout
25317
25318 \begin_layout LyX-Code
25319 // Sample linker script for the PIC18F452 processor
25320 \end_layout
25321
25322 \begin_layout LyX-Code
25323 LIBPATH .
25324 \end_layout
25325
25326 \begin_layout LyX-Code
25327 CODEPAGE   NAME=vectors    START=0x0            END=0x29           PROTECTED
25328 \end_layout
25329
25330 \begin_layout LyX-Code
25331 CODEPAGE   NAME=page       START=0x2A           END=0x7FFF
25332 \end_layout
25333
25334 \begin_layout LyX-Code
25335 CODEPAGE   NAME=idlocs     START=0x200000       END=0x200007       PROTECTED
25336 \end_layout
25337
25338 \begin_layout LyX-Code
25339 CODEPAGE   NAME=config     START=0x300000       END=0x30000D       PROTECTED
25340 \end_layout
25341
25342 \begin_layout LyX-Code
25343 CODEPAGE   NAME=devid      START=0x3FFFFE       END=0x3FFFFF       PROTECTED
25344 \end_layout
25345
25346 \begin_layout LyX-Code
25347 CODEPAGE   NAME=eedata     START=0xF00000       END=0xF000FF       PROTECTED
25348 \end_layout
25349
25350 \begin_layout LyX-Code
25351 ACCESSBANK NAME=accessram  START=0x0            END=0x7F
25352 \end_layout
25353
25354 \begin_layout LyX-Code
25355
25356 \end_layout
25357
25358 \begin_layout LyX-Code
25359 DATABANK   NAME=gpr0       START=0x80           END=0xFF
25360 \end_layout
25361
25362 \begin_layout LyX-Code
25363 DATABANK   NAME=gpr1       START=0x100          END=0x1FF
25364 \end_layout
25365
25366 \begin_layout LyX-Code
25367 DATABANK   NAME=gpr2       START=0x200          END=0x2FF
25368 \end_layout
25369
25370 \begin_layout LyX-Code
25371 DATABANK   NAME=gpr3       START=0x300          END=0x3FF
25372 \end_layout
25373
25374 \begin_layout LyX-Code
25375 DATABANK   NAME=gpr4       START=0x400          END=0x4FF
25376 \end_layout
25377
25378 \begin_layout LyX-Code
25379 DATABANK   NAME=gpr5       START=0x500          END=0x5FF
25380 \end_layout
25381
25382 \begin_layout LyX-Code
25383 ACCESSBANK NAME=accesssfr  START=0xF80          END=0xFFF          PROTECTED
25384 \end_layout
25385
25386 \begin_layout LyX-Code
25387
25388 \end_layout
25389
25390 \begin_layout LyX-Code
25391 SECTION    NAME=CONFIG     ROM=config
25392 \end_layout
25393
25394 \begin_layout LyX-Code
25395
25396 \end_layout
25397
25398 \begin_layout LyX-Code
25399 SECTION    NAME=bank0      RAM=gpr0       # these SECTION directives
25400 \end_layout
25401
25402 \begin_layout LyX-Code
25403 SECTION    NAME=bank1      RAM=gpr1       # should be added to link
25404 \end_layout
25405
25406 \begin_layout LyX-Code
25407 SECTION    NAME=bank2      RAM=gpr2       # section name 'bank?' with
25408 \end_layout
25409
25410 \begin_layout LyX-Code
25411 SECTION    NAME=bank3      RAM=gpr3       # a specific DATABANK name
25412 \end_layout
25413
25414 \begin_layout LyX-Code
25415 SECTION    NAME=bank4      RAM=gpr4
25416 \end_layout
25417
25418 \begin_layout LyX-Code
25419 SECTION    NAME=bank5      RAM=gpr5
25420 \end_layout
25421
25422 \begin_layout Standard
25423 The linker will recognise the section name set in the pragma statement and
25424  will position the variable at the memory bank set with the RAM field at
25425  the SECTION line in the linker script file.
25426 \end_layout
25427
25428 \begin_layout Subsection
25429 Header Files
25430 \begin_inset LatexCommand \label{sub:PIC16_Header-Files}
25431
25432 \end_inset
25433
25434
25435 \end_layout
25436
25437 \begin_layout Standard
25438 There is one main header file
25439 \begin_inset LatexCommand \index{PIC16!Header files}
25440
25441 \end_inset
25442
25443  that can be included to the source files using the pic16
25444 \begin_inset LatexCommand \index{PIC16}
25445
25446 \end_inset
25447
25448  port.
25449  That file is the 
25450 \series bold
25451 pic18fregs.h
25452 \series default
25453 .
25454  This header file contains the definitions for the processor special registers,
25455  so it is necessary if the source accesses them.
25456  It can be included by adding the following line in the beginning of the
25457  file:
25458 \end_layout
25459
25460 \begin_layout LyX-Code
25461 #include <pic18fregs.h>
25462 \end_layout
25463
25464 \begin_layout Standard
25465 The specific microcontroller is selected within the pic18fregs.h automatically,
25466  so the same source can be used with a variety of devices.
25467 \end_layout
25468
25469 \begin_layout Subsection
25470 Libraries
25471 \end_layout
25472
25473 \begin_layout Standard
25474 The libraries
25475 \begin_inset LatexCommand \index{PIC16!Libraries}
25476
25477 \end_inset
25478
25479  that PIC16
25480 \begin_inset LatexCommand \index{PIC16}
25481
25482 \end_inset
25483
25484  port depends on are the microcontroller device libraries which contain
25485  the symbol definitions for the microcontroller special function registers.
25486  These libraries have the format pic18fxxxx.lib, where 
25487 \emph on
25488 xxxx
25489 \emph default
25490  is the microcontroller identification number.
25491  The specific library is selected automatically by the compiler at link
25492  stage according to the selected device.
25493 \end_layout
25494
25495 \begin_layout Standard
25496 Libraries are created with gplib which is part of the gputils package 
25497 \begin_inset LatexCommand \url{http://sourceforge.net/projects/gputils}
25498
25499 \end_inset
25500
25501 .
25502 \end_layout
25503
25504 \begin_layout Subsubsection*
25505 Building the libraries
25506 \end_layout
25507
25508 \begin_layout Standard
25509 Before using SDCC/pic16 there are some libraries that need to be compiled.
25510  This process is not done automatically by SDCC since not all users use
25511  SDCC for pic16 projects.
25512  So each user should compile the libraries separately.
25513 \end_layout
25514
25515 \begin_layout Standard
25516 The steps to compile the pic16 libraries under Linux and Mac OS X are:
25517 \end_layout
25518
25519 \begin_layout LyX-Code
25520 cd device/lib/pic16
25521 \end_layout
25522
25523 \begin_layout LyX-Code
25524 ./configure
25525 \end_layout
25526
25527 \begin_layout LyX-Code
25528 make
25529 \end_layout
25530
25531 \begin_layout LyX-Code
25532 cd ..
25533 \end_layout
25534
25535 \begin_layout LyX-Code
25536 make model-pic16
25537 \end_layout
25538
25539 \begin_layout LyX-Code
25540 su -c 'make install'     # install the libraries, you need the root password
25541 \end_layout
25542
25543 \begin_layout Standard
25544 If you need to install the headers too, do:
25545 \end_layout
25546
25547 \begin_layout LyX-Code
25548 cd device/include
25549 \end_layout
25550
25551 \begin_layout LyX-Code
25552 su -c 'make install'     # install the headers, you need the root password
25553 \end_layout
25554
25555 \begin_layout Standard
25556 There exist a special target to build the I/O libraries.
25557  This target is not automatically build because it will build the I/O library
25558  for 
25559 \emph on
25560 every
25561 \emph default
25562  supported device.
25563  This way building will take quite a lot of time.
25564  Users are advised to edit the 
25565 \series bold
25566 device/lib/pic16/pics.build
25567 \series default
25568  file and then execute:
25569 \end_layout
25570
25571 \begin_layout LyX-Code
25572 make lib-io
25573 \end_layout
25574
25575 \begin_layout Subsection
25576 Adding New Devices to the Port
25577 \end_layout
25578
25579 \begin_layout Standard
25580 Adding support for a new 16
25581 \begin_inset ERT
25582 status open
25583
25584 \begin_layout Standard
25585
25586
25587 \backslash
25588 ,
25589 \end_layout
25590
25591 \end_inset
25592
25593 bit PIC MCU requires the following steps:
25594 \end_layout
25595
25596 \begin_layout Enumerate
25597 Create picDEVICE.c and picDEVICE.h from pDEVICE.inc using
25598 \newline
25599
25600 \family typewriter
25601 perl /path/to/sdcc/support/scripts/inc2h-pic16.pl /path/to/gputils/header/pDEVICE.
25602 inc
25603 \end_layout
25604
25605 \begin_layout Enumerate
25606
25607 \family typewriter
25608 mv picDEVICE.h /path/to/sdcc/device/include/pic16
25609 \end_layout
25610
25611 \begin_layout Enumerate
25612
25613 \family typewriter
25614 mv picDEVICE.c /path/to/sdcc/device/lib/pic16/libdev
25615 \end_layout
25616
25617 \begin_layout Enumerate
25618 Add DEVICE to 
25619 \family typewriter
25620 /path/to/sdcc/device/lib/pics.all
25621 \family default
25622  (and 
25623 \family typewriter
25624 .build
25625 \family default
25626 ).
25627 \newline
25628 Note: No 18f prefix here!
25629 \end_layout
25630
25631 \begin_layout Enumerate
25632 Adjust 
25633 \family typewriter
25634 /path/to/sdcc/device/lib/pic16/libio/*.ignore
25635 \family default
25636
25637 \newline
25638 Add your DEVICE if it does not compile in 
25639 \family typewriter
25640 adc
25641 \family default
25642
25643 \family typewriter
25644 i2c
25645 \family default
25646 , or 
25647 \family typewriter
25648 usart
25649 \family default
25650 .
25651 \end_layout
25652
25653 \begin_layout Enumerate
25654 Edit 
25655 \family typewriter
25656 /path/to/sdcc/device/include/pic16/pic18fregs.h
25657 \family default
25658 .
25659  The file format is self-explanatory, just add
25660 \newline
25661
25662 \family typewriter
25663 #elif defined(picDEVICE)
25664 \newline
25665 # include <picDEVICE.h>
25666 \family default
25667
25668 \newline
25669 at the right place (keep it sorted).
25670 \end_layout
25671
25672 \begin_layout Enumerate
25673 Edit 
25674 \family typewriter
25675 /path/to/sdcc/src/pic16/devices.inc
25676 \family default
25677 .
25678  Copy and modify an existing entry and insert it at the correct place (keep
25679  the file sorted).
25680  The file is hardly documented, look at the entries for the 18f2221...
25681 \end_layout
25682
25683 \begin_layout Enumerate
25684 Recompile SDCC, including the pic16 libraries.
25685 \end_layout
25686
25687 \begin_layout Subsection
25688 Memory Models
25689 \end_layout
25690
25691 \begin_layout Standard
25692 The following memory models are supported by the PIC16 port:
25693 \end_layout
25694
25695 \begin_layout Itemize
25696 small model
25697 \end_layout
25698
25699 \begin_layout Itemize
25700 large model
25701 \end_layout
25702
25703 \begin_layout Standard
25704 Memory model affects the default size of pointers within the source.
25705  The sizes are shown in the next table:
25706 \end_layout
25707
25708 \begin_layout Standard
25709 \align center
25710 \begin_inset Tabular
25711 <lyxtabular version="3" rows="3" columns="3">
25712 <features>
25713 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
25714 <column alignment="center" valignment="top" leftline="true" width="0">
25715 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
25716 <row topline="true" bottomline="true">
25717 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25718 \begin_inset Text
25719
25720 \begin_layout Standard
25721 Pointer sizes according to memory model
25722 \end_layout
25723
25724 \end_inset
25725 </cell>
25726 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25727 \begin_inset Text
25728
25729 \begin_layout Standard
25730 small model
25731 \end_layout
25732
25733 \end_inset
25734 </cell>
25735 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
25736 \begin_inset Text
25737
25738 \begin_layout Standard
25739 large model
25740 \end_layout
25741
25742 \end_inset
25743 </cell>
25744 </row>
25745 <row topline="true" bottomline="true">
25746 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25747 \begin_inset Text
25748
25749 \begin_layout Standard
25750 code pointers
25751 \end_layout
25752
25753 \end_inset
25754 </cell>
25755 <cell multicolumn="1" alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25756 \begin_inset Text
25757
25758 \begin_layout Standard
25759 16-bits
25760 \end_layout
25761
25762 \end_inset
25763 </cell>
25764 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
25765 \begin_inset Text
25766
25767 \begin_layout Standard
25768 24-bits
25769 \end_layout
25770
25771 \end_inset
25772 </cell>
25773 </row>
25774 <row topline="true" bottomline="true">
25775 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25776 \begin_inset Text
25777
25778 \begin_layout Standard
25779 data pointers
25780 \end_layout
25781
25782 \end_inset
25783 </cell>
25784 <cell multicolumn="1" alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
25785 \begin_inset Text
25786
25787 \begin_layout Standard
25788 16-bits
25789 \end_layout
25790
25791 \end_inset
25792 </cell>
25793 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
25794 \begin_inset Text
25795
25796 \begin_layout Standard
25797 16-bits
25798 \end_layout
25799
25800 \end_inset
25801 </cell>
25802 </row>
25803 </lyxtabular>
25804
25805 \end_inset
25806
25807
25808 \end_layout
25809
25810 \begin_layout Standard
25811 It is advisable that all sources within a project are compiled with the
25812  same memory model.
25813  If one wants to override the default memory model, this can be done by
25814  declaring a pointer as 
25815 \series bold
25816 far
25817 \series default
25818  or 
25819 \series bold
25820 near
25821 \series default
25822 .
25823  Far selects large memory model's pointers, while near selects small memory
25824  model's pointers.
25825 \end_layout
25826
25827 \begin_layout Standard
25828 The standard device libraries (see 
25829 \begin_inset LatexCommand \ref{sub:PIC16_Header-Files}
25830
25831 \end_inset
25832
25833 ) contain no reference to pointers, so they can be used with both memory
25834  models.
25835 \end_layout
25836
25837 \begin_layout Subsection
25838 Stack
25839 \end_layout
25840
25841 \begin_layout Standard
25842 The stack
25843 \begin_inset LatexCommand \index{PIC16!stack}
25844
25845 \end_inset
25846
25847  implementation for the PIC16 port uses two indirect registers, FSR1 and
25848  FSR2.
25849 \end_layout
25850
25851 \begin_layout Description
25852 FSR1 is assigned as stack pointer
25853 \end_layout
25854
25855 \begin_layout Description
25856 FSR2 is assigned as frame pointer
25857 \end_layout
25858
25859 \begin_layout Standard
25860 The following stack models are supported by the PIC16 port
25861 \end_layout
25862
25863 \begin_layout Itemize
25864
25865 \noun on
25866 small
25867 \noun default
25868  model
25869 \end_layout
25870
25871 \begin_layout Itemize
25872
25873 \noun on
25874 large
25875 \noun default
25876  model
25877 \end_layout
25878
25879 \begin_layout Standard
25880
25881 \noun on
25882 Small
25883 \noun default
25884  model means that only the FSRxL byte is used to access stack and frame,
25885  while 
25886 \emph on
25887 \noun on
25888 large
25889 \emph default
25890 \noun default
25891  uses both FSRxL and FSRxH registers.
25892  The following table shows the stack/frame pointers sizes according to stack
25893  model and the maximum space they can address:
25894 \end_layout
25895
25896 \begin_layout Standard
25897 \align center
25898 \begin_inset Tabular
25899 <lyxtabular version="3" rows="3" columns="3">
25900 <features>
25901 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
25902 <column alignment="center" valignment="top" leftline="true" width="0">
25903 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
25904 <row topline="true" bottomline="true">
25905 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25906 \begin_inset Text
25907
25908 \begin_layout Standard
25909 Stack & Frame pointer sizes according to stack model
25910 \end_layout
25911
25912 \end_inset
25913 </cell>
25914 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25915 \begin_inset Text
25916
25917 \begin_layout Standard
25918 small
25919 \end_layout
25920
25921 \end_inset
25922 </cell>
25923 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25924 \begin_inset Text
25925
25926 \begin_layout Standard
25927 large
25928 \end_layout
25929
25930 \end_inset
25931 </cell>
25932 </row>
25933 <row topline="true">
25934 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25935 \begin_inset Text
25936
25937 \begin_layout Standard
25938 Stack pointer FSR1
25939 \end_layout
25940
25941 \end_inset
25942 </cell>
25943 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25944 \begin_inset Text
25945
25946 \begin_layout Standard
25947 8-bits
25948 \end_layout
25949
25950 \end_inset
25951 </cell>
25952 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25953 \begin_inset Text
25954
25955 \begin_layout Standard
25956 16-bits
25957 \end_layout
25958
25959 \end_inset
25960 </cell>
25961 </row>
25962 <row topline="true" bottomline="true">
25963 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25964 \begin_inset Text
25965
25966 \begin_layout Standard
25967 Frame pointer FSR2
25968 \end_layout
25969
25970 \end_inset
25971 </cell>
25972 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25973 \begin_inset Text
25974
25975 \begin_layout Standard
25976 8-bits
25977 \end_layout
25978
25979 \end_inset
25980 </cell>
25981 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25982 \begin_inset Text
25983
25984 \begin_layout Standard
25985 16-bits
25986 \end_layout
25987
25988 \end_inset
25989 </cell>
25990 </row>
25991 </lyxtabular>
25992
25993 \end_inset
25994
25995
25996 \end_layout
25997
25998 \begin_layout Standard
25999
26000 \noun on
26001 Large 
26002 \noun default
26003 stack model is currently not working properly throughout the code generator.
26004  So its use is not advised.
26005  Also there are some other points that need special care:
26006 \newline
26007
26008 \end_layout
26009
26010 \begin_layout Enumerate
26011 Do not create stack sections with size more than one physical bank (that
26012  is 256 bytes)
26013 \end_layout
26014
26015 \begin_layout Enumerate
26016 Stack sections should no cross physical bank limits (i.e.
26017  #pragma stack 0x50 0x100)
26018 \end_layout
26019
26020 \begin_layout Standard
26021 These limitations are caused by the fact that only FSRxL is modified when
26022  using SMALL stack model, so no more than 256 bytes of stack can be used.
26023  This problem will disappear after LARGE model is fully implemented.
26024 \end_layout
26025
26026 \begin_layout Subsection
26027 Functions
26028 \end_layout
26029
26030 \begin_layout Standard
26031 In addition to the standard SDCC function keywords, PIC16
26032 \begin_inset LatexCommand \index{PIC16}
26033
26034 \end_inset
26035
26036  port makes available two more:
26037 \end_layout
26038
26039 \begin_layout Description
26040 wparam
26041 \begin_inset LatexCommand \index{PIC16!wparam}
26042
26043 \end_inset
26044
26045  Use the WREG to pass one byte of the first function argument.
26046  This improves speed but you may not use this for functions with arguments
26047  that are called via function pointers, otherwise the first byte of the
26048  first parameter will get lost.
26049  Usage:
26050 \end_layout
26051
26052 \begin_layout LyX-Code
26053 void func_wparam(int a) wparam
26054 \end_layout
26055
26056 \begin_layout LyX-Code
26057 {
26058 \end_layout
26059
26060 \begin_layout LyX-Code
26061     /* WREG hold the lower part of a */
26062 \end_layout
26063
26064 \begin_layout LyX-Code
26065     /* the high part of a is stored in FSR2+2 (or +3 for large stack model)
26066  */
26067 \end_layout
26068
26069 \begin_layout LyX-Code
26070 ...
26071 \end_layout
26072
26073 \begin_layout LyX-Code
26074 }
26075 \end_layout
26076
26077 \begin_layout Description
26078 shadowregs
26079 \begin_inset LatexCommand \index{PIC16!shadowregs}
26080
26081 \end_inset
26082
26083  When entering/exiting an ISR, it is possible to take advantage of the PIC18F
26084  hardware shadow registers which hold the values of WREG, STATUS and BSR
26085  registers.
26086  This can be done by adding the keyword 
26087 \emph on
26088 shadowregs
26089 \emph default
26090  before the 
26091 \emph on
26092 interrupt
26093 \emph default
26094  keyword in the function's header.
26095 \end_layout
26096
26097 \begin_layout LyX-Code
26098 void isr_shadow(void) shadowregs interrupt 1
26099 \end_layout
26100
26101 \begin_layout LyX-Code
26102 {
26103 \end_layout
26104
26105 \begin_layout LyX-Code
26106 ...
26107 \end_layout
26108
26109 \begin_layout LyX-Code
26110 }
26111 \end_layout
26112
26113 \begin_layout Standard
26114
26115 \emph on
26116 shadowregs
26117 \emph default
26118  instructs the code generator not to store/restore WREG, STATUS, BSR when
26119  entering/exiting the ISR.
26120 \end_layout
26121
26122 \begin_layout Subsection
26123 Function return values
26124 \end_layout
26125
26126 \begin_layout Standard
26127 Return values from functions are placed to the appropriate registers following
26128  a modified Microchip policy optimized for SDCC.
26129  The following table shows these registers:
26130 \end_layout
26131
26132 \begin_layout Standard
26133 \align center
26134 \begin_inset Tabular
26135 <lyxtabular version="3" rows="6" columns="2">
26136 <features>
26137 <column alignment="center" valignment="top" leftline="true" width="0">
26138 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
26139 <row topline="true" bottomline="true">
26140 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26141 \begin_inset Text
26142
26143 \begin_layout Standard
26144 size
26145 \end_layout
26146
26147 \end_inset
26148 </cell>
26149 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26150 \begin_inset Text
26151
26152 \begin_layout Standard
26153 destination register
26154 \end_layout
26155
26156 \end_inset
26157 </cell>
26158 </row>
26159 <row topline="true">
26160 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26161 \begin_inset Text
26162
26163 \begin_layout Standard
26164 8 bits
26165 \end_layout
26166
26167 \end_inset
26168 </cell>
26169 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26170 \begin_inset Text
26171
26172 \begin_layout Standard
26173 WREG
26174 \end_layout
26175
26176 \end_inset
26177 </cell>
26178 </row>
26179 <row topline="true">
26180 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26181 \begin_inset Text
26182
26183 \begin_layout Standard
26184 16 bits
26185 \end_layout
26186
26187 \end_inset
26188 </cell>
26189 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26190 \begin_inset Text
26191
26192 \begin_layout Standard
26193 PRODL:WREG
26194 \end_layout
26195
26196 \end_inset
26197 </cell>
26198 </row>
26199 <row topline="true">
26200 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26201 \begin_inset Text
26202
26203 \begin_layout Standard
26204 24 bits
26205 \end_layout
26206
26207 \end_inset
26208 </cell>
26209 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26210 \begin_inset Text
26211
26212 \begin_layout Standard
26213 PRODH:PRODL:WREG
26214 \end_layout
26215
26216 \end_inset
26217 </cell>
26218 </row>
26219 <row topline="true">
26220 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26221 \begin_inset Text
26222
26223 \begin_layout Standard
26224 32 bits
26225 \end_layout
26226
26227 \end_inset
26228 </cell>
26229 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26230 \begin_inset Text
26231
26232 \begin_layout Standard
26233 FSR0L:PRODH:PRODL:WREG
26234 \end_layout
26235
26236 \end_inset
26237 </cell>
26238 </row>
26239 <row topline="true" bottomline="true">
26240 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26241 \begin_inset Text
26242
26243 \begin_layout Standard
26244 >32 bits
26245 \end_layout
26246
26247 \end_inset
26248 </cell>
26249 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26250 \begin_inset Text
26251
26252 \begin_layout Standard
26253 on stack, FSR0 points to the beginning
26254 \end_layout
26255
26256 \end_inset
26257 </cell>
26258 </row>
26259 </lyxtabular>
26260
26261 \end_inset
26262
26263
26264 \end_layout
26265
26266 \begin_layout Subsection
26267 Interrupts
26268 \end_layout
26269
26270 \begin_layout Standard
26271 An interrupt
26272 \begin_inset LatexCommand \index{PIC16!interrupt}
26273
26274 \end_inset
26275
26276  service routine (ISR) is declared using the 
26277 \emph on
26278 interrupt
26279 \emph default
26280  keyword.
26281 \end_layout
26282
26283 \begin_layout LyX-Code
26284 void isr(void) interrupt 
26285 \emph on
26286 n
26287 \end_layout
26288
26289 \begin_layout LyX-Code
26290 {
26291 \end_layout
26292
26293 \begin_layout LyX-Code
26294 ...
26295 \end_layout
26296
26297 \begin_layout LyX-Code
26298 }
26299 \end_layout
26300
26301 \begin_layout Standard
26302
26303 \emph on
26304 n
26305 \emph default
26306  is the interrupt number, which for PIC18F devices can be:
26307 \end_layout
26308
26309 \begin_layout Standard
26310 \align center
26311 \begin_inset Tabular
26312 <lyxtabular version="3" rows="4" columns="3">
26313 <features>
26314 <column alignment="center" valignment="top" leftline="true" width="0">
26315 <column alignment="center" valignment="top" leftline="true" width="0">
26316 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
26317 <row topline="true" bottomline="true">
26318 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26319 \begin_inset Text
26320
26321 \begin_layout Standard
26322
26323 \emph on
26324 n
26325 \end_layout
26326
26327 \end_inset
26328 </cell>
26329 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26330 \begin_inset Text
26331
26332 \begin_layout Standard
26333 Interrupt Vector
26334 \end_layout
26335
26336 \end_inset
26337 </cell>
26338 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26339 \begin_inset Text
26340
26341 \begin_layout Standard
26342 Interrupt Vector Address
26343 \end_layout
26344
26345 \end_inset
26346 </cell>
26347 </row>
26348 <row topline="true">
26349 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26350 \begin_inset Text
26351
26352 \begin_layout Standard
26353 0
26354 \end_layout
26355
26356 \end_inset
26357 </cell>
26358 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26359 \begin_inset Text
26360
26361 \begin_layout Standard
26362 RESET vector
26363 \end_layout
26364
26365 \end_inset
26366 </cell>
26367 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26368 \begin_inset Text
26369
26370 \begin_layout Standard
26371 0x000000
26372 \end_layout
26373
26374 \end_inset
26375 </cell>
26376 </row>
26377 <row topline="true">
26378 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26379 \begin_inset Text
26380
26381 \begin_layout Standard
26382
26383 \family roman
26384 \series medium
26385 \shape up
26386 \size normal
26387 \emph off
26388 \bar no
26389 \noun off
26390 \color none
26391 1
26392 \end_layout
26393
26394 \end_inset
26395 </cell>
26396 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26397 \begin_inset Text
26398
26399 \begin_layout Standard
26400
26401 \family roman
26402 \series medium
26403 \shape up
26404 \size normal
26405 \emph off
26406 \bar no
26407 \noun off
26408 \color none
26409 HIGH priority interrupts
26410 \end_layout
26411
26412 \end_inset
26413 </cell>
26414 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26415 \begin_inset Text
26416
26417 \begin_layout Standard
26418 0x000008
26419 \end_layout
26420
26421 \end_inset
26422 </cell>
26423 </row>
26424 <row topline="true" bottomline="true">
26425 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26426 \begin_inset Text
26427
26428 \begin_layout Standard
26429 2
26430 \end_layout
26431
26432 \end_inset
26433 </cell>
26434 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26435 \begin_inset Text
26436
26437 \begin_layout Standard
26438 LOW priority interrupts
26439 \end_layout
26440
26441 \end_inset
26442 </cell>
26443 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26444 \begin_inset Text
26445
26446 \begin_layout Standard
26447 0x000018
26448 \end_layout
26449
26450 \end_inset
26451 </cell>
26452 </row>
26453 </lyxtabular>
26454
26455 \end_inset
26456
26457
26458 \end_layout
26459
26460 \begin_layout Standard
26461 When generating assembly code for ISR the code generator places a 
26462 \noun on
26463 goto 
26464 \noun default
26465 instruction at the 
26466 \emph on
26467 Interrupt Vector Address
26468 \emph default
26469  which points at the genetated ISR.
26470  This single GOTO instruction is part of an automatically generated 
26471 \emph on
26472 interrupt entry point
26473 \emph default
26474  function.
26475  The actuall ISR code is placed as normally would in the code space.
26476  Upon interrupt request, the GOTO instruction is executed which jumps to
26477  the ISR code.
26478  When declaring interrupt functions as _naked this GOTO instruction is 
26479 \series bold
26480 not
26481 \series default
26482  generated.
26483  The whole interrupt functions is therefore placed at the Interrupt Vector
26484  Address of the specific interrupt.
26485  This is not a problem for the LOW priority interrupts, but it is a problem
26486  for the RESET and the HIGH priority interrupts because code may be written
26487  at the next interrupt's vector address and cause undeterminate program
26488  behaviour if that interrupt is raised.
26489 \begin_inset Foot
26490 status open
26491
26492 \begin_layout Standard
26493 This is not a problem when
26494 \end_layout
26495
26496 \begin_layout Enumerate
26497 this is a HIGH interrupt ISR and LOW interrupts are 
26498 \emph on
26499 disabled
26500 \emph default
26501  or not used.
26502 \end_layout
26503
26504 \begin_layout Enumerate
26505 when the ISR is small enough not to reach the next interrupt's vector address.
26506 \end_layout
26507
26508 \end_inset
26509
26510
26511 \end_layout
26512
26513 \begin_layout Standard
26514
26515 \emph on
26516 n
26517 \emph default
26518  may be omitted.
26519  This way a function is generated similar to an ISR, but it is not assigned
26520  to any interrupt.
26521 \end_layout
26522
26523 \begin_layout Standard
26524 When entering an interrupt, currently the PIC16
26525 \begin_inset LatexCommand \index{PIC16}
26526
26527 \end_inset
26528
26529  port automatically saves the following registers:
26530 \end_layout
26531
26532 \begin_layout Itemize
26533 WREG
26534 \end_layout
26535
26536 \begin_layout Itemize
26537 STATUS
26538 \end_layout
26539
26540 \begin_layout Itemize
26541 BSR
26542 \end_layout
26543
26544 \begin_layout Itemize
26545 PROD (PRODL and PRODH)
26546 \end_layout
26547
26548 \begin_layout Itemize
26549 FSR0 (FSR0L and FSR0H)
26550 \end_layout
26551
26552 \begin_layout Standard
26553 These registers are restored upon return from the interrupt routine.
26554 \begin_inset Foot
26555 status open
26556
26557 \begin_layout Standard
26558 NOTE that when the _naked attribute is specified for an interrupt routine,
26559  then NO registers are stored or restored.
26560 \end_layout
26561
26562 \end_inset
26563
26564
26565 \end_layout
26566
26567 \begin_layout Subsection
26568 Generic Pointers
26569 \end_layout
26570
26571 \begin_layout Standard
26572 Generic pointers are implemented in PIC16 port as 3-byte (24-bit) types.
26573  There are 3 types of generic pointers currently implemented data, code
26574  and eeprom pointers.
26575  They are differentiated by the value of the 7th and 6th bits of the upper
26576  byte:
26577 \end_layout
26578
26579 \begin_layout Standard
26580 \align center
26581 \begin_inset Tabular
26582 <lyxtabular version="3" rows="5" columns="5">
26583 <features>
26584 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
26585 <column alignment="center" valignment="top" width="0">
26586 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
26587 <column alignment="center" valignment="top" width="0">
26588 <column alignment="left" valignment="top" rightline="true" width="0">
26589 <row topline="true" bottomline="true">
26590 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26591 \begin_inset Text
26592
26593 \begin_layout Standard
26594 pointer type
26595 \end_layout
26596
26597 \end_inset
26598 </cell>
26599 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26600 \begin_inset Text
26601
26602 \begin_layout Standard
26603 7th bit
26604 \end_layout
26605
26606 \end_inset
26607 </cell>
26608 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26609 \begin_inset Text
26610
26611 \begin_layout Standard
26612 6th bit
26613 \end_layout
26614
26615 \end_inset
26616 </cell>
26617 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26618 \begin_inset Text
26619
26620 \begin_layout Standard
26621 rest of the pointer
26622 \end_layout
26623
26624 \end_inset
26625 </cell>
26626 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26627 \begin_inset Text
26628
26629 \begin_layout Standard
26630 description
26631 \end_layout
26632
26633 \end_inset
26634 </cell>
26635 </row>
26636 <row topline="true" bottomline="true">
26637 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26638 \begin_inset Text
26639
26640 \begin_layout Standard
26641 data 
26642 \end_layout
26643
26644 \end_inset
26645 </cell>
26646 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26647 \begin_inset Text
26648
26649 \begin_layout Standard
26650 1
26651 \end_layout
26652
26653 \end_inset
26654 </cell>
26655 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26656 \begin_inset Text
26657
26658 \begin_layout Standard
26659 0
26660 \end_layout
26661
26662 \end_inset
26663 </cell>
26664 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26665 \begin_inset Text
26666
26667 \begin_layout Standard
26668
26669 \family typewriter
26670 \shape slanted
26671 \emph on
26672 uuuuuu uuuuxxxx xxxxxxxx
26673 \end_layout
26674
26675 \end_inset
26676 </cell>
26677 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26678 \begin_inset Text
26679
26680 \begin_layout Standard
26681 a 12-bit data pointer in data RAM memory
26682 \end_layout
26683
26684 \end_inset
26685 </cell>
26686 </row>
26687 <row bottomline="true">
26688 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26689 \begin_inset Text
26690
26691 \begin_layout Standard
26692 code
26693 \end_layout
26694
26695 \end_inset
26696 </cell>
26697 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26698 \begin_inset Text
26699
26700 \begin_layout Standard
26701 0
26702 \end_layout
26703
26704 \end_inset
26705 </cell>
26706 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26707 \begin_inset Text
26708
26709 \begin_layout Standard
26710 0
26711 \end_layout
26712
26713 \end_inset
26714 </cell>
26715 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26716 \begin_inset Text
26717
26718 \begin_layout Standard
26719
26720 \family typewriter
26721 \shape slanted
26722 \emph on
26723 uxxxxx xxxxxxxx xxxxxxxx
26724 \end_layout
26725
26726 \end_inset
26727 </cell>
26728 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26729 \begin_inset Text
26730
26731 \begin_layout Standard
26732 a 21-bit code pointer in FLASH memory
26733 \end_layout
26734
26735 \end_inset
26736 </cell>
26737 </row>
26738 <row bottomline="true">
26739 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26740 \begin_inset Text
26741
26742 \begin_layout Standard
26743 eeprom
26744 \end_layout
26745
26746 \end_inset
26747 </cell>
26748 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26749 \begin_inset Text
26750
26751 \begin_layout Standard
26752 0
26753 \end_layout
26754
26755 \end_inset
26756 </cell>
26757 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26758 \begin_inset Text
26759
26760 \begin_layout Standard
26761 1
26762 \end_layout
26763
26764 \end_inset
26765 </cell>
26766 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26767 \begin_inset Text
26768
26769 \begin_layout Standard
26770
26771 \family typewriter
26772 \shape slanted
26773 \emph on
26774 uuuuuu uuuuuuxx xxxxxxxx
26775 \end_layout
26776
26777 \end_inset
26778 </cell>
26779 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26780 \begin_inset Text
26781
26782 \begin_layout Standard
26783 a 10-bit eeprom pointer in EEPROM memory
26784 \end_layout
26785
26786 \end_inset
26787 </cell>
26788 </row>
26789 <row bottomline="true">
26790 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26791 \begin_inset Text
26792
26793 \begin_layout Standard
26794 (unimplemented)
26795 \end_layout
26796
26797 \end_inset
26798 </cell>
26799 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26800 \begin_inset Text
26801
26802 \begin_layout Standard
26803 1
26804 \end_layout
26805
26806 \end_inset
26807 </cell>
26808 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26809 \begin_inset Text
26810
26811 \begin_layout Standard
26812 1
26813 \end_layout
26814
26815 \end_inset
26816 </cell>
26817 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26818 \begin_inset Text
26819
26820 \begin_layout Standard
26821
26822 \family typewriter
26823 \shape slanted
26824 \emph on
26825 xxxxxx xxxxxxxx xxxxxxxx
26826 \end_layout
26827
26828 \end_inset
26829 </cell>
26830 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26831 \begin_inset Text
26832
26833 \begin_layout Standard
26834 unimplemented pointer type
26835 \end_layout
26836
26837 \end_inset
26838 </cell>
26839 </row>
26840 </lyxtabular>
26841
26842 \end_inset
26843
26844
26845 \end_layout
26846
26847 \begin_layout Standard
26848 Generic pointer are read and written with a set of library functions which
26849  read/write 1, 2, 3, 4 bytes.
26850 \end_layout
26851
26852 \begin_layout Subsection
26853 PIC16 C Libraries
26854 \end_layout
26855
26856 \begin_layout Subsubsection
26857 Standard I/O Streams
26858 \end_layout
26859
26860 \begin_layout Standard
26861 In the 
26862 \emph on
26863 stdio.h
26864 \emph default
26865  the type FILE is defined as:
26866 \end_layout
26867
26868 \begin_layout LyX-Code
26869 typedef char * FILE;
26870 \end_layout
26871
26872 \begin_layout Standard
26873 This type is the stream type implemented I/O in the PIC18F devices.
26874  Also the standard input and output streams are declared in stdio.h:
26875 \end_layout
26876
26877 \begin_layout LyX-Code
26878 extern FILE * stdin;
26879 \end_layout
26880
26881 \begin_layout LyX-Code
26882 extern FILE * stdout;
26883 \end_layout
26884
26885 \begin_layout Standard
26886 The FILE type is actually a generic pointer which defines one more type
26887  of generic pointers, the 
26888 \emph on
26889 stream 
26890 \emph default
26891 pointer.
26892  This new type has the format:
26893 \end_layout
26894
26895 \begin_layout Standard
26896 \align center
26897 \begin_inset Tabular
26898 <lyxtabular version="3" rows="2" columns="7">
26899 <features>
26900 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
26901 <column alignment="center" valignment="top" width="0">
26902 <column alignment="center" valignment="top" leftline="true" width="0">
26903 <column alignment="center" valignment="top" leftline="true" width="0">
26904 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
26905 <column alignment="center" valignment="top" width="0">
26906 <column alignment="left" valignment="top" rightline="true" width="0">
26907 <row topline="true" bottomline="true">
26908 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26909 \begin_inset Text
26910
26911 \begin_layout Standard
26912 pointer type
26913 \end_layout
26914
26915 \end_inset
26916 </cell>
26917 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26918 \begin_inset Text
26919
26920 \begin_layout Standard
26921 <7:6>
26922 \end_layout
26923
26924 \end_inset
26925 </cell>
26926 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26927 \begin_inset Text
26928
26929 \begin_layout Standard
26930 <5>
26931 \end_layout
26932
26933 \end_inset
26934 </cell>
26935 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26936 \begin_inset Text
26937
26938 \begin_layout Standard
26939 <4>
26940 \end_layout
26941
26942 \end_inset
26943 </cell>
26944 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26945 \begin_inset Text
26946
26947 \begin_layout Standard
26948 <3:0>
26949 \end_layout
26950
26951 \end_inset
26952 </cell>
26953 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26954 \begin_inset Text
26955
26956 \begin_layout Standard
26957 rest of the pointer
26958 \end_layout
26959
26960 \end_inset
26961 </cell>
26962 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26963 \begin_inset Text
26964
26965 \begin_layout Standard
26966 descrption
26967 \end_layout
26968
26969 \end_inset
26970 </cell>
26971 </row>
26972 <row topline="true" bottomline="true">
26973 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26974 \begin_inset Text
26975
26976 \begin_layout Standard
26977 stream
26978 \end_layout
26979
26980 \end_inset
26981 </cell>
26982 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26983 \begin_inset Text
26984
26985 \begin_layout Standard
26986 00
26987 \end_layout
26988
26989 \end_inset
26990 </cell>
26991 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26992 \begin_inset Text
26993
26994 \begin_layout Standard
26995 1
26996 \end_layout
26997
26998 \end_inset
26999 </cell>
27000 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27001 \begin_inset Text
27002
27003 \begin_layout Standard
27004 0
27005 \end_layout
27006
27007 \end_inset
27008 </cell>
27009 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27010 \begin_inset Text
27011
27012 \begin_layout Standard
27013 nnnn
27014 \end_layout
27015
27016 \end_inset
27017 </cell>
27018 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27019 \begin_inset Text
27020
27021 \begin_layout Standard
27022
27023 \family typewriter
27024 \shape slanted
27025 \emph on
27026 uuuuuuuu uuuuuuuu
27027 \end_layout
27028
27029 \end_inset
27030 </cell>
27031 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27032 \begin_inset Text
27033
27034 \begin_layout Standard
27035 upper byte high nubble is 0x2n, the rest are zeroes
27036 \end_layout
27037
27038 \end_inset
27039 </cell>
27040 </row>
27041 </lyxtabular>
27042
27043 \end_inset
27044
27045
27046 \end_layout
27047
27048 \begin_layout Standard
27049 Currently implemented there are 3 types of streams defined:
27050 \end_layout
27051
27052 \begin_layout Standard
27053 \align center
27054 \begin_inset Tabular
27055 <lyxtabular version="3" rows="4" columns="4">
27056 <features>
27057 <column alignment="center" valignment="top" leftline="true" width="0">
27058 <column alignment="center" valignment="top" leftline="true" width="0">
27059 <column alignment="center" valignment="top" leftline="true" width="0">
27060 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
27061 <row topline="true" bottomline="true">
27062 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27063 \begin_inset Text
27064
27065 \begin_layout Standard
27066 stream type
27067 \end_layout
27068
27069 \end_inset
27070 </cell>
27071 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27072 \begin_inset Text
27073
27074 \begin_layout Standard
27075 value
27076 \end_layout
27077
27078 \end_inset
27079 </cell>
27080 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27081 \begin_inset Text
27082
27083 \begin_layout Standard
27084 module
27085 \end_layout
27086
27087 \end_inset
27088 </cell>
27089 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27090 \begin_inset Text
27091
27092 \begin_layout Standard
27093 description
27094 \end_layout
27095
27096 \end_inset
27097 </cell>
27098 </row>
27099 <row topline="true">
27100 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27101 \begin_inset Text
27102
27103 \begin_layout Standard
27104 STREAM_USART
27105 \end_layout
27106
27107 \end_inset
27108 </cell>
27109 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27110 \begin_inset Text
27111
27112 \begin_layout Standard
27113
27114 \family typewriter
27115 0x200000UL
27116 \end_layout
27117
27118 \end_inset
27119 </cell>
27120 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27121 \begin_inset Text
27122
27123 \begin_layout Standard
27124 USART
27125 \end_layout
27126
27127 \end_inset
27128 </cell>
27129 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27130 \begin_inset Text
27131
27132 \begin_layout Standard
27133 Writes/Reads characters via the USART peripheral
27134 \end_layout
27135
27136 \end_inset
27137 </cell>
27138 </row>
27139 <row topline="true">
27140 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27141 \begin_inset Text
27142
27143 \begin_layout Standard
27144 STREAM_MSSP
27145 \end_layout
27146
27147 \end_inset
27148 </cell>
27149 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27150 \begin_inset Text
27151
27152 \begin_layout Standard
27153
27154 \family typewriter
27155 0x210000UL
27156 \end_layout
27157
27158 \end_inset
27159 </cell>
27160 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27161 \begin_inset Text
27162
27163 \begin_layout Standard
27164 MSSP
27165 \end_layout
27166
27167 \end_inset
27168 </cell>
27169 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27170 \begin_inset Text
27171
27172 \begin_layout Standard
27173 Writes/Reads characters via the MSSP peripheral
27174 \end_layout
27175
27176 \end_inset
27177 </cell>
27178 </row>
27179 <row topline="true" bottomline="true">
27180 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27181 \begin_inset Text
27182
27183 \begin_layout Standard
27184 STREAM_USER
27185 \end_layout
27186
27187 \end_inset
27188 </cell>
27189 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27190 \begin_inset Text
27191
27192 \begin_layout Standard
27193
27194 \family typewriter
27195 0x2f0000UL
27196 \end_layout
27197
27198 \end_inset
27199 </cell>
27200 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27201 \begin_inset Text
27202
27203 \begin_layout Standard
27204 (none)
27205 \end_layout
27206
27207 \end_inset
27208 </cell>
27209 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27210 \begin_inset Text
27211
27212 \begin_layout Standard
27213 Writes/Reads characters via used defined functions
27214 \end_layout
27215
27216 \end_inset
27217 </cell>
27218 </row>
27219 </lyxtabular>
27220
27221 \end_inset
27222
27223
27224 \end_layout
27225
27226 \begin_layout Standard
27227 The stream identifiers are declared as macros in the stdio.h header.
27228 \end_layout
27229
27230 \begin_layout Standard
27231 In the libc library there exist the functions that are used to write to
27232  each of the above streams.
27233  These are
27234 \end_layout
27235
27236 \begin_layout Description
27237 _
27238 \begin_inset ERT
27239 status collapsed
27240
27241 \begin_layout Standard
27242
27243
27244 \backslash
27245 /
27246 \end_layout
27247
27248 \end_inset
27249
27250 _stream_usart_putchar writes a character at the USART stream
27251 \end_layout
27252
27253 \begin_layout Description
27254 _
27255 \begin_inset ERT
27256 status collapsed
27257
27258 \begin_layout Standard
27259
27260
27261 \backslash
27262 /
27263 \end_layout
27264
27265 \end_inset
27266
27267 _stream_mssp_putchar writes a character at the MSSP stream
27268 \end_layout
27269
27270 \begin_layout Description
27271 putchar dummy function.
27272  This writes a character to a user specified manner.
27273 \end_layout
27274
27275 \begin_layout Standard
27276 In order to increase performance 
27277 \emph on
27278 putchar 
27279 \emph default
27280 is declared in stdio.h as having its parameter in WREG (it has the wparam
27281  keyword).
27282  In stdio.h exists the macro PUTCHAR(arg) that defines the putchar function
27283  in a user-friendly way.
27284  
27285 \emph on
27286 arg
27287 \emph default
27288  is the name of the variable that holds the character to print.
27289  An example follows:
27290 \end_layout
27291
27292 \begin_layout LyX-Code
27293 #include <pic18fregs.h>
27294 \newline
27295 #include <stdio.h>
27296 \newline
27297
27298 \newline
27299 PUTCHAR( c )
27300 \end_layout
27301
27302 \begin_layout LyX-Code
27303 {
27304 \end_layout
27305
27306 \begin_layout LyX-Code
27307     PORTA = c;    /* dump character c to PORTA */
27308 \end_layout
27309
27310 \begin_layout LyX-Code
27311
27312 \newline
27313
27314 \newline
27315 void main(void)
27316 \end_layout
27317
27318 \begin_layout LyX-Code
27319 {
27320 \end_layout
27321
27322 \begin_layout LyX-Code
27323     stdout = STREAM_USER;    /* this is not necessary, since stdout points
27324 \end_layout
27325
27326 \begin_layout LyX-Code
27327                               * by default to STREAM_USER */
27328 \end_layout
27329
27330 \begin_layout LyX-Code
27331     printf (
27332 \begin_inset Quotes sld
27333 \end_inset
27334
27335 This is a printf test
27336 \backslash
27337 n
27338 \begin_inset Quotes srd
27339 \end_inset
27340
27341 );
27342 \end_layout
27343
27344 \begin_layout LyX-Code
27345 }
27346 \end_layout
27347
27348 \begin_layout LyX-Code
27349
27350 \end_layout
27351
27352 \begin_layout Subsubsection
27353 Printing functions
27354 \end_layout
27355
27356 \begin_layout Standard
27357 PIC16 contains an implementation of the printf-family of functions.
27358  There exist the following functions:
27359 \end_layout
27360
27361 \begin_layout LyX-Code
27362 extern unsigned int sprintf(char *buf, char *fmt, ...);
27363 \end_layout
27364
27365 \begin_layout LyX-Code
27366 extern unsigned int vsprintf(char *buf, char *fmt, va_list ap);
27367 \end_layout
27368
27369 \begin_layout LyX-Code
27370
27371 \end_layout
27372
27373 \begin_layout LyX-Code
27374 extern unsigned int printf(char *fmt, ...);
27375 \end_layout
27376
27377 \begin_layout LyX-Code
27378 extern unsigned int vprintf(char *fmt, va_lista ap);
27379 \end_layout
27380
27381 \begin_layout LyX-Code
27382
27383 \end_layout
27384
27385 \begin_layout LyX-Code
27386 extern unsigned int fprintf(FILE *fp, char *fmt, ...);
27387 \end_layout
27388
27389 \begin_layout LyX-Code
27390 extern unsigned int vfprintf(FILE *fp, char *fmt, va_list ap);
27391 \end_layout
27392
27393 \begin_layout Standard
27394 For sprintf and vsprintf 
27395 \emph on
27396 buf 
27397 \emph default
27398 should normally be a data pointer where the resulting string will be placed.
27399  No range checking is done so the user should allocate the necessery buffer.
27400  For fprintf and vfprintf 
27401 \emph on
27402 fp
27403 \emph default
27404  should be a stream pointer (i.e.
27405  stdout, STREAM_MSSP, etc...).
27406 \end_layout
27407
27408 \begin_layout Subsubsection
27409 Signals
27410 \end_layout
27411
27412 \begin_layout Standard
27413 The PIC18F family of microcontrollers supports a number of interrupt sources.
27414  A list of these interrupts is shown in the following table:
27415 \end_layout
27416
27417 \begin_layout Standard
27418 \align center
27419 \begin_inset Tabular
27420 <lyxtabular version="3" rows="11" columns="4">
27421 <features>
27422 <column alignment="left" valignment="top" leftline="true" width="0">
27423 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
27424 <column alignment="left" valignment="top" leftline="true" width="0">
27425 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
27426 <row topline="true" bottomline="true">
27427 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27428 \begin_inset Text
27429
27430 \begin_layout Standard
27431 signal name
27432 \end_layout
27433
27434 \end_inset
27435 </cell>
27436 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27437 \begin_inset Text
27438
27439 \begin_layout Standard
27440 description
27441 \end_layout
27442
27443 \end_inset
27444 </cell>
27445 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27446 \begin_inset Text
27447
27448 \begin_layout Standard
27449 signal name
27450 \end_layout
27451
27452 \end_inset
27453 </cell>
27454 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27455 \begin_inset Text
27456
27457 \begin_layout Standard
27458 descritpion
27459 \end_layout
27460
27461 \end_inset
27462 </cell>
27463 </row>
27464 <row topline="true">
27465 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27466 \begin_inset Text
27467
27468 \begin_layout Standard
27469 SIG_RB
27470 \end_layout
27471
27472 \end_inset
27473 </cell>
27474 <cell multicolumn="1" alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27475 \begin_inset Text
27476
27477 \begin_layout Standard
27478 PORTB change interrupt
27479 \end_layout
27480
27481 \end_inset
27482 </cell>
27483 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27484 \begin_inset Text
27485
27486 \begin_layout Standard
27487 SIG_EE
27488 \end_layout
27489
27490 \end_inset
27491 </cell>
27492 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27493 \begin_inset Text
27494
27495 \begin_layout Standard
27496 EEPROM/FLASH write complete interrupt
27497 \end_layout
27498
27499 \end_inset
27500 </cell>
27501 </row>
27502 <row topline="true">
27503 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27504 \begin_inset Text
27505
27506 \begin_layout Standard
27507 SIG_INT0
27508 \end_layout
27509
27510 \end_inset
27511 </cell>
27512 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27513 \begin_inset Text
27514
27515 \begin_layout Standard
27516 INT0 external interrupt
27517 \end_layout
27518
27519 \end_inset
27520 </cell>
27521 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27522 \begin_inset Text
27523
27524 \begin_layout Standard
27525 SIG_BCOL
27526 \end_layout
27527
27528 \end_inset
27529 </cell>
27530 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27531 \begin_inset Text
27532
27533 \begin_layout Standard
27534 Bus collision interrupt
27535 \end_layout
27536
27537 \end_inset
27538 </cell>
27539 </row>
27540 <row topline="true">
27541 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27542 \begin_inset Text
27543
27544 \begin_layout Standard
27545 SIG_INT1
27546 \end_layout
27547
27548 \end_inset
27549 </cell>
27550 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27551 \begin_inset Text
27552
27553 \begin_layout Standard
27554 INT1 external interrupt
27555 \end_layout
27556
27557 \end_inset
27558 </cell>
27559 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27560 \begin_inset Text
27561
27562 \begin_layout Standard
27563 SIG_LVD
27564 \end_layout
27565
27566 \end_inset
27567 </cell>
27568 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27569 \begin_inset Text
27570
27571 \begin_layout Standard
27572 Low voltage detect interrupt
27573 \end_layout
27574
27575 \end_inset
27576 </cell>
27577 </row>
27578 <row topline="true">
27579 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27580 \begin_inset Text
27581
27582 \begin_layout Standard
27583 SIG_INT2
27584 \end_layout
27585
27586 \end_inset
27587 </cell>
27588 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27589 \begin_inset Text
27590
27591 \begin_layout Standard
27592 INT2 external interrupt
27593 \end_layout
27594
27595 \end_inset
27596 </cell>
27597 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27598 \begin_inset Text
27599
27600 \begin_layout Standard
27601 SIG_PSP
27602 \end_layout
27603
27604 \end_inset
27605 </cell>
27606 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27607 \begin_inset Text
27608
27609 \begin_layout Standard
27610 Parallel slave port interrupt
27611 \end_layout
27612
27613 \end_inset
27614 </cell>
27615 </row>
27616 <row topline="true">
27617 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27618 \begin_inset Text
27619
27620 \begin_layout Standard
27621 SIG_CCP1
27622 \end_layout
27623
27624 \end_inset
27625 </cell>
27626 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27627 \begin_inset Text
27628
27629 \begin_layout Standard
27630 CCP1 module interrupt
27631 \end_layout
27632
27633 \end_inset
27634 </cell>
27635 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27636 \begin_inset Text
27637
27638 \begin_layout Standard
27639 SIG_AD
27640 \end_layout
27641
27642 \end_inset
27643 </cell>
27644 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27645 \begin_inset Text
27646
27647 \begin_layout Standard
27648 AD convertion complete interrupt
27649 \end_layout
27650
27651 \end_inset
27652 </cell>
27653 </row>
27654 <row topline="true">
27655 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27656 \begin_inset Text
27657
27658 \begin_layout Standard
27659 SIG_CCP2
27660 \end_layout
27661
27662 \end_inset
27663 </cell>
27664 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27665 \begin_inset Text
27666
27667 \begin_layout Standard
27668 CCP2 module interrupt
27669 \end_layout
27670
27671 \end_inset
27672 </cell>
27673 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27674 \begin_inset Text
27675
27676 \begin_layout Standard
27677 SIG_RC
27678 \end_layout
27679
27680 \end_inset
27681 </cell>
27682 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27683 \begin_inset Text
27684
27685 \begin_layout Standard
27686 USART receive interrupt
27687 \end_layout
27688
27689 \end_inset
27690 </cell>
27691 </row>
27692 <row topline="true">
27693 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27694 \begin_inset Text
27695
27696 \begin_layout Standard
27697 SIG_TMR0
27698 \end_layout
27699
27700 \end_inset
27701 </cell>
27702 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27703 \begin_inset Text
27704
27705 \begin_layout Standard
27706 TMR0 overflow interrupt
27707 \end_layout
27708
27709 \end_inset
27710 </cell>
27711 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27712 \begin_inset Text
27713
27714 \begin_layout Standard
27715 SIG_TX
27716 \end_layout
27717
27718 \end_inset
27719 </cell>
27720 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27721 \begin_inset Text
27722
27723 \begin_layout Standard
27724 USART transmit interrupt
27725 \end_layout
27726
27727 \end_inset
27728 </cell>
27729 </row>
27730 <row topline="true">
27731 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27732 \begin_inset Text
27733
27734 \begin_layout Standard
27735 SIG_TMR1
27736 \end_layout
27737
27738 \end_inset
27739 </cell>
27740 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27741 \begin_inset Text
27742
27743 \begin_layout Standard
27744 TMR1 overflow interrupt
27745 \end_layout
27746
27747 \end_inset
27748 </cell>
27749 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27750 \begin_inset Text
27751
27752 \begin_layout Standard
27753 SIG_MSSP
27754 \end_layout
27755
27756 \end_inset
27757 </cell>
27758 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27759 \begin_inset Text
27760
27761 \begin_layout Standard
27762 SSP receive/transmit interrupt
27763 \end_layout
27764
27765 \end_inset
27766 </cell>
27767 </row>
27768 <row topline="true">
27769 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27770 \begin_inset Text
27771
27772 \begin_layout Standard
27773 SIG_TMR2
27774 \end_layout
27775
27776 \end_inset
27777 </cell>
27778 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27779 \begin_inset Text
27780
27781 \begin_layout Standard
27782 TMR2 matches PR2 interrupt
27783 \end_layout
27784
27785 \end_inset
27786 </cell>
27787 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27788 \begin_inset Text
27789
27790 \begin_layout Standard
27791
27792 \end_layout
27793
27794 \end_inset
27795 </cell>
27796 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27797 \begin_inset Text
27798
27799 \begin_layout Standard
27800
27801 \end_layout
27802
27803 \end_inset
27804 </cell>
27805 </row>
27806 <row topline="true" bottomline="true">
27807 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27808 \begin_inset Text
27809
27810 \begin_layout Standard
27811 SIG_TMR3
27812 \end_layout
27813
27814 \end_inset
27815 </cell>
27816 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27817 \begin_inset Text
27818
27819 \begin_layout Standard
27820 TMR3 overflow interrupt
27821 \end_layout
27822
27823 \end_inset
27824 </cell>
27825 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27826 \begin_inset Text
27827
27828 \begin_layout Standard
27829
27830 \end_layout
27831
27832 \end_inset
27833 </cell>
27834 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27835 \begin_inset Text
27836
27837 \begin_layout Standard
27838
27839 \end_layout
27840
27841 \end_inset
27842 </cell>
27843 </row>
27844 </lyxtabular>
27845
27846 \end_inset
27847
27848
27849 \end_layout
27850
27851 \begin_layout Standard
27852 The prototypes for these names are defined in the header file 
27853 \emph on
27854 signal.h
27855 \emph default
27856  .
27857 \end_layout
27858
27859 \begin_layout Standard
27860 In order to simplify signal handling, a number of macros is provided:
27861 \end_layout
27862
27863 \begin_layout List
27864 \labelwidthstring 00.00.0000
27865 DEF_INTHIGH(name) begin the definition of the interrupt dispatch table for
27866  high priority interrupts.
27867  
27868 \emph on
27869 name
27870 \emph default
27871  is the function name to use.
27872 \end_layout
27873
27874 \begin_layout List
27875 \labelwidthstring 00.00.0000
27876 DEF_INTLOW(name) begin the definition of the interrupt dispatch table fo
27877  low priority interrupt.
27878  
27879 \emph on
27880 name
27881 \emph default
27882  is the function name to use.
27883 \end_layout
27884
27885 \begin_layout List
27886 \labelwidthstring 00.00.0000
27887 DEF_HANDLER(sig,handler) define a handler for signal 
27888 \emph on
27889 sig.
27890 \end_layout
27891
27892 \begin_layout List
27893 \labelwidthstring 00.00.0000
27894 END_DEF end the declaration of the dispatch table.
27895 \end_layout
27896
27897 \begin_layout Standard
27898 Additionally there are two more macros to simplify the declaration of the
27899  signal handler:
27900 \end_layout
27901
27902 \begin_layout List
27903 \labelwidthstring 00.00.0000
27904
27905 \series medium
27906 SIGHANDLER(handler) 
27907 \series default
27908 this declares the function prototype for the 
27909 \emph on
27910 handler
27911 \emph default
27912  function.
27913 \end_layout
27914
27915 \begin_layout List
27916 \labelwidthstring 00.00.0000
27917 SIGHANDLERNAKED(handler) same as SIGHANDLER() but declares a naked function.
27918 \end_layout
27919
27920 \begin_layout Standard
27921 An example of using the macros above is shown below:
27922 \end_layout
27923
27924 \begin_layout LyX-Code
27925 #include <pic18fregs.h>
27926 \end_layout
27927
27928 \begin_layout LyX-Code
27929 #include <signal.h>
27930 \newline
27931
27932 \newline
27933 DEF_INTHIGH(high_int)
27934 \end_layout
27935
27936 \begin_layout LyX-Code
27937 DEF_HANDLER(SIG_TMR0, _tmr0_handler)
27938 \end_layout
27939
27940 \begin_layout LyX-Code
27941 DEF_HANDLER(SIG_BCOL, _bcol_handler)
27942 \end_layout
27943
27944 \begin_layout LyX-Code
27945 END_DEF
27946 \newline
27947
27948 \newline
27949 SIGHANDLER(_tmr0_handler)
27950 \end_layout
27951
27952 \begin_layout LyX-Code
27953 {
27954 \end_layout
27955
27956 \begin_layout LyX-Code
27957   /* action to be taken when timer 0 overflows */
27958 \end_layout
27959
27960 \begin_layout LyX-Code
27961 }
27962 \newline
27963
27964 \newline
27965 SIGHANDLERNAKED(_bcol_handler)
27966 \end_layout
27967
27968 \begin_layout LyX-Code
27969 {
27970 \end_layout
27971
27972 \begin_layout LyX-Code
27973   _asm
27974 \end_layout
27975
27976 \begin_layout LyX-Code
27977     /* action to be taken when bus collision occurs */
27978 \end_layout
27979
27980 \begin_layout LyX-Code
27981     retfie
27982 \end_layout
27983
27984 \begin_layout LyX-Code
27985  _endasm;
27986 \end_layout
27987
27988 \begin_layout LyX-Code
27989 }
27990 \end_layout
27991
27992 \begin_layout Standard
27993
27994 \series bold
27995 NOTES:
27996 \series default
27997  Special care should be taken when using the above scheme:
27998 \end_layout
27999
28000 \begin_layout Itemize
28001 do not place a colon (;) at the end of the DEF_* and END_DEF macros.
28002 \end_layout
28003
28004 \begin_layout Itemize
28005 when declaring SIGHANDLERNAKED handler never forget to use 
28006 \emph on
28007 retfie
28008 \emph default
28009  for proper returning.
28010 \end_layout
28011
28012 \begin_layout Subsection
28013 PIC16 Port -- Tips
28014 \end_layout
28015
28016 \begin_layout Standard
28017 Here you can find some general tips for compiling programs with SDCC/pic16.
28018 \end_layout
28019
28020 \begin_layout Subsubsection
28021 Stack size
28022 \end_layout
28023
28024 \begin_layout Standard
28025 The default stack
28026 \begin_inset LatexCommand \index{PIC16!stack}
28027
28028 \end_inset
28029
28030  size (that is 64 bytes) probably is enough for many programs.
28031  One must take care that when there are many levels of function nesting,
28032  or there is excessive usage of stack, its size should be extended.
28033  An example of such a case is the printf/sprintf family of functions.
28034  If you encounter problems like not being able to print integers, then you
28035  need to set the stack size around the maximum (256 for small stack model).
28036  The following diagram shows what happens when calling printf to print an
28037  integer:
28038 \end_layout
28039
28040 \begin_layout LyX-Code
28041 printf () --> ltoa () --> ultoa () --> divschar ()
28042 \end_layout
28043
28044 \begin_layout Standard
28045 It is should be understood that stack is easily consumed when calling complicate
28046 d functions.
28047  Using command line arguments like -
28048 \begin_inset ERT
28049 status collapsed
28050
28051 \begin_layout Standard
28052
28053
28054 \backslash
28055 /
28056 \end_layout
28057
28058 \end_inset
28059
28060 -fommit-frame-pointer might reduce stack usage by not creating unnecessery
28061  stack frames.
28062  Other ways to reduce stack usage may exist.
28063 \end_layout
28064
28065 \begin_layout Subsection
28066 Known Bugs
28067 \end_layout
28068
28069 \begin_layout Standard
28070 The PIC16 Port currently does not pass SDCC's regression test
28071 \begin_inset LatexCommand \index{Regression test (PIC16)}
28072
28073 \end_inset
28074
28075  suite (see section 
28076 \begin_inset LatexCommand \ref{sec:Quality-control}
28077
28078 \end_inset
28079
28080 ) and thus the snapshot build regression tests for the PIC16 target are
28081  currently disabled for all hosts
28082 \emph on
28083 .
28084 \end_layout
28085
28086 \begin_layout Chapter
28087 Debugging
28088 \end_layout
28089
28090 \begin_layout Standard
28091 There are several approaches to debugging your code.
28092  This chapter is meant to show your options and to give detail on some of
28093  them:
28094 \newline
28095
28096 \newline
28097 When writing your code:
28098 \end_layout
28099
28100 \begin_layout Itemize
28101 write your code with debugging in mind (avoid duplicating code, put conceptually
28102  similar variables into structs, use structured code, have strategic points
28103  within your code where all variables are consistent, ...)
28104 \end_layout
28105
28106 \begin_layout Itemize
28107 run a syntax-checking tool like splint
28108 \begin_inset LatexCommand \index{splint (syntax checking tool)}
28109
28110 \end_inset
28111
28112
28113 \begin_inset LatexCommand \index{lint (syntax checking tool)}
28114
28115 \end_inset
28116
28117  (see -
28118 \begin_inset ERT
28119 status collapsed
28120
28121 \begin_layout Standard
28122
28123
28124 \backslash
28125 /
28126 \end_layout
28127
28128 \end_inset
28129
28130 -more-pedantic 
28131 \begin_inset LatexCommand \ref{lyx:more-pedantic-SPLINT}
28132
28133 \end_inset
28134
28135 ) over the code.
28136 \end_layout
28137
28138 \begin_layout Itemize
28139 for the high level code use a C-compiler (like f.e.
28140  GCC) to compile run and debug the code on your host.
28141  See (see -
28142 \begin_inset ERT
28143 status collapsed
28144
28145 \begin_layout Standard
28146
28147
28148 \backslash
28149 /
28150 \end_layout
28151
28152 \end_inset
28153
28154 -more-pedantic 
28155 \begin_inset LatexCommand \ref{lyx:more-pedantic-SPLINT}
28156
28157 \end_inset
28158
28159 ) on how to handle syntax extensions like __xdata, __at(), ...
28160  
28161 \end_layout
28162
28163 \begin_layout Itemize
28164 use another C-compiler to compile code for your target.
28165  Always an option but not recommended:) And not very likely to help you.
28166  If you seriously consider walking this path you should at least occasionally
28167  check portability of your code.
28168  Most commercial compiler vendors will offer an evaluation version so you
28169  can test compile your code or snippets of your code.
28170 \end_layout
28171
28172 \begin_layout Standard
28173 Debugging on a simulator:
28174 \end_layout
28175
28176 \begin_layout Itemize
28177 there is a separate section about SDCDB (section 
28178 \begin_inset LatexCommand \ref{cha:Debugging-with-SDCDB}
28179
28180 \end_inset
28181
28182 ) below.
28183 \end_layout
28184
28185 \begin_layout Itemize
28186 or (8051 specific) use a freeware/commercial simulator which interfaces
28187  to the AOMF
28188 \begin_inset LatexCommand \index{AOMF, AOMF51}
28189
28190 \end_inset
28191
28192  file (see 
28193 \begin_inset LatexCommand \ref{OMF file}
28194
28195 \end_inset
28196
28197 ) optionally generated by SDCC.
28198 \end_layout
28199
28200 \begin_layout Standard
28201 Debugging On-target: 
28202 \end_layout
28203
28204 \begin_layout Itemize
28205 use a MCU port pin to serially output debug data to the RS232 port of your
28206  host.
28207  You'll probably want some level shifting device typically involving a MAX232
28208  or similar IC.
28209  If the hardware serial port of the MCU is not available search for 'Software
28210  UART' in your favourite search machine.
28211 \end_layout
28212
28213 \begin_layout Itemize
28214 use an on-target monitor.
28215  In this context a monitor is a small program which usually accepts commands
28216  via a serial line and allows to set program counter, to single step through
28217  a program and read/write memory locations.
28218  For the 8051 good examples of monitors are paulmon and cmon51 (see section
28219  
28220 \begin_inset LatexCommand \ref{sec:Related-open-source-tools}
28221
28222 \end_inset
28223
28224 ).
28225 \end_layout
28226
28227 \begin_layout Itemize
28228 toggle MCU port pins at strategic points within your code and use an oscilloscop
28229 e.
28230  A 
28231 \emph on
28232 digital oscilloscope
28233 \emph default
28234
28235 \begin_inset LatexCommand \index{Oscilloscope}
28236
28237 \end_inset
28238
28239  with deep trace memory is really helpful especially if you have to debug
28240  a realtime application.
28241  If you need to monitor more pins than your oscilloscope provides you can
28242  sometimes get away with a small R-2R network.
28243  On a single channel oscilloscope you could f.e.
28244  monitor 2 push-pull driven pins by connecting one via a 10\InsetSpace ~
28245 k
28246 \begin_inset Formula $\Omega$
28247 \end_inset
28248
28249  resistor and the other one by a 5\InsetSpace ~
28250 k
28251 \begin_inset Formula $\Omega$
28252 \end_inset
28253
28254  resistor to the oscilloscope probe (check output drive capability of the
28255  pins you want to monitor).
28256  If you need to monitor many more pins a 
28257 \emph on
28258 logic analyzer
28259 \emph default
28260  will be handy.
28261 \end_layout
28262
28263 \begin_layout Itemize
28264 use an ICE (
28265 \emph on
28266 i
28267 \emph default
28268
28269 \emph on
28270 c
28271 \emph default
28272 ircuit 
28273 \emph on
28274 e
28275 \emph default
28276 mulator
28277 \begin_inset LatexCommand \index{ICE (in circuit emulator)}
28278
28279 \end_inset
28280
28281 ).
28282  Usually very expensive.
28283  And very nice to have too.
28284  And usually locks you (for years...) to the devices the ICE can emulate.
28285  
28286 \end_layout
28287
28288 \begin_layout Itemize
28289 use a remote debugger.
28290  In most 8-bit systems the symbol information is not available on the target,
28291  and a complete debugger is too bulky for the target system.
28292  Therefore usually a debugger on the host system connects to an on-target
28293  debugging stub which accepts only primitive commands.
28294  
28295 \newline
28296 Terms to enter into your favourite search engine could be 'remote debugging',
28297  'gdb stub' or 'inferior debugger'.
28298  (is there one?)
28299 \end_layout
28300
28301 \begin_layout Itemize
28302 use an on target hardware debugger.
28303  Some of the more modern MCUs include hardware support for setting break
28304  points and monitoring/changing variables by using dedicated hardware pins.
28305  This facility doesn't require additional code to run on the target and
28306  
28307 \emph on
28308 usually
28309 \emph default
28310  doesn't affect runtime behaviour until a breakpoint is hit.
28311  For the mcs51 most hardware debuggers use the AOMF
28312 \begin_inset LatexCommand \index{AOMF, AOMF51}
28313
28314 \end_inset
28315
28316  file (see 
28317 \begin_inset LatexCommand \ref{OMF file}
28318
28319 \end_inset
28320
28321 ) as input file.
28322  
28323 \end_layout
28324
28325 \begin_layout Standard
28326 Last not least:
28327 \end_layout
28328
28329 \begin_layout Itemize
28330 if you are not familiar with any of the following terms you're likely to
28331  run into problems rather sooner than later: 
28332 \emph on
28333 volatile
28334 \emph default
28335
28336 \emph on
28337 atomic
28338 \emph default
28339
28340 \emph on
28341 memory map
28342 \emph default
28343
28344 \emph on
28345 overlay
28346 \emph default
28347 .
28348  As an embedded programmer you 
28349 \emph on
28350 have
28351 \emph default
28352  to know them so why not look them up 
28353 \emph on
28354 before
28355 \emph default
28356  you have problems?)
28357 \end_layout
28358
28359 \begin_layout Itemize
28360 tell someone else about your problem (actually this is a surprisingly effective
28361  means to hunt down the bug even if the listener is not familiar with your
28362  environment).
28363  As 'failure to communicate' is probably one of the job-induced deformations
28364  of an embedded programmer this is highly encouraged.
28365 \end_layout
28366
28367 \begin_layout Section
28368 Debugging with SDCDB
28369 \begin_inset LatexCommand \label{cha:Debugging-with-SDCDB}
28370
28371 \end_inset
28372
28373
28374 \begin_inset LatexCommand \index{SDCDB (debugger)}
28375
28376 \end_inset
28377
28378  
28379 \end_layout
28380
28381 \begin_layout Standard
28382 SDCC is distributed with a source level debugger
28383 \begin_inset LatexCommand \index{Debugger}
28384
28385 \end_inset
28386
28387 .
28388  The debugger uses a command line interface, the command repertoire of the
28389  debugger has been kept as close to gdb
28390 \begin_inset LatexCommand \index{gdb}
28391
28392 \end_inset
28393
28394  (the GNU debugger) as possible.
28395  The configuration and build process is part of the standard compiler installati
28396 on, which also builds and installs the debugger in the target directory
28397  specified during configuration.
28398  The debugger allows you debug BOTH at the C source and at the ASM source
28399  level.
28400 \end_layout
28401
28402 \begin_layout Subsection
28403 Compiling for Debugging
28404 \end_layout
28405
28406 \begin_layout Standard
28407 The -
28408 \begin_inset ERT
28409 status collapsed
28410
28411 \begin_layout Standard
28412
28413
28414 \backslash
28415 /
28416 \end_layout
28417
28418 \end_inset
28419
28420 -debug
28421 \begin_inset LatexCommand \index{-\/-debug}
28422
28423 \end_inset
28424
28425  option must be specified for all files for which debug information is to
28426  be generated.
28427  The compiler generates a .adb file for each of these files.
28428  The linker creates the .cdb
28429 \begin_inset LatexCommand \index{<file>.cdb}
28430
28431 \end_inset
28432
28433  file from the .adb
28434 \begin_inset LatexCommand \index{<file>.adb}
28435
28436 \end_inset
28437
28438  files and the address information.
28439  This .cdb is used by the debugger.
28440 \end_layout
28441
28442 \begin_layout Subsection
28443 How the Debugger Works
28444 \end_layout
28445
28446 \begin_layout Standard
28447 When the -
28448 \begin_inset ERT
28449 status collapsed
28450
28451 \begin_layout Standard
28452
28453
28454 \backslash
28455 /
28456 \end_layout
28457
28458 \end_inset
28459
28460 -debug option is specified the compiler generates extra symbol information
28461  some of which are put into the assembler source and some are put into the
28462  .adb file.
28463  Then the linker creates the .cdb file from the individual .adb files with
28464  the address information for the symbols.
28465  The debugger reads the symbolic information generated by the compiler &
28466  the address information generated by the linker.
28467  It uses the SIMULATOR (Daniel's S51) to execute the program, the program
28468  execution is controlled by the debugger.
28469  When a command is issued for the debugger, it translates it into appropriate
28470  commands for the simulator.
28471  (Currently SDCDM only connects to the simulator but 
28472 \emph on
28473 newcdb
28474 \emph default
28475  at 
28476 \begin_inset LatexCommand \url{http://ec2drv.sf.net/}
28477
28478 \end_inset
28479
28480  is an effort to connect directly to the hardware.) 
28481 \end_layout
28482
28483 \begin_layout Subsection
28484 Starting the Debugger SDCDB
28485 \end_layout
28486
28487 \begin_layout Standard
28488 The debugger can be started using the following command line.
28489  (Assume the file you are debugging has the file name foo).
28490 \newline
28491
28492 \newline
28493
28494 \family sans
28495 \series bold
28496 sdcdb foo
28497 \newline
28498
28499 \family default
28500 \series default
28501
28502 \newline
28503 The debugger will look for the following files.
28504 \end_layout
28505
28506 \begin_layout Itemize
28507 foo.c - the source file.
28508 \end_layout
28509
28510 \begin_layout Itemize
28511 foo.cdb - the debugger symbol information file.
28512 \end_layout
28513
28514 \begin_layout Itemize
28515 foo.ihx - the Intel hex format
28516 \begin_inset LatexCommand \index{Intel hex format}
28517
28518 \end_inset
28519
28520  object file.
28521 \end_layout
28522
28523 \begin_layout Subsection
28524 SDCDB Command Line Options
28525 \end_layout
28526
28527 \begin_layout Itemize
28528 -
28529 \begin_inset ERT
28530 status collapsed
28531
28532 \begin_layout Standard
28533
28534
28535 \backslash
28536 /
28537 \end_layout
28538
28539 \end_inset
28540
28541 -directory=<source file directory> this option can used to specify the directory
28542  search list.
28543  The debugger will look into the directory list specified for source, cdb
28544  & ihx files.
28545  The items in the directory list must be separated by ':', e.g.
28546  if the source files can be in the directories /home/src1 and /home/src2,
28547  the -
28548 \begin_inset ERT
28549 status collapsed
28550
28551 \begin_layout Standard
28552
28553
28554 \backslash
28555 /
28556 \end_layout
28557
28558 \end_inset
28559
28560 -directory option should be -
28561 \begin_inset ERT
28562 status collapsed
28563
28564 \begin_layout Standard
28565
28566
28567 \backslash
28568 /
28569 \end_layout
28570
28571 \end_inset
28572
28573 -directory=/home/src1:/home/src2.
28574  Note there can be no spaces in the option.
28575  
28576 \end_layout
28577
28578 \begin_layout Itemize
28579 -cd <directory> - change to the <directory>.
28580 \end_layout
28581
28582 \begin_layout Itemize
28583 -fullname - used by GUI front ends.
28584 \end_layout
28585
28586 \begin_layout Itemize
28587 -cpu <cpu-type> - this argument is passed to the simulator please see the
28588  simulator docs for details.
28589 \end_layout
28590
28591 \begin_layout Itemize
28592 -X <Clock frequency > this options is passed to the simulator please see
28593  the simulator docs for details.
28594 \end_layout
28595
28596 \begin_layout Itemize
28597 -s <serial port file> passed to simulator see the simulator docs for details.
28598 \end_layout
28599
28600 \begin_layout Itemize
28601 -S <serial in,out> passed to simulator see the simulator docs for details.
28602 \end_layout
28603
28604 \begin_layout Itemize
28605 -k <port number> passed to simulator see the simulator docs for details.
28606 \end_layout
28607
28608 \begin_layout Subsection
28609 SDCDB Debugger Commands
28610 \end_layout
28611
28612 \begin_layout Standard
28613 As mentioned earlier the command interface for the debugger has been deliberatel
28614 y kept as close the GNU debugger gdb, as possible.
28615  This will help the integration with existing graphical user interfaces
28616  (like ddd, xxgdb or xemacs) existing for the GNU debugger.
28617  If you use a graphical user interface for the debugger you can skip this
28618  section.
28619 \end_layout
28620
28621 \begin_layout Subsubsection*
28622 break [line | file:line | function | file:function]
28623 \end_layout
28624
28625 \begin_layout Standard
28626 Set breakpoint at specified line or function:
28627 \newline
28628
28629 \newline
28630
28631 \family sans
28632 \series bold
28633 sdcdb>break 100 
28634 \newline
28635 sdcdb>break foo.c:100
28636 \newline
28637 sdcdb>break funcfoo
28638 \newline
28639 sdcdb>break foo.c:funcfoo
28640 \end_layout
28641
28642 \begin_layout Subsubsection*
28643 clear [line | file:line | function | file:function ]
28644 \end_layout
28645
28646 \begin_layout Standard
28647 Clear breakpoint at specified line or function:
28648 \newline
28649
28650 \newline
28651
28652 \family sans
28653 \series bold
28654 sdcdb>clear 100
28655 \newline
28656 sdcdb>clear foo.c:100
28657 \newline
28658 sdcdb>clear funcfoo
28659 \newline
28660 sdcdb>clear foo.c:funcfoo
28661 \end_layout
28662
28663 \begin_layout Subsubsection*
28664 continue
28665 \end_layout
28666
28667 \begin_layout Standard
28668 Continue program being debugged, after breakpoint.
28669 \end_layout
28670
28671 \begin_layout Subsubsection*
28672 finish
28673 \end_layout
28674
28675 \begin_layout Standard
28676 Execute till the end of the current function.
28677 \end_layout
28678
28679 \begin_layout Subsubsection*
28680 delete [n]
28681 \end_layout
28682
28683 \begin_layout Standard
28684 Delete breakpoint number 'n'.
28685  If used without any option clear ALL user defined break points.
28686 \end_layout
28687
28688 \begin_layout Subsubsection*
28689 info [break | stack | frame | registers ]
28690 \end_layout
28691
28692 \begin_layout Itemize
28693 info break - list all breakpoints
28694 \end_layout
28695
28696 \begin_layout Itemize
28697 info stack - show the function call stack.
28698 \end_layout
28699
28700 \begin_layout Itemize
28701 info frame - show information about the current execution frame.
28702 \end_layout
28703
28704 \begin_layout Itemize
28705 info registers - show content of all registers.
28706 \end_layout
28707
28708 \begin_layout Subsubsection*
28709 step
28710 \end_layout
28711
28712 \begin_layout Standard
28713 Step program until it reaches a different source line.
28714  Note: pressing <return> repeats the last command.
28715 \end_layout
28716
28717 \begin_layout Subsubsection*
28718 next
28719 \end_layout
28720
28721 \begin_layout Standard
28722 Step program, proceeding through subroutine calls.
28723 \end_layout
28724
28725 \begin_layout Subsubsection*
28726 run
28727 \end_layout
28728
28729 \begin_layout Standard
28730 Start debugged program.
28731 \end_layout
28732
28733 \begin_layout Subsubsection*
28734 ptype variable 
28735 \end_layout
28736
28737 \begin_layout Standard
28738 Print type information of the variable.
28739 \end_layout
28740
28741 \begin_layout Subsubsection*
28742 print variable
28743 \end_layout
28744
28745 \begin_layout Standard
28746 print value of variable.
28747 \end_layout
28748
28749 \begin_layout Subsubsection*
28750 file filename
28751 \end_layout
28752
28753 \begin_layout Standard
28754 load the given file name.
28755  Note this is an alternate method of loading file for debugging.
28756 \end_layout
28757
28758 \begin_layout Subsubsection*
28759 frame
28760 \end_layout
28761
28762 \begin_layout Standard
28763 print information about current frame.
28764 \end_layout
28765
28766 \begin_layout Subsubsection*
28767 set srcmode
28768 \end_layout
28769
28770 \begin_layout Standard
28771 Toggle between C source & assembly source.
28772 \end_layout
28773
28774 \begin_layout Subsubsection*
28775 ! simulator command
28776 \end_layout
28777
28778 \begin_layout Standard
28779 Send the string following '!' to the simulator, the simulator response is
28780  displayed.
28781  Note the debugger does not interpret the command being sent to the simulator,
28782  so if a command like 'go' is sent the debugger can loose its execution
28783  context and may display incorrect values.
28784 \end_layout
28785
28786 \begin_layout Subsubsection*
28787 quit
28788 \end_layout
28789
28790 \begin_layout Standard
28791 "Watch me now.
28792  Iam going Down.
28793  My name is Bobby Brown"
28794 \end_layout
28795
28796 \begin_layout Subsection
28797 Interfacing SDCDB with DDD
28798 \end_layout
28799
28800 \begin_layout Standard
28801 \begin_inset Note Note
28802 status collapsed
28803
28804 \begin_layout Standard
28805 The screenshot was converted from png to eps with: 
28806 \begin_inset Quotes sld
28807 \end_inset
28808
28809 bmeps -c -e8f -p3 ddd_example.png >ddd_example.eps
28810 \begin_inset Quotes srd
28811 \end_inset
28812
28813  which produces a pretty compact eps file which is free from compression
28814  artifacts.
28815 \end_layout
28816
28817 \begin_layout Standard
28818 The screenshot was included in sdccman.lyx cvs version 1.120 but later removed
28819  as this broke the build system on Sourceforge (pdf-file was broken.
28820  pdflatex does not accept eps files).
28821 \end_layout
28822
28823 \end_inset
28824
28825
28826 \end_layout
28827
28828 \begin_layout Standard
28829 The 
28830 \emph on
28831 p
28832 \emph default
28833 ortable 
28834 \emph on
28835 n
28836 \emph default
28837 etwork 
28838 \emph on
28839 g
28840 \emph default
28841 raphics File 
28842 \size footnotesize
28843
28844 \begin_inset LatexCommand \url{http://sdcc.svn.sourceforge.net/viewvc/*checkout*/sdcc/trunk/sdcc/doc/figures/ddd_example.png}
28845
28846 \end_inset
28847
28848
28849 \size default
28850  shows a screenshot of a debugging session with DDD
28851 \begin_inset LatexCommand \index{DDD (debugger)}
28852
28853 \end_inset
28854
28855  (Unix only) on a simulated 8032.
28856  The debugging session might not run as smoothly as the screenshot suggests.
28857  The debugger allows setting of breakpoints, displaying and changing variables,
28858  single stepping through C and assembler code.
28859  
28860 \newline
28861 The source was compiled with 
28862 \family sans
28863 \series bold
28864
28865 \newline
28866
28867 \newline
28868 sdcc -
28869 \family default
28870 \series default
28871
28872 \begin_inset ERT
28873 status collapsed
28874
28875 \begin_layout Standard
28876
28877
28878 \backslash
28879 /
28880 \end_layout
28881
28882 \end_inset
28883
28884
28885 \family sans
28886 \series bold
28887 -debug ddd_example.c
28888 \family default
28889 \series default
28890  
28891 \family sans
28892 \series bold
28893
28894 \newline
28895
28896 \family default
28897 \series default
28898
28899 \newline
28900 and DDD was invoked with 
28901 \family sans
28902 \series bold
28903
28904 \newline
28905
28906 \newline
28907 ddd -debugger "sdcdb -cpu 8032 ddd_example"
28908 \end_layout
28909
28910 \begin_layout Standard
28911 \begin_inset Note Note
28912 status open
28913
28914 \begin_layout Standard
28915 Check that the double quotes or an apostroph within the command line survive
28916  the LyX tool chain.
28917  Previously the apostrophs got slanted in the PDF output so a cut and paste
28918  did not work.
28919 \end_layout
28920
28921 \end_inset
28922
28923
28924 \end_layout
28925
28926 \begin_layout Subsection
28927 Interfacing SDCDB with XEmacs
28928 \begin_inset LatexCommand \index{XEmacs}
28929
28930 \end_inset
28931
28932
28933 \begin_inset LatexCommand \index{Emacs}
28934
28935 \end_inset
28936
28937
28938 \end_layout
28939
28940 \begin_layout Standard
28941 Two files (in emacs lisp) are provided for the interfacing with XEmacs,
28942  sdcdb.el and sdcdbsrc.el.
28943  These two files can be found in the $(prefix)/bin directory after the installat
28944 ion is complete.
28945  These files need to be loaded into XEmacs for the interface to work.
28946  This can be done at XEmacs startup time by inserting the following into
28947  your '.xemacs' file (which can be found in your HOME directory): 
28948 \newline
28949
28950 \newline
28951
28952 \family typewriter
28953 (load-file sdcdbsrc.el) 
28954 \family default
28955
28956 \newline
28957
28958 \newline
28959 .xemacs is a lisp file so the () around the command is REQUIRED.
28960  The files can also be loaded dynamically while XEmacs is running, set the
28961  environment variable 'EMACSLOADPATH' to the installation bin directory
28962  (<installdir>/bin), then enter the following command ESC-x load-file sdcdbsrc.
28963  To start the interface enter the following command: 
28964 \newline
28965
28966 \newline
28967
28968 \family sans
28969 \series bold
28970 ESC-x sdcdbsrc
28971 \family default
28972 \series default
28973
28974 \newline
28975
28976 \newline
28977 You will prompted to enter the file name to be debugged.
28978  
28979 \newline
28980
28981 \newline
28982 The command line options that are passed to the simulator directly are
28983  bound to default values in the file sdcdbsrc.el.
28984  The variables are listed below, these values maybe changed as required.
28985 \end_layout
28986
28987 \begin_layout Itemize
28988 sdcdbsrc-cpu-type '51
28989 \end_layout
28990
28991 \begin_layout Itemize
28992 sdcdbsrc-frequency '11059200
28993 \end_layout
28994
28995 \begin_layout Itemize
28996 sdcdbsrc-serial nil
28997 \end_layout
28998
28999 \begin_layout Standard
29000 The following is a list of key mapping for the debugger interface.
29001 \end_layout
29002
29003 \begin_layout Standard
29004 \InsetSpace ~
29005
29006 \family typewriter
29007
29008 \newline
29009 ;;\InsetSpace ~
29010 Current Listing :: 
29011 \newline
29012 ;;key\InsetSpace ~
29013 \InsetSpace ~
29014 \InsetSpace ~
29015 \InsetSpace ~
29016 \InsetSpace ~
29017 \InsetSpace ~
29018 \InsetSpace ~
29019 \InsetSpace ~
29020 \InsetSpace ~
29021 \InsetSpace ~
29022 \InsetSpace ~
29023 \InsetSpace ~
29024 \InsetSpace ~
29025 \InsetSpace ~
29026 binding\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 Comment 
29049 \newline
29050 ;;---\InsetSpace ~
29051 \InsetSpace ~
29052 \InsetSpace ~
29053 \InsetSpace ~
29054 \InsetSpace ~
29055 \InsetSpace ~
29056 \InsetSpace ~
29057 \InsetSpace ~
29058 \InsetSpace ~
29059 \InsetSpace ~
29060 \InsetSpace ~
29061 \InsetSpace ~
29062 \InsetSpace ~
29063 \InsetSpace ~
29064 -------\InsetSpace ~
29065 \InsetSpace ~
29066 \InsetSpace ~
29067 \InsetSpace ~
29068 \InsetSpace ~
29069 \InsetSpace ~
29070 \InsetSpace ~
29071 \InsetSpace ~
29072 \InsetSpace ~
29073 \InsetSpace ~
29074 \InsetSpace ~
29075 \InsetSpace ~
29076 \InsetSpace ~
29077 \InsetSpace ~
29078 \InsetSpace ~
29079 \InsetSpace ~
29080 \InsetSpace ~
29081 \InsetSpace ~
29082 \InsetSpace ~
29083 \InsetSpace ~
29084 \InsetSpace ~
29085 \InsetSpace ~
29086 -------
29087 \newline
29088 ;; 
29089 \newline
29090 ;;\InsetSpace ~
29091 n\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 \InsetSpace ~
29106 sdcdb-next-fro
29107 m-src\InsetSpace ~
29108 \InsetSpace ~
29109 \InsetSpace ~
29110 \InsetSpace ~
29111 \InsetSpace ~
29112 \InsetSpace ~
29113 \InsetSpace ~
29114 \InsetSpace ~
29115 \InsetSpace ~
29116 \InsetSpace ~
29117 SDCDB next command 
29118 \newline
29119 ;;\InsetSpace ~
29120 b\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 \InsetSpace ~
29134 \InsetSpace ~
29135 sdcdb-back-from-src\InsetSpace ~
29136 \InsetSpace ~
29137 \InsetSpace ~
29138 \InsetSpace ~
29139 \InsetSpace ~
29140 \InsetSpace ~
29141 \InsetSpace ~
29142 \InsetSpace ~
29143 \InsetSpace ~
29144 \InsetSpace ~
29145 SDCDB back command 
29146 \newline
29147 ;;\InsetSpace ~
29148 c\InsetSpace ~
29149 \InsetSpace ~
29150 \InsetSpace ~
29151 \InsetSpace ~
29152 \InsetSpace ~
29153 \InsetSpace ~
29154 \InsetSpace ~
29155 \InsetSpace ~
29156 \InsetSpace ~
29157 \InsetSpace ~
29158 \InsetSpace ~
29159 \InsetSpace ~
29160 \InsetSpace ~
29161 \InsetSpace ~
29162 \InsetSpace ~
29163 sdcdb-cont-f
29164 rom-src\InsetSpace ~
29165 \InsetSpace ~
29166 \InsetSpace ~
29167 \InsetSpace ~
29168 \InsetSpace ~
29169 \InsetSpace ~
29170 \InsetSpace ~
29171 \InsetSpace ~
29172 \InsetSpace ~
29173 \InsetSpace ~
29174 SDCDB continue command
29175 \newline
29176 ;;\InsetSpace ~
29177 s\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 \InsetSpace ~
29191 \InsetSpace ~
29192 sdcdb-step-from-src\InsetSpace ~
29193 \InsetSpace ~
29194 \InsetSpace ~
29195 \InsetSpace ~
29196 \InsetSpace ~
29197 \InsetSpace ~
29198 \InsetSpace ~
29199 \InsetSpace ~
29200 \InsetSpace ~
29201 \InsetSpace ~
29202 SDCDB step command 
29203 \newline
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 sdcdb-w
29221 hatis-c-sexp\InsetSpace ~
29222 \InsetSpace ~
29223 \InsetSpace ~
29224 \InsetSpace ~
29225 \InsetSpace ~
29226 \InsetSpace ~
29227 \InsetSpace ~
29228 \InsetSpace ~
29229 \InsetSpace ~
29230 \InsetSpace ~
29231 SDCDB ptypecommand for data at 
29232 \newline
29233 ;;\InsetSpace ~
29234 \InsetSpace ~
29235 \InsetSpace ~
29236 \InsetSpace ~
29237 \InsetSpace ~
29238 \InsetSpace ~
29239 \InsetSpace ~
29240 \InsetSpace ~
29241 \InsetSpace ~
29242 \InsetSpace ~
29243 \InsetSpace ~
29244 \InsetSpace ~
29245 \InsetSpace ~
29246 \InsetSpace ~
29247 \InsetSpace ~
29248 \InsetSpace ~
29249 \InsetSpace ~
29250 \InsetSpace ~
29251 \InsetSpace ~
29252 \InsetSpace ~
29253 \InsetSpace ~
29254 \InsetSpace ~
29255 \InsetSpace ~
29256 \InsetSpace ~
29257 \InsetSpace ~
29258 \InsetSpace ~
29259 \InsetSpace ~
29260 \InsetSpace ~
29261 \InsetSpace ~
29262 \InsetSpace ~
29263 \InsetSpace ~
29264 \InsetSpace ~
29265 \InsetSpace ~
29266 \InsetSpace ~
29267 \InsetSpace ~
29268 \InsetSpace ~
29269 \InsetSpace ~
29270 \InsetSpace ~
29271 \InsetSpace ~
29272 \InsetSpace ~
29273 \InsetSpace ~
29274 \InsetSpace ~
29275 \InsetSpace ~
29276 \InsetSpace ~
29277 \InsetSpace ~
29278 \InsetSpace ~
29279 \InsetSpace ~
29280 buffer point 
29281 \newline
29282 ;;\InsetSpace ~
29283 x\InsetSpace ~
29284 \InsetSpace ~
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 sdcdbsrc-delete\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 SDCD
29313 B Delete all breakpoints if no arg 
29314 \newline
29315 ;;\InsetSpace ~
29316 \InsetSpace ~
29317 \InsetSpace ~
29318 \InsetSpace ~
29319 \InsetSpace ~
29320 \InsetSpace ~
29321 \InsetSpace ~
29322 \InsetSpace ~
29323 \InsetSpace ~
29324 \InsetSpace ~
29325 \InsetSpace ~
29326 \InsetSpace ~
29327 \InsetSpace ~
29328 \InsetSpace ~
29329 \InsetSpace ~
29330 \InsetSpace ~
29331 \InsetSpace ~
29332 \InsetSpace ~
29333 \InsetSpace ~
29334 \InsetSpace ~
29335 \InsetSpace ~
29336 \InsetSpace ~
29337 \InsetSpace ~
29338 \InsetSpace ~
29339 \InsetSpace ~
29340 \InsetSpace ~
29341 \InsetSpace ~
29342 \InsetSpace ~
29343 \InsetSpace ~
29344 \InsetSpace ~
29345 \InsetSpace ~
29346 \InsetSpace ~
29347 \InsetSpace ~
29348 \InsetSpace ~
29349 \InsetSpace ~
29350 \InsetSpace ~
29351 \InsetSpace ~
29352 \InsetSpace ~
29353 \InsetSpace ~
29354 \InsetSpace ~
29355 \InsetSpace ~
29356 \InsetSpace ~
29357 \InsetSpace ~
29358 \InsetSpace ~
29359 \InsetSpace ~
29360 \InsetSpace ~
29361 \InsetSpace ~
29362 given or delete arg (C-u arg x) 
29363 \newline
29364 ;;\InsetSpace ~
29365 m\InsetSpace ~
29366 \InsetSpace ~
29367 \InsetSpace ~
29368 \InsetSpace ~
29369 \InsetSpace ~
29370 \InsetSpace ~
29371 \InsetSpace ~
29372 \InsetSpace ~
29373 \InsetSpace ~
29374 \InsetSpace ~
29375 \InsetSpace ~
29376 \InsetSpace ~
29377 \InsetSpace ~
29378 \InsetSpace ~
29379 \InsetSpace ~
29380 sdcdbsrc
29381 -frame\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 SDCDB Display current frame if no arg, 
29397 \newline
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 \InsetSpace ~
29416 \InsetSpace ~
29417 \InsetSpace ~
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 given or display frame arg
29446  
29447 \newline
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 \InsetSpace ~
29466 \InsetSpace ~
29467 \InsetSpace ~
29468 \InsetSpace ~
29469 \InsetSpace ~
29470 \InsetSpace ~
29471 \InsetSpace ~
29472 \InsetSpace ~
29473 \InsetSpace ~
29474 \InsetSpace ~
29475 \InsetSpace ~
29476 \InsetSpace ~
29477 \InsetSpace ~
29478 \InsetSpace ~
29479 \InsetSpace ~
29480 \InsetSpace ~
29481 \InsetSpace ~
29482 \InsetSpace ~
29483 \InsetSpace ~
29484 \InsetSpace ~
29485 \InsetSpace ~
29486 \InsetSpace ~
29487 \InsetSpace ~
29488 \InsetSpace ~
29489 \InsetSpace ~
29490 \InsetSpace ~
29491 \InsetSpace ~
29492 \InsetSpace ~
29493 \InsetSpace ~
29494 \InsetSpace ~
29495 buffer point 
29496 \newline
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 \InsetSpace ~
29512 \InsetSpace ~
29513 sdcdbsrc-goto-sdcdb\InsetSpace ~
29514 \InsetSpace ~
29515 \InsetSpace ~
29516 \InsetSpace ~
29517 \InsetSpace ~
29518 \InsetSpace ~
29519 \InsetSpace ~
29520 \InsetSpace ~
29521 \InsetSpace ~
29522 \InsetSpace ~
29523 Goto the SDCDB output buffer 
29524 \newline
29525 ;;\InsetSpace ~
29526 p\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 sdcdb-prin
29542 t-c-sexp\InsetSpace ~
29543 \InsetSpace ~
29544 \InsetSpace ~
29545 \InsetSpace ~
29546 \InsetSpace ~
29547 \InsetSpace ~
29548 \InsetSpace ~
29549 \InsetSpace ~
29550 \InsetSpace ~
29551 \InsetSpace ~
29552 \InsetSpace ~
29553 SDCDB print command for data at 
29554 \newline
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 \InsetSpace ~
29573 \InsetSpace ~
29574 \InsetSpace ~
29575 \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 \InsetSpace ~
29591 \InsetSpace ~
29592 \InsetSpace ~
29593 \InsetSpace ~
29594 \InsetSpace ~
29595 \InsetSpace ~
29596 \InsetSpace ~
29597 \InsetSpace ~
29598 \InsetSpace ~
29599 \InsetSpace ~
29600 \InsetSpace ~
29601 \InsetSpace ~
29602 buffer point 
29603 \newline
29604 ;;\InsetSpace ~
29605 g\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 \InsetSpace ~
29620 sdcdbsrc-goto-sdcdb\InsetSpace ~
29621 \InsetSpace ~
29622 \InsetSpace ~
29623 \InsetSpace ~
29624 \InsetSpace ~
29625 \InsetSpace ~
29626 \InsetSpace ~
29627 \InsetSpace ~
29628 \InsetSpace ~
29629 \InsetSpace ~
29630 Got
29631 o the SDCDB output buffer 
29632 \newline
29633 ;;\InsetSpace ~
29634 t\InsetSpace ~
29635 \InsetSpace ~
29636 \InsetSpace ~
29637 \InsetSpace ~
29638 \InsetSpace ~
29639 \InsetSpace ~
29640 \InsetSpace ~
29641 \InsetSpace ~
29642 \InsetSpace ~
29643 \InsetSpace ~
29644 \InsetSpace ~
29645 \InsetSpace ~
29646 \InsetSpace ~
29647 \InsetSpace ~
29648 \InsetSpace ~
29649 sdcdbsrc-mode\InsetSpace ~
29650 \InsetSpace ~
29651 \InsetSpace ~
29652 \InsetSpace ~
29653 \InsetSpace ~
29654 \InsetSpace ~
29655 \InsetSpace ~
29656 \InsetSpace ~
29657 \InsetSpace ~
29658 \InsetSpace ~
29659 \InsetSpace ~
29660 \InsetSpace ~
29661 \InsetSpace ~
29662 \InsetSpace ~
29663 \InsetSpace ~
29664 \InsetSpace ~
29665 Toggles Sdcdbsrc mode (turns it
29666  off) 
29667 \newline
29668 ;; 
29669 \newline
29670 ;;\InsetSpace ~
29671 C-c\InsetSpace ~
29672 C-f\InsetSpace ~
29673 \InsetSpace ~
29674 \InsetSpace ~
29675 \InsetSpace ~
29676 \InsetSpace ~
29677 \InsetSpace ~
29678 \InsetSpace ~
29679 \InsetSpace ~
29680 \InsetSpace ~
29681 sdcdb-finish-from-src\InsetSpace ~
29682 \InsetSpace ~
29683 \InsetSpace ~
29684 \InsetSpace ~
29685 \InsetSpace ~
29686 \InsetSpace ~
29687 \InsetSpace ~
29688 \InsetSpace ~
29689 SDCDB finish command 
29690 \newline
29691 ;; 
29692 \newline
29693 ;;\InsetSpace ~
29694 C-x\InsetSpace ~
29695 SPC\InsetSpace ~
29696 \InsetSpace ~
29697 \InsetSpace ~
29698 \InsetSpace ~
29699 \InsetSpace ~
29700 \InsetSpace ~
29701 \InsetSpace ~
29702 \InsetSpace ~
29703 \InsetSpace ~
29704 sdcdb-brea
29705 k\InsetSpace ~
29706 \InsetSpace ~
29707 \InsetSpace ~
29708 \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 Set break for line with point 
29724 \newline
29725 ;;\InsetSpace ~
29726 ESC\InsetSpace ~
29727 t\InsetSpace ~
29728 \InsetSpace ~
29729 \InsetSpace ~
29730 \InsetSpace ~
29731 \InsetSpace ~
29732 \InsetSpace ~
29733 \InsetSpace ~
29734 \InsetSpace ~
29735 \InsetSpace ~
29736 \InsetSpace ~
29737 \InsetSpace ~
29738 sdcdbsrc-mode\InsetSpace ~
29739 \InsetSpace ~
29740 \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 \InsetSpace ~
29754 Toggle Sdcdbsrc mode 
29755 \newline
29756 ;;\InsetSpace ~
29757 ESC\InsetSpace ~
29758 m\InsetSpace ~
29759 \InsetSpace ~
29760 \InsetSpace ~
29761 \InsetSpace ~
29762 \InsetSpace ~
29763 \InsetSpace ~
29764 \InsetSpace ~
29765 \InsetSpace ~
29766 \InsetSpace ~
29767 \InsetSpace ~
29768 \InsetSpace ~
29769 sdc
29770 dbsrc-srcmode\InsetSpace ~
29771 \InsetSpace ~
29772 \InsetSpace ~
29773 \InsetSpace ~
29774 \InsetSpace ~
29775 \InsetSpace ~
29776 \InsetSpace ~
29777 \InsetSpace ~
29778 \InsetSpace ~
29779 \InsetSpace ~
29780 \InsetSpace ~
29781 \InsetSpace ~
29782 \InsetSpace ~
29783 Toggle list mode 
29784 \newline
29785 ;; 
29786 \newline
29787
29788 \family default
29789
29790 \newpage
29791
29792 \end_layout
29793
29794 \begin_layout Chapter
29795 TIPS
29796 \end_layout
29797
29798 \begin_layout Standard
29799 Here are a few guidelines that will help the compiler generate more efficient
29800  code, some of the tips are specific to this compiler others are generally
29801  good programming practice.
29802 \end_layout
29803
29804 \begin_layout Itemize
29805 Use the smallest data type to represent your data-value.
29806  If it is known in advance that the value is going to be less than 256 then
29807  use an 'unsigned char' instead of a 'short' or 'int'.
29808  Please note, that ANSI C requires both signed and unsigned chars to be
29809  promoted to 'signed int'
29810 \begin_inset LatexCommand \index{promotion to signed int}
29811
29812 \end_inset
29813
29814
29815 \begin_inset Marginal
29816 status collapsed
29817
29818 \begin_layout Standard
29819
29820 \series bold
29821 \InsetSpace ~
29822 !
29823 \end_layout
29824
29825 \end_inset
29826
29827  before doing any operation.
29828  This promotion
29829 \begin_inset LatexCommand \index{type promotion}
29830
29831 \end_inset
29832
29833
29834 \begin_inset LatexCommand \label{type promotion}
29835
29836 \end_inset
29837
29838  can be omitted, if the result is the same.
29839  The effect of the promotion rules together with the sign-extension is often
29840  surprising:
29841 \end_layout
29842
29843 \begin_deeper
29844 \begin_layout Verse
29845
29846 \family typewriter
29847 unsigned char uc = 0xfe;
29848 \newline
29849 if (uc * uc < 0) /* this is true! */
29850 \newline
29851 {
29852 \newline
29853 \InsetSpace ~
29854 \InsetSpace ~
29855 \InsetSpace ~
29856 \InsetSpace ~
29857 ....
29858 \newline
29859 }
29860 \end_layout
29861
29862 \begin_layout Standard
29863
29864 \family typewriter
29865 uc * uc
29866 \family default
29867  is evaluated as 
29868 \family typewriter
29869 (int) uc * (int) uc = (int) 0xfe * (int) 0xfe = (int) 0xfc04 = -1024
29870 \family default
29871 .
29872  
29873 \newline
29874 Another one:
29875 \end_layout
29876
29877 \begin_layout Verse
29878
29879 \family typewriter
29880 (unsigned char) -12 / (signed char) -3 = ...
29881 \end_layout
29882
29883 \begin_layout Standard
29884 No, the result is not 4:
29885 \end_layout
29886
29887 \begin_layout Verse
29888
29889 \family typewriter
29890 (int) (unsigned char) -12 / (int) (signed char) -3 =
29891 \newline
29892 (int) (unsigned char)
29893  0xf4 / (int) (signed char) 0xfd =
29894 \newline
29895 (int) 0x00f4 / (int) 0xfffd =
29896 \newline
29897 (int) 0x00f4
29898  / (int) 0xfffd =
29899 \newline
29900 (int) 244 / (int) -3 =
29901 \newline
29902 (int) -81 = (int) 0xffaf;
29903 \end_layout
29904
29905 \begin_layout Standard
29906 Don't complain, that gcc gives you a different result.
29907  gcc uses 32 bit ints, while SDCC uses 16 bit ints.
29908  Therefore the results are different.
29909 \newline
29910 From 
29911 \begin_inset Quotes sld
29912 \end_inset
29913
29914 comp.lang.c FAQ
29915 \begin_inset Quotes srd
29916 \end_inset
29917
29918 :
29919 \end_layout
29920
29921 \begin_layout Quote
29922
29923 \emph on
29924 If well-defined overflow characteristics are important and negative values
29925  are not, or if you want to steer clear of sign-extension problems when
29926  manipulating bits or bytes, use one of the corresponding unsigned types.
29927  (Beware when mixing signed and unsigned values in expressions, though.)
29928 \newline
29929 Although
29930  character types (especially unsigned char) can be used as "tiny" integers,
29931  doing so is sometimes more trouble than it's worth, due to unpredictable
29932  sign extension and increased code size.
29933 \end_layout
29934
29935 \end_deeper
29936 \begin_layout Itemize
29937 Use unsigned when it is known in advance that the value is not going to
29938  be negative.
29939  This helps especially if you are doing division or multiplication, bit-shifting
29940  or are using an array index.
29941 \end_layout
29942
29943 \begin_layout Itemize
29944 NEVER jump into a LOOP.
29945 \end_layout
29946
29947 \begin_layout Itemize
29948 Declare the variables to be local
29949 \begin_inset LatexCommand \index{local variables}
29950
29951 \end_inset
29952
29953  whenever possible, especially loop control variables (induction).
29954 \end_layout
29955
29956 \begin_layout Itemize
29957 Have a look at the assembly listing to get a 
29958 \begin_inset Quotes sld
29959 \end_inset
29960
29961 feeling
29962 \begin_inset Quotes srd
29963 \end_inset
29964
29965  for the code generation.
29966 \end_layout
29967
29968 \begin_layout Section
29969 Porting code from or to other compilers
29970 \begin_inset LatexCommand \label{sec:Porting-code-to-other-compilers}
29971
29972 \end_inset
29973
29974
29975 \end_layout
29976
29977 \begin_layout Itemize
29978 check whether endianness of the compilers differs and adapt where needed.
29979 \end_layout
29980
29981 \begin_layout Itemize
29982 check the device specific header files
29983 \begin_inset LatexCommand \index{Header files}
29984
29985 \end_inset
29986
29987
29988 \begin_inset LatexCommand \index{Include files}
29989
29990 \end_inset
29991
29992  for compiler specific syntax.
29993  Eventually include the file <compiler.h
29994 \begin_inset LatexCommand \index{compiler.h (include file)}
29995
29996 \end_inset
29997
29998
29999 \begin_inset LatexCommand \url{http://sdcc.svn.sourceforge.net/viewvc/sdcc/trunk/sdcc/device/include/mcs51/compiler.h?view=markup}
30000
30001 \end_inset
30002
30003  to allow using common header files.
30004  (see f.e.
30005  cc2510fx.h 
30006 \begin_inset LatexCommand \url{http://sdcc.svn.sourceforge.net/viewvc/sdcc/trunk/sdcc/device/include/mcs51/cc2510fx.h?view=markup}
30007
30008 \end_inset
30009
30010 ).
30011 \end_layout
30012
30013 \begin_layout Itemize
30014 check whether the startup code contains the correct initialization (watchdog,
30015  peripherals).
30016 \end_layout
30017
30018 \begin_layout Itemize
30019 check whether the sizes of short, int, long match.
30020 \end_layout
30021
30022 \begin_layout Itemize
30023 check if some 16 or 32 bit hardware registers require a specific addressing
30024  order (least significant or most significant byte first) and adapt if needed
30025  (
30026 \emph on
30027 first
30028 \emph default
30029  and 
30030 \emph on
30031 last
30032 \emph default
30033  relate to time and not to lower/upper memory location here, so this is
30034  
30035 \emph on
30036 not
30037 \emph default
30038  the same as endianness).
30039 \end_layout
30040
30041 \begin_layout Itemize
30042 check whether the keyword 
30043 \emph on
30044 volatile
30045 \emph default
30046  is used where needed.
30047  The compilers might differ in their optimization characteristics (as different
30048  versions of the same compiler might also use more clever optimizations
30049  this is good idea anyway).
30050  See section 
30051 \begin_inset LatexCommand \ref{sub:Common-interrupt-pitfall-volatile}
30052
30053 \end_inset
30054
30055 .
30056 \end_layout
30057
30058 \begin_layout Itemize
30059 check that the compilers are not told to supress warnings.
30060 \end_layout
30061
30062 \begin_layout Itemize
30063 check and convert compiler specific extensions (interrupts, memory areas,
30064  pragmas etc.).
30065 \end_layout
30066
30067 \begin_layout Itemize
30068 check for differences in type promotion.
30069  Especially check for math operations on 
30070 \family typewriter
30071 char
30072 \family default
30073  or 
30074 \family typewriter
30075 unsigned char
30076 \family default
30077  variables.
30078  For the sake of C99 compatibility SDCC will probably promote these to 
30079 \family typewriter
30080 int
30081 \family default
30082  more often than other compilers.
30083  Eventually insert explicit casts to 
30084 \family typewriter
30085 (char) 
30086 \family default
30087 or
30088 \family typewriter
30089  (unsigned char)
30090 \family default
30091 .
30092  Also check that the ~\InsetSpace ~
30093 operator
30094 \begin_inset LatexCommand \index{\~\/ Operator}
30095
30096 \end_inset
30097
30098  is not used on 
30099 \family typewriter
30100 bit
30101 \begin_inset LatexCommand \index{bit}
30102
30103 \end_inset
30104
30105
30106 \family default
30107  variables, use the !\InsetSpace ~
30108 operator instead.
30109  See sections 
30110 \begin_inset LatexCommand \ref{type promotion}
30111
30112 \end_inset
30113
30114  and 
30115 \begin_inset LatexCommand \ref{sec:Compatibility-with-previous}
30116
30117 \end_inset
30118
30119 .
30120 \end_layout
30121
30122 \begin_layout Itemize
30123 check the assembly code generated for interrupt routines (f.e.
30124  for calls to possibly non-reentrant library functions).
30125 \end_layout
30126
30127 \begin_layout Itemize
30128 check whether timing loops result in proper timing (or preferably consider
30129  a rewrite of the code with timer based delays instead).
30130 \end_layout
30131
30132 \begin_layout Itemize
30133 check for differences in printf parameters (some compilers push (va_arg
30134 \begin_inset LatexCommand \index{vararg, va\_arg}
30135
30136 \end_inset
30137
30138 ) char variables as 
30139 \family typewriter
30140 int
30141 \family default
30142  others push them as 
30143 \family typewriter
30144 char
30145 \family default
30146 .
30147  See section 
30148 \begin_inset LatexCommand \ref{sec:Compatibility-with-previous}
30149
30150 \end_inset
30151
30152 ).
30153 \end_layout
30154
30155 \begin_layout Itemize
30156 check the resulting memory map
30157 \begin_inset LatexCommand \index{Memory map}
30158
30159 \end_inset
30160
30161 .
30162  Usage of different memory spaces: code, stack, data (for mcs51/ds390 additional
30163 ly idata, pdata, xdata).
30164  Eventually check if unexpected library functions are included.
30165 \end_layout
30166
30167 \begin_layout Section
30168 Tools
30169 \begin_inset LatexCommand \index{Tools}
30170
30171 \end_inset
30172
30173  included in the distribution
30174 \end_layout
30175
30176 \begin_layout Standard
30177 \align left
30178 \begin_inset Tabular
30179 <lyxtabular version="3" rows="12" columns="3">
30180 <features>
30181 <column alignment="left" valignment="top" leftline="true" width="0pt">
30182 <column alignment="left" valignment="top" leftline="true" width="0pt">
30183 <column alignment="left" valignment="top" leftline="true" rightline="true" width="0pt">
30184 <row topline="true" bottomline="true">
30185 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
30186 \begin_inset Text
30187
30188 \begin_layout Standard
30189
30190 \series bold
30191 Name
30192 \end_layout
30193
30194 \end_inset
30195 </cell>
30196 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
30197 \begin_inset Text
30198
30199 \begin_layout Standard
30200
30201 \series bold
30202 Purpose
30203 \end_layout
30204
30205 \end_inset
30206 </cell>
30207 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
30208 \begin_inset Text
30209
30210 \begin_layout Standard
30211
30212 \series bold
30213 Directory
30214 \end_layout
30215
30216 \end_inset
30217 </cell>
30218 </row>
30219 <row topline="true">
30220 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
30221 \begin_inset Text
30222
30223 \begin_layout Standard
30224 uCsim
30225 \begin_inset LatexCommand \index{uCsim}
30226
30227 \end_inset
30228
30229
30230 \end_layout
30231
30232 \end_inset
30233 </cell>
30234 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
30235 \begin_inset Text
30236
30237 \begin_layout Standard
30238 Simulator for various architectures
30239 \end_layout
30240
30241 \end_inset
30242 </cell>
30243 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
30244 \begin_inset Text
30245
30246 \begin_layout Standard
30247 sdcc/sim/ucsim
30248 \end_layout
30249
30250 \end_inset
30251 </cell>
30252 </row>
30253 <row topline="true">
30254 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
30255 \begin_inset Text
30256
30257 \begin_layout Standard
30258 keil2sdcc.pl
30259 \end_layout
30260
30261 \end_inset
30262 </cell>
30263 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
30264 \begin_inset Text
30265
30266 \begin_layout Standard
30267 header file
30268 \begin_inset LatexCommand \index{Header files}
30269
30270 \end_inset
30271
30272
30273 \begin_inset LatexCommand \index{Include files}
30274
30275 \end_inset
30276
30277  conversion
30278 \end_layout
30279
30280 \end_inset
30281 </cell>
30282 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
30283 \begin_inset Text
30284
30285 \begin_layout Standard
30286 sdcc/support/scripts
30287 \end_layout
30288
30289 \end_inset
30290 </cell>
30291 </row>
30292 <row topline="true">
30293 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
30294 \begin_inset Text
30295
30296 \begin_layout Standard
30297 mh2h.c
30298 \end_layout
30299
30300 \end_inset
30301 </cell>
30302 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
30303 \begin_inset Text
30304
30305 \begin_layout Standard
30306 header file conversion
30307 \end_layout
30308
30309 \end_inset
30310 </cell>
30311 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
30312 \begin_inset Text
30313
30314 \begin_layout Standard
30315 sdcc/support/scripts
30316 \end_layout
30317
30318 \end_inset
30319 </cell>
30320 </row>
30321 <row topline="true">
30322 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
30323 \begin_inset Text
30324
30325 \begin_layout Standard
30326 as-gbz80
30327 \end_layout
30328
30329 \end_inset
30330 </cell>
30331 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
30332 \begin_inset Text
30333
30334 \begin_layout Standard
30335 Assembler
30336 \end_layout
30337
30338 \end_inset
30339 </cell>
30340 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
30341 \begin_inset Text
30342
30343 \begin_layout Standard
30344
30345 \family roman
30346 \series medium
30347 \shape up
30348 \size normal
30349 \emph off
30350 \bar no
30351 \noun off
30352 \color none
30353 sdcc/bin
30354 \end_layout
30355
30356 \end_inset
30357 </cell>
30358 </row>
30359 <row topline="true">
30360 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
30361 \begin_inset Text
30362
30363 \begin_layout Standard
30364 as-z80
30365 \end_layout
30366
30367 \end_inset
30368 </cell>
30369 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
30370 \begin_inset Text
30371
30372 \begin_layout Standard
30373 Assembler
30374 \end_layout
30375
30376 \end_inset
30377 </cell>
30378 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
30379 \begin_inset Text
30380
30381 \begin_layout Standard
30382
30383 \family roman
30384 \series medium
30385 \shape up
30386 \size normal
30387 \emph off
30388 \bar no
30389 \noun off
30390 \color none
30391 sdcc/bin
30392 \end_layout
30393
30394 \end_inset
30395 </cell>
30396 </row>
30397 <row topline="true">
30398 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
30399 \begin_inset Text
30400
30401 \begin_layout Standard
30402 asx8051
30403 \end_layout
30404
30405 \end_inset
30406 </cell>
30407 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
30408 \begin_inset Text
30409
30410 \begin_layout Standard
30411 Assembler
30412 \end_layout
30413
30414 \end_inset
30415 </cell>
30416 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
30417 \begin_inset Text
30418
30419 \begin_layout Standard
30420
30421 \family roman
30422 \series medium
30423 \shape up
30424 \size normal
30425 \emph off
30426 \bar no
30427 \noun off
30428 \color none
30429 sdcc/bin
30430 \end_layout
30431
30432 \end_inset
30433 </cell>
30434 </row>
30435 <row topline="true">
30436 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
30437 \begin_inset Text
30438
30439 \begin_layout Standard
30440 SDCDB
30441 \end_layout
30442
30443 \end_inset
30444 </cell>
30445 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
30446 \begin_inset Text
30447
30448 \begin_layout Standard
30449 Simulator
30450 \end_layout
30451
30452 \end_inset
30453 </cell>
30454 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
30455 \begin_inset Text
30456
30457 \begin_layout Standard
30458
30459 \family roman
30460 \series medium
30461 \shape up
30462 \size normal
30463 \emph off
30464 \bar no
30465 \noun off
30466 \color none
30467 sdcc/bin
30468 \end_layout
30469
30470 \end_inset
30471 </cell>
30472 </row>
30473 <row topline="true">
30474 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
30475 \begin_inset Text
30476
30477 \begin_layout Standard
30478 aslink
30479 \end_layout
30480
30481 \end_inset
30482 </cell>
30483 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
30484 \begin_inset Text
30485
30486 \begin_layout Standard
30487 Linker
30488 \end_layout
30489
30490 \end_inset
30491 </cell>
30492 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
30493 \begin_inset Text
30494
30495 \begin_layout Standard
30496
30497 \family roman
30498 \series medium
30499 \shape up
30500 \size normal
30501 \emph off
30502 \bar no
30503 \noun off
30504 \color none
30505 sdcc/bin
30506 \end_layout
30507
30508 \end_inset
30509 </cell>
30510 </row>
30511 <row topline="true">
30512 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
30513 \begin_inset Text
30514
30515 \begin_layout Standard
30516 link-z80
30517 \end_layout
30518
30519 \end_inset
30520 </cell>
30521 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
30522 \begin_inset Text
30523
30524 \begin_layout Standard
30525 Linker
30526 \end_layout
30527
30528 \end_inset
30529 </cell>
30530 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
30531 \begin_inset Text
30532
30533 \begin_layout Standard
30534
30535 \family roman
30536 \series medium
30537 \shape up
30538 \size normal
30539 \emph off
30540 \bar no
30541 \noun off
30542 \color none
30543 sdcc/bin
30544 \end_layout
30545
30546 \end_inset
30547 </cell>
30548 </row>
30549 <row topline="true">
30550 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
30551 \begin_inset Text
30552
30553 \begin_layout Standard
30554 link-gbz80
30555 \end_layout
30556
30557 \end_inset
30558 </cell>
30559 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
30560 \begin_inset Text
30561
30562 \begin_layout Standard
30563 Linker
30564 \end_layout
30565
30566 \end_inset
30567 </cell>
30568 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
30569 \begin_inset Text
30570
30571 \begin_layout Standard
30572
30573 \family roman
30574 \series medium
30575 \shape up
30576 \size normal
30577 \emph off
30578 \bar no
30579 \noun off
30580 \color none
30581 sdcc/bin
30582 \end_layout
30583
30584 \end_inset
30585 </cell>
30586 </row>
30587 <row topline="true" bottomline="true">
30588 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
30589 \begin_inset Text
30590
30591 \begin_layout Standard
30592 packihx
30593 \end_layout
30594
30595 \end_inset
30596 </cell>
30597 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
30598 \begin_inset Text
30599
30600 \begin_layout Standard
30601 Intel Hex packer 
30602 \begin_inset LatexCommand \index{packihx (tool)}
30603
30604 \end_inset
30605
30606
30607 \end_layout
30608
30609 \end_inset
30610 </cell>
30611 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
30612 \begin_inset Text
30613
30614 \begin_layout Standard
30615
30616 \family roman
30617 \series medium
30618 \shape up
30619 \size normal
30620 \emph off
30621 \bar no
30622 \noun off
30623 \color none
30624 sdcc/bin
30625 \end_layout
30626
30627 \end_inset
30628 </cell>
30629 </row>
30630 </lyxtabular>
30631
30632 \end_inset
30633
30634
30635 \newline
30636
30637 \end_layout
30638
30639 \begin_layout Section
30640 Documentation
30641 \begin_inset LatexCommand \index{Documentation}
30642
30643 \end_inset
30644
30645  included in the distribution
30646 \end_layout
30647
30648 \begin_layout Standard
30649 \align left
30650 \begin_inset Tabular
30651 <lyxtabular version="3" rows="10" columns="2">
30652 <features>
30653 <column alignment="block" valignment="top" leftline="true" width="40col%">
30654 <column alignment="block" valignment="top" leftline="true" rightline="true" width="60col%">
30655 <row topline="true" bottomline="true" endhead="true">
30656 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
30657 \begin_inset Text
30658
30659 \begin_layout Standard
30660
30661 \series bold
30662 Subject / Title
30663 \end_layout
30664
30665 \end_inset
30666 </cell>
30667 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
30668 \begin_inset Text
30669
30670 \begin_layout Standard
30671
30672 \series bold
30673 Filename / Where to get
30674 \end_layout
30675
30676 \end_inset
30677 </cell>
30678 </row>
30679 <row topline="true">
30680 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
30681 \begin_inset Text
30682
30683 \begin_layout Standard
30684 SDCC Compiler User Guide
30685 \end_layout
30686
30687 \end_inset
30688 </cell>
30689 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
30690 \begin_inset Text
30691
30692 \begin_layout Standard
30693 You're reading it right now
30694 \emph on
30695  \InsetSpace ~
30696 \InsetSpace ~
30697 \InsetSpace ~
30698
30699 \hfill
30700 online at:
30701 \emph default
30702
30703 \newline
30704
30705 \begin_inset LatexCommand \url{http://sdcc.sourceforge.net/doc/sdccman.pdf}
30706
30707 \end_inset
30708
30709
30710 \end_layout
30711
30712 \end_inset
30713 </cell>
30714 </row>
30715 <row topline="true">
30716 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
30717 \begin_inset Text
30718
30719 \begin_layout Standard
30720 Changelog of SDCC
30721 \end_layout
30722
30723 \end_inset
30724 </cell>
30725 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
30726 \begin_inset Text
30727
30728 \begin_layout Standard
30729 sdcc/Changelog
30730 \emph on
30731  \InsetSpace ~
30732 \InsetSpace ~
30733 \InsetSpace ~
30734
30735 \hfill
30736 online at:
30737 \emph default
30738
30739 \newline
30740
30741 \begin_inset LatexCommand \url{http://sdcc.svn.sourceforge.net/viewvc/*checkout*/sdcc/trunk/sdcc/ChangeLog}
30742
30743 \end_inset
30744
30745
30746 \end_layout
30747
30748 \end_inset
30749 </cell>
30750 </row>
30751 <row topline="true">
30752 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
30753 \begin_inset Text
30754
30755 \begin_layout Standard
30756 ASXXXX
30757 \begin_inset LatexCommand \index{asXXXX (as-gbz80, as-hc08, asx8051, as-z80)}
30758
30759 \end_inset
30760
30761
30762 \begin_inset LatexCommand \index{Assembler documentation}
30763
30764 \end_inset
30765
30766  Assemblers and
30767 \newline
30768 ASLINK
30769 \begin_inset LatexCommand \index{aslink}
30770
30771 \end_inset
30772
30773
30774 \begin_inset LatexCommand \index{Linker documentation}
30775
30776 \end_inset
30777
30778  Relocating Linker
30779 \end_layout
30780
30781 \end_inset
30782 </cell>
30783 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
30784 \begin_inset Text
30785
30786 \begin_layout Standard
30787 sdcc/as/doc/asxhtm.html 
30788 \emph on
30789 \InsetSpace ~
30790 \InsetSpace ~
30791 \InsetSpace ~
30792
30793 \hfill
30794 online at:
30795 \emph default
30796
30797 \newline
30798
30799 \begin_inset LatexCommand \url{http://sdcc.svn.sourceforge.net/viewvc/*checkout*/sdcc/trunk/sdcc/as/doc/asxhtm.html}
30800
30801 \end_inset
30802
30803
30804 \end_layout
30805
30806 \end_inset
30807 </cell>
30808 </row>
30809 <row topline="true">
30810 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
30811 \begin_inset Text
30812
30813 \begin_layout Standard
30814 SDCC regression test
30815 \begin_inset LatexCommand \index{Regression test}
30816
30817 \end_inset
30818
30819
30820 \end_layout
30821
30822 \end_inset
30823 </cell>
30824 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
30825 \begin_inset Text
30826
30827 \begin_layout Standard
30828 sdcc/doc/test_suite_spec.pdf 
30829 \emph on
30830 \InsetSpace ~
30831 \InsetSpace ~
30832 \InsetSpace ~
30833
30834 \hfill
30835 online at:
30836 \emph default
30837
30838 \newline
30839
30840 \begin_inset LatexCommand \url{http://sdcc.sourceforge.net/doc/test_suite_spec.pdf}
30841
30842 \end_inset
30843
30844
30845 \end_layout
30846
30847 \end_inset
30848 </cell>
30849 </row>
30850 <row topline="true">
30851 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
30852 \begin_inset Text
30853
30854 \begin_layout Standard
30855 Various notes
30856 \end_layout
30857
30858 \end_inset
30859 </cell>
30860 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
30861 \begin_inset Text
30862
30863 \begin_layout Standard
30864 sdcc/doc/* 
30865 \emph on
30866 \InsetSpace ~
30867 \InsetSpace ~
30868 \InsetSpace ~
30869
30870 \hfill
30871 online at:
30872 \emph default
30873
30874 \newline
30875
30876 \begin_inset LatexCommand \url{http://sdcc.svn.sourceforge.net/viewvc/sdcc/trunk/sdcc/doc/}
30877
30878 \end_inset
30879
30880
30881 \end_layout
30882
30883 \end_inset
30884 </cell>
30885 </row>
30886 <row topline="true">
30887 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
30888 \begin_inset Text
30889
30890 \begin_layout Standard
30891 Notes on debugging with SDCDB
30892 \begin_inset LatexCommand \index{SDCDB (debugger)}
30893
30894 \end_inset
30895
30896
30897 \end_layout
30898
30899 \end_inset
30900 </cell>
30901 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
30902 \begin_inset Text
30903
30904 \begin_layout Standard
30905 sdcc/debugger/README 
30906 \emph on
30907 \InsetSpace ~
30908 \InsetSpace ~
30909 \InsetSpace ~
30910
30911 \hfill
30912 online at
30913 \emph default
30914 :
30915 \newline
30916
30917 \begin_inset LatexCommand \url{http://sdcc.svn.sourceforge.net/viewvc/*checkout*/sdcc/trunk/sdcc/debugger/README}
30918
30919 \end_inset
30920
30921
30922 \end_layout
30923
30924 \end_inset
30925 </cell>
30926 </row>
30927 <row topline="true">
30928 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
30929 \begin_inset Text
30930
30931 \begin_layout Standard
30932 uCsim
30933 \begin_inset LatexCommand \index{uCsim}
30934
30935 \end_inset
30936
30937  Software simulator for microcontrollers
30938 \end_layout
30939
30940 \end_inset
30941 </cell>
30942 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
30943 \begin_inset Text
30944
30945 \begin_layout Standard
30946
30947 \family roman
30948 \series medium
30949 \shape up
30950 \size normal
30951 \emph off
30952 \bar no
30953 \noun off
30954 \color none
30955 sdcc/sim/ucsim/doc
30956 \family default
30957 \series default
30958 \shape default
30959 \size default
30960 \emph default
30961 \bar default
30962 \noun default
30963 /index.html 
30964 \emph on
30965 \InsetSpace ~
30966 \InsetSpace ~
30967 \InsetSpace ~
30968
30969 \hfill
30970 online at:
30971 \emph default
30972
30973 \newline
30974
30975 \begin_inset LatexCommand \url{http://sdcc.svn.sourceforge.net/viewvc/*checkout*/sdcc/trunk/sdcc/sim/ucsim/doc/index.html}
30976
30977 \end_inset
30978
30979
30980 \end_layout
30981
30982 \end_inset
30983 </cell>
30984 </row>
30985 <row topline="true">
30986 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
30987 \begin_inset Text
30988
30989 \begin_layout Standard
30990 Temporary notes on the pic16
30991 \begin_inset LatexCommand \index{PIC16}
30992
30993 \end_inset
30994
30995  port
30996 \end_layout
30997
30998 \end_inset
30999 </cell>
31000 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31001 \begin_inset Text
31002
31003 \begin_layout Standard
31004 sdcc/src/pic16/NOTES 
31005 \emph on
31006 \InsetSpace ~
31007 \InsetSpace ~
31008 \InsetSpace ~
31009
31010 \hfill
31011 online at:
31012 \newline
31013
31014 \emph default
31015
31016 \begin_inset LatexCommand \url{http://sdcc.svn.sourceforge.net/viewvc/*checkout*/sdcc/trunk/sdcc/src/pic16/NOTES}
31017
31018 \end_inset
31019
31020
31021 \end_layout
31022
31023 \end_inset
31024 </cell>
31025 </row>
31026 <row topline="true" bottomline="true">
31027 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31028 \begin_inset Text
31029
31030 \begin_layout Standard
31031 SDCC internal documentation (debugging file format)
31032 \end_layout
31033
31034 \end_inset
31035 </cell>
31036 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31037 \begin_inset Text
31038
31039 \begin_layout Standard
31040 sdcc/doc/
31041 \family roman
31042 \series medium
31043 \shape up
31044 \size normal
31045 \emph off
31046 \bar no
31047 \noun off
31048 \color none
31049 cdbfileformat.pd
31050 \family default
31051 \series default
31052 \shape default
31053 \size default
31054 \emph default
31055 \bar default
31056 \noun default
31057 f
31058 \emph on
31059  \InsetSpace ~
31060 \InsetSpace ~
31061 \InsetSpace ~
31062
31063 \hfill
31064 online at:
31065 \emph default
31066
31067 \newline
31068
31069 \begin_inset LatexCommand \url{http://sdcc.sourceforge.net/doc/cdbfileformat.pdf}
31070
31071 \end_inset
31072
31073
31074 \end_layout
31075
31076 \end_inset
31077 </cell>
31078 </row>
31079 </lyxtabular>
31080
31081 \end_inset
31082
31083
31084 \newline
31085
31086 \end_layout
31087
31088 \begin_layout Section
31089 Related open source tools
31090 \begin_inset LatexCommand \label{sec:Related-open-source-tools}
31091
31092 \end_inset
31093
31094
31095 \begin_inset LatexCommand \index{Related tools}
31096
31097 \end_inset
31098
31099
31100 \end_layout
31101
31102 \begin_layout Standard
31103 \align left
31104 \begin_inset Tabular
31105 <lyxtabular version="3" rows="16" columns="3">
31106 <features>
31107 <column alignment="left" valignment="top" leftline="true" width="0pt">
31108 <column alignment="block" valignment="top" leftline="true" width="30line%">
31109 <column alignment="left" valignment="top" leftline="true" rightline="true" width="40col%">
31110 <row topline="true" bottomline="true">
31111 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31112 \begin_inset Text
31113
31114 \begin_layout Standard
31115
31116 \series bold
31117 Name
31118 \end_layout
31119
31120 \end_inset
31121 </cell>
31122 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31123 \begin_inset Text
31124
31125 \begin_layout Standard
31126
31127 \series bold
31128 Purpose
31129 \end_layout
31130
31131 \end_inset
31132 </cell>
31133 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31134 \begin_inset Text
31135
31136 \begin_layout Standard
31137
31138 \series bold
31139 Where to get
31140 \end_layout
31141
31142 \end_inset
31143 </cell>
31144 </row>
31145 <row topline="true">
31146 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31147 \begin_inset Text
31148
31149 \begin_layout Standard
31150 gpsim
31151 \begin_inset LatexCommand \index{gpsim (pic simulator)}
31152
31153 \end_inset
31154
31155
31156 \end_layout
31157
31158 \end_inset
31159 </cell>
31160 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31161 \begin_inset Text
31162
31163 \begin_layout Standard
31164 PIC simulator
31165 \end_layout
31166
31167 \end_inset
31168 </cell>
31169 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31170 \begin_inset Text
31171
31172 \begin_layout Standard
31173 \begin_inset LatexCommand \url{http://www.dattalo.com/gnupic/gpsim.html}
31174
31175 \end_inset
31176
31177
31178 \end_layout
31179
31180 \end_inset
31181 </cell>
31182 </row>
31183 <row topline="true">
31184 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31185 \begin_inset Text
31186
31187 \begin_layout Standard
31188 gputils
31189 \begin_inset LatexCommand \index{gputils (pic tools)}
31190
31191 \end_inset
31192
31193
31194 \end_layout
31195
31196 \end_inset
31197 </cell>
31198 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31199 \begin_inset Text
31200
31201 \begin_layout Standard
31202 GNU PIC utilities
31203 \end_layout
31204
31205 \end_inset
31206 </cell>
31207 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31208 \begin_inset Text
31209
31210 \begin_layout Standard
31211 \begin_inset LatexCommand \url{http://sourceforge.net/projects/gputils}
31212
31213 \end_inset
31214
31215
31216 \end_layout
31217
31218 \end_inset
31219 </cell>
31220 </row>
31221 <row topline="true">
31222 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31223 \begin_inset Text
31224
31225 \begin_layout Standard
31226 flP5
31227 \end_layout
31228
31229 \end_inset
31230 </cell>
31231 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31232 \begin_inset Text
31233
31234 \begin_layout Standard
31235 PIC programmer
31236 \end_layout
31237
31238 \end_inset
31239 </cell>
31240 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31241 \begin_inset Text
31242
31243 \begin_layout Standard
31244 \begin_inset LatexCommand \url{http://freshmeat.net/projects/flp5/}
31245
31246 \end_inset
31247
31248
31249 \end_layout
31250
31251 \end_inset
31252 </cell>
31253 </row>
31254 <row topline="true">
31255 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31256 \begin_inset Text
31257
31258 \begin_layout Standard
31259 ec2drv/newcdb
31260 \end_layout
31261
31262 \end_inset
31263 </cell>
31264 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31265 \begin_inset Text
31266
31267 \begin_layout Standard
31268 Tools for Silicon Laboratories JTAG debug adapter, partly based on SDCDB
31269  (Unix only)
31270 \end_layout
31271
31272 \end_inset
31273 </cell>
31274 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31275 \begin_inset Text
31276
31277 \begin_layout Standard
31278 \begin_inset LatexCommand \url{http://sourceforge.net/projects/ec2drv}
31279
31280 \end_inset
31281
31282
31283 \end_layout
31284
31285 \end_inset
31286 </cell>
31287 </row>
31288 <row topline="true">
31289 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31290 \begin_inset Text
31291
31292 \begin_layout Standard
31293 indent
31294 \begin_inset LatexCommand \index{indent (source formatting tool)}
31295
31296 \end_inset
31297
31298
31299 \end_layout
31300
31301 \end_inset
31302 </cell>
31303 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31304 \begin_inset Text
31305
31306 \begin_layout Standard
31307 Formats C source - Master of the white spaces
31308 \end_layout
31309
31310 \end_inset
31311 </cell>
31312 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31313 \begin_inset Text
31314
31315 \begin_layout Standard
31316 \begin_inset LatexCommand \url{http://directory.fsf.org/GNU/indent.html}
31317
31318 \end_inset
31319
31320
31321 \end_layout
31322
31323 \end_inset
31324 </cell>
31325 </row>
31326 <row topline="true">
31327 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31328 \begin_inset Text
31329
31330 \begin_layout Standard
31331 srecord
31332 \begin_inset LatexCommand \index{srecord (bin, hex, ... tool)}
31333
31334 \end_inset
31335
31336
31337 \end_layout
31338
31339 \end_inset
31340 </cell>
31341 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31342 \begin_inset Text
31343
31344 \begin_layout Standard
31345 Object file conversion, checksumming, ...
31346 \end_layout
31347
31348 \end_inset
31349 </cell>
31350 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31351 \begin_inset Text
31352
31353 \begin_layout Standard
31354 \begin_inset LatexCommand \url{http://sourceforge.net/projects/srecord}
31355
31356 \end_inset
31357
31358
31359 \end_layout
31360
31361 \end_inset
31362 </cell>
31363 </row>
31364 <row topline="true">
31365 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31366 \begin_inset Text
31367
31368 \begin_layout Standard
31369 objdump
31370 \begin_inset LatexCommand \index{objdump (tool)}
31371
31372 \end_inset
31373
31374
31375 \end_layout
31376
31377 \end_inset
31378 </cell>
31379 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31380 \begin_inset Text
31381
31382 \begin_layout Standard
31383 Object file conversion, ...
31384 \end_layout
31385
31386 \end_inset
31387 </cell>
31388 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31389 \begin_inset Text
31390
31391 \begin_layout Standard
31392 Part of binutils (should be there anyway)
31393 \end_layout
31394
31395 \end_inset
31396 </cell>
31397 </row>
31398 <row topline="true">
31399 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31400 \begin_inset Text
31401
31402 \begin_layout Standard
31403 cmon51
31404 \end_layout
31405
31406 \end_inset
31407 </cell>
31408 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31409 \begin_inset Text
31410
31411 \begin_layout Standard
31412 8051 monitor (hex up-/download, single step, disassemble)
31413 \end_layout
31414
31415 \end_inset
31416 </cell>
31417 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31418 \begin_inset Text
31419
31420 \begin_layout Standard
31421 \begin_inset LatexCommand \url{http://sourceforge.net/projects/cmon51}
31422
31423 \end_inset
31424
31425
31426 \end_layout
31427
31428 \end_inset
31429 </cell>
31430 </row>
31431 <row topline="true">
31432 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31433 \begin_inset Text
31434
31435 \begin_layout Standard
31436 doxygen
31437 \begin_inset LatexCommand \index{doxygen (source documentation tool)}
31438
31439 \end_inset
31440
31441
31442 \end_layout
31443
31444 \end_inset
31445 </cell>
31446 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31447 \begin_inset Text
31448
31449 \begin_layout Standard
31450 Source code documentation system
31451 \end_layout
31452
31453 \end_inset
31454 </cell>
31455 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31456 \begin_inset Text
31457
31458 \begin_layout Standard
31459 \begin_inset LatexCommand \url{http://www.doxygen.org}
31460
31461 \end_inset
31462
31463
31464 \end_layout
31465
31466 \end_inset
31467 </cell>
31468 </row>
31469 <row topline="true">
31470 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31471 \begin_inset Text
31472
31473 \begin_layout Standard
31474 kdevelop
31475 \end_layout
31476
31477 \end_inset
31478 </cell>
31479 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31480 \begin_inset Text
31481
31482 \begin_layout Standard
31483 IDE (has anyone tried integrating SDCC & SDCDB? Unix only)
31484 \end_layout
31485
31486 \end_inset
31487 </cell>
31488 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31489 \begin_inset Text
31490
31491 \begin_layout Standard
31492 \begin_inset LatexCommand \url{http://www.kdevelop.org}
31493
31494 \end_inset
31495
31496
31497 \end_layout
31498
31499 \end_inset
31500 </cell>
31501 </row>
31502 <row topline="true">
31503 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31504 \begin_inset Text
31505
31506 \begin_layout Standard
31507 paulmon
31508 \end_layout
31509
31510 \end_inset
31511 </cell>
31512 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31513 \begin_inset Text
31514
31515 \begin_layout Standard
31516 8051 monitor (hex up-/download, single step, disassemble)
31517 \end_layout
31518
31519 \end_inset
31520 </cell>
31521 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31522 \begin_inset Text
31523
31524 \begin_layout Standard
31525 \begin_inset LatexCommand \url{http://www.pjrc.com/tech/8051/paulmon2.html}
31526
31527 \end_inset
31528
31529
31530 \end_layout
31531
31532 \end_inset
31533 </cell>
31534 </row>
31535 <row topline="true">
31536 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31537 \begin_inset Text
31538
31539 \begin_layout Standard
31540 splint
31541 \begin_inset LatexCommand \index{splint (syntax checking tool)}
31542
31543 \end_inset
31544
31545
31546 \end_layout
31547
31548 \end_inset
31549 </cell>
31550 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31551 \begin_inset Text
31552
31553 \begin_layout Standard
31554 Statically checks c sources (see 
31555 \begin_inset LatexCommand \ref{lyx:more-pedantic-SPLINT}
31556
31557 \end_inset
31558
31559 )
31560 \end_layout
31561
31562 \end_inset
31563 </cell>
31564 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31565 \begin_inset Text
31566
31567 \begin_layout Standard
31568 \begin_inset LatexCommand \url{http://www.splint.org}
31569
31570 \end_inset
31571
31572
31573 \end_layout
31574
31575 \end_inset
31576 </cell>
31577 </row>
31578 <row topline="true" bottomline="true">
31579 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31580 \begin_inset Text
31581
31582 \begin_layout Standard
31583 ddd
31584 \begin_inset LatexCommand \index{DDD (debugger)}
31585
31586 \end_inset
31587
31588
31589 \end_layout
31590
31591 \end_inset
31592 </cell>
31593 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31594 \begin_inset Text
31595
31596 \begin_layout Standard
31597 Debugger, serves nicely as GUI to SDCDB
31598 \begin_inset LatexCommand \index{SDCDB (debugger)}
31599
31600 \end_inset
31601
31602  (Unix only)
31603 \end_layout
31604
31605 \end_inset
31606 </cell>
31607 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31608 \begin_inset Text
31609
31610 \begin_layout Standard
31611 \begin_inset LatexCommand \url{http://www.gnu.org/software/ddd/}
31612
31613 \end_inset
31614
31615
31616 \end_layout
31617
31618 \end_inset
31619 </cell>
31620 </row>
31621 <row bottomline="true">
31622 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31623 \begin_inset Text
31624
31625 \begin_layout Standard
31626 d52
31627 \begin_inset LatexCommand \index{d52}
31628
31629 \end_inset
31630
31631
31632 \begin_inset LatexCommand \index{d52 (disassembler)}
31633
31634 \end_inset
31635
31636
31637 \end_layout
31638
31639 \end_inset
31640 </cell>
31641 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31642 \begin_inset Text
31643
31644 \begin_layout Standard
31645 Disassembler, can count instruction cycles
31646 \begin_inset LatexCommand \index{instruction cycles (count)}
31647
31648 \end_inset
31649
31650 , use with options -pnd
31651 \end_layout
31652
31653 \end_inset
31654 </cell>
31655 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31656 \begin_inset Text
31657
31658 \begin_layout Standard
31659 \begin_inset LatexCommand \url{http://www.8052.com/users/disasm/}
31660
31661 \end_inset
31662
31663
31664 \end_layout
31665
31666 \end_inset
31667 </cell>
31668 </row>
31669 <row bottomline="true">
31670 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31671 \begin_inset Text
31672
31673 \begin_layout Standard
31674 cmake
31675 \begin_inset LatexCommand \index{cmake}
31676
31677 \end_inset
31678
31679
31680 \end_layout
31681
31682 \end_inset
31683 </cell>
31684 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31685 \begin_inset Text
31686
31687 \begin_layout Standard
31688 Cross platform build system, generates Makefiles
31689 \begin_inset LatexCommand \index{Makefile}
31690
31691 \end_inset
31692
31693  and project workspaces
31694 \begin_inset LatexCommand \index{project workspace}
31695
31696 \end_inset
31697
31698
31699 \end_layout
31700
31701 \end_inset
31702 </cell>
31703 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31704 \begin_inset Text
31705
31706 \begin_layout Standard
31707 \begin_inset LatexCommand \url{http://www.cmake.org}
31708
31709 \end_inset
31710
31711  \InsetSpace ~
31712 \InsetSpace ~
31713 \InsetSpace ~
31714 \InsetSpace ~
31715 and a dedicated wiki entry: 
31716 \begin_inset LatexCommand \url{http://www.cmake.org/Wiki/CmakeSdcc}
31717
31718 \end_inset
31719
31720
31721 \end_layout
31722
31723 \end_inset
31724 </cell>
31725 </row>
31726 </lyxtabular>
31727
31728 \end_inset
31729
31730
31731 \newline
31732
31733 \end_layout
31734
31735 \begin_layout Section
31736 Related documentation / recommended reading
31737 \end_layout
31738
31739 \begin_layout Standard
31740 \align left
31741 \begin_inset Tabular
31742 <lyxtabular version="3" rows="7" columns="3">
31743 <features>
31744 <column alignment="left" valignment="top" leftline="true" width="0pt">
31745 <column alignment="left" valignment="top" leftline="true" width="0">
31746 <column alignment="left" valignment="top" leftline="true" rightline="true" width="0pt">
31747 <row topline="true" bottomline="true">
31748 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31749 \begin_inset Text
31750
31751 \begin_layout Standard
31752
31753 \series bold
31754 Name
31755 \end_layout
31756
31757 \end_inset
31758 </cell>
31759 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31760 \begin_inset Text
31761
31762 \begin_layout Standard
31763
31764 \series bold
31765 Subject / Title
31766 \end_layout
31767
31768 \end_inset
31769 </cell>
31770 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31771 \begin_inset Text
31772
31773 \begin_layout Standard
31774
31775 \series bold
31776 Where to get
31777 \end_layout
31778
31779 \end_inset
31780 </cell>
31781 </row>
31782 <row topline="true">
31783 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31784 \begin_inset Text
31785
31786 \begin_layout Standard
31787
31788 \family roman
31789 \series medium
31790 \shape up
31791 \size normal
31792 \emph off
31793 \bar no
31794 \noun off
31795 \color none
31796 c-refcard.pdf
31797 \end_layout
31798
31799 \end_inset
31800 </cell>
31801 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31802 \begin_inset Text
31803
31804 \begin_layout Standard
31805 C Reference Card
31806 \begin_inset LatexCommand \index{C Reference card}
31807
31808 \end_inset
31809
31810 , 2 pages
31811 \end_layout
31812
31813 \end_inset
31814 </cell>
31815 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31816 \begin_inset Text
31817
31818 \begin_layout Standard
31819 \begin_inset LatexCommand \url{http://refcards.com/refcards/c/index.html}
31820
31821 \end_inset
31822
31823
31824 \end_layout
31825
31826 \end_inset
31827 </cell>
31828 </row>
31829 <row topline="true">
31830 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31831 \begin_inset Text
31832
31833 \begin_layout Standard
31834 c-faq
31835 \end_layout
31836
31837 \end_inset
31838 </cell>
31839 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31840 \begin_inset Text
31841
31842 \begin_layout Standard
31843 C-FAQ
31844 \begin_inset LatexCommand \index{C FAQ}
31845
31846 \end_inset
31847
31848
31849 \end_layout
31850
31851 \end_inset
31852 </cell>
31853 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31854 \begin_inset Text
31855
31856 \begin_layout Standard
31857 \begin_inset LatexCommand \url{http://www.c-faq.com}
31858
31859 \end_inset
31860
31861
31862 \end_layout
31863
31864 \end_inset
31865 </cell>
31866 </row>
31867 <row topline="true">
31868 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31869 \begin_inset Text
31870
31871 \begin_layout Standard
31872 ISO/IEC 9899:TC2
31873 \end_layout
31874
31875 \end_inset
31876 </cell>
31877 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31878 \begin_inset Text
31879
31880 \begin_layout Standard
31881 \begin_inset Quotes sld
31882 \end_inset
31883
31884 C-Standard
31885 \begin_inset Quotes srd
31886 \end_inset
31887
31888
31889 \end_layout
31890
31891 \end_inset
31892 </cell>
31893 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31894 \begin_inset Text
31895
31896 \begin_layout Standard
31897
31898 \size footnotesize
31899 \begin_inset LatexCommand \url{http://www.open-std.org/jtc1/sc22/wg14/www/standards.html#9899}
31900
31901 \end_inset
31902
31903
31904 \end_layout
31905
31906 \end_inset
31907 </cell>
31908 </row>
31909 <row topline="true">
31910 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31911 \begin_inset Text
31912
31913 \begin_layout Standard
31914 ISO/IEC DTR 18037
31915 \end_layout
31916
31917 \end_inset
31918 </cell>
31919 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31920 \begin_inset Text
31921
31922 \begin_layout Standard
31923 \begin_inset Quotes sld
31924 \end_inset
31925
31926 Extensions for Embedded C
31927 \begin_inset Quotes srd
31928 \end_inset
31929
31930
31931 \end_layout
31932
31933 \end_inset
31934 </cell>
31935 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31936 \begin_inset Text
31937
31938 \begin_layout Standard
31939
31940 \size footnotesize
31941 \begin_inset LatexCommand \url{http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1021.pdf}
31942
31943 \end_inset
31944
31945
31946 \end_layout
31947
31948 \end_inset
31949 </cell>
31950 </row>
31951 <row topline="true">
31952 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31953 \begin_inset Text
31954
31955 \begin_layout Standard
31956
31957 \end_layout
31958
31959 \end_inset
31960 </cell>
31961 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31962 \begin_inset Text
31963
31964 \begin_layout Standard
31965 Latest datasheet of target CPU
31966 \end_layout
31967
31968 \end_inset
31969 </cell>
31970 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31971 \begin_inset Text
31972
31973 \begin_layout Standard
31974 vendor
31975 \end_layout
31976
31977 \end_inset
31978 </cell>
31979 </row>
31980 <row topline="true" bottomline="true">
31981 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31982 \begin_inset Text
31983
31984 \begin_layout Standard
31985
31986 \end_layout
31987
31988 \end_inset
31989 </cell>
31990 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31991 \begin_inset Text
31992
31993 \begin_layout Standard
31994 Revision history of datasheet
31995 \end_layout
31996
31997 \end_inset
31998 </cell>
31999 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32000 \begin_inset Text
32001
32002 \begin_layout Standard
32003 vendor
32004 \end_layout
32005
32006 \end_inset
32007 </cell>
32008 </row>
32009 </lyxtabular>
32010
32011 \end_inset
32012
32013
32014 \newline
32015
32016 \end_layout
32017
32018 \begin_layout Section
32019 Application notes specifically for SDCC
32020 \end_layout
32021
32022 \begin_layout Standard
32023 SDCC makes no claims about the completeness of this list and about up-to-datenes
32024 s or correctness of the application notes
32025 \begin_inset LatexCommand \index{Application notes}
32026
32027 \end_inset
32028
32029 .
32030 \end_layout
32031
32032 \begin_layout Standard
32033 \align left
32034
32035 \size footnotesize
32036 \begin_inset Tabular
32037 <lyxtabular version="3" rows="7" columns="3">
32038 <features>
32039 <column alignment="block" valignment="top" leftline="true" width="17col%">
32040 <column alignment="block" valignment="top" leftline="true" width="27col%">
32041 <column alignment="block" valignment="top" leftline="true" rightline="true" width="57col%">
32042 <row topline="true" bottomline="true">
32043 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32044 \begin_inset Text
32045
32046 \begin_layout Standard
32047
32048 \series bold
32049 \size footnotesize
32050 Vendor
32051 \end_layout
32052
32053 \end_inset
32054 </cell>
32055 <cell alignment="left" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
32056 \begin_inset Text
32057
32058 \begin_layout Standard
32059
32060 \series bold
32061 \size footnotesize
32062 Subject / Title
32063 \end_layout
32064
32065 \end_inset
32066 </cell>
32067 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32068 \begin_inset Text
32069
32070 \begin_layout Standard
32071
32072 \series bold
32073 \size footnotesize
32074 Where to get
32075 \end_layout
32076
32077 \end_inset
32078 </cell>
32079 </row>
32080 <row topline="true">
32081 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32082 \begin_inset Text
32083
32084 \begin_layout Standard
32085
32086 \size footnotesize
32087 Maxim / Dallas
32088 \end_layout
32089
32090 \end_inset
32091 </cell>
32092 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32093 \begin_inset Text
32094
32095 \begin_layout Standard
32096
32097 \size footnotesize
32098 Using the SDCC Compiler for the DS80C400
32099 \begin_inset LatexCommand \index{DS80C400}
32100
32101 \end_inset
32102
32103
32104 \end_layout
32105
32106 \end_inset
32107 </cell>
32108 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32109 \begin_inset Text
32110
32111 \begin_layout Standard
32112
32113 \size footnotesize
32114 \begin_inset LatexCommand \url{http://pdfserv.maxim-ic.com/en/an/AN3346.pdf}
32115
32116 \end_inset
32117
32118
32119 \end_layout
32120
32121 \end_inset
32122 </cell>
32123 </row>
32124 <row topline="true">
32125 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32126 \begin_inset Text
32127
32128 \begin_layout Standard
32129
32130 \size footnotesize
32131 Maxim / Dallas
32132 \end_layout
32133
32134 \end_inset
32135 </cell>
32136 <cell multicolumn="1" alignment="left" valignment="top" topline="true" leftline="true" usebox="none" width="30line%">
32137 \begin_inset Text
32138
32139 \begin_layout Standard
32140
32141 \size footnotesize
32142 Using the Free SDCC C Compiler to Develop Firmware for the DS89C420/430/440/450
32143 \begin_inset LatexCommand \index{DS89C4x0}
32144
32145 \end_inset
32146
32147  Family of Microcontrollers
32148 \end_layout
32149
32150 \end_inset
32151 </cell>
32152 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32153 \begin_inset Text
32154
32155 \begin_layout Standard
32156
32157 \size footnotesize
32158 \begin_inset LatexCommand \url{http://pdfserv.maxim-ic.com/en/an/AN3477.pdf}
32159
32160 \end_inset
32161
32162
32163 \end_layout
32164
32165 \end_inset
32166 </cell>
32167 </row>
32168 <row topline="true">
32169 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32170 \begin_inset Text
32171
32172 \begin_layout Standard
32173
32174 \size footnotesize
32175 Silicon Laboratories / Cygnal
32176 \end_layout
32177
32178 \end_inset
32179 </cell>
32180 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32181 \begin_inset Text
32182
32183 \begin_layout Standard
32184
32185 \size footnotesize
32186 Integrating SDCC 8051 Tools Into The Silicon Labs IDE
32187 \begin_inset LatexCommand \index{IDE}
32188
32189 \end_inset
32190
32191
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.silabs.com/public/documents/tpub_doc/anote/Microcontrollers/en/an198.pdf}
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 Interfacing SDCC to Syn and Textpad
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">
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 Ramtron / Goal Semiconductor
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 Installing and Configuring SDCC and Crimson Editor 
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://www.ramtron.com/doc/Products/Microcontroller/Support_Tools.asp}
32281
32282 \end_inset
32283
32284
32285 \end_layout
32286
32287 \end_inset
32288 </cell>
32289 </row>
32290 <row topline="true" bottomline="true">
32291 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32292 \begin_inset Text
32293
32294 \begin_layout Standard
32295
32296 \size footnotesize
32297 Texas Instruments
32298 \end_layout
32299
32300 \end_inset
32301 </cell>
32302 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32303 \begin_inset Text
32304
32305 \begin_layout Standard
32306
32307 \size footnotesize
32308 MSC12xx Programming with SDCC
32309 \end_layout
32310
32311 \end_inset
32312 </cell>
32313 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32314 \begin_inset Text
32315
32316 \begin_layout Standard
32317
32318 \size footnotesize
32319 \begin_inset LatexCommand \url{http://focus.ti.com/general/docs/lit/getliterature.tsp?literatureNumber=sbaa109&fileType=pdf}
32320
32321 \end_inset
32322
32323
32324 \end_layout
32325
32326 \end_inset
32327 </cell>
32328 </row>
32329 </lyxtabular>
32330
32331 \end_inset
32332
32333
32334 \end_layout
32335
32336 \begin_layout Section
32337 Some Questions
32338 \end_layout
32339
32340 \begin_layout Standard
32341 Some questions answered, some pointers given - it might be time to in turn
32342  ask 
32343 \emph on
32344 you
32345 \emph default
32346  some questions: 
32347 \end_layout
32348
32349 \begin_layout Itemize
32350 can you solve your project with the selected microcontroller? Would you
32351  find out early or rather late that your target is too small/slow/whatever?
32352  Can you switch to a slightly better device if it doesn't fit?
32353 \end_layout
32354
32355 \begin_layout Itemize
32356 should you solve the problem with an 8 bit CPU? Or would a 16/32 bit CPU
32357  and/or another programming language be more adequate? Would an operating
32358  system on the target device help?
32359 \end_layout
32360
32361 \begin_layout Itemize
32362 if you solved the problem, will the marketing department be happy?
32363 \end_layout
32364
32365 \begin_layout Itemize
32366 if the marketing department is happy, will customers be happy?
32367 \end_layout
32368
32369 \begin_layout Itemize
32370 if you're the project manager, marketing department and maybe even the customer
32371  in one person, have you tried to see the project from the outside?
32372 \end_layout
32373
32374 \begin_layout Itemize
32375 is the project done if you think it is done? Or is just that other interface/pro
32376 tocol/feature/configuration/option missing? How about website, manual(s),
32377  internationali(z|s)ation, packaging, labels, 2nd source for components,
32378  electromagnetic compatability/interference, documentation for production,
32379  production test software, update mechanism, patent issues?
32380 \end_layout
32381
32382 \begin_layout Itemize
32383 is your project adequately positioned in that magic triangle: fame, fortune,
32384  fun?
32385 \end_layout
32386
32387 \begin_layout Standard
32388 Maybe not all answers to these questions are known and some answers may
32389  even be 
32390 \emph on
32391 no
32392 \emph default
32393 , nevertheless knowing these questions may help you to avoid burnout
32394 \begin_inset Foot
32395 status open
32396
32397 \begin_layout Standard
32398 burnout is bad for electronic devices, programmers and motorcycle tyres
32399 \end_layout
32400
32401 \end_inset
32402
32403 .
32404  Chances are you didn't want to hear some of them...
32405 \end_layout
32406
32407 \begin_layout Chapter
32408 Support
32409 \begin_inset LatexCommand \index{Support}
32410
32411 \end_inset
32412
32413
32414 \end_layout
32415
32416 \begin_layout Standard
32417 SDCC has grown to be a large project.
32418  The compiler alone (without the preprocessor, assembler and linker) is
32419  well over 150,000 lines of code (blank stripped).
32420  The open source nature of this project is a key to its continued growth
32421  and support.
32422  You gain the benefit and support of many active software developers and
32423  end users.
32424  Is SDCC perfect? No, that's why we need your help.
32425  The developers take pride in fixing reported bugs.
32426  You can help by reporting the bugs and helping other SDCC users.
32427  There are lots of ways to contribute, and we encourage you to take part
32428  in making SDCC a great software package.
32429  
32430 \end_layout
32431
32432 \begin_layout Standard
32433 The SDCC project is hosted on the SDCC sourceforge site at 
32434 \begin_inset LatexCommand \htmlurl{http://sourceforge.net/projects/sdcc}
32435
32436 \end_inset
32437
32438 .
32439  You'll find the complete set of mailing lists
32440 \begin_inset LatexCommand \index{Mailing list(s)}
32441
32442 \end_inset
32443
32444 , forums, bug reporting system, patch submission
32445 \begin_inset LatexCommand \index{Patch submission}
32446
32447 \end_inset
32448
32449  system, download
32450 \begin_inset LatexCommand \index{download}
32451
32452 \end_inset
32453
32454  area and Subversion code repository
32455 \begin_inset LatexCommand \index{Subversion code repository}
32456
32457 \end_inset
32458
32459  there.
32460 \end_layout
32461
32462 \begin_layout Section
32463 Reporting Bugs
32464 \begin_inset LatexCommand \index{Bug reporting}
32465
32466 \end_inset
32467
32468
32469 \begin_inset LatexCommand \index{Reporting bugs}
32470
32471 \end_inset
32472
32473
32474 \end_layout
32475
32476 \begin_layout Standard
32477 The recommended way of reporting bugs is using the infrastructure of the
32478  sourceforge site.
32479  You can follow the status of bug reports there and have an overview about
32480  the known bugs.
32481 \end_layout
32482
32483 \begin_layout Standard
32484 Bug reports are automatically forwarded to the developer mailing list and
32485  will be fixed ASAP.
32486  When reporting a bug, it is very useful to include a small test program
32487  (the smaller the better) which reproduces the problem.
32488  If you can isolate the problem by looking at the generated assembly code,
32489  this can be very helpful.
32490  Compiling your program with the -
32491 \begin_inset ERT
32492 status collapsed
32493
32494 \begin_layout Standard
32495
32496
32497 \backslash
32498 /
32499 \end_layout
32500
32501 \end_inset
32502
32503 -dumpall
32504 \begin_inset LatexCommand \index{-\/-dumpall}
32505
32506 \end_inset
32507
32508  option can sometimes be useful in locating optimization problems.
32509  When reporting a bug please make sure you:
32510 \end_layout
32511
32512 \begin_layout Enumerate
32513 Attach the code you are compiling with SDCC.
32514  
32515 \end_layout
32516
32517 \begin_layout Enumerate
32518 Specify the exact command you use to run SDCC, or attach your Makefile.
32519  
32520 \end_layout
32521
32522 \begin_layout Enumerate
32523 Specify the SDCC version (type "
32524 \family sans
32525 \series bold
32526 sdcc -v
32527 \family default
32528 \series default
32529 "), your platform, and operating system.
32530  
32531 \end_layout
32532
32533 \begin_layout Enumerate
32534 Provide an exact copy of any error message or incorrect output.
32535  
32536 \end_layout
32537
32538 \begin_layout Enumerate
32539 Put something meaningful in the subject of your message.
32540 \end_layout
32541
32542 \begin_layout Standard
32543 Please attempt to include these 5 important parts, as applicable, in all
32544  requests for support or when reporting any problems or bugs with SDCC.
32545  Though this will make your message lengthy, it will greatly improve your
32546  chance that SDCC users and developers will be able to help you.
32547  Some SDCC developers are frustrated by bug reports without code provided
32548  that they can use to reproduce and ultimately fix the problem, so please
32549  be sure to provide sample code if you are reporting a bug! 
32550 \end_layout
32551
32552 \begin_layout Standard
32553 Please have a short check that you are using a recent version of SDCC and
32554  the bug is not yet known.
32555  This is the link for reporting bugs: 
32556 \begin_inset LatexCommand \htmlurl{http://sourceforge.net/tracker/?group_id=599&atid=100599}
32557
32558 \end_inset
32559
32560 .
32561  With SDCC on average having more than 200 downloads
32562 \begin_inset LatexCommand \index{download}
32563
32564 \end_inset
32565
32566  on sourceforge per day
32567 \begin_inset Foot
32568 status open
32569
32570 \begin_layout Standard
32571 220 daily downloads on average Jan-Sept 2006 and about 150 daily downloads
32572  between 2002 and 2005.
32573  This does not include other methods of distribution.
32574 \end_layout
32575
32576 \end_inset
32577
32578  there must be some users.
32579  So it's not exactly easy to find a new bug.
32580  If you find one we need it: 
32581 \emph on
32582 reporting bugs is good
32583 \emph default
32584 .
32585 \end_layout
32586
32587 \begin_layout Section
32588 Requesting Features
32589 \begin_inset LatexCommand \label{sub:Requesting-Features}
32590
32591 \end_inset
32592
32593
32594 \begin_inset LatexCommand \index{Feature request}
32595
32596 \end_inset
32597
32598
32599 \begin_inset LatexCommand \index{Requesting features}
32600
32601 \end_inset
32602
32603
32604 \end_layout
32605
32606 \begin_layout Standard
32607 Like bug reports feature requests are forwarded to the developer mailing
32608  list.
32609  This is the link for requesting features: 
32610 \begin_inset LatexCommand \htmlurl{http://sourceforge.net/tracker/?group_id=599&atid=350599}
32611
32612 \end_inset
32613
32614 .
32615 \end_layout
32616
32617 \begin_layout Section
32618 Submitting patches
32619 \end_layout
32620
32621 \begin_layout Standard
32622 Like bug reports contributed patches are forwarded to the developer mailing
32623  list.
32624  This is the link for submitting patches
32625 \begin_inset LatexCommand \index{Patch submission}
32626
32627 \end_inset
32628
32629
32630 \begin_inset LatexCommand \url{http://sourceforge.net/tracker/?group_id=599&atid=300599}
32631
32632 \end_inset
32633
32634 .
32635 \end_layout
32636
32637 \begin_layout Standard
32638 You need to specify some parameters to the 
32639 \family typewriter
32640 diff
32641 \family default
32642  command for the patches to be useful.
32643  If you modified more than one file a patch created f.e.
32644  with 
32645 \family sans
32646 \series bold
32647
32648 \begin_inset Quotes sld
32649 \end_inset
32650
32651 diff -Naur unmodified_directory modified_directory >my_changes.patch
32652 \begin_inset Quotes srd
32653 \end_inset
32654
32655
32656 \family default
32657 \series default
32658  will be fine, otherwise 
32659 \family sans
32660 \series bold
32661
32662 \begin_inset Quotes sld
32663 \end_inset
32664
32665 diff -u sourcefile.c.orig sourcefile.c >my_changes.patch
32666 \begin_inset Quotes srd
32667 \end_inset
32668
32669
32670 \series default
32671  
32672 \family default
32673 will do.
32674 \end_layout
32675
32676 \begin_layout Section
32677 Getting Help
32678 \end_layout
32679
32680 \begin_layout Standard
32681 These links should take you directly to the 
32682 \begin_inset LatexCommand \url[Mailing lists]{http://sourceforge.net/mail/?group_id=599}
32683
32684 \end_inset
32685
32686
32687 \begin_inset Foot
32688 status open
32689
32690 \begin_layout Standard
32691 Traffic on sdcc-devel and sdcc-user is about 100 mails/month each not counting
32692  automated messages (mid 2003)
32693 \end_layout
32694
32695 \end_inset
32696
32697  and the 
32698 \begin_inset LatexCommand \url[Forums]{http://sourceforge.net/forum/?group_id=599}
32699
32700 \end_inset
32701
32702 , lists
32703 \begin_inset LatexCommand \index{Mailing list(s)}
32704
32705 \end_inset
32706
32707  and forums are archived and searchable so if you are lucky someone already
32708  had a similar problem.
32709  While mails to the lists themselves are delivered promptly their web front
32710  end on sourceforge sometimes shows a severe time lag (up to several weeks),
32711  if you're seriously using SDCC please consider subscribing to the lists.
32712 \end_layout
32713
32714 \begin_layout Section
32715 ChangeLog
32716 \end_layout
32717
32718 \begin_layout Standard
32719 You can follow the status of the Subversion version
32720 \begin_inset LatexCommand \index{version}
32721
32722 \end_inset
32723
32724  of SDCC by watching the Changelog
32725 \begin_inset LatexCommand \index{Changelog}
32726
32727 \end_inset
32728
32729  in the Subversion repository
32730 \size footnotesize
32731  
32732 \begin_inset LatexCommand \htmlurl{http://sdcc.svn.sourceforge.net/viewcvs.cgi/*checkout*/sdcc/trunk/sdcc/ChangeLog}
32733
32734 \end_inset
32735
32736 .
32737 \end_layout
32738
32739 \begin_layout Section
32740 Subversion Source Code Repository
32741 \end_layout
32742
32743 \begin_layout Standard
32744 The output of 
32745 \family sans
32746 \series bold
32747 sdcc -
32748 \family default
32749
32750 \begin_inset ERT
32751 status open
32752
32753 \begin_layout Standard
32754
32755
32756 \backslash
32757 /
32758 \end_layout
32759
32760 \end_inset
32761
32762
32763 \family sans
32764 -version
32765 \family default
32766 \series default
32767  or the filenames of the snapshot versions of SDCC include date and its
32768  Subversion
32769 \begin_inset LatexCommand \index{Subversion code repository}
32770
32771 \end_inset
32772
32773  number.
32774  Subversion allows to download the source of recent or previous versions
32775  
32776 \begin_inset LatexCommand \url{http://sourceforge.net/svn/?group_id=599}
32777
32778 \end_inset
32779
32780  (by number or by date).
32781  An on-line source code browser and detailled instructions are also available
32782  there.
32783  SDCC versions starting from 1999 up to now are available (currently the
32784  versions prior to the conversion from cvs
32785 \begin_inset LatexCommand \index{cvs|see{Subversion}}
32786
32787 \end_inset
32788
32789  to Subversion (April 2006) are either by accessible by Subversion or by
32790  cvs).
32791 \end_layout
32792
32793 \begin_layout Section
32794 Release policy
32795 \begin_inset LatexCommand \index{Release policy}
32796
32797 \end_inset
32798
32799
32800 \end_layout
32801
32802 \begin_layout Standard
32803 Historically there often were long delays between official releases and
32804  the sourceforge download area tends to get not updated at all.
32805  Excuses in the past might have referred to problems with live range analysis,
32806  but as this was fixed a while ago, the current problem is that another
32807  excuse has to be found.
32808  Kidding aside, we have to get better there! On the other hand there are
32809  daily snapshots available at 
32810 \begin_inset LatexCommand \htmlurl[snap]{http://sdcc.sourceforge.net/snap.php}
32811
32812 \end_inset
32813
32814 , and you can always build the very last version (hopefully with many bugs
32815  fixed, and features added) from the source code available at 
32816 \begin_inset LatexCommand \htmlurl[Source]{http://sdcc.sourceforge.net/snap.php#Source}
32817
32818 \end_inset
32819
32820 .
32821  The SDCC Wiki
32822 \begin_inset LatexCommand \index{wiki}
32823
32824 \end_inset
32825
32826
32827 \begin_inset LatexCommand \index{SDCC Wiki}
32828
32829 \end_inset
32830
32831  at 
32832 \begin_inset LatexCommand \url{http://sdcc.wiki.sourceforge.net/}
32833
32834 \end_inset
32835
32836  also holds some information about past and future releases.
32837 \end_layout
32838
32839 \begin_layout Section
32840 Examples
32841 \begin_inset LatexCommand \index{Examples}
32842
32843 \end_inset
32844
32845
32846 \end_layout
32847
32848 \begin_layout Standard
32849 You'll find some small examples in the directory 
32850 \emph on
32851 sdcc/device/examples/.
32852  
32853 \emph default
32854 More examples and libraries are available at
32855 \emph on
32856  The SDCC Open Knowledge Resource 
32857 \begin_inset LatexCommand \url{http://sdccokr.dl9sec.de/}
32858
32859 \end_inset
32860
32861  
32862 \emph default
32863 web site or at 
32864 \begin_inset LatexCommand \url{http://www.pjrc.com/tech/8051/}
32865
32866 \end_inset
32867
32868 .
32869 \end_layout
32870
32871 \begin_layout Standard
32872 \begin_inset Note Note
32873 status collapsed
32874
32875 \begin_layout Standard
32876 I did insert a reference to Paul's web site here although it seems rather
32877  dedicated to a specific 8032 board (I think it's okay because it f.e.
32878  shows LCD/Harddisc interface and has a free 8051 monitor.
32879  Independent 8032 board vendors face hard competition of heavily subsidized
32880  development boards anyway).
32881 \end_layout
32882
32883 \begin_layout Standard
32884 Maybe we should include some links to real world applications.
32885  Preferably pointer to pointers (one for each architecture) so this stays
32886  manageable here?
32887 \end_layout
32888
32889 \end_inset
32890
32891
32892 \end_layout
32893
32894 \begin_layout Section
32895 Quality control
32896 \begin_inset LatexCommand \label{sec:Quality-control}
32897
32898 \end_inset
32899
32900
32901 \begin_inset LatexCommand \index{Quality control}
32902
32903 \end_inset
32904
32905
32906 \end_layout
32907
32908 \begin_layout Standard
32909 The compiler is passed through snaphot build compile and build checks.
32910  The so called 
32911 \shape italic
32912 regression tests
32913 \shape default
32914
32915 \begin_inset LatexCommand \index{Regression test}
32916
32917 \end_inset
32918
32919  check that SDCC itself compiles flawlessly on several host platforms (i386,
32920  Opteron, 64 bit Alpha, ppc64, Mac OS X on ppc and i386, Solaris on Sparc)
32921  and checks the quality of the code generated by SDCC by running the code
32922  for several target platforms through simulators.
32923  The regression test suite comprises more than 100 files which expand to
32924  more than 500 test cases which include more than 4500 tests.
32925  The results of these tests are published daily on SDCC's snapshot page
32926  (click on the red or green symbols on the right side of 
32927 \begin_inset LatexCommand \url{http://sdcc.sourceforge.net/snap.php}
32928
32929 \end_inset
32930
32931 ).
32932 \end_layout
32933
32934 \begin_layout Standard
32935 There is a separate document 
32936 \shape italic
32937 test_suite.pdf 
32938 \begin_inset LatexCommand \index{Test suite}
32939
32940 \end_inset
32941
32942
32943 \shape default
32944  
32945 \begin_inset LatexCommand \url{http://sdcc.sourceforge.net/doc/test_suite_spec.pdf}
32946
32947 \end_inset
32948
32949  about the regression test suite.
32950 \end_layout
32951
32952 \begin_layout Standard
32953 You'll find the test code in the directory 
32954 \shape italic
32955 sdcc/support/regression
32956 \shape default
32957 .
32958  You can run these tests manually by running 
32959 \family sans
32960 make
32961 \family default
32962  in this directory (or f.e.
32963  
32964 \family sans
32965 \series bold
32966
32967 \begin_inset Quotes sld
32968 \end_inset
32969
32970 make test-mcs51
32971 \begin_inset Quotes srd
32972 \end_inset
32973
32974
32975 \family default
32976 \series default
32977  if you don't want to run the complete tests).
32978  The test code might also be interesting if you want to look for examples
32979 \begin_inset LatexCommand \index{Examples}
32980
32981 \end_inset
32982
32983  checking corner cases of SDCC or if you plan to submit patches
32984 \begin_inset LatexCommand \index{Patch submission}
32985
32986 \end_inset
32987
32988 .
32989 \end_layout
32990
32991 \begin_layout Standard
32992 The PIC14 port uses a different set of regression tests 
32993 \begin_inset LatexCommand \index{Regression test (PIC14)}
32994
32995 \end_inset
32996
32997 , you'll find them in the directory 
32998 \shape italic
32999 sdcc/src/regression
33000 \shape default
33001 .
33002 \end_layout
33003
33004 \begin_layout Section
33005 Use of SDCC in Education
33006 \end_layout
33007
33008 \begin_layout Standard
33009 In short: 
33010 \emph on
33011 highly
33012 \emph default
33013  encouraged
33014 \begin_inset Foot
33015 status open
33016
33017 \begin_layout Standard
33018 the phrase "use in education" might evoke the association "
33019 \emph on
33020 only
33021 \emph default
33022  fit for use in education".
33023  This connotation is not intended but nevertheless risked as the licensing
33024  of SDCC makes it difficult to offer educational discounts
33025 \end_layout
33026
33027 \end_inset
33028
33029 .
33030  If your rationales are to:
33031 \end_layout
33032
33033 \begin_layout Enumerate
33034 give students a chance to understand the 
33035 \emph on
33036 complete
33037 \emph default
33038  steps of code generation
33039 \end_layout
33040
33041 \begin_layout Enumerate
33042 have a curriculum that can be extended for years.
33043  Then you could use an fpga board as target and your curriculum will seamlessly
33044  extend from logic synthesis (
33045 \begin_inset LatexCommand \url[http://www.opencores.org]{opencores.org}
33046
33047 \end_inset
33048
33049
33050 \begin_inset LatexCommand \url[Oregano]{http://www.oregano.at/ip/ip01.htm}
33051
33052 \end_inset
33053
33054 ), over assembly programming, to C to FPGA compilers (
33055 \begin_inset LatexCommand \url[FPGAC]{http://sf.net/projects/fpgac}
33056
33057 \end_inset
33058
33059 ) and to C.
33060 \end_layout
33061
33062 \begin_layout Enumerate
33063 be able to insert excursions about skills like using a revision control
33064  system, submitting/applying patches, using a type-setting (as opposed to
33065  word-processing) engine LyX/LaTeX, using 
33066 \begin_inset LatexCommand \url[SourceForge]{http://www.sf.net}
33067
33068 \end_inset
33069
33070 , following some 
33071 \begin_inset LatexCommand \url[netiquette]{http://en.wikipedia.org/wiki/Netiquette}
33072
33073 \end_inset
33074
33075 , understanding BSD/LGPL/GPL/Proprietary licensing, growth models of Open
33076  Source Software, CPU simulation, compiler regression tests
33077 \begin_inset LatexCommand \index{Regression test}
33078
33079 \end_inset
33080
33081 .
33082  
33083 \newline
33084 And if there should be a shortage of ideas then you can always point students
33085  to the ever-growing feature request list 
33086 \begin_inset LatexCommand \htmlurl{http://sourceforge.net/tracker/?group_id=599&atid=350599}
33087
33088 \end_inset
33089
33090 .
33091 \end_layout
33092
33093 \begin_layout Enumerate
33094 not tie students to a specific host platform and instead allow them to use
33095  a host platform of 
33096 \emph on
33097 their
33098 \emph default
33099  choice (among them Alpha, i386, i386_64, Mac OS X, Mips, Sparc, Windows
33100  and eventually 
33101 \begin_inset LatexCommand \url[OLPC]{http://www.laptop.org}
33102
33103 \end_inset
33104
33105 )
33106 \end_layout
33107
33108 \begin_layout Enumerate
33109 not encourage students to use illegal copies of educational software
33110 \end_layout
33111
33112 \begin_layout Enumerate
33113 be immune to licensing/availability/price changes of the chosen tool chain
33114 \end_layout
33115
33116 \begin_layout Enumerate
33117 be able to change to a new target platform without having to adopt a new
33118  tool chain
33119 \end_layout
33120
33121 \begin_layout Enumerate
33122 have complete control over and insight into the tool chain
33123 \end_layout
33124
33125 \begin_layout Enumerate
33126 make your students aware about the pros and cons of open source software
33127  development
33128 \end_layout
33129
33130 \begin_layout Enumerate
33131 give back to the public as you are probably at least partially publically
33132  funded
33133 \end_layout
33134
33135 \begin_layout Enumerate
33136 give students a chance to publically prove their skills and to possibly
33137  see a world wide impact
33138 \end_layout
33139
33140 \begin_layout Standard
33141 then SDCC is probably among the first choices.
33142  Well, probably SDCC might be the only choice.
33143 \newpage
33144
33145 \end_layout
33146
33147 \begin_layout Chapter
33148 SDCC Technical Data
33149 \end_layout
33150
33151 \begin_layout Section
33152 Optimizations
33153 \begin_inset LatexCommand \index{Optimizations}
33154
33155 \end_inset
33156
33157
33158 \end_layout
33159
33160 \begin_layout Standard
33161 SDCC performs a host of standard optimizations in addition to some MCU specific
33162  optimizations.
33163  
33164 \end_layout
33165
33166 \begin_layout Subsection
33167 Sub-expression Elimination
33168 \begin_inset LatexCommand \index{Subexpression elimination}
33169
33170 \end_inset
33171
33172
33173 \end_layout
33174
33175 \begin_layout Standard
33176 The compiler does local and 
33177 \emph on
33178 g
33179 \emph default
33180 lobal 
33181 \emph on
33182 c
33183 \emph default
33184 ommon 
33185 \emph on
33186 s
33187 \emph default
33188 ubexpression 
33189 \emph on
33190 e
33191 \emph default
33192 limination, e.g.: 
33193 \end_layout
33194
33195 \begin_layout Verse
33196
33197 \family typewriter
33198 i = x + y + 1; 
33199 \newline
33200 j = x + y;
33201 \end_layout
33202
33203 \begin_layout Standard
33204 will be translated to
33205 \end_layout
33206
33207 \begin_layout Verse
33208
33209 \family typewriter
33210 iTemp = x + y; 
33211 \newline
33212 i = iTemp + 1; 
33213 \newline
33214 j = iTemp;
33215 \end_layout
33216
33217 \begin_layout Standard
33218 Some subexpressions are not as obvious as the above example, e.g.:
33219 \end_layout
33220
33221 \begin_layout Verse
33222
33223 \family typewriter
33224 a->b[i].c = 10; 
33225 \newline
33226 a->b[i].d = 11;
33227 \end_layout
33228
33229 \begin_layout Standard
33230 In this case the address arithmetic a->b[i] will be computed only once;
33231  the equivalent code in C would be.
33232 \end_layout
33233
33234 \begin_layout Verse
33235
33236 \family typewriter
33237 iTemp = a->b[i]; 
33238 \newline
33239 iTemp.c = 10; 
33240 \newline
33241 iTemp.d = 11;
33242 \end_layout
33243
33244 \begin_layout Standard
33245 The compiler will try to keep these temporary variables in registers.
33246 \end_layout
33247
33248 \begin_layout Subsection
33249 Dead-Code Elimination
33250 \begin_inset LatexCommand \index{Dead-code elimination}
33251
33252 \end_inset
33253
33254
33255 \end_layout
33256
33257 \begin_layout Verse
33258
33259 \family typewriter
33260 int global;
33261 \newline
33262
33263 \newline
33264 void f () { 
33265 \newline
33266 \InsetSpace ~
33267 \InsetSpace ~
33268 int i; 
33269 \newline
33270 \InsetSpace ~
33271 \InsetSpace ~
33272 i = 1; \InsetSpace ~
33273 \InsetSpace ~
33274 \InsetSpace ~
33275 \InsetSpace ~
33276 \InsetSpace ~
33277 /* dead store */ 
33278 \newline
33279 \InsetSpace ~
33280 \InsetSpace ~
33281 global = 1;\InsetSpace ~
33282 /* dead
33283  store */ 
33284 \newline
33285 \InsetSpace ~
33286 \InsetSpace ~
33287 global = 2; 
33288 \newline
33289 \InsetSpace ~
33290 \InsetSpace ~
33291 return; 
33292 \newline
33293 \InsetSpace ~
33294 \InsetSpace ~
33295 global = 3;\InsetSpace ~
33296 /* unreachable */ 
33297 \newline
33298 }
33299 \end_layout
33300
33301 \begin_layout Standard
33302 will be changed to
33303 \end_layout
33304
33305 \begin_layout Verse
33306
33307 \family typewriter
33308 int global;
33309 \newline
33310
33311 \newline
33312 void f () {
33313 \newline
33314 \InsetSpace ~
33315 \InsetSpace ~
33316 global = 2; 
33317 \newline
33318 }
33319 \end_layout
33320
33321 \begin_layout Subsection
33322 Copy-Propagation
33323 \begin_inset LatexCommand \index{Copy propagation}
33324
33325 \end_inset
33326
33327
33328 \end_layout
33329
33330 \begin_layout Verse
33331
33332 \family typewriter
33333 int f() { 
33334 \newline
33335 \InsetSpace ~
33336 \InsetSpace ~
33337 int i, j; 
33338 \newline
33339 \InsetSpace ~
33340 \InsetSpace ~
33341 i = 10; 
33342 \newline
33343 \InsetSpace ~
33344 \InsetSpace ~
33345 j = i; 
33346 \newline
33347 \InsetSpace ~
33348 \InsetSpace ~
33349 return j; 
33350 \newline
33351 }
33352 \end_layout
33353
33354 \begin_layout Standard
33355 will be changed to 
33356 \end_layout
33357
33358 \begin_layout Verse
33359
33360 \family typewriter
33361 int f() { 
33362 \newline
33363 \InsetSpace ~
33364 \InsetSpace ~
33365 int i, j; 
33366 \newline
33367 \InsetSpace ~
33368 \InsetSpace ~
33369 i = 10; 
33370 \newline
33371 \InsetSpace ~
33372 \InsetSpace ~
33373 j = 10; 
33374 \newline
33375 \InsetSpace ~
33376 \InsetSpace ~
33377 return 10; 
33378 \newline
33379 }
33380 \end_layout
33381
33382 \begin_layout Standard
33383 Note: the dead stores created by this copy propagation will be eliminated
33384  by dead-code elimination.
33385 \end_layout
33386
33387 \begin_layout Subsection
33388 Loop Optimizations
33389 \begin_inset LatexCommand \index{Loop optimization}
33390
33391 \end_inset
33392
33393
33394 \begin_inset LatexCommand \label{sub:Loop-Optimizations}
33395
33396 \end_inset
33397
33398
33399 \end_layout
33400
33401 \begin_layout Standard
33402 Two types of loop optimizations are done by SDCC 
33403 \emph on
33404 loop invariant
33405 \emph default
33406  lifting and
33407 \emph on
33408  strength reduction
33409 \emph default
33410  of loop induction variables.
33411  In addition to the strength reduction the optimizer marks the induction
33412  variables and the register allocator tries to keep the induction variables
33413  in registers for the duration of the loop.
33414  Because of this preference of the register allocator
33415 \begin_inset LatexCommand \index{Register allocation}
33416
33417 \end_inset
33418
33419 , loop induction optimization causes an increase in register pressure, which
33420  may cause unwanted spilling of other temporary variables into the stack
33421 \begin_inset LatexCommand \index{stack}
33422
33423 \end_inset
33424
33425  / data space.
33426  The compiler will generate a warning message when it is forced to allocate
33427  extra space either on the stack or data space.
33428  If this extra space allocation is undesirable then induction optimization
33429  can be eliminated either for the entire source file (with -
33430 \begin_inset ERT
33431 status collapsed
33432
33433 \begin_layout Standard
33434
33435
33436 \backslash
33437 /
33438 \end_layout
33439
33440 \end_inset
33441
33442 -noinduction option) or for a given function only using #pragma\InsetSpace ~
33443 noinduction
33444 \begin_inset LatexCommand \index{\#pragma noinduction}
33445
33446 \end_inset
33447
33448 .
33449 \newline
33450
33451 \newline
33452 Loop Invariant:
33453 \end_layout
33454
33455 \begin_layout Verse
33456
33457 \family typewriter
33458 for (i = 0 ; i < 100 ; i ++) 
33459 \newline
33460 \InsetSpace ~
33461 \InsetSpace ~
33462 \InsetSpace ~
33463 \InsetSpace ~
33464 f += k + l;
33465 \end_layout
33466
33467 \begin_layout Standard
33468 changed to
33469 \end_layout
33470
33471 \begin_layout Verse
33472
33473 \family typewriter
33474 itemp = k + l; 
33475 \newline
33476 for (i = 0; i < 100; i++) 
33477 \newline
33478 \InsetSpace ~
33479 \InsetSpace ~
33480 \InsetSpace ~
33481 \InsetSpace ~
33482 f += itemp;
33483 \end_layout
33484
33485 \begin_layout Standard
33486 As mentioned previously some loop invariants are not as apparent, all static
33487  address computations are also moved out of the loop.
33488 \newline
33489
33490 \newline
33491 Strength Reduction
33492 \begin_inset LatexCommand \index{Strength reduction}
33493
33494 \end_inset
33495
33496 , this optimization substitutes an expression by a cheaper expression:
33497 \end_layout
33498
33499 \begin_layout Verse
33500
33501 \family typewriter
33502 for (i=0;i < 100; i++)
33503 \newline
33504 \InsetSpace ~
33505 \InsetSpace ~
33506 \InsetSpace ~
33507 \InsetSpace ~
33508 ar[i*5] = i*3;
33509 \end_layout
33510
33511 \begin_layout Standard
33512 changed to
33513 \end_layout
33514
33515 \begin_layout Verse
33516
33517 \family typewriter
33518 itemp1 = 0; 
33519 \newline
33520 itemp2 = 0; 
33521 \newline
33522 for (i=0;i< 100;i++) { 
33523 \newline
33524 \InsetSpace ~
33525 \InsetSpace ~
33526 \InsetSpace ~
33527 \InsetSpace ~
33528 ar[itemp1] = itemp2; 
33529 \newline
33530 \InsetSpace ~
33531 \InsetSpace ~
33532 \InsetSpace ~
33533 \InsetSpace ~
33534 itemp1
33535  += 5; 
33536 \newline
33537 \InsetSpace ~
33538 \InsetSpace ~
33539 \InsetSpace ~
33540 \InsetSpace ~
33541 itemp2 += 3; 
33542 \newline
33543 }
33544 \end_layout
33545
33546 \begin_layout Standard
33547 The more expensive multiplication
33548 \begin_inset LatexCommand \index{Multiplication}
33549
33550 \end_inset
33551
33552  is changed to a less expensive addition.
33553 \end_layout
33554
33555 \begin_layout Subsection
33556 Loop Reversing
33557 \begin_inset LatexCommand \index{Loop reversing}
33558
33559 \end_inset
33560
33561
33562 \end_layout
33563
33564 \begin_layout Standard
33565 This optimization is done to reduce the overhead of checking loop boundaries
33566  for every iteration.
33567  Some simple loops can be reversed and implemented using a 
33568 \begin_inset Quotes eld
33569 \end_inset
33570
33571 decrement and jump if not zero
33572 \begin_inset Quotes erd
33573 \end_inset
33574
33575  instruction.
33576  SDCC checks for the following criterion to determine if a loop is reversible
33577  (note: more sophisticated compilers use data-dependency analysis to make
33578  this determination, SDCC uses a more simple minded analysis).
33579 \end_layout
33580
33581 \begin_layout Itemize
33582 The 'for' loop is of the form 
33583 \newline
33584
33585 \newline
33586
33587 \family typewriter
33588 for(<symbol> = <expression>; <sym> [< | <=] <expression>; [<sym>++ | <sym>
33589  += 1])
33590 \newline
33591 \InsetSpace ~
33592 \InsetSpace ~
33593 \InsetSpace ~
33594 \InsetSpace ~
33595 <for body>
33596 \end_layout
33597
33598 \begin_layout Itemize
33599 The <for body> does not contain 
33600 \begin_inset Quotes eld
33601 \end_inset
33602
33603 continue
33604 \begin_inset Quotes erd
33605 \end_inset
33606
33607  or 'break
33608 \begin_inset Quotes erd
33609 \end_inset
33610
33611 .
33612 \end_layout
33613
33614 \begin_layout Itemize
33615 All goto's are contained within the loop.
33616 \end_layout
33617
33618 \begin_layout Itemize
33619 No function calls within the loop.
33620 \end_layout
33621
33622 \begin_layout Itemize
33623 The loop control variable <sym> is not assigned any value within the loop
33624 \end_layout
33625
33626 \begin_layout Itemize
33627 The loop control variable does NOT participate in any arithmetic operation
33628  within the loop.
33629 \end_layout
33630
33631 \begin_layout Itemize
33632 There are NO switch statements in the loop.
33633 \end_layout
33634
33635 \begin_layout Subsection
33636 Algebraic Simplifications
33637 \end_layout
33638
33639 \begin_layout Standard
33640 SDCC does numerous algebraic simplifications, the following is a small sub-set
33641  of these optimizations.
33642 \end_layout
33643
33644 \begin_layout Verse
33645
33646 \family typewriter
33647 i = j + 0;\InsetSpace ~
33648 \InsetSpace ~
33649 \InsetSpace ~
33650 \InsetSpace ~
33651  /* changed to: */\InsetSpace ~
33652 \InsetSpace ~
33653 \InsetSpace ~
33654 \InsetSpace ~
33655  i = j; 
33656 \newline
33657 i /= 2;\InsetSpace ~
33658 \InsetSpace ~
33659 \InsetSpace ~
33660 \InsetSpace ~
33661 \InsetSpace ~
33662 \InsetSpace ~
33663 \InsetSpace ~
33664  /* changed to: */\InsetSpace ~
33665 \InsetSpace ~
33666 \InsetSpace ~
33667 \InsetSpace ~
33668  i >>= 1; 
33669 \newline
33670 i
33671  = j - j;\InsetSpace ~
33672 \InsetSpace ~
33673 \InsetSpace ~
33674 \InsetSpace ~
33675  /* changed to: */\InsetSpace ~
33676 \InsetSpace ~
33677 \InsetSpace ~
33678 \InsetSpace ~
33679  i = 0; 
33680 \newline
33681 i = j / 1;\InsetSpace ~
33682 \InsetSpace ~
33683 \InsetSpace ~
33684 \InsetSpace ~
33685  /* changed to: */\InsetSpace ~
33686 \InsetSpace ~
33687 \InsetSpace ~
33688 \InsetSpace ~
33689  i = j;
33690 \end_layout
33691
33692 \begin_layout Standard
33693 Note the subexpressions
33694 \begin_inset LatexCommand \index{Subexpression}
33695
33696 \end_inset
33697
33698  given above are generally introduced by macro expansions or as a result
33699  of copy/constant propagation.
33700 \end_layout
33701
33702 \begin_layout Subsection
33703 'switch' Statements
33704 \begin_inset LatexCommand \label{sub:'switch'-Statements}
33705
33706 \end_inset
33707
33708
33709 \begin_inset LatexCommand \index{switch statement}
33710
33711 \end_inset
33712
33713
33714 \end_layout
33715
33716 \begin_layout Standard
33717 SDCC can optimize switch statements to jump tables
33718 \begin_inset LatexCommand \index{jump tables}
33719
33720 \end_inset
33721
33722 .
33723  It makes the decision based on an estimate of the generated code size.
33724  SDCC is quite liberal in the requirements for jump table generation: 
33725 \end_layout
33726
33727 \begin_layout Itemize
33728 The labels need not be in order, and the starting number need not be one
33729  or zero, the case labels are in numerical sequence or not too many case
33730  labels are missing.
33731 \end_layout
33732
33733 \begin_deeper
33734 \begin_layout Verse
33735
33736 \family typewriter
33737 switch(i) {\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 \InsetSpace ~
33756 \InsetSpace ~
33757 \InsetSpace ~
33758 \InsetSpace ~
33759 \InsetSpace ~
33760 \InsetSpace ~
33761 \InsetSpace ~
33762 \InsetSpace ~
33763 switch (i) { 
33764 \newline
33765 \InsetSpace ~
33766 \InsetSpace ~
33767 \InsetSpace ~
33768 case 4: ...\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 \InsetSpace ~
33788 \InsetSpace ~
33789 \InsetSpace ~
33790 \InsetSpace ~
33791 \InsetSpace ~
33792 \InsetSpace ~
33793 \InsetSpace ~
33794 case 0: ...
33795  
33796 \newline
33797 \InsetSpace ~
33798 \InsetSpace ~
33799 \InsetSpace ~
33800 case 5: ...\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 \InsetSpace ~
33820 \InsetSpace ~
33821 \InsetSpace ~
33822 \InsetSpace ~
33823 \InsetSpace ~
33824 \InsetSpace ~
33825 \InsetSpace ~
33826 case 1: ...
33827  
33828 \newline
33829 \InsetSpace ~
33830 \InsetSpace ~
33831 \InsetSpace ~
33832 case 3: ...\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 \InsetSpace ~
33851 \InsetSpace ~
33852 \InsetSpace ~
33853 \InsetSpace ~
33854 \InsetSpace ~
33855 \InsetSpace ~
33856 \InsetSpace ~
33857 \InsetSpace ~
33858
33859 \newline
33860 \InsetSpace ~
33861 \InsetSpace ~
33862 \InsetSpace ~
33863 case 6: ...\InsetSpace ~
33864 \InsetSpace ~
33865 \InsetSpace ~
33866 \InsetSpace ~
33867 \InsetSpace ~
33868 \InsetSpace ~
33869 \InsetSpace ~
33870 \InsetSpace ~
33871 \InsetSpace ~
33872 \InsetSpace ~
33873 \InsetSpace ~
33874 \InsetSpace ~
33875 \InsetSpace ~
33876 \InsetSpace ~
33877 \InsetSpace ~
33878 \InsetSpace ~
33879 \InsetSpace ~
33880 \InsetSpace ~
33881 \InsetSpace ~
33882 \InsetSpace ~
33883 \InsetSpace ~
33884 \InsetSpace ~
33885 \InsetSpace ~
33886 \InsetSpace ~
33887 \InsetSpace ~
33888 \InsetSpace ~
33889 case 3: ...
33890  
33891 \newline
33892 \InsetSpace ~
33893 \InsetSpace ~
33894 \InsetSpace ~
33895 case 7: ...\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 \InsetSpace ~
33915 \InsetSpace ~
33916 \InsetSpace ~
33917 \InsetSpace ~
33918 \InsetSpace ~
33919 \InsetSpace ~
33920 \InsetSpace ~
33921 case 4: ...
33922  
33923 \newline
33924 \InsetSpace ~
33925 \InsetSpace ~
33926 \InsetSpace ~
33927 case 8: ...\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 \InsetSpace ~
33947 \InsetSpace ~
33948 \InsetSpace ~
33949 \InsetSpace ~
33950 \InsetSpace ~
33951 \InsetSpace ~
33952 \InsetSpace ~
33953 case 5: ...
33954  
33955 \newline
33956 \InsetSpace ~
33957 \InsetSpace ~
33958 \InsetSpace ~
33959 case 9: ...\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 \InsetSpace ~
33978 \InsetSpace ~
33979 \InsetSpace ~
33980 \InsetSpace ~
33981 \InsetSpace ~
33982 \InsetSpace ~
33983 \InsetSpace ~
33984 \InsetSpace ~
33985 case 6: ...
33986  
33987 \newline
33988 \InsetSpace ~
33989 \InsetSpace ~
33990 \InsetSpace ~
33991 case 10: ...\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 \InsetSpace ~
34009 \InsetSpace ~
34010 \InsetSpace ~
34011 \InsetSpace ~
34012 \InsetSpace ~
34013 \InsetSpace ~
34014 \InsetSpace ~
34015 \InsetSpace ~
34016 case 7: ...
34017  
34018 \newline
34019 \InsetSpace ~
34020 \InsetSpace ~
34021 \InsetSpace ~
34022 case 11: ...\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 case 8: ...
34048  
34049 \newline
34050 }\InsetSpace ~
34051 \InsetSpace ~
34052 \InsetSpace ~
34053 \InsetSpace ~
34054 \InsetSpace ~
34055 \InsetSpace ~
34056 \InsetSpace ~
34057 \InsetSpace ~
34058 \InsetSpace ~
34059 \InsetSpace ~
34060 \InsetSpace ~
34061 \InsetSpace ~
34062 \InsetSpace ~
34063 \InsetSpace ~
34064 \InsetSpace ~
34065 \InsetSpace ~
34066 \InsetSpace ~
34067 \InsetSpace ~
34068 \InsetSpace ~
34069 \InsetSpace ~
34070 \InsetSpace ~
34071 \InsetSpace ~
34072 \InsetSpace ~
34073 \InsetSpace ~
34074 \InsetSpace ~
34075 \InsetSpace ~
34076 \InsetSpace ~
34077 \InsetSpace ~
34078 \InsetSpace ~
34079 \InsetSpace ~
34080 \InsetSpace ~
34081 \InsetSpace ~
34082 \InsetSpace ~
34083 \InsetSpace ~
34084 \InsetSpace ~
34085 \InsetSpace ~
34086 }
34087 \end_layout
34088
34089 \begin_layout Standard
34090 Both the above switch statements will be implemented using a jump-table.
34091  The example to the right side is slightly more efficient as the check for
34092  the lower boundary of the jump-table is not needed.
34093 \end_layout
34094
34095 \end_deeper
34096 \begin_layout Itemize
34097 The number of case labels is not larger than supported by the target architectur
34098 e.
34099 \end_layout
34100
34101 \begin_layout Itemize
34102 If the case labels are not in numerical sequence ('gaps' between cases)
34103  SDCC checks whether a jump table with additionally inserted dummy cases
34104  is still attractive.
34105  
34106 \end_layout
34107
34108 \begin_layout Itemize
34109 If the starting number is not zero and a check for the lower boundary of
34110  the jump-table can thus be eliminated SDCC might insert dummy cases 0,
34111  ...
34112  .
34113 \end_layout
34114
34115 \begin_layout Standard
34116 Switch statements which have large gaps in the numeric sequence or those
34117  that have too many case labels can be split into more than one switch statement
34118  for efficient code generation, e.g.:
34119 \end_layout
34120
34121 \begin_layout Verse
34122
34123 \family typewriter
34124 switch (i) { 
34125 \newline
34126 \InsetSpace ~
34127 \InsetSpace ~
34128 case 1: ...
34129  
34130 \newline
34131 \InsetSpace ~
34132 \InsetSpace ~
34133 case 2: ...
34134  
34135 \newline
34136 \InsetSpace ~
34137 \InsetSpace ~
34138 case 3: ...
34139  
34140 \newline
34141 \InsetSpace ~
34142 \InsetSpace ~
34143 case 4: ...
34144  
34145 \newline
34146 \InsetSpace ~
34147 \InsetSpace ~
34148 case 5: ...
34149  
34150 \newline
34151 \InsetSpace ~
34152 \InsetSpace ~
34153 case 6: ...
34154  
34155 \newline
34156 \InsetSpace ~
34157 \InsetSpace ~
34158 case 7: ...
34159  
34160 \newline
34161 \InsetSpace ~
34162 \InsetSpace ~
34163 case 101: ...
34164  
34165 \newline
34166 \InsetSpace ~
34167 \InsetSpace ~
34168 case 102: ...
34169  
34170 \newline
34171 \InsetSpace ~
34172 \InsetSpace ~
34173 case 103: ...
34174  
34175 \newline
34176 \InsetSpace ~
34177 \InsetSpace ~
34178 case 104: ...
34179  
34180 \newline
34181 \InsetSpace ~
34182 \InsetSpace ~
34183 case 105: ...
34184  
34185 \newline
34186 \InsetSpace ~
34187 \InsetSpace ~
34188 case 106: ...
34189  
34190 \newline
34191 \InsetSpace ~
34192 \InsetSpace ~
34193 case 107: ...
34194  
34195 \newline
34196 }
34197 \end_layout
34198
34199 \begin_layout Standard
34200 If the above switch statement is broken down into two switch statements
34201 \end_layout
34202
34203 \begin_layout Verse
34204
34205 \family typewriter
34206 switch (i) { 
34207 \newline
34208 \InsetSpace ~
34209 \InsetSpace ~
34210 case 1: ...
34211  
34212 \newline
34213 \InsetSpace ~
34214 \InsetSpace ~
34215 case 2: ...
34216  
34217 \newline
34218 \InsetSpace ~
34219 \InsetSpace ~
34220 case 3: ...
34221  
34222 \newline
34223 \InsetSpace ~
34224 \InsetSpace ~
34225 case 4: ...
34226  
34227 \newline
34228 \InsetSpace ~
34229 \InsetSpace ~
34230 case 5: ...
34231  
34232 \newline
34233 \InsetSpace ~
34234 \InsetSpace ~
34235 case 6: ...
34236  
34237 \newline
34238 \InsetSpace ~
34239 \InsetSpace ~
34240 case 7: ...
34241  
34242 \newline
34243 }
34244 \end_layout
34245
34246 \begin_layout Standard
34247 and
34248 \end_layout
34249
34250 \begin_layout Verse
34251
34252 \family typewriter
34253 switch (i) { 
34254 \newline
34255 \InsetSpace ~
34256 \InsetSpace ~
34257 case 101: ...
34258  
34259 \newline
34260 \InsetSpace ~
34261 \InsetSpace ~
34262 case 102: ...
34263  
34264 \newline
34265 \InsetSpace ~
34266 \InsetSpace ~
34267 case 103: ...
34268  
34269 \newline
34270 \InsetSpace ~
34271 \InsetSpace ~
34272 case 104: ...
34273  
34274 \newline
34275 \InsetSpace ~
34276 \InsetSpace ~
34277 case 105: ...
34278  
34279 \newline
34280 \InsetSpace ~
34281 \InsetSpace ~
34282 case 106: ...
34283  
34284 \newline
34285 \InsetSpace ~
34286 \InsetSpace ~
34287 case 107: ...
34288  
34289 \newline
34290 }
34291 \end_layout
34292
34293 \begin_layout Standard
34294 then both the switch statements will be implemented using jump-tables whereas
34295  the unmodified switch statement will not be.
34296 \end_layout
34297
34298 \begin_layout Standard
34299 \begin_inset Note Note
34300 status collapsed
34301
34302 \begin_layout Standard
34303 There might be reasons which SDCC cannot know about to either favour or
34304  not favour jump tables.
34305  If the target system has to be as quick for the last switch case as for
34306  the first (pro jump table), or if the switch argument is known to be zero
34307  in the majority of the cases (contra jump table).
34308 \end_layout
34309
34310 \end_inset
34311
34312
34313 \end_layout
34314
34315 \begin_layout Standard
34316 The pragma nojtbound
34317 \begin_inset LatexCommand \index{\#pragma nojtbound}
34318
34319 \end_inset
34320
34321  can be used to turn off checking the 
34322 \emph on
34323 j
34324 \emph default
34325 ump 
34326 \emph on
34327 t
34328 \emph default
34329 able 
34330 \emph on
34331 bound
34332 \emph default
34333 aries.
34334  It has no effect if a default label is supplied.
34335  Use of this pragma is dangerous: if the switch
34336 \begin_inset LatexCommand \index{switch statement}
34337
34338 \end_inset
34339
34340  argument is not matched by a case statement the processor will happily
34341  jump into Nirvana.
34342 \end_layout
34343
34344 \begin_layout Subsection
34345 Bit-shifting Operations
34346 \begin_inset LatexCommand \index{Bit shifting}
34347
34348 \end_inset
34349
34350 .
34351 \end_layout
34352
34353 \begin_layout Standard
34354 Bit shifting is one of the most frequently used operation in embedded programmin
34355 g.
34356  SDCC tries to implement bit-shift operations in the most efficient way
34357  possible, e.g.:
34358 \end_layout
34359
34360 \begin_layout Verse
34361
34362 \family typewriter
34363 unsigned char i;
34364 \newline
34365 ...
34366  
34367 \newline
34368 i >>= 4; 
34369 \newline
34370 ...
34371 \end_layout
34372
34373 \begin_layout Standard
34374 generates the following code:
34375 \end_layout
34376
34377 \begin_layout Verse
34378
34379 \family typewriter
34380 mov\InsetSpace ~
34381  a,_i 
34382 \newline
34383 swap a 
34384 \newline
34385 anl\InsetSpace ~
34386  a,#0x0f 
34387 \newline
34388 mov\InsetSpace ~
34389  _i,a
34390 \end_layout
34391
34392 \begin_layout Standard
34393 In general SDCC will never setup a loop if the shift count is known.
34394  Another example:
34395 \end_layout
34396
34397 \begin_layout Verse
34398
34399 \family typewriter
34400 unsigned int i; 
34401 \newline
34402 ...
34403  
34404 \newline
34405 i >>= 9; 
34406 \newline
34407 ...
34408 \end_layout
34409
34410 \begin_layout Standard
34411 will generate:
34412 \end_layout
34413
34414 \begin_layout Verse
34415
34416 \family typewriter
34417 mov\InsetSpace ~
34418 \InsetSpace ~
34419 a,(_i + 1) 
34420 \newline
34421 mov\InsetSpace ~
34422 \InsetSpace ~
34423 (_i + 1),#0x00 
34424 \newline
34425 clr\InsetSpace ~
34426 \InsetSpace ~
34427
34428 \newline
34429 rrc\InsetSpace ~
34430 \InsetSpace ~
34431
34432 \newline
34433 mov\InsetSpace ~
34434 \InsetSpace ~
34435 _i,a
34436 \end_layout
34437
34438 \begin_layout Subsection
34439 Bit-rotation
34440 \begin_inset LatexCommand \index{Bit rotation}
34441
34442 \end_inset
34443
34444
34445 \end_layout
34446
34447 \begin_layout Standard
34448 A special case of the bit-shift operation is bit rotation
34449 \begin_inset LatexCommand \index{rotating bits}
34450
34451 \end_inset
34452
34453 , SDCC recognizes the following expression to be a left bit-rotation:
34454 \end_layout
34455
34456 \begin_layout Verse
34457
34458 \family typewriter
34459 \series bold
34460 unsigned
34461 \series default
34462 \InsetSpace ~
34463 \InsetSpace ~
34464 char i;\InsetSpace ~
34465 \InsetSpace ~
34466 \InsetSpace ~
34467 \InsetSpace ~
34468 \InsetSpace ~
34469 \InsetSpace ~
34470 \InsetSpace ~
34471 \InsetSpace ~
34472 \InsetSpace ~
34473 \InsetSpace ~
34474 \InsetSpace ~
34475 /* unsigned is needed for rotation */ 
34476 \newline
34477 ...
34478  
34479 \newline
34480 i = ((i << 1) | (i >> 7)); 
34481 \family default
34482
34483 \newline
34484
34485 \family typewriter
34486 ...
34487 \end_layout
34488
34489 \begin_layout Standard
34490 will generate the following code:
34491 \end_layout
34492
34493 \begin_layout Verse
34494
34495 \family typewriter
34496 mov\InsetSpace ~
34497 \InsetSpace ~
34498 a,_i 
34499 \newline
34500 rl\InsetSpace ~
34501 \InsetSpace ~
34502 \InsetSpace ~
34503
34504 \newline
34505 mov\InsetSpace ~
34506 \InsetSpace ~
34507 _i,a
34508 \end_layout
34509
34510 \begin_layout Standard
34511 SDCC uses pattern matching on the parse tree to determine this operation.Variatio
34512 ns of this case will also be recognized as bit-rotation, i.e.: 
34513 \end_layout
34514
34515 \begin_layout Verse
34516
34517 \family typewriter
34518 i = ((i >> 7) | (i << 1)); /* left-bit rotation */
34519 \end_layout
34520
34521 \begin_layout Subsection
34522 Nibble and Byte Swapping
34523 \end_layout
34524
34525 \begin_layout Standard
34526 Other special cases of the bit-shift operations are nibble or byte swapping
34527 \begin_inset LatexCommand \index{swapping nibbles/bytes}
34528
34529 \end_inset
34530
34531 , SDCC recognizes the following expressions:
34532 \end_layout
34533
34534 \begin_layout Verse
34535
34536 \family typewriter
34537 \series bold
34538 unsigned
34539 \series default
34540 \InsetSpace ~
34541 \InsetSpace ~
34542 char i; 
34543 \newline
34544
34545 \series bold
34546 unsigned
34547 \series default
34548 \InsetSpace ~
34549 \InsetSpace ~
34550 int j; 
34551 \newline
34552 ...
34553  
34554 \newline
34555 i = ((i << 4) | (i >> 4)); 
34556 \family default
34557
34558 \newline
34559
34560 \family typewriter
34561 j = ((j << 8) | (j >> 8)); 
34562 \end_layout
34563
34564 \begin_layout Standard
34565 and generates a swap instruction for the nibble swapping
34566 \begin_inset LatexCommand \index{Nibble swapping}
34567
34568 \end_inset
34569
34570  or move instructions for the byte swapping
34571 \begin_inset LatexCommand \index{Byte swapping}
34572
34573 \end_inset
34574
34575 .
34576  The 
34577 \begin_inset Quotes sld
34578 \end_inset
34579
34580 j
34581 \begin_inset Quotes srd
34582 \end_inset
34583
34584  example can be used to convert from little to big-endian or vice versa.
34585  If you want to change the endianness of a 
34586 \emph on
34587 signed
34588 \emph default
34589  integer you have to cast to 
34590 \family typewriter
34591 (unsigned int)
34592 \family default
34593  first.
34594 \end_layout
34595
34596 \begin_layout Standard
34597 Note that SDCC stores numbers in little-endian
34598 \begin_inset Foot
34599 status open
34600
34601 \begin_layout Standard
34602 Usually 8-bit processors don't care much about endianness.
34603  This is not the case for the standard 8051 which only has an instruction
34604  to increment its 
34605 \emph on
34606 dptr
34607 \emph default
34608
34609 \begin_inset LatexCommand \index{DPTR}
34610
34611 \end_inset
34612
34613 -datapointer
34614 \emph on
34615  
34616 \emph default
34617 so little-endian is the more efficient byte order.
34618 \end_layout
34619
34620 \end_inset
34621
34622
34623 \begin_inset LatexCommand \index{little-endian}
34624
34625 \end_inset
34626
34627
34628 \begin_inset LatexCommand \index{Endianness}
34629
34630 \end_inset
34631
34632  format (i.e.
34633  lowest order first).
34634 \end_layout
34635
34636 \begin_layout Subsection
34637 Highest Order Bit
34638 \begin_inset LatexCommand \index{Highest Order Bit}
34639
34640 \end_inset
34641
34642  / Any Order Bit
34643 \begin_inset LatexCommand \index{Any Order Bit}
34644
34645 \end_inset
34646
34647
34648 \end_layout
34649
34650 \begin_layout Standard
34651 It is frequently required to obtain the highest order bit of an integral
34652  type (long, int, short or char types).
34653  Also obtaining any other order bit is not uncommon.
34654  SDCC recognizes the following expressions to yield the highest order bit
34655  and generates optimized code for it, e.g.:
34656 \end_layout
34657
34658 \begin_layout Verse
34659
34660 \family typewriter
34661 unsigned int gint; 
34662 \newline
34663
34664 \newline
34665 foo () { 
34666 \newline
34667 \InsetSpace ~
34668 \InsetSpace ~
34669 unsigned char hob1, aob1; 
34670 \newline
34671 \InsetSpace ~
34672 \InsetSpace ~
34673 bit hob2, hob3, aob2,
34674  aob3; 
34675 \newline
34676 \InsetSpace ~
34677 \InsetSpace ~
34678 ...
34679  
34680 \newline
34681 \InsetSpace ~
34682 \InsetSpace ~
34683 hob1 = (gint >> 15) & 1; 
34684 \newline
34685 \InsetSpace ~
34686 \InsetSpace ~
34687 hob2 = (gint >> 15) & 1; 
34688 \newline
34689 \InsetSpace ~
34690 \InsetSpace ~
34691 hob3 = gint & 0x8000;
34692  
34693 \newline
34694 \InsetSpace ~
34695 \InsetSpace ~
34696 aob1 = (gint >> 9) & 1; 
34697 \newline
34698 \InsetSpace ~
34699 \InsetSpace ~
34700 aob2 = (gint >> 8) & 1; 
34701 \newline
34702 \InsetSpace ~
34703 \InsetSpace ~
34704 aob3 = gint & 0x0800; 
34705 \newline
34706 \InsetSpace ~
34707 \InsetSpace ~
34708 ..
34709  
34710 \newline
34711 }
34712 \end_layout
34713
34714 \begin_layout Standard
34715 will generate the following code:
34716 \end_layout
34717
34718 \begin_layout Verse
34719
34720 \family typewriter
34721 \InsetSpace ~
34722 \InsetSpace ~
34723 \InsetSpace ~
34724 \InsetSpace ~
34725 \InsetSpace ~
34726 \InsetSpace ~
34727 \InsetSpace ~
34728 \InsetSpace ~
34729 \InsetSpace ~
34730 \InsetSpace ~
34731 \InsetSpace ~
34732 \InsetSpace ~
34733 \InsetSpace ~
34734 \InsetSpace ~
34735 \InsetSpace ~
34736 \InsetSpace ~
34737 \InsetSpace ~
34738 \InsetSpace ~
34739 \InsetSpace ~
34740 \InsetSpace ~
34741 \InsetSpace ~
34742 \InsetSpace ~
34743 \InsetSpace ~
34744 \InsetSpace ~
34745 \InsetSpace ~
34746  61 ;\InsetSpace ~
34747  hob.c 7 
34748 \newline
34749 000A E5*01\InsetSpace ~
34750 \InsetSpace ~
34751 \InsetSpace ~
34752 \InsetSpace ~
34753 \InsetSpace ~
34754 \InsetSpace ~
34755 \InsetSpace ~
34756 \InsetSpace ~
34757 \InsetSpace ~
34758 \InsetSpace ~
34759 \InsetSpace ~
34760 \InsetSpace ~
34761 \InsetSpace ~
34762 \InsetSpace ~
34763 \InsetSpace ~
34764  62\InsetSpace ~
34765 \InsetSpace ~
34766 \InsetSpace ~
34767 \InsetSpace ~
34768 \InsetSpace ~
34769 \InsetSpace ~
34770 \InsetSpace ~
34771 \InsetSpace ~
34772  mov\InsetSpace ~
34773 \InsetSpace ~
34774  a,(_gint + 1) 
34775 \newline
34776 000C 23\InsetSpace ~
34777 \InsetSpace ~
34778 \InsetSpace ~
34779 \InsetSpace ~
34780 \InsetSpace ~
34781 \InsetSpace ~
34782 \InsetSpace ~
34783 \InsetSpace ~
34784 \InsetSpace ~
34785 \InsetSpace ~
34786 \InsetSpace ~
34787 \InsetSpace ~
34788 \InsetSpace ~
34789 \InsetSpace ~
34790 \InsetSpace ~
34791 \InsetSpace ~
34792 \InsetSpace ~
34793 \InsetSpace ~
34794  63\InsetSpace ~
34795 \InsetSpace ~
34796 \InsetSpace ~
34797 \InsetSpace ~
34798 \InsetSpace ~
34799 \InsetSpace ~
34800 \InsetSpace ~
34801 \InsetSpace ~
34802  rl\InsetSpace ~
34803 \InsetSpace ~
34804 \InsetSpace ~
34805  a 
34806 \newline
34807 000D 54 01\InsetSpace ~
34808 \InsetSpace ~
34809 \InsetSpace ~
34810 \InsetSpace ~
34811 \InsetSpace ~
34812 \InsetSpace ~
34813 \InsetSpace ~
34814 \InsetSpace ~
34815 \InsetSpace ~
34816 \InsetSpace ~
34817 \InsetSpace ~
34818 \InsetSpace ~
34819 \InsetSpace ~
34820 \InsetSpace ~
34821 \InsetSpace ~
34822
34823  64\InsetSpace ~
34824 \InsetSpace ~
34825 \InsetSpace ~
34826 \InsetSpace ~
34827 \InsetSpace ~
34828 \InsetSpace ~
34829 \InsetSpace ~
34830 \InsetSpace ~
34831  anl\InsetSpace ~
34832 \InsetSpace ~
34833  a,#0x01 
34834 \newline
34835 000F F5*02\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 \InsetSpace ~
34849 \InsetSpace ~
34850  65\InsetSpace ~
34851 \InsetSpace ~
34852 \InsetSpace ~
34853 \InsetSpace ~
34854 \InsetSpace ~
34855 \InsetSpace ~
34856 \InsetSpace ~
34857 \InsetSpace ~
34858  mov\InsetSpace ~
34859 \InsetSpace ~
34860  _foo_hob1_1_1,a 
34861 \newline
34862 \InsetSpace ~
34863 \InsetSpace ~
34864 \InsetSpace ~
34865 \InsetSpace ~
34866 \InsetSpace ~
34867 \InsetSpace ~
34868 \InsetSpace ~
34869 \InsetSpace ~
34870 \InsetSpace ~
34871 \InsetSpace ~
34872 \InsetSpace ~
34873 \InsetSpace ~
34874 \InsetSpace ~
34875 \InsetSpace ~
34876 \InsetSpace ~
34877 \InsetSpace ~
34878 \InsetSpace ~
34879 \InsetSpace ~
34880 \InsetSpace ~
34881 \InsetSpace ~
34882 \InsetSpace ~
34883 \InsetSpace ~
34884 \InsetSpace ~
34885 \InsetSpace ~
34886 \InsetSpace ~
34887  66 ;\InsetSpace ~
34888  hob.c 8 
34889 \newline
34890 0011 E5*01\InsetSpace ~
34891 \InsetSpace ~
34892 \InsetSpace ~
34893 \InsetSpace ~
34894 \InsetSpace ~
34895 \InsetSpace ~
34896 \InsetSpace ~
34897 \InsetSpace ~
34898 \InsetSpace ~
34899 \InsetSpace ~
34900 \InsetSpace ~
34901 \InsetSpace ~
34902 \InsetSpace ~
34903 \InsetSpace ~
34904 \InsetSpace ~
34905
34906  67\InsetSpace ~
34907 \InsetSpace ~
34908 \InsetSpace ~
34909 \InsetSpace ~
34910 \InsetSpace ~
34911 \InsetSpace ~
34912 \InsetSpace ~
34913 \InsetSpace ~
34914  mov\InsetSpace ~
34915 \InsetSpace ~
34916  a,(_gint + 1) 
34917 \newline
34918 0013 33\InsetSpace ~
34919 \InsetSpace ~
34920 \InsetSpace ~
34921 \InsetSpace ~
34922 \InsetSpace ~
34923 \InsetSpace ~
34924 \InsetSpace ~
34925 \InsetSpace ~
34926 \InsetSpace ~
34927 \InsetSpace ~
34928 \InsetSpace ~
34929 \InsetSpace ~
34930 \InsetSpace ~
34931 \InsetSpace ~
34932 \InsetSpace ~
34933 \InsetSpace ~
34934 \InsetSpace ~
34935 \InsetSpace ~
34936  68\InsetSpace ~
34937 \InsetSpace ~
34938 \InsetSpace ~
34939 \InsetSpace ~
34940 \InsetSpace ~
34941 \InsetSpace ~
34942 \InsetSpace ~
34943 \InsetSpace ~
34944  rlc\InsetSpace ~
34945 \InsetSpace ~
34946  a 
34947 \newline
34948 0014 92*00\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 \InsetSpace ~
34963  69\InsetSpace ~
34964 \InsetSpace ~
34965 \InsetSpace ~
34966 \InsetSpace ~
34967 \InsetSpace ~
34968 \InsetSpace ~
34969 \InsetSpace ~
34970 \InsetSpace ~
34971  mov\InsetSpace ~
34972 \InsetSpace ~
34973  _foo_hob2_1_1,c
34974  
34975 \newline
34976 \InsetSpace ~
34977 \InsetSpace ~
34978 \InsetSpace ~
34979 \InsetSpace ~
34980 \InsetSpace ~
34981 \InsetSpace ~
34982 \InsetSpace ~
34983 \InsetSpace ~
34984 \InsetSpace ~
34985 \InsetSpace ~
34986 \InsetSpace ~
34987 \InsetSpace ~
34988 \InsetSpace ~
34989 \InsetSpace ~
34990 \InsetSpace ~
34991 \InsetSpace ~
34992 \InsetSpace ~
34993 \InsetSpace ~
34994 \InsetSpace ~
34995 \InsetSpace ~
34996 \InsetSpace ~
34997 \InsetSpace ~
34998 \InsetSpace ~
34999 \InsetSpace ~
35000 \InsetSpace ~
35001  66 ;\InsetSpace ~
35002  hob.c 9 
35003 \newline
35004 0016 E5*01\InsetSpace ~
35005 \InsetSpace ~
35006 \InsetSpace ~
35007 \InsetSpace ~
35008 \InsetSpace ~
35009 \InsetSpace ~
35010 \InsetSpace ~
35011 \InsetSpace ~
35012 \InsetSpace ~
35013 \InsetSpace ~
35014 \InsetSpace ~
35015 \InsetSpace ~
35016 \InsetSpace ~
35017 \InsetSpace ~
35018 \InsetSpace ~
35019  67\InsetSpace ~
35020 \InsetSpace ~
35021 \InsetSpace ~
35022 \InsetSpace ~
35023 \InsetSpace ~
35024 \InsetSpace ~
35025 \InsetSpace ~
35026 \InsetSpace ~
35027  mov\InsetSpace ~
35028 \InsetSpace ~
35029  a,(_gint + 1) 
35030 \newline
35031 0018 33\InsetSpace ~
35032 \InsetSpace ~
35033 \InsetSpace ~
35034 \InsetSpace ~
35035 \InsetSpace ~
35036 \InsetSpace ~
35037 \InsetSpace ~
35038 \InsetSpace ~
35039 \InsetSpace ~
35040 \InsetSpace ~
35041 \InsetSpace ~
35042 \InsetSpace ~
35043 \InsetSpace ~
35044 \InsetSpace ~
35045 \InsetSpace ~
35046 \InsetSpace ~
35047 \InsetSpace ~
35048 \InsetSpace ~
35049  68\InsetSpace ~
35050 \InsetSpace ~
35051 \InsetSpace ~
35052 \InsetSpace ~
35053 \InsetSpace ~
35054 \InsetSpace ~
35055 \InsetSpace ~
35056 \InsetSpace ~
35057  rlc\InsetSpace ~
35058 \InsetSpace ~
35059  a 
35060 \newline
35061 0019 92*01\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 \InsetSpace ~
35076
35077  69\InsetSpace ~
35078 \InsetSpace ~
35079 \InsetSpace ~
35080 \InsetSpace ~
35081 \InsetSpace ~
35082 \InsetSpace ~
35083 \InsetSpace ~
35084 \InsetSpace ~
35085  mov\InsetSpace ~
35086 \InsetSpace ~
35087  _foo_hob3_1_1,c 
35088 \newline
35089 \InsetSpace ~
35090 \InsetSpace ~
35091 \InsetSpace ~
35092 \InsetSpace ~
35093 \InsetSpace ~
35094 \InsetSpace ~
35095 \InsetSpace ~
35096 \InsetSpace ~
35097 \InsetSpace ~
35098 \InsetSpace ~
35099 \InsetSpace ~
35100 \InsetSpace ~
35101 \InsetSpace ~
35102 \InsetSpace ~
35103 \InsetSpace ~
35104 \InsetSpace ~
35105 \InsetSpace ~
35106 \InsetSpace ~
35107 \InsetSpace ~
35108 \InsetSpace ~
35109 \InsetSpace ~
35110 \InsetSpace ~
35111 \InsetSpace ~
35112 \InsetSpace ~
35113 \InsetSpace ~
35114  70 ;\InsetSpace ~
35115  hob.c 10 
35116 \newline
35117 001B E5*01\InsetSpace ~
35118 \InsetSpace ~
35119 \InsetSpace ~
35120 \InsetSpace ~
35121 \InsetSpace ~
35122 \InsetSpace ~
35123 \InsetSpace ~
35124 \InsetSpace ~
35125 \InsetSpace ~
35126 \InsetSpace ~
35127 \InsetSpace ~
35128 \InsetSpace ~
35129 \InsetSpace ~
35130 \InsetSpace ~
35131 \InsetSpace ~
35132  71\InsetSpace ~
35133 \InsetSpace ~
35134 \InsetSpace ~
35135 \InsetSpace ~
35136 \InsetSpace ~
35137 \InsetSpace ~
35138 \InsetSpace ~
35139 \InsetSpace ~
35140  mov\InsetSpace ~
35141 \InsetSpace ~
35142  a,(_gint + 1) 
35143 \newline
35144 001D
35145  03\InsetSpace ~
35146 \InsetSpace ~
35147 \InsetSpace ~
35148 \InsetSpace ~
35149 \InsetSpace ~
35150 \InsetSpace ~
35151 \InsetSpace ~
35152 \InsetSpace ~
35153 \InsetSpace ~
35154 \InsetSpace ~
35155 \InsetSpace ~
35156 \InsetSpace ~
35157 \InsetSpace ~
35158 \InsetSpace ~
35159 \InsetSpace ~
35160 \InsetSpace ~
35161 \InsetSpace ~
35162 \InsetSpace ~
35163  72\InsetSpace ~
35164 \InsetSpace ~
35165 \InsetSpace ~
35166 \InsetSpace ~
35167 \InsetSpace ~
35168 \InsetSpace ~
35169 \InsetSpace ~
35170 \InsetSpace ~
35171  rr\InsetSpace ~
35172 \InsetSpace ~
35173 \InsetSpace ~
35174  a 
35175 \newline
35176 001E 54 01\InsetSpace ~
35177 \InsetSpace ~
35178 \InsetSpace ~
35179 \InsetSpace ~
35180 \InsetSpace ~
35181 \InsetSpace ~
35182 \InsetSpace ~
35183 \InsetSpace ~
35184 \InsetSpace ~
35185 \InsetSpace ~
35186 \InsetSpace ~
35187 \InsetSpace ~
35188 \InsetSpace ~
35189 \InsetSpace ~
35190 \InsetSpace ~
35191  73\InsetSpace ~
35192 \InsetSpace ~
35193 \InsetSpace ~
35194 \InsetSpace ~
35195 \InsetSpace ~
35196 \InsetSpace ~
35197 \InsetSpace ~
35198 \InsetSpace ~
35199  anl\InsetSpace ~
35200 \InsetSpace ~
35201  a,#0x01 
35202 \newline
35203 0020 F5*03\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 \InsetSpace ~
35218  74\InsetSpace ~
35219 \InsetSpace ~
35220 \InsetSpace ~
35221 \InsetSpace ~
35222 \InsetSpace ~
35223 \InsetSpace ~
35224 \InsetSpace ~
35225 \InsetSpace ~
35226  mov\InsetSpace ~
35227 \InsetSpace ~
35228  _foo_aob1_1_1,a
35229  
35230 \newline
35231 \InsetSpace ~
35232 \InsetSpace ~
35233 \InsetSpace ~
35234 \InsetSpace ~
35235 \InsetSpace ~
35236 \InsetSpace ~
35237 \InsetSpace ~
35238 \InsetSpace ~
35239 \InsetSpace ~
35240 \InsetSpace ~
35241 \InsetSpace ~
35242 \InsetSpace ~
35243 \InsetSpace ~
35244 \InsetSpace ~
35245 \InsetSpace ~
35246 \InsetSpace ~
35247 \InsetSpace ~
35248 \InsetSpace ~
35249 \InsetSpace ~
35250 \InsetSpace ~
35251 \InsetSpace ~
35252 \InsetSpace ~
35253 \InsetSpace ~
35254 \InsetSpace ~
35255 \InsetSpace ~
35256  75 ;\InsetSpace ~
35257  hob.c 11 
35258 \newline
35259 0022 E5*01\InsetSpace ~
35260 \InsetSpace ~
35261 \InsetSpace ~
35262 \InsetSpace ~
35263 \InsetSpace ~
35264 \InsetSpace ~
35265 \InsetSpace ~
35266 \InsetSpace ~
35267 \InsetSpace ~
35268 \InsetSpace ~
35269 \InsetSpace ~
35270 \InsetSpace ~
35271 \InsetSpace ~
35272 \InsetSpace ~
35273 \InsetSpace ~
35274  76\InsetSpace ~
35275 \InsetSpace ~
35276 \InsetSpace ~
35277 \InsetSpace ~
35278 \InsetSpace ~
35279 \InsetSpace ~
35280 \InsetSpace ~
35281 \InsetSpace ~
35282  mov\InsetSpace ~
35283 \InsetSpace ~
35284  a,(_gint + 1) 
35285 \newline
35286 0024 13\InsetSpace ~
35287 \InsetSpace ~
35288 \InsetSpace ~
35289 \InsetSpace ~
35290 \InsetSpace ~
35291 \InsetSpace ~
35292 \InsetSpace ~
35293 \InsetSpace ~
35294 \InsetSpace ~
35295 \InsetSpace ~
35296 \InsetSpace ~
35297 \InsetSpace ~
35298 \InsetSpace ~
35299 \InsetSpace ~
35300 \InsetSpace ~
35301 \InsetSpace ~
35302 \InsetSpace ~
35303 \InsetSpace ~
35304  77\InsetSpace ~
35305 \InsetSpace ~
35306 \InsetSpace ~
35307 \InsetSpace ~
35308 \InsetSpace ~
35309 \InsetSpace ~
35310 \InsetSpace ~
35311 \InsetSpace ~
35312  rrc\InsetSpace ~
35313 \InsetSpace ~
35314  a 
35315 \newline
35316 0025 92*02\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 \InsetSpace ~
35331
35332  78\InsetSpace ~
35333 \InsetSpace ~
35334 \InsetSpace ~
35335 \InsetSpace ~
35336 \InsetSpace ~
35337 \InsetSpace ~
35338 \InsetSpace ~
35339 \InsetSpace ~
35340  mov\InsetSpace ~
35341 \InsetSpace ~
35342  _foo_aob2_1_1,c 
35343 \newline
35344 \InsetSpace ~
35345 \InsetSpace ~
35346 \InsetSpace ~
35347 \InsetSpace ~
35348 \InsetSpace ~
35349 \InsetSpace ~
35350 \InsetSpace ~
35351 \InsetSpace ~
35352 \InsetSpace ~
35353 \InsetSpace ~
35354 \InsetSpace ~
35355 \InsetSpace ~
35356 \InsetSpace ~
35357 \InsetSpace ~
35358 \InsetSpace ~
35359 \InsetSpace ~
35360 \InsetSpace ~
35361 \InsetSpace ~
35362 \InsetSpace ~
35363 \InsetSpace ~
35364 \InsetSpace ~
35365 \InsetSpace ~
35366 \InsetSpace ~
35367 \InsetSpace ~
35368 \InsetSpace ~
35369  79 ;\InsetSpace ~
35370  hob.c 12 
35371 \newline
35372 0027 E5*01\InsetSpace ~
35373 \InsetSpace ~
35374 \InsetSpace ~
35375 \InsetSpace ~
35376 \InsetSpace ~
35377 \InsetSpace ~
35378 \InsetSpace ~
35379 \InsetSpace ~
35380 \InsetSpace ~
35381 \InsetSpace ~
35382 \InsetSpace ~
35383 \InsetSpace ~
35384 \InsetSpace ~
35385 \InsetSpace ~
35386 \InsetSpace ~
35387  80\InsetSpace ~
35388 \InsetSpace ~
35389 \InsetSpace ~
35390 \InsetSpace ~
35391 \InsetSpace ~
35392 \InsetSpace ~
35393 \InsetSpace ~
35394 \InsetSpace ~
35395  mov\InsetSpace ~
35396 \InsetSpace ~
35397  a,(_gint + 1) 
35398 \newline
35399 0029
35400  A2 E3\InsetSpace ~
35401 \InsetSpace ~
35402 \InsetSpace ~
35403 \InsetSpace ~
35404 \InsetSpace ~
35405 \InsetSpace ~
35406 \InsetSpace ~
35407 \InsetSpace ~
35408 \InsetSpace ~
35409 \InsetSpace ~
35410 \InsetSpace ~
35411 \InsetSpace ~
35412 \InsetSpace ~
35413 \InsetSpace ~
35414 \InsetSpace ~
35415  81\InsetSpace ~
35416 \InsetSpace ~
35417 \InsetSpace ~
35418 \InsetSpace ~
35419 \InsetSpace ~
35420 \InsetSpace ~
35421 \InsetSpace ~
35422 \InsetSpace ~
35423  mov\InsetSpace ~
35424 \InsetSpace ~
35425  c,acc[3] 
35426 \newline
35427 002B 92*03\InsetSpace ~
35428 \InsetSpace ~
35429 \InsetSpace ~
35430 \InsetSpace ~
35431 \InsetSpace ~
35432 \InsetSpace ~
35433 \InsetSpace ~
35434 \InsetSpace ~
35435 \InsetSpace ~
35436 \InsetSpace ~
35437 \InsetSpace ~
35438 \InsetSpace ~
35439 \InsetSpace ~
35440 \InsetSpace ~
35441 \InsetSpace ~
35442  82\InsetSpace ~
35443 \InsetSpace ~
35444 \InsetSpace ~
35445 \InsetSpace ~
35446 \InsetSpace ~
35447 \InsetSpace ~
35448 \InsetSpace ~
35449 \InsetSpace ~
35450  mov\InsetSpace ~
35451 \InsetSpace ~
35452  _foo_aob3_1_1,c 
35453 \end_layout
35454
35455 \begin_layout Standard
35456 Other variations of these cases however will 
35457 \emph on
35458 not
35459 \emph default
35460  be recognized.
35461  They are standard C expressions, so I heartily recommend these be the only
35462  way to get the highest order bit, (it is portable).
35463  Of course it will be recognized even if it is embedded in other expressions,
35464  e.g.:
35465 \end_layout
35466
35467 \begin_layout Verse
35468
35469 \family typewriter
35470 xyz = gint + ((gint >> 15) & 1);
35471 \end_layout
35472
35473 \begin_layout Standard
35474 will still be recognized.
35475 \end_layout
35476
35477 \begin_layout Subsection
35478 Higher Order Byte
35479 \begin_inset LatexCommand \index{Higher Order Byte}
35480
35481 \end_inset
35482
35483  / Higher Order Word
35484 \begin_inset LatexCommand \index{Higher Order Word}
35485
35486 \end_inset
35487
35488
35489 \end_layout
35490
35491 \begin_layout Standard
35492 It is also frequently required to obtain a higher order byte or word of
35493  a larger integral type (long, int or short types).
35494  SDCC recognizes the following expressions to yield the higher order byte
35495  or word and generates optimized code for it, e.g.:
35496 \end_layout
35497
35498 \begin_layout Verse
35499
35500 \family typewriter
35501 unsigned int gint; 
35502 \newline
35503 unsigned long int glong; 
35504 \newline
35505
35506 \newline
35507 foo () { 
35508 \newline
35509 \InsetSpace ~
35510 \InsetSpace ~
35511 unsigned char hob1,
35512  hob2; 
35513 \newline
35514 \InsetSpace ~
35515 \InsetSpace ~
35516 unsigned int how1, how2; 
35517 \newline
35518 \InsetSpace ~
35519 \InsetSpace ~
35520 ...
35521  
35522 \newline
35523 \InsetSpace ~
35524 \InsetSpace ~
35525 hob1 = (gint >> 8) & 0xFF; 
35526 \newline
35527 \InsetSpace ~
35528 \InsetSpace ~
35529 hob2 = glong >> 24; 
35530 \newline
35531 \InsetSpace ~
35532 \InsetSpace ~
35533 how1 = (glong >> 16) & 0xFFFF;
35534  
35535 \newline
35536 \InsetSpace ~
35537 \InsetSpace ~
35538 how2 = glong >> 8; 
35539 \newline
35540 \InsetSpace ~
35541 \InsetSpace ~
35542 ..
35543  
35544 \newline
35545 }
35546 \end_layout
35547
35548 \begin_layout Standard
35549 will generate the following code:
35550 \end_layout
35551
35552 \begin_layout Verse
35553
35554 \family typewriter
35555 \InsetSpace ~
35556 \InsetSpace ~
35557 \InsetSpace ~
35558 \InsetSpace ~
35559 \InsetSpace ~
35560 \InsetSpace ~
35561 \InsetSpace ~
35562 \InsetSpace ~
35563 \InsetSpace ~
35564 \InsetSpace ~
35565 \InsetSpace ~
35566 \InsetSpace ~
35567 \InsetSpace ~
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  91 ;\InsetSpace ~
35581  hob.c 15 
35582 \newline
35583 0037 85*01*06\InsetSpace ~
35584 \InsetSpace ~
35585 \InsetSpace ~
35586 \InsetSpace ~
35587 \InsetSpace ~
35588 \InsetSpace ~
35589 \InsetSpace ~
35590 \InsetSpace ~
35591 \InsetSpace ~
35592 \InsetSpace ~
35593 \InsetSpace ~
35594 \InsetSpace ~
35595  92\InsetSpace ~
35596 \InsetSpace ~
35597 \InsetSpace ~
35598 \InsetSpace ~
35599 \InsetSpace ~
35600 \InsetSpace ~
35601 \InsetSpace ~
35602 \InsetSpace ~
35603  mov\InsetSpace ~
35604 \InsetSpace ~
35605  _foo_hob1_1_1,(_gint + 1) 
35606 \newline
35607 \InsetSpace ~
35608 \InsetSpace ~
35609 \InsetSpace ~
35610 \InsetSpace ~
35611 \InsetSpace ~
35612 \InsetSpace ~
35613 \InsetSpace ~
35614 \InsetSpace ~
35615 \InsetSpace ~
35616 \InsetSpace ~
35617 \InsetSpace ~
35618 \InsetSpace ~
35619 \InsetSpace ~
35620 \InsetSpace ~
35621 \InsetSpace ~
35622 \InsetSpace ~
35623 \InsetSpace ~
35624 \InsetSpace ~
35625 \InsetSpace ~
35626 \InsetSpace ~
35627 \InsetSpace ~
35628 \InsetSpace ~
35629 \InsetSpace ~
35630 \InsetSpace ~
35631 \InsetSpace ~
35632  93 ;\InsetSpace ~
35633  hob.c
35634  16 
35635 \newline
35636 003A 85*05*07\InsetSpace ~
35637 \InsetSpace ~
35638 \InsetSpace ~
35639 \InsetSpace ~
35640 \InsetSpace ~
35641 \InsetSpace ~
35642 \InsetSpace ~
35643 \InsetSpace ~
35644 \InsetSpace ~
35645 \InsetSpace ~
35646 \InsetSpace ~
35647 \InsetSpace ~
35648  94\InsetSpace ~
35649 \InsetSpace ~
35650 \InsetSpace ~
35651 \InsetSpace ~
35652 \InsetSpace ~
35653 \InsetSpace ~
35654 \InsetSpace ~
35655 \InsetSpace ~
35656  mov\InsetSpace ~
35657 \InsetSpace ~
35658  _foo_hob2_1_1,(_glong + 3) 
35659 \newline
35660 \InsetSpace ~
35661 \InsetSpace ~
35662 \InsetSpace ~
35663 \InsetSpace ~
35664 \InsetSpace ~
35665 \InsetSpace ~
35666 \InsetSpace ~
35667 \InsetSpace ~
35668 \InsetSpace ~
35669 \InsetSpace ~
35670 \InsetSpace ~
35671 \InsetSpace ~
35672 \InsetSpace ~
35673 \InsetSpace ~
35674 \InsetSpace ~
35675 \InsetSpace ~
35676 \InsetSpace ~
35677 \InsetSpace ~
35678 \InsetSpace ~
35679 \InsetSpace ~
35680 \InsetSpace ~
35681 \InsetSpace ~
35682 \InsetSpace ~
35683 \InsetSpace ~
35684 \InsetSpace ~
35685  95 ;\InsetSpace ~
35686  hob.c 17 
35687 \newline
35688 003D 85*04*08\InsetSpace ~
35689 \InsetSpace ~
35690 \InsetSpace ~
35691 \InsetSpace ~
35692 \InsetSpace ~
35693 \InsetSpace ~
35694 \InsetSpace ~
35695 \InsetSpace ~
35696 \InsetSpace ~
35697 \InsetSpace ~
35698 \InsetSpace ~
35699 \InsetSpace ~
35700
35701  96\InsetSpace ~
35702 \InsetSpace ~
35703 \InsetSpace ~
35704 \InsetSpace ~
35705 \InsetSpace ~
35706 \InsetSpace ~
35707 \InsetSpace ~
35708 \InsetSpace ~
35709  mov\InsetSpace ~
35710 \InsetSpace ~
35711  _foo_how1_1_1,(_glong + 2) 
35712 \newline
35713 0040 85*05*09\InsetSpace ~
35714 \InsetSpace ~
35715 \InsetSpace ~
35716 \InsetSpace ~
35717 \InsetSpace ~
35718 \InsetSpace ~
35719 \InsetSpace ~
35720 \InsetSpace ~
35721 \InsetSpace ~
35722 \InsetSpace ~
35723 \InsetSpace ~
35724 \InsetSpace ~
35725  97\InsetSpace ~
35726 \InsetSpace ~
35727 \InsetSpace ~
35728 \InsetSpace ~
35729 \InsetSpace ~
35730 \InsetSpace ~
35731 \InsetSpace ~
35732 \InsetSpace ~
35733  mov\InsetSpace ~
35734 \InsetSpace ~
35735  (_foo_how1_1_1 +
35736  1),(_glong + 3) 
35737 \newline
35738 0043 85*03*0A\InsetSpace ~
35739 \InsetSpace ~
35740 \InsetSpace ~
35741 \InsetSpace ~
35742 \InsetSpace ~
35743 \InsetSpace ~
35744 \InsetSpace ~
35745 \InsetSpace ~
35746 \InsetSpace ~
35747 \InsetSpace ~
35748 \InsetSpace ~
35749 \InsetSpace ~
35750  98\InsetSpace ~
35751 \InsetSpace ~
35752 \InsetSpace ~
35753 \InsetSpace ~
35754 \InsetSpace ~
35755 \InsetSpace ~
35756 \InsetSpace ~
35757 \InsetSpace ~
35758  mov\InsetSpace ~
35759 \InsetSpace ~
35760  _foo_how2_1_1,(_glong + 1) 
35761 \newline
35762 0046 85*04*0B\InsetSpace ~
35763 \InsetSpace ~
35764 \InsetSpace ~
35765 \InsetSpace ~
35766 \InsetSpace ~
35767 \InsetSpace ~
35768 \InsetSpace ~
35769 \InsetSpace ~
35770 \InsetSpace ~
35771 \InsetSpace ~
35772 \InsetSpace ~
35773 \InsetSpace ~
35774
35775  99\InsetSpace ~
35776 \InsetSpace ~
35777 \InsetSpace ~
35778 \InsetSpace ~
35779 \InsetSpace ~
35780 \InsetSpace ~
35781 \InsetSpace ~
35782 \InsetSpace ~
35783  mov\InsetSpace ~
35784 \InsetSpace ~
35785  (_foo_how2_1_1 + 1),(_glong + 2) 
35786 \end_layout
35787
35788 \begin_layout Standard
35789 Again, variations of these cases may 
35790 \emph on
35791 not
35792 \emph default
35793  be recognized.
35794  They are standard C expressions, so I heartily recommend these be the only
35795  way to get the higher order byte/word, (it is portable).
35796  Of course it will be recognized even if it is embedded in other expressions,
35797  e.g.:
35798 \end_layout
35799
35800 \begin_layout Verse
35801
35802 \family typewriter
35803 xyz = gint + ((gint >> 8) & 0xFF);
35804 \end_layout
35805
35806 \begin_layout Standard
35807 will still be recognized.
35808 \end_layout
35809
35810 \begin_layout Subsection
35811 Peephole Optimizer
35812 \begin_inset LatexCommand \label{sub:Peephole-Optimizer}
35813
35814 \end_inset
35815
35816
35817 \begin_inset LatexCommand \index{Peephole optimizer}
35818
35819 \end_inset
35820
35821
35822 \end_layout
35823
35824 \begin_layout Standard
35825 The compiler uses a rule based, pattern matching and re-writing mechanism
35826  for peep-hole optimization.
35827  It is inspired by 
35828 \emph on
35829 copt
35830 \emph default
35831  a peep-hole optimizer by Christopher W.
35832  Fraser (cwfraser\InsetSpace ~
35833 @\InsetSpace ~
35834 microsoft.com).
35835  A default set of rules are compiled into the compiler, additional rules
35836  may be added with the 
35837 \emph on
35838 -
35839 \begin_inset ERT
35840 status collapsed
35841
35842 \begin_layout Standard
35843
35844
35845 \backslash
35846 /
35847 \end_layout
35848
35849 \end_inset
35850
35851 -peep-file
35852 \begin_inset LatexCommand \index{-\/-peep-file}
35853
35854 \end_inset
35855
35856  <filename>
35857 \emph default
35858  option.
35859  The rule language is best illustrated with examples.
35860 \end_layout
35861
35862 \begin_layout Verse
35863
35864 \family typewriter
35865 replace { 
35866 \newline
35867 \InsetSpace ~
35868 \InsetSpace ~
35869 mov %1,a 
35870 \newline
35871 \InsetSpace ~
35872 \InsetSpace ~
35873 mov a,%1
35874 \newline
35875 } by {
35876 \newline
35877 \InsetSpace ~
35878 \InsetSpace ~
35879 mov %1,a
35880 \newline
35881 }
35882 \end_layout
35883
35884 \begin_layout Standard
35885 The above rule will change the following assembly
35886 \begin_inset LatexCommand \index{Assembler routines}
35887
35888 \end_inset
35889
35890  sequence:
35891 \end_layout
35892
35893 \begin_layout Verse
35894
35895 \family typewriter
35896 mov r1,a 
35897 \newline
35898 mov a,r1
35899 \end_layout
35900
35901 \begin_layout Standard
35902 to
35903 \end_layout
35904
35905 \begin_layout Verse
35906
35907 \family typewriter
35908 mov r1,a
35909 \end_layout
35910
35911 \begin_layout Standard
35912 Note: All occurrences of a 
35913 \emph on
35914 %n
35915 \emph default
35916  (pattern variable) must denote the same string.
35917  With the above rule, the assembly sequence:
35918 \end_layout
35919
35920 \begin_layout Verse
35921
35922 \family typewriter
35923 mov r1,a 
35924 \newline
35925 mov a,r2
35926 \end_layout
35927
35928 \begin_layout Standard
35929 will remain unmodified.
35930 \newline
35931
35932 \newline
35933 Other special case optimizations may be added by the
35934  user (via 
35935 \emph on
35936 -
35937 \begin_inset ERT
35938 status collapsed
35939
35940 \begin_layout Standard
35941
35942
35943 \backslash
35944 /
35945 \end_layout
35946
35947 \end_inset
35948
35949 -peep-file option
35950 \emph default
35951 ).
35952  E.g.
35953  some variants of the 8051 MCU
35954 \begin_inset LatexCommand \index{MCS51 variants}
35955
35956 \end_inset
35957
35958  allow only 
35959 \family typewriter
35960 ajmp
35961 \family default
35962  and 
35963 \family typewriter
35964 acall
35965 \family default
35966 .
35967  The following two rules will change all 
35968 \family typewriter
35969 ljmp
35970 \family default
35971  and 
35972 \family typewriter
35973 lcall
35974 \family default
35975  to 
35976 \family typewriter
35977 ajmp
35978 \family default
35979  and 
35980 \family typewriter
35981 acall
35982 \end_layout
35983
35984 \begin_layout Verse
35985
35986 \family typewriter
35987 replace { lcall %1 } by { acall %1 } 
35988 \newline
35989 replace { ljmp %1 } by { ajmp %1 }
35990 \end_layout
35991
35992 \begin_layout Standard
35993 (NOTE: from version 2.7.3 on, you can use option -
35994 \emph on
35995
35996 \begin_inset ERT
35997 status collapsed
35998
35999 \begin_layout Standard
36000
36001
36002 \backslash
36003 /
36004 \end_layout
36005
36006 \end_inset
36007
36008
36009 \emph default
36010 -acall-ajmp
36011 \begin_inset LatexCommand \index{-\/-acall-ajmp}
36012
36013 \end_inset
36014
36015 , which also takes care of aligning the interrupt vectors properly.)
36016 \newline
36017
36018 \end_layout
36019
36020 \begin_layout Standard
36021 The 
36022 \emph on
36023 inline-assembler code
36024 \emph default
36025  is also passed through the peep hole optimizer, thus the peephole optimizer
36026  can also be used as an assembly level macro expander.
36027  The rules themselves are MCU dependent whereas the rule language infra-structur
36028 e is MCU independent.
36029  Peephole optimization rules for other MCU can be easily programmed using
36030  the rule language.
36031 \newline
36032
36033 \newline
36034 The syntax for a rule is as follows:
36035 \end_layout
36036
36037 \begin_layout Verse
36038
36039 \family typewriter
36040 rule := replace [ restart ] '{' <assembly sequence> '
36041 \backslash
36042 n' 
36043 \newline
36044 \InsetSpace ~
36045  \InsetSpace ~
36046  \InsetSpace ~
36047  \InsetSpace ~
36048  \InsetSpace ~
36049  \InsetSpace ~
36050  \InsetSpace ~
36051  \InsetSpace ~
36052  \InsetSpace ~
36053  \InsetSpace ~
36054  \InsetSpace ~
36055  \InsetSpace ~
36056  \InsetSpace ~
36057  \InsetSpace ~
36058  '}' by '{' '
36059 \backslash
36060 n' 
36061 \newline
36062 \InsetSpace ~
36063  \InsetSpace ~
36064  \InsetSpace ~
36065  \InsetSpace ~
36066  \InsetSpace ~
36067  \InsetSpace ~
36068  \InsetSpace ~
36069  \InsetSpace ~
36070  \InsetSpace ~
36071  \InsetSpace ~
36072  \InsetSpace ~
36073  \InsetSpace ~
36074  \InsetSpace ~
36075  \InsetSpace ~
36076  \InsetSpace ~
36077  \InsetSpace ~
36078  <assembly sequence> '
36079 \backslash
36080 n' 
36081 \newline
36082 \InsetSpace ~
36083  \InsetSpace ~
36084  \InsetSpace ~
36085  \InsetSpace ~
36086  \InsetSpace ~
36087  \InsetSpace ~
36088  \InsetSpace ~
36089  \InsetSpace ~
36090  \InsetSpace ~
36091  \InsetSpace ~
36092  \InsetSpace ~
36093  \InsetSpace ~
36094  \InsetSpace ~
36095  \InsetSpace ~
36096  '}' [if <functionName> ] '
36097 \backslash
36098 n' 
36099 \end_layout
36100
36101 \begin_layout Standard
36102 <assembly sequence> := assembly instruction (each instruction including
36103  labels must be on a separate line).
36104 \newline
36105
36106 \newline
36107 The optimizer will apply to the rules
36108  one by one from the top in the sequence of their appearance, it will terminate
36109  when all rules are exhausted.
36110  If the 'restart' option is specified, then the optimizer will start matching
36111  the rules again from the top, this option for a rule is expensive (performance)
36112 , it is intended to be used in situations where a transformation will trigger
36113  the same rule again.
36114  An example of this (not a good one, it has side effects) is the following
36115  rule:
36116 \end_layout
36117
36118 \begin_layout Verse
36119
36120 \family typewriter
36121 replace restart { 
36122 \newline
36123 \InsetSpace ~
36124 \InsetSpace ~
36125 pop %1 
36126 \newline
36127 \InsetSpace ~
36128 \InsetSpace ~
36129 push %1 } by { 
36130 \newline
36131 \InsetSpace ~
36132 \InsetSpace ~
36133 ; nop 
36134 \newline
36135 }
36136 \end_layout
36137
36138 \begin_layout Standard
36139 Note that the replace pattern cannot be a blank, but can be a comment line.
36140  Without the 'restart' option only the innermost 'pop' 'push' pair would
36141  be eliminated, i.e.:
36142 \end_layout
36143
36144 \begin_layout Verse
36145
36146 \family typewriter
36147 pop ar1 
36148 \newline
36149 pop ar2 
36150 \newline
36151 push ar2 
36152 \newline
36153 push ar1
36154 \end_layout
36155
36156 \begin_layout Standard
36157 would result in:
36158 \end_layout
36159
36160 \begin_layout Verse
36161
36162 \family typewriter
36163 pop ar1 
36164 \newline
36165 ; nop 
36166 \newline
36167 push ar1
36168 \end_layout
36169
36170 \begin_layout Standard
36171
36172 \emph on
36173 with
36174 \emph default
36175  the restart option the rule will be applied again to the resulting code
36176  and then all the pop-push pairs will be eliminated to yield:
36177 \end_layout
36178
36179 \begin_layout Verse
36180
36181 \family typewriter
36182 ; nop 
36183 \newline
36184 ; nop
36185 \end_layout
36186
36187 \begin_layout Standard
36188 A conditional function can be attached to a rule.
36189  Attaching rules are somewhat more involved, let me illustrate this with
36190  an example.
36191 \end_layout
36192
36193 \begin_layout Verse
36194
36195 \family typewriter
36196 replace { 
36197 \newline
36198 \InsetSpace ~
36199  \InsetSpace ~
36200  \InsetSpace ~
36201 ljmp %5 
36202 \newline
36203 %2:
36204 \newline
36205 } by { 
36206 \newline
36207 \InsetSpace ~
36208  \InsetSpace ~
36209  \InsetSpace ~
36210 sjmp %5 
36211 \newline
36212 %2:
36213 \newline
36214 } if labelInRange
36215 \end_layout
36216
36217 \begin_layout Standard
36218 The optimizer does a look-up of a function name table defined in function
36219  
36220 \emph on
36221 callFuncByName
36222 \emph default
36223  in the source file SDCCpeeph.c, with the name 
36224 \emph on
36225 labelInRange
36226 \emph default
36227 .
36228  If it finds a corresponding entry the function is called.
36229  Note there can be no parameters specified for these functions, in this
36230  case the use of 
36231 \emph on
36232 %5
36233 \emph default
36234  is crucial, since the function 
36235 \emph on
36236 labelInRange
36237 \emph default
36238  expects to find the label in that particular variable (the hash table containin
36239 g the variable bindings is passed as a parameter).
36240  If you want to code more such functions, take a close look at the function
36241  labelInRange and the calling mechanism in source file SDCCpeeph.c.
36242  Currently implemented are 
36243 \emph on
36244 labelInRange, labelRefCount, labelIsReturnOnly, operandsNotSame, xramMovcOption,
36245  24bitMode, portIsDS390, 24bitModeAndPortDS390 
36246 \emph default
36247 and
36248 \emph on
36249  notVolatile
36250 \emph default
36251 .
36252 \end_layout
36253
36254 \begin_layout Standard
36255 I know this whole thing is a little kludgey, but maybe some day we will
36256  have some better means.
36257  If you are looking at this file, you will see the default rules that are
36258  compiled into the compiler, you can add your own rules in the default set
36259  there if you get tired of specifying the -
36260 \begin_inset ERT
36261 status collapsed
36262
36263 \begin_layout Standard
36264
36265
36266 \backslash
36267 /
36268 \end_layout
36269
36270 \end_inset
36271
36272 -peep-file option.
36273 \end_layout
36274
36275 \begin_layout Section
36276 ANSI-Compliance
36277 \begin_inset LatexCommand \index{ANSI-compliance}
36278
36279 \end_inset
36280
36281
36282 \begin_inset LatexCommand \label{sub:ANSI-Compliance}
36283
36284 \end_inset
36285
36286
36287 \end_layout
36288
36289 \begin_layout Standard
36290 The latest publically available version of the standard 
36291 \emph on
36292 ISO/IEC 9899 - Programming languages - C
36293 \emph default
36294  should be available at: 
36295 \begin_inset LatexCommand \url{http://www.open-std.org/jtc1/sc22/wg14/www/standards.html#9899}
36296
36297 \end_inset
36298
36299 .
36300 \newline
36301
36302 \end_layout
36303
36304 \begin_layout Standard
36305 Deviations from the compliance:
36306 \end_layout
36307
36308 \begin_layout Itemize
36309 functions are not reentrant
36310 \begin_inset LatexCommand \index{reentrant}
36311
36312 \end_inset
36313
36314  unless explicitly declared as such or the 
36315 \series bold
36316 -
36317 \begin_inset ERT
36318 status collapsed
36319
36320 \begin_layout Standard
36321
36322
36323 \backslash
36324 /
36325 \end_layout
36326
36327 \end_inset
36328
36329 -stack-auto
36330 \begin_inset LatexCommand \index{-\/-stack-auto}
36331
36332 \end_inset
36333
36334
36335 \series default
36336  command line option is specified.
36337 \end_layout
36338
36339 \begin_layout Itemize
36340 structures
36341 \begin_inset LatexCommand \index{struct}
36342
36343 \end_inset
36344
36345  and unions
36346 \begin_inset LatexCommand \index{union}
36347
36348 \end_inset
36349
36350  cannot be assigned values directly, cannot be passed as function parameters
36351  or assigned to each other and cannot be a return value
36352 \begin_inset LatexCommand \index{return value}
36353
36354 \end_inset
36355
36356  from a function, e.g.:
36357 \end_layout
36358
36359 \begin_deeper
36360 \begin_layout Verse
36361
36362 \family typewriter
36363 struct s { ...
36364  }; 
36365 \newline
36366 struct s s1, s2; 
36367 \newline
36368 foo() 
36369 \newline
36370
36371 \newline
36372 \InsetSpace ~
36373 \InsetSpace ~
36374 \InsetSpace ~
36375 \InsetSpace ~
36376 ...
36377  
36378 \newline
36379 \InsetSpace ~
36380 \InsetSpace ~
36381 \InsetSpace ~
36382 \InsetSpace ~
36383 s1 = s2 ; /* is invalid in SDCC although allowed in ANSI */ 
36384 \newline
36385 \InsetSpace ~
36386 \InsetSpace ~
36387 \InsetSpace ~
36388 \InsetSpace ~
36389 ...
36390  
36391 \newline
36392 }
36393 \newline
36394
36395 \series bold
36396 struct
36397 \series default
36398  s foo1 (
36399 \series bold
36400 struct
36401 \series default
36402  s parms) /* invalid in SDCC although allowed in ANSI */
36403 \newline
36404
36405 \newline
36406 \InsetSpace ~
36407 \InsetSpace ~
36408 \InsetSpace ~
36409 \InsetSpace ~
36410 struct s rets;
36411  
36412 \newline
36413 \InsetSpace ~
36414 \InsetSpace ~
36415 \InsetSpace ~
36416 \InsetSpace ~
36417 ...
36418  
36419 \newline
36420 \InsetSpace ~
36421 \InsetSpace ~
36422 \InsetSpace ~
36423 \InsetSpace ~
36424 return rets; /* is invalid in SDCC although allowed in ANSI */ 
36425 \newline
36426 }
36427 \end_layout
36428
36429 \end_deeper
36430 \begin_layout Itemize
36431 initialization of structure arrays must be fully braced.
36432 \end_layout
36433
36434 \begin_deeper
36435 \begin_layout Verse
36436
36437 \family typewriter
36438 struct s { char x } a[] = {1, 2};\InsetSpace ~
36439 \InsetSpace ~
36440 \InsetSpace ~
36441 \InsetSpace ~
36442 \InsetSpace ~
36443 /* invalid in SDCC */
36444 \newline
36445 struct s { char x
36446  } a[] = {{1}, {2}}; /* OK */
36447 \end_layout
36448
36449 \end_deeper
36450 \begin_layout Itemize
36451 'long long
36452 \begin_inset LatexCommand \index{long long (not supported)}
36453
36454 \end_inset
36455
36456 ' (64 bit integers
36457 \begin_inset LatexCommand \index{int (64 bit) (not supported)}
36458
36459 \end_inset
36460
36461 ) not supported.
36462 \end_layout
36463
36464 \begin_layout Itemize
36465 'double
36466 \begin_inset LatexCommand \index{double (not supported)}
36467
36468 \end_inset
36469
36470 ' precision floating point 
36471 \begin_inset LatexCommand \index{Floating point support}
36472
36473 \end_inset
36474
36475 not supported.
36476 \end_layout
36477
36478 \begin_layout Itemize
36479 Old K&R style
36480 \begin_inset LatexCommand \index{K\&R style}
36481
36482 \end_inset
36483
36484  function declarations are NOT allowed.
36485 \end_layout
36486
36487 \begin_deeper
36488 \begin_layout Verse
36489
36490 \family typewriter
36491 foo(i,j) /* this old style of function declarations */ 
36492 \newline
36493 int i,j; /* is valid
36494  in ANSI but not valid in SDCC */ 
36495 \newline
36496
36497 \newline
36498 \InsetSpace ~
36499 \InsetSpace ~
36500 \InsetSpace ~
36501 \InsetSpace ~
36502 ...
36503  
36504 \newline
36505 }
36506 \end_layout
36507
36508 \end_deeper
36509 \begin_layout Itemize
36510 Most enhancements in C99 are not supported, e.g.:
36511 \end_layout
36512
36513 \begin_deeper
36514 \begin_layout Verse
36515
36516 \family typewriter
36517 for (
36518 \series bold
36519 int
36520 \series default
36521  i=0; i<10; i++) /* is invalid in SDCC although allowed in C99 */
36522 \end_layout
36523
36524 \end_deeper
36525 \begin_layout Itemize
36526 But some have been added recently in SDCC 2.7.0.
36527  They must be considered alpha quality however.
36528 \end_layout
36529
36530 \begin_deeper
36531 \begin_layout Verse
36532
36533 \family typewriter
36534 \series bold
36535 inline
36536 \begin_inset LatexCommand \index{inline (not supported)}
36537
36538 \end_inset
36539
36540
36541 \series default
36542  int increment (int a) { return a+1; } /* inlines the increment without
36543  function call overhead */
36544 \newline
36545 int * 
36546 \series bold
36547 restrict
36548 \begin_inset LatexCommand \index{inline (not supported)}
36549
36550 \end_inset
36551
36552
36553 \series default
36554  p; /* accepted but ignored */
36555 \end_layout
36556
36557 \end_deeper
36558 \begin_layout Itemize
36559 Certain words that are valid identifiers in the standard may be reserved
36560  words in SDCC unless the 
36561 \series bold
36562 -
36563 \begin_inset ERT
36564 status collapsed
36565
36566 \begin_layout Standard
36567
36568
36569 \backslash
36570 /
36571 \end_layout
36572
36573 \end_inset
36574
36575 -std-c89
36576 \begin_inset LatexCommand \index{-\/-std-c89}
36577
36578 \end_inset
36579
36580  or -
36581 \begin_inset ERT
36582 status collapsed
36583
36584 \begin_layout Standard
36585
36586
36587 \backslash
36588 /
36589 \end_layout
36590
36591 \end_inset
36592
36593 -std-c99
36594 \begin_inset LatexCommand \index{-\/-std-c99}
36595
36596 \end_inset
36597
36598
36599 \series default
36600  command line options are used.
36601  These may include (depending on the selected processor): 'at', 'banked',
36602  'bit', 'code', 'critical', 'data', 'eeprom', 'far', 'flash', 'idata', 'interrup
36603 t', 'near', 'nonbanked', 'pdata', 'reentrant', 'sbit', 'sfr', 'shadowregs',
36604  'sram', 'using', 'wparam', 'xdata', '_overlay', '_asm', '_endasm', and
36605  '_naked'.
36606  Compliant equivalents of these keywords are always available in a form
36607  that begin with two underscores
36608 \begin_inset LatexCommand \index{\_\_ (prefix for extended keywords)}
36609
36610 \end_inset
36611
36612 , f.e.
36613  '__data' instead of 'data'.
36614 \end_layout
36615
36616 \begin_layout Section
36617 Cyclomatic Complexity
36618 \begin_inset LatexCommand \index{Cyclomatic complexity}
36619
36620 \end_inset
36621
36622
36623 \end_layout
36624
36625 \begin_layout Standard
36626 Cyclomatic complexity of a function is defined as the number of independent
36627  paths the program can take during execution of the function.
36628  This is an important number since it defines the number test cases you
36629  have to generate to validate the function.
36630  The accepted industry standard for complexity number is 10, if the cyclomatic
36631  complexity reported by SDCC exceeds 10 you should think about simplification
36632  of the function logic.
36633  Note that the complexity level is not related to the number of lines of
36634  code in a function.
36635  Large functions can have low complexity, and small functions can have large
36636  complexity levels.
36637  
36638 \newline
36639
36640 \newline
36641 SDCC uses the following formula to compute the complexity:
36642 \newline
36643
36644 \end_layout
36645
36646 \begin_layout Standard
36647 complexity = (number of edges in control flow graph) - (number of nodes
36648  in control flow graph) + 2;
36649 \newline
36650
36651 \newline
36652 Having said that the industry standard is 10,
36653  you should be aware that in some cases it be may unavoidable to have a
36654  complexity level of less than 10.
36655  For example if you have switch statement with more than 10 case labels,
36656  each case label adds one to the complexity level.
36657  The complexity level is by no means an absolute measure of the algorithmic
36658  complexity of the function, it does however provide a good starting point
36659  for which functions you might look at for further optimization.
36660 \end_layout
36661
36662 \begin_layout Section
36663 Retargetting for other Processors
36664 \end_layout
36665
36666 \begin_layout Standard
36667 The issues for retargetting the compiler are far too numerous to be covered
36668  by this document.
36669  What follows is a brief description of each of the seven phases of the
36670  compiler and its MCU dependency.
36671 \end_layout
36672
36673 \begin_layout Itemize
36674 Parsing the source and building the annotated parse tree.
36675  This phase is largely MCU independent (except for the language extensions).
36676  Syntax & semantic checks are also done in this phase, along with some initial
36677  optimizations like back patching labels and the pattern matching optimizations
36678  like bit-rotation etc.
36679 \end_layout
36680
36681 \begin_layout Itemize
36682 The second phase involves generating an intermediate code which can be easy
36683  manipulated during the later phases.
36684  This phase is entirely MCU independent.
36685  The intermediate code generation assumes the target machine has unlimited
36686  number of registers, and designates them with the name iTemp.
36687  The compiler can be made to dump a human readable form of the code generated
36688  by using the -
36689 \begin_inset ERT
36690 status collapsed
36691
36692 \begin_layout Standard
36693
36694
36695 \backslash
36696 /
36697 \end_layout
36698
36699 \end_inset
36700
36701 -dumpraw option.
36702 \end_layout
36703
36704 \begin_layout Itemize
36705 This phase does the bulk of the standard optimizations and is also MCU independe
36706 nt.
36707  This phase can be broken down into several sub-phases:
36708 \newline
36709
36710 \newline
36711 Break down intermediate
36712  code (iCode) into basic blocks.
36713 \newline
36714 Do control flow & data flow analysis on the
36715  basic blocks.
36716 \newline
36717 Do local common subexpression elimination, then global subexpressio
36718 n elimination
36719 \newline
36720 Dead code elimination
36721 \newline
36722 Loop optimizations
36723 \newline
36724 If loop optimizations
36725  caused any changes then do 'global subexpression elimination' and 'dead
36726  code elimination' again.
36727 \end_layout
36728
36729 \begin_layout Itemize
36730 This phase determines the live-ranges; by live range I mean those iTemp
36731  variables defined by the compiler that still survive after all the optimization
36732 s.
36733  Live range analysis
36734 \begin_inset LatexCommand \index{Live range analysis}
36735
36736 \end_inset
36737
36738  is essential for register allocation, since these computation determines
36739  which of these iTemps will be assigned to registers, and for how long.
36740 \end_layout
36741
36742 \begin_layout Itemize
36743 Phase five is register allocation.
36744  There are two parts to this process.
36745 \newline
36746
36747 \newline
36748 The first part I call 'register packing'
36749  (for lack of a better term).
36750  In this case several MCU specific expression folding is done to reduce
36751  register pressure.
36752 \newline
36753
36754 \newline
36755 The second part is more MCU independent and deals with
36756  allocating registers to the remaining live ranges.
36757  A lot of MCU specific code does creep into this phase because of the limited
36758  number of index registers available in the 8051.
36759 \end_layout
36760
36761 \begin_layout Itemize
36762 The Code generation phase is (unhappily), entirely MCU dependent and very
36763  little (if any at all) of this code can be reused for other MCU.
36764  However the scheme for allocating a homogenized assembler operand for each
36765  iCode operand may be reused.
36766 \end_layout
36767
36768 \begin_layout Itemize
36769 As mentioned in the optimization section the peep-hole optimizer is rule
36770  based system, which can reprogrammed for other MCUs.
36771 \end_layout
36772
36773 \begin_layout Standard
36774 More information is available on SDCC Wiki
36775 \begin_inset LatexCommand \index{wiki}
36776
36777 \end_inset
36778
36779  (preliminary link 
36780 \begin_inset LatexCommand \url{http://sdcc.wiki.sourceforge.net/SDCC+internals+and+porting}
36781
36782 \end_inset
36783
36784 ) and in the thread 
36785 \begin_inset LatexCommand \url{http://sf.net/mailarchive/message.php?msg_id=13954144}
36786
36787 \end_inset
36788
36789  .
36790 \end_layout
36791
36792 \begin_layout Chapter
36793 Compiler internals
36794 \begin_inset LatexCommand \index{Compiler internals}
36795
36796 \end_inset
36797
36798
36799 \end_layout
36800
36801 \begin_layout Section
36802 The anatomy of the compiler
36803 \begin_inset LatexCommand \label{sub:The-anatomy-of}
36804
36805 \end_inset
36806
36807
36808 \end_layout
36809
36810 \begin_layout Standard
36811
36812 \shape italic
36813 This is an excerpt from an article published in Circuit Cellar Magazine
36814  in 
36815 \series bold
36816 August 2000
36817 \series default
36818 .
36819  It's a little outdated (the compiler is much more efficient now and user/develo
36820 per friendly), but pretty well exposes the guts of it all.
36821 \shape default
36822
36823 \newline
36824
36825 \newline
36826 The current version of SDCC can generate code for Intel 8051 and Z80 MCU.
36827  It is fairly easy to retarget for other 8-bit MCU.
36828  Here we take a look at some of the internals of the compiler.
36829  
36830 \end_layout
36831
36832 \begin_layout Paragraph*
36833 Parsing
36834 \begin_inset LatexCommand \index{Parsing}
36835
36836 \end_inset
36837
36838  
36839 \end_layout
36840
36841 \begin_layout Standard
36842 Parsing the input source file and creating an AST (Annotated Syntax Tree
36843 \begin_inset LatexCommand \index{Annotated syntax tree}
36844
36845 \end_inset
36846
36847 ).
36848  This phase also involves propagating types (annotating each node of the
36849  parse tree with type information) and semantic analysis.
36850  There are some MCU specific parsing rules.
36851  For example the storage classes, the extended storage classes are MCU specific
36852  while there may be a xdata storage class for 8051 there is no such storage
36853  class for z80 or Atmel AVR.
36854  SDCC allows MCU specific storage class extensions, i.e.
36855  xdata will be treated as a storage class specifier when parsing 8051 C
36856  code but will be treated as a C identifier when parsing z80 or ATMEL AVR
36857  C code.
36858 \end_layout
36859
36860 \begin_layout Paragraph*
36861 Generating iCode
36862 \begin_inset LatexCommand \index{iCode}
36863
36864 \end_inset
36865
36866
36867 \end_layout
36868
36869 \begin_layout Standard
36870 Intermediate code generation.
36871  In this phase the AST is broken down into three-operand form (iCode).
36872  These three operand forms are represented as doubly linked lists.
36873  ICode is the term given to the intermediate form generated by the compiler.
36874  ICode example section shows some examples of iCode generated for some simple
36875  C source functions.
36876 \end_layout
36877
36878 \begin_layout Paragraph*
36879 Optimizations
36880 \begin_inset LatexCommand \index{Optimizations}
36881
36882 \end_inset
36883
36884 .
36885 \end_layout
36886
36887 \begin_layout Standard
36888 Bulk of the target independent optimizations is performed in this phase.
36889  The optimizations include constant propagation, common sub-expression eliminati
36890 on, loop invariant code movement, strength reduction of loop induction variables
36891  and dead-code elimination.
36892 \end_layout
36893
36894 \begin_layout Paragraph*
36895 Live range analysis
36896 \begin_inset LatexCommand \index{Live range analysis}
36897
36898 \end_inset
36899
36900
36901 \end_layout
36902
36903 \begin_layout Standard
36904 During intermediate code generation phase, the compiler assumes the target
36905  machine has infinite number of registers and generates a lot of temporary
36906  variables.
36907  The live range computation determines the lifetime of each of these compiler-ge
36908 nerated temporaries.
36909  A picture speaks a thousand words.
36910  ICode example sections show the live range annotations for each of the
36911  operand.
36912  It is important to note here, each iCode is assigned a number in the order
36913  of its execution in the function.
36914  The live ranges are computed in terms of these numbers.
36915  The from number is the number of the iCode which first defines the operand
36916  and the to number signifies the iCode which uses this operand last.
36917 \end_layout
36918
36919 \begin_layout Paragraph*
36920 Register Allocation
36921 \begin_inset LatexCommand \index{Register allocation}
36922
36923 \end_inset
36924
36925
36926 \end_layout
36927
36928 \begin_layout Standard
36929 The register allocation determines the type and number of registers needed
36930  by each operand.
36931  In most MCUs only a few registers can be used for indirect addressing.
36932  In case of 8051 for example the registers R0 & R1 can be used to indirectly
36933  address the internal ram and DPTR to indirectly address the external ram.
36934  The compiler will try to allocate the appropriate register to pointer variables
36935  if it can.
36936  ICode example section shows the operands annotated with the registers assigned
36937  to them.
36938  The compiler will try to keep operands in registers as much as possible;
36939  there are several schemes the compiler uses to do achieve this.
36940  When the compiler runs out of registers the compiler will check to see
36941  if there are any live operands which is not used or defined in the current
36942  basic block being processed, if there are any found then it will push that
36943  operand and use the registers in this block, the operand will then be popped
36944  at the end of the basic block.
36945  
36946 \end_layout
36947
36948 \begin_layout Standard
36949 There are other MCU specific considerations in this phase.
36950  Some MCUs have an accumulator; very short-lived operands could be assigned
36951  to the accumulator instead of a general-purpose register.
36952 \end_layout
36953
36954 \begin_layout Paragraph*
36955 Code generation
36956 \end_layout
36957
36958 \begin_layout Standard
36959 Figure II gives a table of iCode
36960 \begin_inset LatexCommand \index{iCode}
36961
36962 \end_inset
36963
36964  operations supported by the compiler.
36965  The code generation involves translating these operations into corresponding
36966  assembly code for the processor.
36967  This sounds overly simple but that is the essence of code generation.
36968  Some of the iCode operations are generated on a MCU specific manner for
36969  example, the z80 port does not use registers to pass parameters so the
36970  SEND and RECV iCode operations will not be generated, and it also does
36971  not support JUMPTABLES.
36972  
36973 \newline
36974
36975 \end_layout
36976
36977 \begin_layout Standard
36978
36979 \size footnotesize
36980 Figure II 
36981 \begin_inset Tabular
36982 <lyxtabular version="3" rows="39" columns="4">
36983 <features islongtable="true" headBottomDL="true">
36984 <column alignment="block" valignment="top" leftline="true" width="13col%">
36985 <column alignment="left" valignment="top" leftline="true" width="13col%">
36986 <column alignment="block" valignment="top" leftline="true" width="22col%">
36987 <column alignment="block" valignment="top" leftline="true" rightline="true" width="40col%">
36988 <row topline="true" bottomline="true" endhead="true">
36989 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
36990 \begin_inset Text
36991
36992 \begin_layout Standard
36993
36994 \series bold
36995 iCode
36996 \series default
36997
36998 \begin_inset LatexCommand \index{iCode}
36999
37000 \end_inset
37001
37002
37003 \end_layout
37004
37005 \end_inset
37006 </cell>
37007 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37008 \begin_inset Text
37009
37010 \begin_layout Standard
37011
37012 \series bold
37013 Operands
37014 \end_layout
37015
37016 \end_inset
37017 </cell>
37018 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37019 \begin_inset Text
37020
37021 \begin_layout Standard
37022
37023 \series bold
37024 Description
37025 \end_layout
37026
37027 \end_inset
37028 </cell>
37029 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
37030 \begin_inset Text
37031
37032 \begin_layout Standard
37033
37034 \series bold
37035 C Equivalent
37036 \end_layout
37037
37038 \end_inset
37039 </cell>
37040 </row>
37041 <row topline="true">
37042 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37043 \begin_inset Text
37044
37045 \begin_layout Standard
37046
37047 \size footnotesize
37048 '!'
37049 \end_layout
37050
37051 \end_inset
37052 </cell>
37053 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37054 \begin_inset Text
37055
37056 \begin_layout Standard
37057
37058 \size footnotesize
37059 IC_LEFT() IC_RESULT()
37060 \end_layout
37061
37062 \end_inset
37063 </cell>
37064 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37065 \begin_inset Text
37066
37067 \begin_layout Standard
37068
37069 \size footnotesize
37070 NOT operation 
37071 \end_layout
37072
37073 \end_inset
37074 </cell>
37075 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
37076 \begin_inset Text
37077
37078 \begin_layout Standard
37079
37080 \size footnotesize
37081 IC_RESULT = ! IC_LEFT;
37082 \end_layout
37083
37084 \end_inset
37085 </cell>
37086 </row>
37087 <row topline="true">
37088 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37089 \begin_inset Text
37090
37091 \begin_layout Standard
37092
37093 \size footnotesize
37094 '~'
37095 \end_layout
37096
37097 \end_inset
37098 </cell>
37099 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37100 \begin_inset Text
37101
37102 \begin_layout Standard
37103
37104 \size footnotesize
37105 IC_LEFT() IC_RESULT()
37106 \end_layout
37107
37108 \end_inset
37109 </cell>
37110 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37111 \begin_inset Text
37112
37113 \begin_layout Standard
37114
37115 \size footnotesize
37116 Bitwise complement of 
37117 \end_layout
37118
37119 \end_inset
37120 </cell>
37121 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
37122 \begin_inset Text
37123
37124 \begin_layout Standard
37125
37126 \size footnotesize
37127 IC_RESULT = ~IC_LEFT;
37128 \end_layout
37129
37130 \end_inset
37131 </cell>
37132 </row>
37133 <row topline="true">
37134 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37135 \begin_inset Text
37136
37137 \begin_layout Standard
37138
37139 \size footnotesize
37140 RRC
37141 \end_layout
37142
37143 \end_inset
37144 </cell>
37145 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37146 \begin_inset Text
37147
37148 \begin_layout Standard
37149
37150 \size footnotesize
37151 IC_LEFT() IC_RESULT()
37152 \end_layout
37153
37154 \end_inset
37155 </cell>
37156 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37157 \begin_inset Text
37158
37159 \begin_layout Standard
37160
37161 \size footnotesize
37162 Rotate right with carry
37163 \end_layout
37164
37165 \end_inset
37166 </cell>
37167 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
37168 \begin_inset Text
37169
37170 \begin_layout Standard
37171
37172 \size footnotesize
37173 IC_RESULT = (IC_LEFT << 1) | (IC_LEFT >> (sizeof(IC_LEFT)*8-1));
37174 \end_layout
37175
37176 \end_inset
37177 </cell>
37178 </row>
37179 <row topline="true">
37180 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37181 \begin_inset Text
37182
37183 \begin_layout Standard
37184
37185 \size footnotesize
37186 RLC
37187 \end_layout
37188
37189 \end_inset
37190 </cell>
37191 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37192 \begin_inset Text
37193
37194 \begin_layout Standard
37195
37196 \size footnotesize
37197 IC_LEFT() IC_RESULT()
37198 \end_layout
37199
37200 \end_inset
37201 </cell>
37202 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37203 \begin_inset Text
37204
37205 \begin_layout Standard
37206
37207 \size footnotesize
37208 Rotate left with carry
37209 \end_layout
37210
37211 \end_inset
37212 </cell>
37213 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
37214 \begin_inset Text
37215
37216 \begin_layout Standard
37217
37218 \size footnotesize
37219 IC_RESULT = (IC_LEFT << (sizeof(LC_LEFT)*8-1) ) | (IC_LEFT >> 1);
37220 \end_layout
37221
37222 \end_inset
37223 </cell>
37224 </row>
37225 <row topline="true">
37226 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37227 \begin_inset Text
37228
37229 \begin_layout Standard
37230
37231 \size footnotesize
37232 GETHBIT
37233 \end_layout
37234
37235 \end_inset
37236 </cell>
37237 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37238 \begin_inset Text
37239
37240 \begin_layout Standard
37241
37242 \size footnotesize
37243 IC_LEFT() IC_RESULT()
37244 \end_layout
37245
37246 \end_inset
37247 </cell>
37248 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37249 \begin_inset Text
37250
37251 \begin_layout Standard
37252
37253 \size footnotesize
37254 Get the highest order bit of IC_LEFT
37255 \end_layout
37256
37257 \end_inset
37258 </cell>
37259 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
37260 \begin_inset Text
37261
37262 \begin_layout Standard
37263
37264 \size footnotesize
37265 IC_RESULT = (IC_LEFT >> (sizeof(IC_LEFT)*8 -1));
37266 \end_layout
37267
37268 \end_inset
37269 </cell>
37270 </row>
37271 <row topline="true">
37272 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37273 \begin_inset Text
37274
37275 \begin_layout Standard
37276
37277 \size footnotesize
37278 UNARYMINUS
37279 \end_layout
37280
37281 \end_inset
37282 </cell>
37283 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37284 \begin_inset Text
37285
37286 \begin_layout Standard
37287
37288 \size footnotesize
37289 IC_LEFT() IC_RESULT()
37290 \end_layout
37291
37292 \end_inset
37293 </cell>
37294 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37295 \begin_inset Text
37296
37297 \begin_layout Standard
37298
37299 \size footnotesize
37300 Unary minus
37301 \end_layout
37302
37303 \end_inset
37304 </cell>
37305 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
37306 \begin_inset Text
37307
37308 \begin_layout Standard
37309
37310 \size footnotesize
37311 IC_RESULT = - IC_LEFT;
37312 \end_layout
37313
37314 \end_inset
37315 </cell>
37316 </row>
37317 <row topline="true">
37318 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37319 \begin_inset Text
37320
37321 \begin_layout Standard
37322
37323 \size footnotesize
37324 IPUSH
37325 \end_layout
37326
37327 \end_inset
37328 </cell>
37329 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37330 \begin_inset Text
37331
37332 \begin_layout Standard
37333
37334 \size footnotesize
37335 IC_LEFT()
37336 \end_layout
37337
37338 \end_inset
37339 </cell>
37340 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37341 \begin_inset Text
37342
37343 \begin_layout Standard
37344
37345 \size footnotesize
37346 Push the operand into stack
37347 \end_layout
37348
37349 \end_inset
37350 </cell>
37351 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
37352 \begin_inset Text
37353
37354 \begin_layout Standard
37355
37356 \size footnotesize
37357 NONE
37358 \end_layout
37359
37360 \end_inset
37361 </cell>
37362 </row>
37363 <row topline="true">
37364 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37365 \begin_inset Text
37366
37367 \begin_layout Standard
37368
37369 \size footnotesize
37370 IPOP
37371 \end_layout
37372
37373 \end_inset
37374 </cell>
37375 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37376 \begin_inset Text
37377
37378 \begin_layout Standard
37379
37380 \size footnotesize
37381 IC_LEFT()
37382 \end_layout
37383
37384 \end_inset
37385 </cell>
37386 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37387 \begin_inset Text
37388
37389 \begin_layout Standard
37390
37391 \size footnotesize
37392 Pop the operand from the stack 
37393 \end_layout
37394
37395 \end_inset
37396 </cell>
37397 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
37398 \begin_inset Text
37399
37400 \begin_layout Standard
37401
37402 \size footnotesize
37403 NONE
37404 \end_layout
37405
37406 \end_inset
37407 </cell>
37408 </row>
37409 <row topline="true">
37410 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37411 \begin_inset Text
37412
37413 \begin_layout Standard
37414
37415 \size footnotesize
37416 CALL
37417 \end_layout
37418
37419 \end_inset
37420 </cell>
37421 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37422 \begin_inset Text
37423
37424 \begin_layout Standard
37425
37426 \size footnotesize
37427 IC_LEFT() IC_RESULT()
37428 \end_layout
37429
37430 \end_inset
37431 </cell>
37432 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37433 \begin_inset Text
37434
37435 \begin_layout Standard
37436
37437 \size footnotesize
37438 Call the function represented by IC_LEFT 
37439 \end_layout
37440
37441 \end_inset
37442 </cell>
37443 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
37444 \begin_inset Text
37445
37446 \begin_layout Standard
37447
37448 \size footnotesize
37449 IC_RESULT = IC_LEFT();
37450 \end_layout
37451
37452 \end_inset
37453 </cell>
37454 </row>
37455 <row topline="true">
37456 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37457 \begin_inset Text
37458
37459 \begin_layout Standard
37460
37461 \size footnotesize
37462 PCALL
37463 \end_layout
37464
37465 \end_inset
37466 </cell>
37467 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37468 \begin_inset Text
37469
37470 \begin_layout Standard
37471
37472 \size footnotesize
37473 IC_LEFT() IC_RESULT()
37474 \end_layout
37475
37476 \end_inset
37477 </cell>
37478 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37479 \begin_inset Text
37480
37481 \begin_layout Standard
37482
37483 \size footnotesize
37484 Call via function pointer
37485 \end_layout
37486
37487 \end_inset
37488 </cell>
37489 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
37490 \begin_inset Text
37491
37492 \begin_layout Standard
37493
37494 \size footnotesize
37495 IC_RESULT = (*IC_LEFT)();
37496 \end_layout
37497
37498 \end_inset
37499 </cell>
37500 </row>
37501 <row topline="true">
37502 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37503 \begin_inset Text
37504
37505 \begin_layout Standard
37506
37507 \size footnotesize
37508 RETURN
37509 \end_layout
37510
37511 \end_inset
37512 </cell>
37513 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37514 \begin_inset Text
37515
37516 \begin_layout Standard
37517
37518 \size footnotesize
37519 IC_LEFT()
37520 \end_layout
37521
37522 \end_inset
37523 </cell>
37524 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37525 \begin_inset Text
37526
37527 \begin_layout Standard
37528
37529 \size footnotesize
37530 Return the value in operand IC_LEFT 
37531 \end_layout
37532
37533 \end_inset
37534 </cell>
37535 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
37536 \begin_inset Text
37537
37538 \begin_layout Standard
37539
37540 \size footnotesize
37541 return IC_LEFT;
37542 \end_layout
37543
37544 \end_inset
37545 </cell>
37546 </row>
37547 <row topline="true">
37548 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37549 \begin_inset Text
37550
37551 \begin_layout Standard
37552
37553 \size footnotesize
37554 LABEL
37555 \end_layout
37556
37557 \end_inset
37558 </cell>
37559 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37560 \begin_inset Text
37561
37562 \begin_layout Standard
37563
37564 \size footnotesize
37565 IC_LABEL() 
37566 \end_layout
37567
37568 \end_inset
37569 </cell>
37570 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37571 \begin_inset Text
37572
37573 \begin_layout Standard
37574
37575 \size footnotesize
37576 Label
37577 \end_layout
37578
37579 \end_inset
37580 </cell>
37581 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
37582 \begin_inset Text
37583
37584 \begin_layout Standard
37585
37586 \size footnotesize
37587 IC_LABEL:
37588 \end_layout
37589
37590 \end_inset
37591 </cell>
37592 </row>
37593 <row topline="true">
37594 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37595 \begin_inset Text
37596
37597 \begin_layout Standard
37598
37599 \size footnotesize
37600 GOTO
37601 \end_layout
37602
37603 \end_inset
37604 </cell>
37605 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37606 \begin_inset Text
37607
37608 \begin_layout Standard
37609
37610 \size footnotesize
37611 IC_LABEL() 
37612 \end_layout
37613
37614 \end_inset
37615 </cell>
37616 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37617 \begin_inset Text
37618
37619 \begin_layout Standard
37620
37621 \size footnotesize
37622 Goto label
37623 \end_layout
37624
37625 \end_inset
37626 </cell>
37627 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
37628 \begin_inset Text
37629
37630 \begin_layout Standard
37631
37632 \size footnotesize
37633 goto IC_LABEL();
37634 \end_layout
37635
37636 \end_inset
37637 </cell>
37638 </row>
37639 <row topline="true">
37640 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37641 \begin_inset Text
37642
37643 \begin_layout Standard
37644
37645 \size footnotesize
37646 '+'
37647 \end_layout
37648
37649 \end_inset
37650 </cell>
37651 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37652 \begin_inset Text
37653
37654 \begin_layout Standard
37655
37656 \size footnotesize
37657 IC_LEFT() IC_RIGHT() IC_RESULT()
37658 \end_layout
37659
37660 \end_inset
37661 </cell>
37662 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37663 \begin_inset Text
37664
37665 \begin_layout Standard
37666
37667 \size footnotesize
37668 Addition
37669 \end_layout
37670
37671 \end_inset
37672 </cell>
37673 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
37674 \begin_inset Text
37675
37676 \begin_layout Standard
37677
37678 \size footnotesize
37679 IC_RESULT = IC_LEFT + IC_RIGHT
37680 \end_layout
37681
37682 \end_inset
37683 </cell>
37684 </row>
37685 <row topline="true">
37686 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37687 \begin_inset Text
37688
37689 \begin_layout Standard
37690
37691 \size footnotesize
37692 '-'
37693 \end_layout
37694
37695 \end_inset
37696 </cell>
37697 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37698 \begin_inset Text
37699
37700 \begin_layout Standard
37701
37702 \size footnotesize
37703 IC_LEFT() IC_RIGHT() IC_RESULT()
37704 \end_layout
37705
37706 \end_inset
37707 </cell>
37708 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37709 \begin_inset Text
37710
37711 \begin_layout Standard
37712
37713 \size footnotesize
37714 Subtraction
37715 \end_layout
37716
37717 \end_inset
37718 </cell>
37719 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
37720 \begin_inset Text
37721
37722 \begin_layout Standard
37723
37724 \size footnotesize
37725 IC_RESULT = IC_LEFT - IC_RIGHT 
37726 \end_layout
37727
37728 \end_inset
37729 </cell>
37730 </row>
37731 <row topline="true">
37732 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37733 \begin_inset Text
37734
37735 \begin_layout Standard
37736
37737 \size footnotesize
37738 '*'
37739 \end_layout
37740
37741 \end_inset
37742 </cell>
37743 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37744 \begin_inset Text
37745
37746 \begin_layout Standard
37747
37748 \size footnotesize
37749 IC_LEFT() IC_RIGHT() IC_RESULT()
37750 \end_layout
37751
37752 \end_inset
37753 </cell>
37754 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37755 \begin_inset Text
37756
37757 \begin_layout Standard
37758
37759 \size footnotesize
37760 Multiplication 
37761 \end_layout
37762
37763 \end_inset
37764 </cell>
37765 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
37766 \begin_inset Text
37767
37768 \begin_layout Standard
37769
37770 \size footnotesize
37771 IC_RESULT = IC_LEFT * IC_RIGHT;
37772 \end_layout
37773
37774 \end_inset
37775 </cell>
37776 </row>
37777 <row topline="true">
37778 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37779 \begin_inset Text
37780
37781 \begin_layout Standard
37782
37783 \size footnotesize
37784 '/'
37785 \end_layout
37786
37787 \end_inset
37788 </cell>
37789 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37790 \begin_inset Text
37791
37792 \begin_layout Standard
37793
37794 \size footnotesize
37795 IC_LEFT() IC_RIGHT() IC_RESULT()
37796 \end_layout
37797
37798 \end_inset
37799 </cell>
37800 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37801 \begin_inset Text
37802
37803 \begin_layout Standard
37804
37805 \size footnotesize
37806 Division
37807 \end_layout
37808
37809 \end_inset
37810 </cell>
37811 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
37812 \begin_inset Text
37813
37814 \begin_layout Standard
37815
37816 \size footnotesize
37817 IC_RESULT = IC_LEFT / IC_RIGHT;
37818 \end_layout
37819
37820 \end_inset
37821 </cell>
37822 </row>
37823 <row topline="true">
37824 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37825 \begin_inset Text
37826
37827 \begin_layout Standard
37828
37829 \size footnotesize
37830 '%'
37831 \end_layout
37832
37833 \end_inset
37834 </cell>
37835 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37836 \begin_inset Text
37837
37838 \begin_layout Standard
37839
37840 \size footnotesize
37841 IC_LEFT() IC_RIGHT() IC_RESULT()
37842 \end_layout
37843
37844 \end_inset
37845 </cell>
37846 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37847 \begin_inset Text
37848
37849 \begin_layout Standard
37850
37851 \size footnotesize
37852 Modulus
37853 \end_layout
37854
37855 \end_inset
37856 </cell>
37857 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
37858 \begin_inset Text
37859
37860 \begin_layout Standard
37861
37862 \size footnotesize
37863 IC_RESULT = IC_LEFT % IC_RIGHT;
37864 \end_layout
37865
37866 \end_inset
37867 </cell>
37868 </row>
37869 <row topline="true">
37870 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37871 \begin_inset Text
37872
37873 \begin_layout Standard
37874
37875 \size footnotesize
37876 '<'
37877 \end_layout
37878
37879 \end_inset
37880 </cell>
37881 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37882 \begin_inset Text
37883
37884 \begin_layout Standard
37885
37886 \size footnotesize
37887 IC_LEFT() IC_RIGHT() IC_RESULT()
37888 \end_layout
37889
37890 \end_inset
37891 </cell>
37892 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37893 \begin_inset Text
37894
37895 \begin_layout Standard
37896
37897 \size footnotesize
37898 Less than
37899 \end_layout
37900
37901 \end_inset
37902 </cell>
37903 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
37904 \begin_inset Text
37905
37906 \begin_layout Standard
37907
37908 \size footnotesize
37909 IC_RESULT = IC_LEFT < IC_RIGHT;
37910 \end_layout
37911
37912 \end_inset
37913 </cell>
37914 </row>
37915 <row topline="true">
37916 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37917 \begin_inset Text
37918
37919 \begin_layout Standard
37920
37921 \size footnotesize
37922 '>'
37923 \end_layout
37924
37925 \end_inset
37926 </cell>
37927 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37928 \begin_inset Text
37929
37930 \begin_layout Standard
37931
37932 \size footnotesize
37933 IC_LEFT() IC_RIGHT() IC_RESULT()
37934 \end_layout
37935
37936 \end_inset
37937 </cell>
37938 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37939 \begin_inset Text
37940
37941 \begin_layout Standard
37942
37943 \size footnotesize
37944 Greater than 
37945 \end_layout
37946
37947 \end_inset
37948 </cell>
37949 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
37950 \begin_inset Text
37951
37952 \begin_layout Standard
37953
37954 \size footnotesize
37955 IC_RESULT = IC_LEFT > IC_RIGHT;
37956 \end_layout
37957
37958 \end_inset
37959 </cell>
37960 </row>
37961 <row topline="true">
37962 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37963 \begin_inset Text
37964
37965 \begin_layout Standard
37966
37967 \size footnotesize
37968 EQ_OP
37969 \end_layout
37970
37971 \end_inset
37972 </cell>
37973 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37974 \begin_inset Text
37975
37976 \begin_layout Standard
37977
37978 \size footnotesize
37979 IC_LEFT() IC_RIGHT() IC_RESULT()
37980 \end_layout
37981
37982 \end_inset
37983 </cell>
37984 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37985 \begin_inset Text
37986
37987 \begin_layout Standard
37988
37989 \size footnotesize
37990 Equal to 
37991 \end_layout
37992
37993 \end_inset
37994 </cell>
37995 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
37996 \begin_inset Text
37997
37998 \begin_layout Standard
37999
38000 \size footnotesize
38001 IC_RESULT = IC_LEFT == IC_RIGHT;
38002 \end_layout
38003
38004 \end_inset
38005 </cell>
38006 </row>
38007 <row topline="true">
38008 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38009 \begin_inset Text
38010
38011 \begin_layout Standard
38012
38013 \size footnotesize
38014 AND_OP
38015 \end_layout
38016
38017 \end_inset
38018 </cell>
38019 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38020 \begin_inset Text
38021
38022 \begin_layout Standard
38023
38024 \size footnotesize
38025 IC_LEFT() IC_RIGHT() IC_RESULT() 
38026 \end_layout
38027
38028 \end_inset
38029 </cell>
38030 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38031 \begin_inset Text
38032
38033 \begin_layout Standard
38034
38035 \size footnotesize
38036 Logical and operation
38037 \end_layout
38038
38039 \end_inset
38040 </cell>
38041 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
38042 \begin_inset Text
38043
38044 \begin_layout Standard
38045
38046 \size footnotesize
38047 IC_RESULT = IC_LEFT && IC_RIGHT; 
38048 \end_layout
38049
38050 \end_inset
38051 </cell>
38052 </row>
38053 <row topline="true">
38054 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38055 \begin_inset Text
38056
38057 \begin_layout Standard
38058
38059 \size footnotesize
38060 OR_OP
38061 \end_layout
38062
38063 \end_inset
38064 </cell>
38065 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38066 \begin_inset Text
38067
38068 \begin_layout Standard
38069
38070 \size footnotesize
38071 IC_LEFT() IC_RIGHT() IC_RESULT() 
38072 \end_layout
38073
38074 \end_inset
38075 </cell>
38076 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38077 \begin_inset Text
38078
38079 \begin_layout Standard
38080
38081 \size footnotesize
38082 Logical or operation 
38083 \end_layout
38084
38085 \end_inset
38086 </cell>
38087 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
38088 \begin_inset Text
38089
38090 \begin_layout Standard
38091
38092 \size footnotesize
38093 IC_RESULT = IC_LEFT || IC_RIGHT; 
38094 \end_layout
38095
38096 \end_inset
38097 </cell>
38098 </row>
38099 <row topline="true">
38100 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38101 \begin_inset Text
38102
38103 \begin_layout Standard
38104
38105 \size footnotesize
38106 '^'
38107 \end_layout
38108
38109 \end_inset
38110 </cell>
38111 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38112 \begin_inset Text
38113
38114 \begin_layout Standard
38115
38116 \size footnotesize
38117 IC_LEFT() IC_RIGHT() IC_RESULT() 
38118 \end_layout
38119
38120 \end_inset
38121 </cell>
38122 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38123 \begin_inset Text
38124
38125 \begin_layout Standard
38126
38127 \size footnotesize
38128 Exclusive OR
38129 \end_layout
38130
38131 \end_inset
38132 </cell>
38133 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
38134 \begin_inset Text
38135
38136 \begin_layout Standard
38137
38138 \size footnotesize
38139 IC_RESULT = IC_LEFT ^ IC_RIGHT;
38140 \end_layout
38141
38142 \end_inset
38143 </cell>
38144 </row>
38145 <row topline="true">
38146 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38147 \begin_inset Text
38148
38149 \begin_layout Standard
38150
38151 \size footnotesize
38152 '|'
38153 \end_layout
38154
38155 \end_inset
38156 </cell>
38157 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38158 \begin_inset Text
38159
38160 \begin_layout Standard
38161
38162 \size footnotesize
38163 IC_LEFT() IC_RIGHT() IC_RESULT() 
38164 \end_layout
38165
38166 \end_inset
38167 </cell>
38168 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38169 \begin_inset Text
38170
38171 \begin_layout Standard
38172
38173 \size footnotesize
38174 Bitwise OR 
38175 \end_layout
38176
38177 \end_inset
38178 </cell>
38179 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
38180 \begin_inset Text
38181
38182 \begin_layout Standard
38183
38184 \size footnotesize
38185 IC_RESULT = IC_LEFT | IC_RIGHT;
38186 \end_layout
38187
38188 \end_inset
38189 </cell>
38190 </row>
38191 <row topline="true">
38192 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38193 \begin_inset Text
38194
38195 \begin_layout Standard
38196
38197 \size footnotesize
38198 BITWISEAND
38199 \end_layout
38200
38201 \end_inset
38202 </cell>
38203 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38204 \begin_inset Text
38205
38206 \begin_layout Standard
38207
38208 \size footnotesize
38209 IC_LEFT() IC_RIGHT() IC_RESULT()
38210 \end_layout
38211
38212 \end_inset
38213 </cell>
38214 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38215 \begin_inset Text
38216
38217 \begin_layout Standard
38218
38219 \size footnotesize
38220 Bitwise AND 
38221 \end_layout
38222
38223 \end_inset
38224 </cell>
38225 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
38226 \begin_inset Text
38227
38228 \begin_layout Standard
38229
38230 \size footnotesize
38231 IC_RESULT = IC_LEFT & IC_RIGHT;
38232 \end_layout
38233
38234 \end_inset
38235 </cell>
38236 </row>
38237 <row topline="true">
38238 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38239 \begin_inset Text
38240
38241 \begin_layout Standard
38242
38243 \size footnotesize
38244 LEFT_OP
38245 \end_layout
38246
38247 \end_inset
38248 </cell>
38249 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38250 \begin_inset Text
38251
38252 \begin_layout Standard
38253
38254 \size footnotesize
38255 IC_LEFT() IC_RIGHT() IC_RESULT()
38256 \end_layout
38257
38258 \end_inset
38259 </cell>
38260 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38261 \begin_inset Text
38262
38263 \begin_layout Standard
38264
38265 \size footnotesize
38266 Left shift 
38267 \end_layout
38268
38269 \end_inset
38270 </cell>
38271 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
38272 \begin_inset Text
38273
38274 \begin_layout Standard
38275
38276 \size footnotesize
38277 IC_RESULT = IC_LEFT << IC_RIGHT 
38278 \end_layout
38279
38280 \end_inset
38281 </cell>
38282 </row>
38283 <row topline="true">
38284 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38285 \begin_inset Text
38286
38287 \begin_layout Standard
38288
38289 \size footnotesize
38290 RIGHT_OP
38291 \end_layout
38292
38293 \end_inset
38294 </cell>
38295 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38296 \begin_inset Text
38297
38298 \begin_layout Standard
38299
38300 \size footnotesize
38301 IC_LEFT() IC_RIGHT() IC_RESULT()
38302 \end_layout
38303
38304 \end_inset
38305 </cell>
38306 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38307 \begin_inset Text
38308
38309 \begin_layout Standard
38310
38311 \size footnotesize
38312 Right shift
38313 \end_layout
38314
38315 \end_inset
38316 </cell>
38317 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
38318 \begin_inset Text
38319
38320 \begin_layout Standard
38321
38322 \size footnotesize
38323 IC_RESULT = IC_LEFT >> IC_RIGHT 
38324 \end_layout
38325
38326 \end_inset
38327 </cell>
38328 </row>
38329 <row topline="true">
38330 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38331 \begin_inset Text
38332
38333 \begin_layout Standard
38334
38335 \size footnotesize
38336 GET_VALUE_
38337 \newline
38338 AT_ ADDRESS
38339 \end_layout
38340
38341 \end_inset
38342 </cell>
38343 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38344 \begin_inset Text
38345
38346 \begin_layout Standard
38347
38348 \size footnotesize
38349 IC_LEFT() IC_RESULT()
38350 \end_layout
38351
38352 \end_inset
38353 </cell>
38354 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38355 \begin_inset Text
38356
38357 \begin_layout Standard
38358
38359 \size footnotesize
38360 Indirect fetch 
38361 \end_layout
38362
38363 \end_inset
38364 </cell>
38365 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
38366 \begin_inset Text
38367
38368 \begin_layout Standard
38369
38370 \size footnotesize
38371 IC_RESULT = (*IC_LEFT);
38372 \end_layout
38373
38374 \end_inset
38375 </cell>
38376 </row>
38377 <row topline="true">
38378 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38379 \begin_inset Text
38380
38381 \begin_layout Standard
38382
38383 \size footnotesize
38384 POINTER_SET
38385 \end_layout
38386
38387 \end_inset
38388 </cell>
38389 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38390 \begin_inset Text
38391
38392 \begin_layout Standard
38393
38394 \size footnotesize
38395 IC_RIGHT() IC_RESULT() 
38396 \end_layout
38397
38398 \end_inset
38399 </cell>
38400 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38401 \begin_inset Text
38402
38403 \begin_layout Standard
38404
38405 \size footnotesize
38406 Indirect set
38407 \end_layout
38408
38409 \end_inset
38410 </cell>
38411 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
38412 \begin_inset Text
38413
38414 \begin_layout Standard
38415
38416 \size footnotesize
38417 (*IC_RESULT) = IC_RIGHT;
38418 \end_layout
38419
38420 \end_inset
38421 </cell>
38422 </row>
38423 <row topline="true">
38424 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38425 \begin_inset Text
38426
38427 \begin_layout Standard
38428
38429 \size footnotesize
38430 '='
38431 \end_layout
38432
38433 \end_inset
38434 </cell>
38435 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38436 \begin_inset Text
38437
38438 \begin_layout Standard
38439
38440 \size footnotesize
38441 IC_RIGHT() IC_RESULT()
38442 \end_layout
38443
38444 \end_inset
38445 </cell>
38446 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38447 \begin_inset Text
38448
38449 \begin_layout Standard
38450
38451 \size footnotesize
38452 Assignment
38453 \end_layout
38454
38455 \end_inset
38456 </cell>
38457 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
38458 \begin_inset Text
38459
38460 \begin_layout Standard
38461
38462 \size footnotesize
38463 IC_RESULT = IC_RIGHT;
38464 \end_layout
38465
38466 \end_inset
38467 </cell>
38468 </row>
38469 <row topline="true">
38470 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38471 \begin_inset Text
38472
38473 \begin_layout Standard
38474
38475 \size footnotesize
38476 IFX
38477 \end_layout
38478
38479 \end_inset
38480 </cell>
38481 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38482 \begin_inset Text
38483
38484 \begin_layout Standard
38485
38486 \size footnotesize
38487 IC_COND IC_TRUE IC_LABEL
38488 \end_layout
38489
38490 \end_inset
38491 </cell>
38492 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38493 \begin_inset Text
38494
38495 \begin_layout Standard
38496
38497 \size footnotesize
38498 Conditional jump.
38499  If true label is present then jump to true label if condition is true else
38500  jump to false label if condition is false 
38501 \end_layout
38502
38503 \end_inset
38504 </cell>
38505 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
38506 \begin_inset Text
38507
38508 \begin_layout Standard
38509
38510 \size footnotesize
38511 if (IC_COND) goto IC_TRUE; 
38512 \newline
38513 \InsetSpace ~
38514 \InsetSpace ~
38515 Or 
38516 \newline
38517 If (!IC_COND) goto IC_FALSE;
38518 \end_layout
38519
38520 \end_inset
38521 </cell>
38522 </row>
38523 <row topline="true">
38524 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38525 \begin_inset Text
38526
38527 \begin_layout Standard
38528
38529 \size footnotesize
38530 ADDRESS_OF
38531 \end_layout
38532
38533 \end_inset
38534 </cell>
38535 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38536 \begin_inset Text
38537
38538 \begin_layout Standard
38539
38540 \size footnotesize
38541 IC_LEFT() IC_RESULT()
38542 \end_layout
38543
38544 \end_inset
38545 </cell>
38546 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38547 \begin_inset Text
38548
38549 \begin_layout Standard
38550
38551 \size footnotesize
38552 Address of 
38553 \end_layout
38554
38555 \end_inset
38556 </cell>
38557 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
38558 \begin_inset Text
38559
38560 \begin_layout Standard
38561
38562 \size footnotesize
38563 IC_RESULT = &IC_LEFT();
38564 \end_layout
38565
38566 \end_inset
38567 </cell>
38568 </row>
38569 <row topline="true">
38570 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38571 \begin_inset Text
38572
38573 \begin_layout Standard
38574
38575 \size footnotesize
38576 JUMPTABLE
38577 \end_layout
38578
38579 \end_inset
38580 </cell>
38581 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38582 \begin_inset Text
38583
38584 \begin_layout Standard
38585
38586 \size footnotesize
38587 IC_JTCOND IC_JTLABELS
38588 \end_layout
38589
38590 \end_inset
38591 </cell>
38592 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38593 \begin_inset Text
38594
38595 \begin_layout Standard
38596
38597 \size footnotesize
38598 Jump to list of labels depending on the value of JTCOND
38599 \end_layout
38600
38601 \end_inset
38602 </cell>
38603 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
38604 \begin_inset Text
38605
38606 \begin_layout Standard
38607
38608 \size footnotesize
38609 Switch statement
38610 \end_layout
38611
38612 \end_inset
38613 </cell>
38614 </row>
38615 <row topline="true">
38616 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38617 \begin_inset Text
38618
38619 \begin_layout Standard
38620
38621 \size footnotesize
38622 CAST
38623 \end_layout
38624
38625 \end_inset
38626 </cell>
38627 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38628 \begin_inset Text
38629
38630 \begin_layout Standard
38631
38632 \size footnotesize
38633 IC_RIGHT() IC_LEFT() IC_RESULT()
38634 \end_layout
38635
38636 \end_inset
38637 </cell>
38638 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38639 \begin_inset Text
38640
38641 \begin_layout Standard
38642
38643 \size footnotesize
38644 Cast types 
38645 \end_layout
38646
38647 \end_inset
38648 </cell>
38649 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
38650 \begin_inset Text
38651
38652 \begin_layout Standard
38653
38654 \size footnotesize
38655 IC_RESULT = (typeof IC_LEFT) IC_RIGHT;
38656 \end_layout
38657
38658 \end_inset
38659 </cell>
38660 </row>
38661 <row topline="true">
38662 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38663 \begin_inset Text
38664
38665 \begin_layout Standard
38666
38667 \size footnotesize
38668 SEND
38669 \end_layout
38670
38671 \end_inset
38672 </cell>
38673 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38674 \begin_inset Text
38675
38676 \begin_layout Standard
38677
38678 \size footnotesize
38679 IC_LEFT()
38680 \end_layout
38681
38682 \end_inset
38683 </cell>
38684 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38685 \begin_inset Text
38686
38687 \begin_layout Standard
38688
38689 \size footnotesize
38690 This is used for passing parameters in registers; 
38691 \newline
38692 move IC_LEFT to the next
38693  available parameter register.
38694 \end_layout
38695
38696 \end_inset
38697 </cell>
38698 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
38699 \begin_inset Text
38700
38701 \begin_layout Standard
38702
38703 \size footnotesize
38704 None
38705 \end_layout
38706
38707 \end_inset
38708 </cell>
38709 </row>
38710 <row topline="true">
38711 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38712 \begin_inset Text
38713
38714 \begin_layout Standard
38715
38716 \size footnotesize
38717 RECV
38718 \end_layout
38719
38720 \end_inset
38721 </cell>
38722 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38723 \begin_inset Text
38724
38725 \begin_layout Standard
38726
38727 \size footnotesize
38728 IC_RESULT()
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 \size footnotesize
38739 This is used for receiving parameters passed in registers;
38740 \newline
38741 Move the values
38742  in the next parameter register to IC_RESULT 
38743 \end_layout
38744
38745 \end_inset
38746 </cell>
38747 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
38748 \begin_inset Text
38749
38750 \begin_layout Standard
38751
38752 \size footnotesize
38753 None
38754 \end_layout
38755
38756 \end_inset
38757 </cell>
38758 </row>
38759 <row topline="true" bottomline="true">
38760 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38761 \begin_inset Text
38762
38763 \begin_layout Standard
38764
38765 \shape slanted
38766 \size footnotesize
38767 (some more have been added)
38768 \end_layout
38769
38770 \end_inset
38771 </cell>
38772 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38773 \begin_inset Text
38774
38775 \begin_layout Standard
38776
38777 \end_layout
38778
38779 \end_inset
38780 </cell>
38781 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38782 \begin_inset Text
38783
38784 \begin_layout Standard
38785
38786 \end_layout
38787
38788 \end_inset
38789 </cell>
38790 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
38791 \begin_inset Text
38792
38793 \begin_layout Standard
38794
38795 \shape slanted
38796 \size footnotesize
38797 see f.e.
38798  
38799 \family typewriter
38800 gen51Code()
38801 \family default
38802  in 
38803 \family typewriter
38804 src/mcs51/gen.c
38805 \end_layout
38806
38807 \end_inset
38808 </cell>
38809 </row>
38810 </lyxtabular>
38811
38812 \end_inset
38813
38814
38815 \end_layout
38816
38817 \begin_layout Standard
38818 \begin_inset Note Note
38819 status collapsed
38820
38821 \begin_layout Standard
38822 In the original article Figure II was announced to be downloadable on 
38823 \shape italic
38824 Circuit Cellar
38825 \shape default
38826 's web site.
38827  ftp://ftp.circuitcellar.com/pub/Circuit_Cellar/2000/121/dutta.ZIP
38828 \end_layout
38829
38830 \end_inset
38831
38832
38833 \end_layout
38834
38835 \begin_layout Paragraph*
38836 ICode Example
38837 \begin_inset LatexCommand \index{iCode}
38838
38839 \end_inset
38840
38841
38842 \end_layout
38843
38844 \begin_layout Standard
38845 This section shows some details of iCode.
38846  The example C code does not do anything useful; it is used as an example
38847  to illustrate the intermediate code generated by the compiler.
38848 \end_layout
38849
38850 \begin_layout Verse
38851
38852 \family typewriter
38853 1.\InsetSpace ~
38854 xdata int * p;
38855 \newline
38856 2.\InsetSpace ~
38857 int gint;
38858 \newline
38859 3.\InsetSpace ~
38860 /* This function does nothing useful.
38861  It is used
38862 \newline
38863 4.\InsetSpace ~
38864 \InsetSpace ~
38865 \InsetSpace ~
38866 \InsetSpace ~
38867 for the purpose of explaining iCode */
38868 \newline
38869 5.\InsetSpace ~
38870 short function (data
38871  int *x)
38872 \newline
38873 6.\InsetSpace ~
38874 {
38875 \newline
38876 7.\InsetSpace ~
38877 \InsetSpace ~
38878 \InsetSpace ~
38879 short i=10; \InsetSpace ~
38880 \InsetSpace ~
38881 /* dead initialization eliminated */
38882 \newline
38883 8.\InsetSpace ~
38884 \InsetSpace ~
38885 \InsetSpace ~
38886 short sum=10;
38887  /* dead initialization eliminated */
38888 \newline
38889 9.\InsetSpace ~
38890 \InsetSpace ~
38891 \InsetSpace ~
38892 short mul;
38893 \newline
38894 10.\InsetSpace ~
38895 \InsetSpace ~
38896 int j ;
38897 \newline
38898 11.\InsetSpace ~
38899 \InsetSpace ~
38900 while (*x) *x++
38901  = *p++; 
38902 \newline
38903 12.\InsetSpace ~
38904 \InsetSpace ~
38905 \InsetSpace ~
38906 \InsetSpace ~
38907 sum = 0 ; 
38908 \newline
38909 13.\InsetSpace ~
38910 \InsetSpace ~
38911 mul = 0;
38912 \newline
38913 14.\InsetSpace ~
38914 \InsetSpace ~
38915 /* compiler detects i,j to be induction
38916  variables */
38917 \newline
38918 15.\InsetSpace ~
38919 \InsetSpace ~
38920 for (i = 0, j = 10 ; i < 10 ; i++, j
38921 \family default
38922 -
38923 \begin_inset ERT
38924 status collapsed
38925
38926 \begin_layout Standard
38927
38928
38929 \backslash
38930 /
38931 \end_layout
38932
38933 \end_inset
38934
38935 -
38936 \family typewriter
38937 ) {
38938 \newline
38939 16.\InsetSpace ~
38940 \InsetSpace ~
38941 \InsetSpace ~
38942 \InsetSpace ~
38943 sum += i;
38944 \newline
38945 17.\InsetSpace ~
38946 \InsetSpace ~
38947 \InsetSpace ~
38948 \InsetSpace ~
38949 mul += i * 3; \InsetSpace ~
38950 \InsetSpace ~
38951 /* this multiplication remains */
38952 \newline
38953 18.\InsetSpace ~
38954 \InsetSpace ~
38955 \InsetSpace ~
38956 \InsetSpace ~
38957 gint +=
38958  j * 3;\InsetSpace ~
38959 \InsetSpace ~
38960 /* this multiplication changed to addition */
38961 \newline
38962 19.\InsetSpace ~
38963 \InsetSpace ~
38964 }
38965 \newline
38966 20.\InsetSpace ~
38967 \InsetSpace ~
38968 return sum+mul;
38969 \newline
38970 21.\InsetSpace ~
38971 }
38972 \end_layout
38973
38974 \begin_layout Standard
38975 In addition to the operands each iCode contains information about the filename
38976  and line it corresponds to in the source file.
38977  The first field in the listing should be interpreted as follows:
38978 \newline
38979
38980 \shape italic
38981 \size footnotesize
38982 Filename(linenumber: iCode Execution sequence number : ICode hash table
38983  key : loop depth of the iCode).
38984 \shape default
38985 \size default
38986
38987 \newline
38988 Then follows the human readable form of the ICode operation.
38989  Each operand of this triplet form can be of three basic types a) compiler
38990  generated temporary b) user defined variable c) a constant value.
38991  Note that local variables and parameters are replaced by compiler generated
38992  temporaries.
38993  Live ranges
38994 \begin_inset LatexCommand \index{Live range analysis}
38995
38996 \end_inset
38997
38998  are computed only for temporaries (i.e.
38999  live ranges are not computed for global variables).
39000  Registers
39001 \begin_inset LatexCommand \index{Register allocation}
39002
39003 \end_inset
39004
39005  are allocated for temporaries only.
39006  Operands are formatted in the following manner:
39007 \newline
39008
39009 \shape italic
39010 \size footnotesize
39011 Operand Name [lr live-from : live-to ] { type information } [ registers
39012  allocated ].
39013 \shape default
39014 \size default
39015
39016 \newline
39017 As mentioned earlier the live ranges are computed in terms of the execution
39018  sequence number of the iCodes, for example 
39019 \newline
39020 the iTemp0 is live from (i.e.
39021  first defined in iCode with execution sequence number 3, and is last used
39022  in the iCode with sequence number 5).
39023  For induction variables such as iTemp21 the live range computation extends
39024  the lifetime from the start to the end of the loop.
39025 \newline
39026 The register allocator
39027  used the live range information to allocate registers, the same registers
39028  may be used for different temporaries if their live ranges do not overlap,
39029  for example r0 is allocated to both iTemp6 and to iTemp17 since their live
39030  ranges do not overlap.
39031  In addition the allocator also takes into consideration the type and usage
39032  of a temporary, for example itemp6 is a pointer to near space and is used
39033  as to fetch data from (i.e.
39034  used in GET_VALUE_AT_ADDRESS) so it is allocated a pointer register (r0).
39035  Some short lived temporaries are allocated to special registers which have
39036  meaning to the code generator e.g.
39037  iTemp13 is allocated to a pseudo register CC which tells the back end that
39038  the temporary is used only for a conditional jump the code generation makes
39039  use of this information to optimize a compare and jump ICode.
39040 \newline
39041 There are several
39042  loop optimizations
39043 \begin_inset LatexCommand \index{Loop optimization}
39044
39045 \end_inset
39046
39047  performed by the compiler.
39048  It can detect induction variables iTemp21(i) and iTemp23(j).
39049  Also note the compiler does selective strength reduction
39050 \begin_inset LatexCommand \index{Strength reduction}
39051
39052 \end_inset
39053
39054 , i.e.
39055  the multiplication of an induction variable in line 18 (gint = j * 3) is
39056  changed to addition, a new temporary iTemp17 is allocated and assigned
39057  a initial value, a constant 3 is then added for each iteration of the loop.
39058  The compiler does not change the multiplication
39059 \begin_inset LatexCommand \index{Multiplication}
39060
39061 \end_inset
39062
39063  in line 17 however since the processor does support an 8 * 8 bit multiplication.
39064 \newline
39065
39066 Note the dead code elimination
39067 \begin_inset LatexCommand \index{Dead-code elimination}
39068
39069 \end_inset
39070
39071  optimization eliminated the dead assignments in line 7 & 8 to I and sum
39072  respectively.
39073 \newline
39074
39075 \end_layout
39076
39077 \begin_layout Standard
39078
39079 \size footnotesize
39080 Sample.c (5:1:0:0) _entry($9) :
39081 \end_layout
39082
39083 \begin_layout Standard
39084
39085 \size footnotesize
39086 Sample.c(5:2:1:0) proc _function [lr0:0]{function short}
39087 \end_layout
39088
39089 \begin_layout Standard
39090
39091 \size footnotesize
39092 Sample.c(11:3:2:0) iTemp0 [lr3:5]{_near * int}[r2] = recv 
39093 \end_layout
39094
39095 \begin_layout Standard
39096
39097 \size footnotesize
39098 Sample.c(11:4:53:0) preHeaderLbl0($11) :
39099 \end_layout
39100
39101 \begin_layout Standard
39102
39103 \size footnotesize
39104 Sample.c(11:5:55:0) iTemp6 [lr5:16]{_near * int}[r0] := iTemp0 [lr3:5]{_near
39105  * int}[r2]
39106 \end_layout
39107
39108 \begin_layout Standard
39109
39110 \size footnotesize
39111 Sample.c(11:6:5:1) _whilecontinue_0($1) :
39112 \end_layout
39113
39114 \begin_layout Standard
39115
39116 \size footnotesize
39117 Sample.c(11:7:7:1) iTemp4 [lr7:8]{int}[r2 r3] = @[iTemp6 [lr5:16]{_near *
39118  int}[r0]]
39119 \end_layout
39120
39121 \begin_layout Standard
39122
39123 \size footnotesize
39124 Sample.c(11:8:8:1) if iTemp4 [lr7:8]{int}[r2 r3] == 0 goto _whilebreak_0($3)
39125 \end_layout
39126
39127 \begin_layout Standard
39128
39129 \size footnotesize
39130 Sample.c(11:9:14:1) iTemp7 [lr9:13]{_far * int}[DPTR] := _p [lr0:0]{_far
39131  * int}
39132 \end_layout
39133
39134 \begin_layout Standard
39135
39136 \size footnotesize
39137 Sample.c(11:10:15:1) _p [lr0:0]{_far * int} = _p [lr0:0]{_far * int} + 0x2
39138  {short}
39139 \end_layout
39140
39141 \begin_layout Standard
39142
39143 \size footnotesize
39144 Sample.c(11:13:18:1) iTemp10 [lr13:14]{int}[r2 r3] = @[iTemp7 [lr9:13]{_far
39145  * int}[DPTR]]
39146 \end_layout
39147
39148 \begin_layout Standard
39149
39150 \size footnotesize
39151 Sample.c(11:14:19:1) *(iTemp6 [lr5:16]{_near * int}[r0]) := iTemp10 [lr13:14]{int
39152 }[r2 r3]
39153 \end_layout
39154
39155 \begin_layout Standard
39156
39157 \size footnotesize
39158 Sample.c(11:15:12:1) iTemp6 [lr5:16]{_near * int}[r0] = iTemp6 [lr5:16]{_near
39159  * int}[r0] + 0x2 {short}
39160 \end_layout
39161
39162 \begin_layout Standard
39163
39164 \size footnotesize
39165 Sample.c(11:16:20:1) goto _whilecontinue_0($1)
39166 \end_layout
39167
39168 \begin_layout Standard
39169
39170 \size footnotesize
39171 Sample.c(11:17:21:0)_whilebreak_0($3) :
39172 \end_layout
39173
39174 \begin_layout Standard
39175
39176 \size footnotesize
39177 Sample.c(12:18:22:0) iTemp2 [lr18:40]{short}[r2] := 0x0 {short}
39178 \end_layout
39179
39180 \begin_layout Standard
39181
39182 \size footnotesize
39183 Sample.c(13:19:23:0) iTemp11 [lr19:40]{short}[r3] := 0x0 {short}
39184 \end_layout
39185
39186 \begin_layout Standard
39187
39188 \size footnotesize
39189 Sample.c(15:20:54:0)preHeaderLbl1($13) :
39190 \end_layout
39191
39192 \begin_layout Standard
39193
39194 \size footnotesize
39195 Sample.c(15:21:56:0) iTemp21 [lr21:38]{short}[r4] := 0x0 {short}
39196 \end_layout
39197
39198 \begin_layout Standard
39199
39200 \size footnotesize
39201 Sample.c(15:22:57:0) iTemp23 [lr22:38]{int}[r5 r6] := 0xa {int}
39202 \end_layout
39203
39204 \begin_layout Standard
39205
39206 \size footnotesize
39207 Sample.c(15:23:58:0) iTemp17 [lr23:38]{int}[r7 r0] := 0x1e {int}
39208 \end_layout
39209
39210 \begin_layout Standard
39211
39212 \size footnotesize
39213 Sample.c(15:24:26:1)_forcond_0($4) :
39214 \end_layout
39215
39216 \begin_layout Standard
39217
39218 \size footnotesize
39219 Sample.c(15:25:27:1) iTemp13 [lr25:26]{char}[CC] = iTemp21 [lr21:38]{short}[r4]
39220  < 0xa {short}
39221 \end_layout
39222
39223 \begin_layout Standard
39224
39225 \size footnotesize
39226 Sample.c(15:26:28:1) if iTemp13 [lr25:26]{char}[CC] == 0 goto _forbreak_0($7)
39227 \end_layout
39228
39229 \begin_layout Standard
39230
39231 \size footnotesize
39232 Sample.c(16:27:31:1) iTemp2 [lr18:40]{short}[r2] = iTemp2 [lr18:40]{short}[r2]
39233  + ITemp21 [lr21:38]{short}[r4]
39234 \end_layout
39235
39236 \begin_layout Standard
39237
39238 \size footnotesize
39239 Sample.c(17:29:33:1) iTemp15 [lr29:30]{short}[r1] = iTemp21 [lr21:38]{short}[r4]
39240  * 0x3 {short}
39241 \end_layout
39242
39243 \begin_layout Standard
39244
39245 \size footnotesize
39246 Sample.c(17:30:34:1) iTemp11 [lr19:40]{short}[r3] = iTemp11 [lr19:40]{short}[r3]
39247  + iTemp15 [lr29:30]{short}[r1]
39248 \end_layout
39249
39250 \begin_layout Standard
39251
39252 \size footnotesize
39253 Sample.c(18:32:36:1:1) iTemp17 [lr23:38]{int}[r7 r0]= iTemp17 [lr23:38]{int}[r7
39254  r0]- 0x3 {short}
39255 \end_layout
39256
39257 \begin_layout Standard
39258
39259 \size footnotesize
39260 Sample.c(18:33:37:1) _gint [lr0:0]{int} = _gint [lr0:0]{int} + iTemp17 [lr23:38]{
39261 int}[r7 r0]
39262 \end_layout
39263
39264 \begin_layout Standard
39265
39266 \size footnotesize
39267 Sample.c(15:36:42:1) iTemp21 [lr21:38]{short}[r4] = iTemp21 [lr21:38]{short}[r4]
39268  + 0x1 {short}
39269 \end_layout
39270
39271 \begin_layout Standard
39272
39273 \size footnotesize
39274 Sample.c(15:37:45:1) iTemp23 [lr22:38]{int}[r5 r6]= iTemp23 [lr22:38]{int}[r5
39275  r6]- 0x1 {short}
39276 \end_layout
39277
39278 \begin_layout Standard
39279
39280 \size footnotesize
39281 Sample.c(19:38:47:1) goto _forcond_0($4)
39282 \end_layout
39283
39284 \begin_layout Standard
39285
39286 \size footnotesize
39287 Sample.c(19:39:48:0)_forbreak_0($7) :
39288 \end_layout
39289
39290 \begin_layout Standard
39291
39292 \size footnotesize
39293 Sample.c(20:40:49:0) iTemp24 [lr40:41]{short}[DPTR] = iTemp2 [lr18:40]{short}[r2]
39294  + ITemp11 [lr19:40]{short}[r3]
39295 \end_layout
39296
39297 \begin_layout Standard
39298
39299 \size footnotesize
39300 Sample.c(20:41:50:0) ret iTemp24 [lr40:41]{short}
39301 \end_layout
39302
39303 \begin_layout Standard
39304
39305 \size footnotesize
39306 Sample.c(20:42:51:0)_return($8) :
39307 \end_layout
39308
39309 \begin_layout Standard
39310
39311 \size footnotesize
39312 Sample.c(20:43:52:0) eproc _function [lr0:0]{ ia0 re0 rm0}{function short}
39313 \size default
39314
39315 \newline
39316
39317 \newline
39318 Finally the code generated for this function:
39319 \newline
39320
39321 \end_layout
39322
39323 \begin_layout Standard
39324
39325 \size footnotesize
39326 .area DSEG (DATA)
39327 \end_layout
39328
39329 \begin_layout Standard
39330
39331 \size footnotesize
39332 _p::
39333 \end_layout
39334
39335 \begin_layout Standard
39336
39337 \size footnotesize
39338 \InsetSpace ~
39339 \InsetSpace ~
39340 .ds 2
39341 \end_layout
39342
39343 \begin_layout Standard
39344
39345 \size footnotesize
39346 _gint::
39347 \end_layout
39348
39349 \begin_layout Standard
39350
39351 \size footnotesize
39352 \InsetSpace ~
39353 \InsetSpace ~
39354 .ds 2
39355 \end_layout
39356
39357 \begin_layout Standard
39358
39359 \size footnotesize
39360 ; sample.c 5
39361 \end_layout
39362
39363 \begin_layout Standard
39364
39365 \size footnotesize
39366 ; ----------------------------------------------
39367 \end_layout
39368
39369 \begin_layout Standard
39370
39371 \size footnotesize
39372 ; function function
39373 \end_layout
39374
39375 \begin_layout Standard
39376
39377 \size footnotesize
39378 ; ----------------------------------------------
39379 \end_layout
39380
39381 \begin_layout Standard
39382
39383 \size footnotesize
39384 _function:
39385 \end_layout
39386
39387 \begin_layout Standard
39388
39389 \size footnotesize
39390 ; iTemp0 [lr3:5]{_near * int}[r2] = recv 
39391 \end_layout
39392
39393 \begin_layout Standard
39394
39395 \size footnotesize
39396 \InsetSpace ~
39397 \InsetSpace ~
39398 mov r2,dpl
39399 \end_layout
39400
39401 \begin_layout Standard
39402
39403 \size footnotesize
39404 ; iTemp6 [lr5:16]{_near * int}[r0] := iTemp0 [lr3:5]{_near * int}[r2]
39405 \end_layout
39406
39407 \begin_layout Standard
39408
39409 \size footnotesize
39410 \InsetSpace ~
39411 \InsetSpace ~
39412 mov ar0,r2
39413 \end_layout
39414
39415 \begin_layout Standard
39416
39417 \size footnotesize
39418 ;_whilecontinue_0($1) :
39419 \end_layout
39420
39421 \begin_layout Standard
39422
39423 \size footnotesize
39424 00101$:
39425 \end_layout
39426
39427 \begin_layout Standard
39428
39429 \size footnotesize
39430 ; iTemp4 [lr7:8]{int}[r2 r3] = @[iTemp6 [lr5:16]{_near * int}[r0]]
39431 \end_layout
39432
39433 \begin_layout Standard
39434
39435 \size footnotesize
39436 ; if iTemp4 [lr7:8]{int}[r2 r3] == 0 goto _whilebreak_0($3)
39437 \end_layout
39438
39439 \begin_layout Standard
39440
39441 \size footnotesize
39442 \InsetSpace ~
39443 \InsetSpace ~
39444 mov ar2,@r0
39445 \end_layout
39446
39447 \begin_layout Standard
39448
39449 \size footnotesize
39450 \InsetSpace ~
39451 \InsetSpace ~
39452 inc r0
39453 \end_layout
39454
39455 \begin_layout Standard
39456
39457 \size footnotesize
39458 \InsetSpace ~
39459 \InsetSpace ~
39460 mov ar3,@r0
39461 \end_layout
39462
39463 \begin_layout Standard
39464
39465 \size footnotesize
39466 \InsetSpace ~
39467 \InsetSpace ~
39468 dec r0
39469 \end_layout
39470
39471 \begin_layout Standard
39472
39473 \size footnotesize
39474 \InsetSpace ~
39475 \InsetSpace ~
39476 mov a,r2
39477 \end_layout
39478
39479 \begin_layout Standard
39480
39481 \size footnotesize
39482 \InsetSpace ~
39483 \InsetSpace ~
39484 orl a,r3
39485 \end_layout
39486
39487 \begin_layout Standard
39488
39489 \size footnotesize
39490 \InsetSpace ~
39491 \InsetSpace ~
39492 jz 00103$
39493 \end_layout
39494
39495 \begin_layout Standard
39496
39497 \size footnotesize
39498 00114$:
39499 \end_layout
39500
39501 \begin_layout Standard
39502
39503 \size footnotesize
39504 ; iTemp7 [lr9:13]{_far * int}[DPTR] := _p [lr0:0]{_far * int}
39505 \end_layout
39506
39507 \begin_layout Standard
39508
39509 \size footnotesize
39510 \InsetSpace ~
39511 \InsetSpace ~
39512 mov dpl,_p
39513 \end_layout
39514
39515 \begin_layout Standard
39516
39517 \size footnotesize
39518 \InsetSpace ~
39519 \InsetSpace ~
39520 mov dph,(_p + 1)
39521 \end_layout
39522
39523 \begin_layout Standard
39524
39525 \size footnotesize
39526 ; _p [lr0:0]{_far * int} = _p [lr0:0]{_far * int} + 0x2 {short}
39527 \end_layout
39528
39529 \begin_layout Standard
39530
39531 \size footnotesize
39532 \InsetSpace ~
39533 \InsetSpace ~
39534 mov a,#0x02
39535 \end_layout
39536
39537 \begin_layout Standard
39538
39539 \size footnotesize
39540 \InsetSpace ~
39541 \InsetSpace ~
39542 add a,_p
39543 \end_layout
39544
39545 \begin_layout Standard
39546
39547 \size footnotesize
39548 \InsetSpace ~
39549 \InsetSpace ~
39550 mov _p,a
39551 \end_layout
39552
39553 \begin_layout Standard
39554
39555 \size footnotesize
39556 \InsetSpace ~
39557 \InsetSpace ~
39558 clr a
39559 \end_layout
39560
39561 \begin_layout Standard
39562
39563 \size footnotesize
39564 \InsetSpace ~
39565 \InsetSpace ~
39566 addc a,(_p + 1)
39567 \end_layout
39568
39569 \begin_layout Standard
39570
39571 \size footnotesize
39572 \InsetSpace ~
39573 \InsetSpace ~
39574 mov (_p + 1),a
39575 \end_layout
39576
39577 \begin_layout Standard
39578
39579 \size footnotesize
39580 ; iTemp10 [lr13:14]{int}[r2 r3] = @[iTemp7 [lr9:13]{_far * int}[DPTR]]
39581 \end_layout
39582
39583 \begin_layout Standard
39584
39585 \size footnotesize
39586 \InsetSpace ~
39587 \InsetSpace ~
39588 movx a,@dptr
39589 \end_layout
39590
39591 \begin_layout Standard
39592
39593 \size footnotesize
39594 \InsetSpace ~
39595 \InsetSpace ~
39596 mov r2,a
39597 \end_layout
39598
39599 \begin_layout Standard
39600
39601 \size footnotesize
39602 \InsetSpace ~
39603 \InsetSpace ~
39604 inc dptr
39605 \end_layout
39606
39607 \begin_layout Standard
39608
39609 \size footnotesize
39610 \InsetSpace ~
39611 \InsetSpace ~
39612 movx a,@dptr
39613 \end_layout
39614
39615 \begin_layout Standard
39616
39617 \size footnotesize
39618 \InsetSpace ~
39619 \InsetSpace ~
39620 mov r3,a
39621 \end_layout
39622
39623 \begin_layout Standard
39624
39625 \size footnotesize
39626 ; *(iTemp6 [lr5:16]{_near * int}[r0]) := iTemp10 [lr13:14]{int}[r2 r3]
39627 \end_layout
39628
39629 \begin_layout Standard
39630
39631 \size footnotesize
39632 \InsetSpace ~
39633 \InsetSpace ~
39634 mov @r0,ar2
39635 \end_layout
39636
39637 \begin_layout Standard
39638
39639 \size footnotesize
39640 \InsetSpace ~
39641 \InsetSpace ~
39642 inc r0
39643 \end_layout
39644
39645 \begin_layout Standard
39646
39647 \size footnotesize
39648 \InsetSpace ~
39649 \InsetSpace ~
39650 mov @r0,ar3
39651 \end_layout
39652
39653 \begin_layout Standard
39654
39655 \size footnotesize
39656 ; iTemp6 [lr5:16]{_near * int}[r0] = 
39657 \end_layout
39658
39659 \begin_layout Standard
39660
39661 \size footnotesize
39662 ; iTemp6 [lr5:16]{_near * int}[r0] + 
39663 \end_layout
39664
39665 \begin_layout Standard
39666
39667 \size footnotesize
39668 ; 0x2 {short}
39669 \end_layout
39670
39671 \begin_layout Standard
39672
39673 \size footnotesize
39674 \InsetSpace ~
39675 \InsetSpace ~
39676 inc r0
39677 \end_layout
39678
39679 \begin_layout Standard
39680
39681 \size footnotesize
39682 ; goto _whilecontinue_0($1)
39683 \end_layout
39684
39685 \begin_layout Standard
39686
39687 \size footnotesize
39688 \InsetSpace ~
39689 \InsetSpace ~
39690 sjmp 00101$
39691 \end_layout
39692
39693 \begin_layout Standard
39694
39695 \size footnotesize
39696 ; _whilebreak_0($3) :
39697 \end_layout
39698
39699 \begin_layout Standard
39700
39701 \size footnotesize
39702 00103$:
39703 \end_layout
39704
39705 \begin_layout Standard
39706
39707 \size footnotesize
39708 ; iTemp2 [lr18:40]{short}[r2] := 0x0 {short}
39709 \end_layout
39710
39711 \begin_layout Standard
39712
39713 \size footnotesize
39714 \InsetSpace ~
39715 \InsetSpace ~
39716 mov r2,#0x00
39717 \end_layout
39718
39719 \begin_layout Standard
39720
39721 \size footnotesize
39722 ; iTemp11 [lr19:40]{short}[r3] := 0x0 {short}
39723 \end_layout
39724
39725 \begin_layout Standard
39726
39727 \size footnotesize
39728 \InsetSpace ~
39729 \InsetSpace ~
39730 mov r3,#0x00
39731 \end_layout
39732
39733 \begin_layout Standard
39734
39735 \size footnotesize
39736 ; iTemp21 [lr21:38]{short}[r4] := 0x0 {short}
39737 \end_layout
39738
39739 \begin_layout Standard
39740
39741 \size footnotesize
39742 \InsetSpace ~
39743 \InsetSpace ~
39744 mov r4,#0x00
39745 \end_layout
39746
39747 \begin_layout Standard
39748
39749 \size footnotesize
39750 ; iTemp23 [lr22:38]{int}[r5 r6] := 0xa {int}
39751 \end_layout
39752
39753 \begin_layout Standard
39754
39755 \size footnotesize
39756 \InsetSpace ~
39757 \InsetSpace ~
39758 mov r5,#0x0A
39759 \end_layout
39760
39761 \begin_layout Standard
39762
39763 \size footnotesize
39764 \InsetSpace ~
39765 \InsetSpace ~
39766 mov r6,#0x00
39767 \end_layout
39768
39769 \begin_layout Standard
39770
39771 \size footnotesize
39772 ; iTemp17 [lr23:38]{int}[r7 r0] := 0x1e {int}
39773 \end_layout
39774
39775 \begin_layout Standard
39776
39777 \size footnotesize
39778 \InsetSpace ~
39779 \InsetSpace ~
39780 mov r7,#0x1E
39781 \end_layout
39782
39783 \begin_layout Standard
39784
39785 \size footnotesize
39786 \InsetSpace ~
39787 \InsetSpace ~
39788 mov r0,#0x00
39789 \end_layout
39790
39791 \begin_layout Standard
39792
39793 \size footnotesize
39794 ; _forcond_0($4) :
39795 \end_layout
39796
39797 \begin_layout Standard
39798
39799 \size footnotesize
39800 00104$:
39801 \end_layout
39802
39803 \begin_layout Standard
39804
39805 \size footnotesize
39806 ; iTemp13 [lr25:26]{char}[CC] = iTemp21 [lr21:38]{short}[r4] < 0xa {short}
39807 \end_layout
39808
39809 \begin_layout Standard
39810
39811 \size footnotesize
39812 ; if iTemp13 [lr25:26]{char}[CC] == 0 goto _forbreak_0($7)
39813 \end_layout
39814
39815 \begin_layout Standard
39816
39817 \size footnotesize
39818 \InsetSpace ~
39819 \InsetSpace ~
39820 clr c
39821 \end_layout
39822
39823 \begin_layout Standard
39824
39825 \size footnotesize
39826 \InsetSpace ~
39827 \InsetSpace ~
39828 mov a,r4
39829 \end_layout
39830
39831 \begin_layout Standard
39832
39833 \size footnotesize
39834 \InsetSpace ~
39835 \InsetSpace ~
39836 xrl a,#0x80
39837 \end_layout
39838
39839 \begin_layout Standard
39840
39841 \size footnotesize
39842 \InsetSpace ~
39843 \InsetSpace ~
39844 subb a,#0x8a
39845 \end_layout
39846
39847 \begin_layout Standard
39848
39849 \size footnotesize
39850 \InsetSpace ~
39851 \InsetSpace ~
39852 jnc 00107$
39853 \end_layout
39854
39855 \begin_layout Standard
39856
39857 \size footnotesize
39858 00115$:
39859 \end_layout
39860
39861 \begin_layout Standard
39862
39863 \size footnotesize
39864 ; iTemp2 [lr18:40]{short}[r2] = iTemp2 [lr18:40]{short}[r2] + 
39865 \end_layout
39866
39867 \begin_layout Standard
39868
39869 \size footnotesize
39870 ; iTemp21 [lr21:38]{short}[r4]
39871 \end_layout
39872
39873 \begin_layout Standard
39874
39875 \size footnotesize
39876 \InsetSpace ~
39877 \InsetSpace ~
39878 mov a,r4
39879 \end_layout
39880
39881 \begin_layout Standard
39882
39883 \size footnotesize
39884 \InsetSpace ~
39885 \InsetSpace ~
39886 add a,r2
39887 \end_layout
39888
39889 \begin_layout Standard
39890
39891 \size footnotesize
39892 \InsetSpace ~
39893 \InsetSpace ~
39894 mov r2,a
39895 \end_layout
39896
39897 \begin_layout Standard
39898
39899 \size footnotesize
39900 ; iTemp15 [lr29:30]{short}[r1] = iTemp21 [lr21:38]{short}[r4] * 0x3 {short}
39901 \end_layout
39902
39903 \begin_layout Standard
39904
39905 \size footnotesize
39906 \InsetSpace ~
39907 \InsetSpace ~
39908 mov b,#0x03
39909 \end_layout
39910
39911 \begin_layout Standard
39912
39913 \size footnotesize
39914 \InsetSpace ~
39915 \InsetSpace ~
39916 mov a,r4
39917 \end_layout
39918
39919 \begin_layout Standard
39920
39921 \size footnotesize
39922 \InsetSpace ~
39923 \InsetSpace ~
39924 mul ab
39925 \end_layout
39926
39927 \begin_layout Standard
39928
39929 \size footnotesize
39930 \InsetSpace ~
39931 \InsetSpace ~
39932 mov r1,a
39933 \end_layout
39934
39935 \begin_layout Standard
39936
39937 \size footnotesize
39938 ; iTemp11 [lr19:40]{short}[r3] = iTemp11 [lr19:40]{short}[r3] + 
39939 \end_layout
39940
39941 \begin_layout Standard
39942
39943 \size footnotesize
39944 ; iTemp15 [lr29:30]{short}[r1]
39945 \end_layout
39946
39947 \begin_layout Standard
39948
39949 \size footnotesize
39950 \InsetSpace ~
39951 \InsetSpace ~
39952 add a,r3
39953 \end_layout
39954
39955 \begin_layout Standard
39956
39957 \size footnotesize
39958 \InsetSpace ~
39959 \InsetSpace ~
39960 mov r3,a
39961 \end_layout
39962
39963 \begin_layout Standard
39964
39965 \size footnotesize
39966 ; iTemp17 [lr23:38]{int}[r7 r0]= iTemp17 [lr23:38]{int}[r7 r0]- 0x3 {short}
39967 \end_layout
39968
39969 \begin_layout Standard
39970
39971 \size footnotesize
39972 \InsetSpace ~
39973 \InsetSpace ~
39974 mov a,r7
39975 \end_layout
39976
39977 \begin_layout Standard
39978
39979 \size footnotesize
39980 \InsetSpace ~
39981 \InsetSpace ~
39982 add a,#0xfd
39983 \end_layout
39984
39985 \begin_layout Standard
39986
39987 \size footnotesize
39988 \InsetSpace ~
39989 \InsetSpace ~
39990 mov r7,a
39991 \end_layout
39992
39993 \begin_layout Standard
39994
39995 \size footnotesize
39996 \InsetSpace ~
39997 \InsetSpace ~
39998 mov a,r0
39999 \end_layout
40000
40001 \begin_layout Standard
40002
40003 \size footnotesize
40004 \InsetSpace ~
40005 \InsetSpace ~
40006 addc a,#0xff
40007 \end_layout
40008
40009 \begin_layout Standard
40010
40011 \size footnotesize
40012 \InsetSpace ~
40013 \InsetSpace ~
40014 mov r0,a
40015 \end_layout
40016
40017 \begin_layout Standard
40018
40019 \size footnotesize
40020 ; _gint [lr0:0]{int} = _gint [lr0:0]{int} + iTemp17 [lr23:38]{int}[r7 r0]
40021 \end_layout
40022
40023 \begin_layout Standard
40024
40025 \size footnotesize
40026 \InsetSpace ~
40027 \InsetSpace ~
40028 mov a,r7
40029 \end_layout
40030
40031 \begin_layout Standard
40032
40033 \size footnotesize
40034 \InsetSpace ~
40035 \InsetSpace ~
40036 add a,_gint
40037 \end_layout
40038
40039 \begin_layout Standard
40040
40041 \size footnotesize
40042 \InsetSpace ~
40043 \InsetSpace ~
40044 mov _gint,a
40045 \end_layout
40046
40047 \begin_layout Standard
40048
40049 \size footnotesize
40050 \InsetSpace ~
40051 \InsetSpace ~
40052 mov a,r0
40053 \end_layout
40054
40055 \begin_layout Standard
40056
40057 \size footnotesize
40058 \InsetSpace ~
40059 \InsetSpace ~
40060 addc a,(_gint + 1)
40061 \end_layout
40062
40063 \begin_layout Standard
40064
40065 \size footnotesize
40066 \InsetSpace ~
40067 \InsetSpace ~
40068 mov (_gint + 1),a
40069 \end_layout
40070
40071 \begin_layout Standard
40072
40073 \size footnotesize
40074 ; iTemp21 [lr21:38]{short}[r4] = iTemp21 [lr21:38]{short}[r4] + 0x1 {short}
40075 \end_layout
40076
40077 \begin_layout Standard
40078
40079 \size footnotesize
40080 \InsetSpace ~
40081 \InsetSpace ~
40082 inc r4
40083 \end_layout
40084
40085 \begin_layout Standard
40086
40087 \size footnotesize
40088 ; iTemp23 [lr22:38]{int}[r5 r6]= iTemp23 [lr22:38]{int}[r5 r6]- 0x1 {short}
40089 \end_layout
40090
40091 \begin_layout Standard
40092
40093 \size footnotesize
40094 \InsetSpace ~
40095 \InsetSpace ~
40096 dec r5
40097 \end_layout
40098
40099 \begin_layout Standard
40100
40101 \size footnotesize
40102 \InsetSpace ~
40103 \InsetSpace ~
40104 cjne r5,#0xff,00104$
40105 \end_layout
40106
40107 \begin_layout Standard
40108
40109 \size footnotesize
40110 \InsetSpace ~
40111 \InsetSpace ~
40112 dec r6
40113 \end_layout
40114
40115 \begin_layout Standard
40116
40117 \size footnotesize
40118 ; goto _forcond_0($4)
40119 \end_layout
40120
40121 \begin_layout Standard
40122
40123 \size footnotesize
40124 \InsetSpace ~
40125 \InsetSpace ~
40126 sjmp 00104$
40127 \end_layout
40128
40129 \begin_layout Standard
40130
40131 \size footnotesize
40132 ; _forbreak_0($7) :
40133 \end_layout
40134
40135 \begin_layout Standard
40136
40137 \size footnotesize
40138 00107$:
40139 \end_layout
40140
40141 \begin_layout Standard
40142
40143 \size footnotesize
40144 ; ret iTemp24 [lr40:41]{short}
40145 \end_layout
40146
40147 \begin_layout Standard
40148
40149 \size footnotesize
40150 \InsetSpace ~
40151 \InsetSpace ~
40152 mov a,r3
40153 \end_layout
40154
40155 \begin_layout Standard
40156
40157 \size footnotesize
40158 \InsetSpace ~
40159 \InsetSpace ~
40160 add a,r2
40161 \end_layout
40162
40163 \begin_layout Standard
40164
40165 \size footnotesize
40166 \InsetSpace ~
40167 \InsetSpace ~
40168 mov dpl,a
40169 \end_layout
40170
40171 \begin_layout Standard
40172
40173 \size footnotesize
40174 ; _return($8) :
40175 \end_layout
40176
40177 \begin_layout Standard
40178
40179 \size footnotesize
40180 00108$:
40181 \end_layout
40182
40183 \begin_layout Standard
40184
40185 \size footnotesize
40186 \InsetSpace ~
40187 \InsetSpace ~
40188 ret
40189 \newline
40190
40191 \end_layout
40192
40193 \begin_layout Section
40194 A few words about basic block successors, predecessors and dominators
40195 \end_layout
40196
40197 \begin_layout Standard
40198 Successors are basic blocks
40199 \begin_inset LatexCommand \index{Basic blocks}
40200
40201 \end_inset
40202
40203  that might execute after this basic block.
40204 \newline
40205 Predecessors are basic blocks
40206  that might execute before reaching this basic block.
40207 \newline
40208 Dominators are basic
40209  blocks that WILL execute before reaching this basic block.
40210 \newline
40211
40212 \end_layout
40213
40214 \begin_layout Standard
40215 [basic block 1]
40216 \end_layout
40217
40218 \begin_layout Standard
40219 if (something)
40220 \end_layout
40221
40222 \begin_layout Standard
40223 \InsetSpace ~
40224 \InsetSpace ~
40225 \InsetSpace ~
40226 \InsetSpace ~
40227 [basic block 2]
40228 \end_layout
40229
40230 \begin_layout Standard
40231 else
40232 \end_layout
40233
40234 \begin_layout Standard
40235 \InsetSpace ~
40236 \InsetSpace ~
40237 \InsetSpace ~
40238 \InsetSpace ~
40239 [basic block 3]
40240 \end_layout
40241
40242 \begin_layout Standard
40243 [basic block 4]
40244 \newline
40245
40246 \end_layout
40247
40248 \begin_layout Standard
40249 a) succList of [BB2] = [BB4], of [BB3] = [BB4], of [BB1] = [BB2,BB3]
40250 \end_layout
40251
40252 \begin_layout Standard
40253 b) predList of [BB2] = [BB1], of [BB3] = [BB1], of [BB4] = [BB2,BB3]
40254 \end_layout
40255
40256 \begin_layout Standard
40257 c) domVect of [BB4] = BB1 ...
40258  here we are not sure if BB2 or BB3 was executed but we are SURE that BB1
40259  was executed.
40260 \end_layout
40261
40262 \begin_layout Chapter
40263 Acknowledgments
40264 \end_layout
40265
40266 \begin_layout Standard
40267 \begin_inset LatexCommand \url{http://sdcc.sourceforge.net#Who}
40268
40269 \end_inset
40270
40271
40272 \newline
40273
40274 \newline
40275
40276 \emph on
40277 Thanks to all the other volunteer developers who have helped with coding,
40278  testing, web-page creation, distribution sets, etc.
40279  You know who you are :-)
40280 \emph default
40281
40282 \newline
40283
40284 \newline
40285
40286 \emph on
40287 Thanks to Sourceforge 
40288 \begin_inset LatexCommand \url{http://www.sf.net}
40289
40290 \end_inset
40291
40292  which has hosted the project since 1999 and donates significant download
40293  bandwidth.
40294 \emph default
40295
40296 \newline
40297
40298 \newline
40299
40300 \emph on
40301 Also thanks to all SDCC Distributed Compile Farm members for donating CPU
40302  cycles and bandwidth for snapshot builds.
40303 \newline
40304
40305 \end_layout
40306
40307 \begin_layout Standard
40308 This document was initially written by Sandeep Dutta
40309 \end_layout
40310
40311 \begin_layout Standard
40312 All product names mentioned herein may be trademarks
40313 \begin_inset LatexCommand \index{Trademarks}
40314
40315 \end_inset
40316
40317  of their respective companies.
40318  
40319 \end_layout
40320
40321 \begin_layout Section*
40322 Alphabetical index
40323 \end_layout
40324
40325 \begin_layout Standard
40326 To avoid confusion, the installation and building options for SDCC itself
40327  (chapter 2) are not part of the index.
40328 \end_layout
40329
40330 \begin_layout Standard
40331 \begin_inset LatexCommand \printindex{}
40332
40333 \end_inset
40334
40335
40336 \end_layout
40337
40338 \end_body
40339 \end_document