* .version, doc/sdccman.lyx: bumped sdcc version to 2.8.5
[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.8.5
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 and 
872 \series bold
873 -
874 \begin_inset ERT
875 status collapsed
876
877 \begin_layout Standard
878
879
880 \backslash
881 /
882 \end_layout
883
884 \end_inset
885
886 -std-c89
887 \begin_inset LatexCommand \index{-\/-std-c89}
888
889 \end_inset
890
891  
892 \series default
893 and
894 \series bold
895  -
896 \begin_inset ERT
897 status collapsed
898
899 \begin_layout Standard
900
901
902 \backslash
903 /
904 \end_layout
905
906 \end_inset
907
908 -std-c99
909 \begin_inset LatexCommand \index{-\/-std-c99}
910
911 \end_inset
912
913
914 \series default
915  command line option are not defined 
916 \begin_inset Marginal
917 status collapsed
918
919 \begin_layout Standard
920
921 \series bold
922 \InsetSpace ~
923 !
924 \end_layout
925
926 \end_inset
927
928 , e.g.: 
929 \newline
930
931 \family typewriter
932 \InsetSpace ~
933 \InsetSpace ~
934 char a=3;
935 \newline
936 \InsetSpace ~
937 \InsetSpace ~
938 printf ("%d %c
939 \backslash
940 n", a, (char)a);
941 \family default
942
943 \newline
944  will push a as an int and as a char resp if
945 \series bold
946  -
947 \begin_inset ERT
948 status collapsed
949
950 \begin_layout Standard
951
952
953 \backslash
954 /
955 \end_layout
956
957 \end_inset
958
959 -std-c89
960 \begin_inset LatexCommand \index{-\/-std-c89}
961
962 \end_inset
963
964  
965 \series default
966 and
967 \series bold
968  -
969 \begin_inset ERT
970 status collapsed
971
972 \begin_layout Standard
973
974
975 \backslash
976 /
977 \end_layout
978
979 \end_inset
980
981 -std-c99
982 \begin_inset LatexCommand \index{-\/-std-c99}
983
984 \end_inset
985
986
987 \series default
988  command line options are not defined,
989 \newline
990  will push a as two ints if
991 \series bold
992  -
993 \begin_inset ERT
994 status collapsed
995
996 \begin_layout Standard
997
998
999 \backslash
1000 /
1001 \end_layout
1002
1003 \end_inset
1004
1005 -std-c89
1006 \begin_inset LatexCommand \index{-\/-std-c89}
1007
1008 \end_inset
1009
1010  
1011 \series default
1012 or
1013 \series bold
1014  -
1015 \begin_inset ERT
1016 status collapsed
1017
1018 \begin_layout Standard
1019
1020
1021 \backslash
1022 /
1023 \end_layout
1024
1025 \end_inset
1026
1027 -std-c99
1028 \begin_inset LatexCommand \index{-\/-std-c99}
1029
1030 \end_inset
1031
1032
1033 \series default
1034  command line option is defined.
1035 \end_layout
1036
1037 \begin_layout Itemize
1038 option -
1039 \begin_inset ERT
1040 status collapsed
1041
1042 \begin_layout Standard
1043
1044
1045 \backslash
1046 /
1047 \end_layout
1048
1049 \end_inset
1050
1051 -regextend has been removed.
1052 \end_layout
1053
1054 \begin_layout Itemize
1055 option -
1056 \begin_inset ERT
1057 status collapsed
1058
1059 \begin_layout Standard
1060
1061
1062 \backslash
1063 /
1064 \end_layout
1065
1066 \end_inset
1067
1068 -noregparms has been removed.
1069 \end_layout
1070
1071 \begin_layout Itemize
1072 option -
1073 \begin_inset ERT
1074 status collapsed
1075
1076 \begin_layout Standard
1077
1078
1079 \backslash
1080 /
1081 \end_layout
1082
1083 \end_inset
1084
1085 -stack-after-data has been removed.
1086 \end_layout
1087
1088 \begin_layout Itemize
1089 bit
1090 \begin_inset LatexCommand \index{bit}
1091
1092 \end_inset
1093
1094  and sbit
1095 \begin_inset LatexCommand \index{sbit}
1096
1097 \end_inset
1098
1099
1100 \begin_inset LatexCommand \index{\_\_sbit}
1101
1102 \end_inset
1103
1104  types now consistently behave like the C99 _Bool type with respect to type
1105  conversion
1106 \begin_inset LatexCommand \index{type conversion}
1107
1108 \end_inset
1109
1110
1111 \begin_inset LatexCommand \index{type promotion}
1112
1113 \end_inset
1114
1115 .
1116  The most common incompatibility resulting from this change is related to
1117  bit toggling
1118 \begin_inset LatexCommand \index{Bit toggling}
1119
1120 \end_inset
1121
1122  idioms, e.g.:
1123 \newline
1124
1125 \family typewriter
1126 \InsetSpace ~
1127 \InsetSpace ~
1128 bit b;
1129 \newline
1130 \InsetSpace ~
1131 \InsetSpace ~
1132 b = ~
1133 \begin_inset LatexCommand \index{\~\/ Operator}
1134
1135 \end_inset
1136
1137 b; /* equivalent to b=1 instead of toggling b */
1138 \begin_inset Marginal
1139 status collapsed
1140
1141 \begin_layout Standard
1142
1143 \series bold
1144 \InsetSpace ~
1145 !
1146 \end_layout
1147
1148 \end_inset
1149
1150
1151 \newline
1152 \InsetSpace ~
1153 \InsetSpace ~
1154 b = !b; /* toggles b */
1155 \newline
1156
1157 \family default
1158 In previous versions, both forms would have toggled the bit.
1159 \end_layout
1160
1161 \begin_layout Itemize
1162 in older versions, the preprocessor was always called with -std=c99 regardless
1163  of the --std-xxx setting.
1164  This is no longer true, and can cause compilation failures on code built
1165  with --std-c89 but using c99 preprocessor features, such as one-line (//)
1166  comments
1167 \end_layout
1168
1169 \begin_layout Itemize
1170 in versions older then 2.8.4 the pic16 *printf() and printf_tiny() library
1171  functions supported undocumented and not standard compliant 'b' binary
1172  format specifier ("%b", "%hb" and "%lb").
1173  The 'b' specifier is now disabled by default.
1174  It can be enabled by defining BINARY_SPECIFIER macro in files device/lib/pic16/
1175 libc/stdio/vfprintf.c and device/lib/pic16/libc/stdio/printf_tiny.c and recompilin
1176 g the library.
1177 \end_layout
1178
1179 \begin_layout Itemize
1180 in versions older then 2.8.5 the unnamed bitfield structure members participated
1181  in initialization, which is not conforming with ISO/IEC 9899:1999 standard
1182  (see section Section 6.7.8 Initialization, clause 9)
1183 \newline
1184
1185 \newline
1186 Old behaviour, before
1187  version 2.8.5:
1188 \family typewriter
1189
1190 \newline
1191 \InsetSpace ~
1192 \InsetSpace ~
1193 struct {
1194 \newline
1195 \InsetSpace ~
1196 \InsetSpace ~
1197 \InsetSpace ~
1198 \InsetSpace ~
1199 int a : 2;
1200 \newline
1201 \InsetSpace ~
1202 \InsetSpace ~
1203 \InsetSpace ~
1204 \InsetSpace ~
1205 char\InsetSpace ~
1206  : 2;
1207 \newline
1208 \InsetSpace ~
1209 \InsetSpace ~
1210 \InsetSpace ~
1211 \InsetSpace ~
1212 int b : 2;
1213 \newline
1214 \InsetSpace ~
1215 \InsetSpace ~
1216 } s = {1, 2, 3};
1217 \family default
1218
1219 \newline
1220
1221 \family typewriter
1222 /* s.a = 1, s.b = 3 */
1223 \family default
1224
1225 \newline
1226
1227 \newline
1228 New behaviour:
1229 \family typewriter
1230
1231 \newline
1232 \InsetSpace ~
1233 \InsetSpace ~
1234 struct {
1235 \newline
1236 \InsetSpace ~
1237 \InsetSpace ~
1238 \InsetSpace ~
1239 \InsetSpace ~
1240 int a : 2;
1241 \newline
1242 \InsetSpace ~
1243 \InsetSpace ~
1244 \InsetSpace ~
1245 \InsetSpace ~
1246 char\InsetSpace ~
1247  : 2;
1248 \newline
1249 \InsetSpace ~
1250 \InsetSpace ~
1251 \InsetSpace ~
1252 \InsetSpace ~
1253 int b : 2;
1254 \newline
1255 \InsetSpace ~
1256 \InsetSpace ~
1257 } s = {1, 2};
1258 \family default
1259
1260 \newline
1261
1262 \family typewriter
1263 /* s.a = 1, s.b = 2 */
1264 \end_layout
1265
1266 \begin_layout Section
1267 System Requirements
1268 \end_layout
1269
1270 \begin_layout Standard
1271 What do you need before you start installation of SDCC? A computer, and
1272  a desire to compute.
1273  The preferred method of installation is to compile SDCC from source using
1274  GNU gcc and make.
1275  For Windows some pre-compiled binary distributions are available for your
1276  convenience.
1277  You should have some experience with command line tools and compiler use.
1278 \end_layout
1279
1280 \begin_layout Section
1281 Other Resources
1282 \end_layout
1283
1284 \begin_layout Standard
1285 The SDCC home page at 
1286 \begin_inset LatexCommand \url{http://sdcc.sourceforge.net/}
1287
1288 \end_inset
1289
1290  is a great place to find distribution sets.
1291  You can also find links to the user mailing lists that offer help or discuss
1292  SDCC with other SDCC users.
1293  Web links to other SDCC related sites can also be found here.
1294  This document can be found in the DOC directory of the source package as
1295  a text or HTML file.
1296  A pdf version of this document is available at 
1297 \begin_inset LatexCommand \url{http://sdcc.sourceforge.net/doc/sdccman.pdf}
1298
1299 \end_inset
1300
1301 .
1302  Some of the other tools (simulator and assembler) included with SDCC contain
1303  their own documentation and can be found in the source distribution.
1304  If you want the latest unreleased software, the complete source package
1305  is available directly from Subversion on https://sdcc.svn.sourceforge.net/svnroot/
1306 sdcc/trunk/sdcc.
1307 \end_layout
1308
1309 \begin_layout Section
1310 Wishes for the future
1311 \end_layout
1312
1313 \begin_layout Standard
1314 There are (and always will be) some things that could be done.
1315  Here are some I can think of:
1316 \newline
1317
1318 \end_layout
1319
1320 \begin_layout Standard
1321
1322 \family typewriter
1323 char KernelFunction3(char p) at 0x340;
1324 \newline
1325
1326 \end_layout
1327
1328 \begin_layout Standard
1329
1330 \family typewriter
1331 better code banking
1332 \begin_inset LatexCommand \index{code banking (limited support)}
1333
1334 \end_inset
1335
1336  support for mcs51
1337 \newline
1338
1339 \newline
1340
1341 \family default
1342 If you can think of some more, please see the section 
1343 \begin_inset LatexCommand \ref{sub:Requesting-Features}
1344
1345 \end_inset
1346
1347  about filing feature requests
1348 \begin_inset LatexCommand \index{Requesting features}
1349
1350 \end_inset
1351
1352
1353 \begin_inset LatexCommand \index{Feature request}
1354
1355 \end_inset
1356
1357 .
1358 \newline
1359
1360 \end_layout
1361
1362 \begin_layout Chapter
1363 Installing SDCC
1364 \begin_inset LatexCommand \index{Installation}
1365
1366 \end_inset
1367
1368
1369 \end_layout
1370
1371 \begin_layout Standard
1372 For most users it is sufficient to skip to either section 
1373 \begin_inset LatexCommand \ref{sub:Building-SDCC-on-Linux}
1374
1375 \end_inset
1376
1377  (Unix) or section 
1378 \begin_inset LatexCommand \ref{sub:Windows-Install}
1379
1380 \end_inset
1381
1382  (Windows).
1383  More detailed instructions follow below.
1384 \end_layout
1385
1386 \begin_layout Section
1387 Configure Options
1388 \begin_inset LatexCommand \index{Options SDCC configuration}
1389
1390 \end_inset
1391
1392
1393 \end_layout
1394
1395 \begin_layout Standard
1396 The install paths, search paths and other options are defined when running
1397  'configure'.
1398  The defaults can be overridden by:
1399 \end_layout
1400
1401 \begin_layout List
1402 \labelwidthstring 00.00.0000
1403 -
1404 \begin_inset ERT
1405 status collapsed
1406
1407 \begin_layout Standard
1408
1409
1410 \backslash
1411 /
1412 \end_layout
1413
1414 \end_inset
1415
1416 -prefix see table below
1417 \end_layout
1418
1419 \begin_layout List
1420 \labelwidthstring 00.00.0000
1421 -
1422 \begin_inset ERT
1423 status collapsed
1424
1425 \begin_layout Standard
1426
1427
1428 \backslash
1429 /
1430 \end_layout
1431
1432 \end_inset
1433
1434 -exec_prefix see table below
1435 \end_layout
1436
1437 \begin_layout List
1438 \labelwidthstring 00.00.0000
1439 -
1440 \begin_inset ERT
1441 status collapsed
1442
1443 \begin_layout Standard
1444
1445
1446 \backslash
1447 /
1448 \end_layout
1449
1450 \end_inset
1451
1452 -bindir see table below
1453 \end_layout
1454
1455 \begin_layout List
1456 \labelwidthstring 00.00.0000
1457 -
1458 \begin_inset ERT
1459 status collapsed
1460
1461 \begin_layout Standard
1462
1463
1464 \backslash
1465 /
1466 \end_layout
1467
1468 \end_inset
1469
1470 -datadir see table below
1471 \end_layout
1472
1473 \begin_layout List
1474 \labelwidthstring 00.00.0000
1475 -
1476 \begin_inset ERT
1477 status collapsed
1478
1479 \begin_layout Standard
1480
1481
1482 \backslash
1483 /
1484 \end_layout
1485
1486 \end_inset
1487
1488 -datarootdir see table below
1489 \newline
1490
1491 \end_layout
1492
1493 \begin_layout List
1494 \labelwidthstring 00.00.0000
1495 \InsetSpace ~
1496 \InsetSpace ~
1497 docdir environment variable, see table below
1498 \end_layout
1499
1500 \begin_layout List
1501 \labelwidthstring 00.00.0000
1502 \InsetSpace ~
1503 \InsetSpace ~
1504 include_dir_suffix environment variable, see table below
1505 \end_layout
1506
1507 \begin_layout List
1508 \labelwidthstring 00.00.0000
1509 \InsetSpace ~
1510 \InsetSpace ~
1511 lib_dir_suffix environment variable, see table below
1512 \end_layout
1513
1514 \begin_layout List
1515 \labelwidthstring 00.00.0000
1516 \InsetSpace ~
1517 \InsetSpace ~
1518 sdccconf_h_dir_separator environment variable, either / or 
1519 \backslash
1520
1521 \backslash
1522  makes sense here.
1523  This character will only be used in sdccconf.h; don't forget it's a C-header,
1524  therefore a double-backslash is needed there.
1525 \newline
1526
1527 \end_layout
1528
1529 \begin_layout List
1530 \labelwidthstring 00.00.0000
1531 -
1532 \begin_inset ERT
1533 status collapsed
1534
1535 \begin_layout Standard
1536
1537
1538 \backslash
1539 /
1540 \end_layout
1541
1542 \end_inset
1543
1544 -disable-mcs51-port Excludes the Intel mcs51 port
1545 \end_layout
1546
1547 \begin_layout List
1548 \labelwidthstring 00.00.0000
1549 -
1550 \begin_inset ERT
1551 status collapsed
1552
1553 \begin_layout Standard
1554
1555
1556 \backslash
1557 /
1558 \end_layout
1559
1560 \end_inset
1561
1562 -disable-gbz80-port Excludes the Gameboy gbz80 port
1563 \end_layout
1564
1565 \begin_layout List
1566 \labelwidthstring 00.00.0000
1567 -
1568 \begin_inset ERT
1569 status collapsed
1570
1571 \begin_layout Standard
1572
1573
1574 \backslash
1575 /
1576 \end_layout
1577
1578 \end_inset
1579
1580 -disable-z80-port Excludes the z80 port
1581 \end_layout
1582
1583 \begin_layout List
1584 \labelwidthstring 00.00.0000
1585 -
1586 \begin_inset ERT
1587 status collapsed
1588
1589 \begin_layout Standard
1590
1591
1592 \backslash
1593 /
1594 \end_layout
1595
1596 \end_inset
1597
1598 -disable-avr-port Excludes the AVR port
1599 \end_layout
1600
1601 \begin_layout List
1602 \labelwidthstring 00.00.0000
1603 -
1604 \begin_inset ERT
1605 status collapsed
1606
1607 \begin_layout Standard
1608
1609
1610 \backslash
1611 /
1612 \end_layout
1613
1614 \end_inset
1615
1616 -disable-ds390-port Excludes the DS390 port
1617 \end_layout
1618
1619 \begin_layout List
1620 \labelwidthstring 00.00.0000
1621 -
1622 \begin_inset ERT
1623 status collapsed
1624
1625 \begin_layout Standard
1626
1627
1628 \backslash
1629 /
1630 \end_layout
1631
1632 \end_inset
1633
1634 -disable-hc08-port Excludes the HC08 port
1635 \end_layout
1636
1637 \begin_layout List
1638 \labelwidthstring 00.00.0000
1639 -
1640 \begin_inset ERT
1641 status collapsed
1642
1643 \begin_layout Standard
1644
1645
1646 \backslash
1647 /
1648 \end_layout
1649
1650 \end_inset
1651
1652 -disable-pic-port Excludes the PIC14 port
1653 \end_layout
1654
1655 \begin_layout List
1656 \labelwidthstring 00.00.0000
1657 -
1658 \begin_inset ERT
1659 status collapsed
1660
1661 \begin_layout Standard
1662
1663
1664 \backslash
1665 /
1666 \end_layout
1667
1668 \end_inset
1669
1670 -disable-pic16-port Excludes the PIC16 port
1671 \end_layout
1672
1673 \begin_layout List
1674 \labelwidthstring 00.00.0000
1675 -
1676 \begin_inset ERT
1677 status collapsed
1678
1679 \begin_layout Standard
1680
1681
1682 \backslash
1683 /
1684 \end_layout
1685
1686 \end_inset
1687
1688 -disable-xa51-port Excludes the XA51 port
1689 \end_layout
1690
1691 \begin_layout List
1692 \labelwidthstring 00.00.0000
1693 -
1694 \begin_inset ERT
1695 status collapsed
1696
1697 \begin_layout Standard
1698
1699
1700 \backslash
1701 /
1702 \end_layout
1703
1704 \end_inset
1705
1706 -disable-ucsim Disables configuring and building of ucsim
1707 \end_layout
1708
1709 \begin_layout List
1710 \labelwidthstring 00.00.0000
1711 -
1712 \begin_inset ERT
1713 status collapsed
1714
1715 \begin_layout Standard
1716
1717
1718 \backslash
1719 /
1720 \end_layout
1721
1722 \end_inset
1723
1724 -disable-device-lib Disables automatically building device libraries
1725 \end_layout
1726
1727 \begin_layout List
1728 \labelwidthstring 00.00.0000
1729 -
1730 \begin_inset ERT
1731 status collapsed
1732
1733 \begin_layout Standard
1734
1735
1736 \backslash
1737 /
1738 \end_layout
1739
1740 \end_inset
1741
1742 -disable-packihx Disables building packihx
1743 \newline
1744
1745 \end_layout
1746
1747 \begin_layout List
1748 \labelwidthstring 00.00.0000
1749 -
1750 \begin_inset ERT
1751 status collapsed
1752
1753 \begin_layout Standard
1754
1755
1756 \backslash
1757 /
1758 \end_layout
1759
1760 \end_inset
1761
1762 -enable-doc Build pdf, html and txt files from the lyx sources
1763 \end_layout
1764
1765 \begin_layout List
1766 \labelwidthstring 00.00.0000
1767 -
1768 \begin_inset ERT
1769 status collapsed
1770
1771 \begin_layout Standard
1772
1773
1774 \backslash
1775 /
1776 \end_layout
1777
1778 \end_inset
1779
1780 -enable-libgc Use the Bohem memory allocator.
1781  Lower runtime footprint.
1782 \end_layout
1783
1784 \begin_layout List
1785 \labelwidthstring 00.00.0000
1786 -
1787 \begin_inset ERT
1788 status collapsed
1789
1790 \begin_layout Standard
1791
1792
1793 \backslash
1794 /
1795 \end_layout
1796
1797 \end_inset
1798
1799 -without-ccache Do not use ccache even if available
1800 \end_layout
1801
1802 \begin_layout Standard
1803 Furthermore the environment variables CC, CFLAGS, ...
1804  the tools and their arguments can be influenced.
1805  Please see `configure -
1806 \begin_inset ERT
1807 status collapsed
1808
1809 \begin_layout Standard
1810
1811
1812 \backslash
1813 /
1814 \end_layout
1815
1816 \end_inset
1817
1818 -help' and the man/info pages of `configure' for details.
1819 \newline
1820
1821 \newline
1822 The names of the
1823  standard libraries STD_LIB, STD_INT_LIB, STD_LONG_LIB, STD_FP_LIB, STD_DS390_LI
1824 B, STD_XA51_LIB and the environment variables SDCC_DIR_NAME, SDCC_INCLUDE_NAME,
1825  SDCC_LIB_NAME are defined by `configure' too.
1826  At the moment it's not possible to change the default settings (it was
1827  simply never required).
1828 \newline
1829
1830 \newline
1831 These configure options are compiled into the binaries,
1832  and can only be changed by rerunning 'configure' and recompiling SDCC.
1833  The configure options are written in 
1834 \emph on
1835 italics
1836 \emph default
1837  to distinguish them from run time environment variables (see section search
1838  paths).
1839 \newline
1840
1841 \newline
1842 The settings for 
1843 \begin_inset Quotes sld
1844 \end_inset
1845
1846 Win32 builds
1847 \begin_inset Quotes srd
1848 \end_inset
1849
1850  are used by the SDCC team to build the official Win32 binaries.
1851  The SDCC team uses Mingw32 to build the official Windows binaries, because
1852  it's
1853 \end_layout
1854
1855 \begin_layout Enumerate
1856 open source, 
1857 \end_layout
1858
1859 \begin_layout Enumerate
1860 a gcc compiler and last but not least
1861 \end_layout
1862
1863 \begin_layout Enumerate
1864 the binaries can be built by cross compiling on SDCC Distributed Compile
1865  Farm.
1866 \end_layout
1867
1868 \begin_layout Standard
1869 See the examples, how to pass the Win32 settings to 'configure'.
1870  The other Win32 builds using Borland, VC or whatever don't use 'configure',
1871  but a header file sdcc_vc_in.h is the same as sdccconf.h built by 'configure'
1872  for Win32.
1873 \newline
1874
1875 \newline
1876 These defaults are:
1877 \newline
1878
1879 \end_layout
1880
1881 \begin_layout Standard
1882 \align center
1883 \begin_inset Tabular
1884 <lyxtabular version="3" rows="9" columns="3">
1885 <features>
1886 <column alignment="block" valignment="top" leftline="true" width="0in">
1887 <column alignment="block" valignment="top" leftline="true" width="0in">
1888 <column alignment="block" valignment="top" leftline="true" rightline="true" width="0in">
1889 <row topline="true" bottomline="true">
1890 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1891 \begin_inset Text
1892
1893 \begin_layout Standard
1894 Variable
1895 \end_layout
1896
1897 \end_inset
1898 </cell>
1899 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1900 \begin_inset Text
1901
1902 \begin_layout Standard
1903 default
1904 \end_layout
1905
1906 \end_inset
1907 </cell>
1908 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1909 \begin_inset Text
1910
1911 \begin_layout Standard
1912 Win32 builds
1913 \end_layout
1914
1915 \end_inset
1916 </cell>
1917 </row>
1918 <row topline="true">
1919 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1920 \begin_inset Text
1921
1922 \begin_layout Standard
1923
1924 \emph on
1925 PREFIX
1926 \end_layout
1927
1928 \end_inset
1929 </cell>
1930 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1931 \begin_inset Text
1932
1933 \begin_layout Standard
1934 /usr/local
1935 \end_layout
1936
1937 \end_inset
1938 </cell>
1939 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1940 \begin_inset Text
1941
1942 \begin_layout Standard
1943
1944 \backslash
1945 sdcc
1946 \end_layout
1947
1948 \end_inset
1949 </cell>
1950 </row>
1951 <row topline="true">
1952 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1953 \begin_inset Text
1954
1955 \begin_layout Standard
1956
1957 \emph on
1958 EXEC_PREFIX
1959 \end_layout
1960
1961 \end_inset
1962 </cell>
1963 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1964 \begin_inset Text
1965
1966 \begin_layout Standard
1967
1968 \emph on
1969 $PREFIX
1970 \end_layout
1971
1972 \end_inset
1973 </cell>
1974 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1975 \begin_inset Text
1976
1977 \begin_layout Standard
1978
1979 \emph on
1980 $PREFIX
1981 \end_layout
1982
1983 \end_inset
1984 </cell>
1985 </row>
1986 <row topline="true">
1987 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1988 \begin_inset Text
1989
1990 \begin_layout Standard
1991
1992 \emph on
1993 BINDIR
1994 \end_layout
1995
1996 \end_inset
1997 </cell>
1998 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1999 \begin_inset Text
2000
2001 \begin_layout Standard
2002
2003 \emph on
2004 $EXEC_PREFIX
2005 \emph default
2006 /bin
2007 \end_layout
2008
2009 \end_inset
2010 </cell>
2011 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2012 \begin_inset Text
2013
2014 \begin_layout Standard
2015
2016 \emph on
2017 $EXEC_PREFIX
2018 \emph default
2019
2020 \backslash
2021 bin
2022 \end_layout
2023
2024 \end_inset
2025 </cell>
2026 </row>
2027 <row topline="true">
2028 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2029 \begin_inset Text
2030
2031 \begin_layout Standard
2032
2033 \emph on
2034 DATADIR
2035 \end_layout
2036
2037 \end_inset
2038 </cell>
2039 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2040 \begin_inset Text
2041
2042 \begin_layout Standard
2043
2044 \emph on
2045 $DATAROOTDIR
2046 \end_layout
2047
2048 \end_inset
2049 </cell>
2050 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2051 \begin_inset Text
2052
2053 \begin_layout Standard
2054
2055 \emph on
2056 $DATAROOTDIR
2057 \end_layout
2058
2059 \end_inset
2060 </cell>
2061 </row>
2062 <row topline="true">
2063 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2064 \begin_inset Text
2065
2066 \begin_layout Standard
2067
2068 \emph on
2069 DATAROOTDIR
2070 \end_layout
2071
2072 \end_inset
2073 </cell>
2074 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2075 \begin_inset Text
2076
2077 \begin_layout Standard
2078
2079 \emph on
2080 $PREFIX
2081 \emph default
2082 /share
2083 \end_layout
2084
2085 \end_inset
2086 </cell>
2087 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2088 \begin_inset Text
2089
2090 \begin_layout Standard
2091
2092 \emph on
2093 $PREFIX
2094 \end_layout
2095
2096 \end_inset
2097 </cell>
2098 </row>
2099 <row topline="true">
2100 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2101 \begin_inset Text
2102
2103 \begin_layout Standard
2104
2105 \emph on
2106 DOCDIR
2107 \end_layout
2108
2109 \end_inset
2110 </cell>
2111 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2112 \begin_inset Text
2113
2114 \begin_layout Standard
2115
2116 \emph on
2117 $DATAROOTDIR
2118 \emph default
2119 /sdcc/doc
2120 \end_layout
2121
2122 \end_inset
2123 </cell>
2124 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2125 \begin_inset Text
2126
2127 \begin_layout Standard
2128
2129 \emph on
2130 $DATAROOTDIR
2131 \emph default
2132
2133 \backslash
2134 doc
2135 \end_layout
2136
2137 \end_inset
2138 </cell>
2139 </row>
2140 <row topline="true">
2141 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2142 \begin_inset Text
2143
2144 \begin_layout Standard
2145
2146 \emph on
2147 INCLUDE_DIR_SUFFIX
2148 \end_layout
2149
2150 \end_inset
2151 </cell>
2152 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2153 \begin_inset Text
2154
2155 \begin_layout Standard
2156 sdcc/include
2157 \end_layout
2158
2159 \end_inset
2160 </cell>
2161 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2162 \begin_inset Text
2163
2164 \begin_layout Standard
2165 include
2166 \end_layout
2167
2168 \end_inset
2169 </cell>
2170 </row>
2171 <row topline="true" bottomline="true">
2172 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2173 \begin_inset Text
2174
2175 \begin_layout Standard
2176
2177 \emph on
2178 LIB_DIR_SUFFIX
2179 \end_layout
2180
2181 \end_inset
2182 </cell>
2183 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2184 \begin_inset Text
2185
2186 \begin_layout Standard
2187 sdcc/lib
2188 \end_layout
2189
2190 \end_inset
2191 </cell>
2192 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2193 \begin_inset Text
2194
2195 \begin_layout Standard
2196 lib
2197 \end_layout
2198
2199 \end_inset
2200 </cell>
2201 </row>
2202 </lyxtabular>
2203
2204 \end_inset
2205
2206
2207 \newline
2208
2209 \end_layout
2210
2211 \begin_layout Standard
2212 \noindent
2213 'configure' also computes relative paths.
2214  This is needed for full relocatability of a binary package and to complete
2215  search paths (see section search paths below):
2216 \newline
2217  
2218 \end_layout
2219
2220 \begin_layout Standard
2221 \align center
2222 \begin_inset Tabular
2223 <lyxtabular version="3" rows="4" columns="3">
2224 <features>
2225 <column alignment="block" valignment="top" leftline="true" width="0in">
2226 <column alignment="block" valignment="top" leftline="true" width="0in">
2227 <column alignment="block" valignment="top" leftline="true" rightline="true" width="0in">
2228 <row topline="true" bottomline="true">
2229 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2230 \begin_inset Text
2231
2232 \begin_layout Standard
2233 Variable (computed)
2234 \end_layout
2235
2236 \end_inset
2237 </cell>
2238 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2239 \begin_inset Text
2240
2241 \begin_layout Standard
2242 default
2243 \end_layout
2244
2245 \end_inset
2246 </cell>
2247 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2248 \begin_inset Text
2249
2250 \begin_layout Standard
2251 Win32 builds
2252 \end_layout
2253
2254 \end_inset
2255 </cell>
2256 </row>
2257 <row topline="true" bottomline="true">
2258 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2259 \begin_inset Text
2260
2261 \begin_layout Standard
2262
2263 \emph on
2264 BIN2DATA_DIR
2265 \end_layout
2266
2267 \end_inset
2268 </cell>
2269 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2270 \begin_inset Text
2271
2272 \begin_layout Standard
2273 ../share
2274 \end_layout
2275
2276 \end_inset
2277 </cell>
2278 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2279 \begin_inset Text
2280
2281 \begin_layout Standard
2282 ..
2283 \end_layout
2284
2285 \end_inset
2286 </cell>
2287 </row>
2288 <row bottomline="true">
2289 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2290 \begin_inset Text
2291
2292 \begin_layout Standard
2293
2294 \emph on
2295 PREFIX2BIN_DIR
2296 \end_layout
2297
2298 \end_inset
2299 </cell>
2300 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2301 \begin_inset Text
2302
2303 \begin_layout Standard
2304 bin
2305 \end_layout
2306
2307 \end_inset
2308 </cell>
2309 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2310 \begin_inset Text
2311
2312 \begin_layout Standard
2313 bin
2314 \end_layout
2315
2316 \end_inset
2317 </cell>
2318 </row>
2319 <row bottomline="true">
2320 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2321 \begin_inset Text
2322
2323 \begin_layout Standard
2324
2325 \emph on
2326 PREFIX2DATA_DIR
2327 \end_layout
2328
2329 \end_inset
2330 </cell>
2331 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2332 \begin_inset Text
2333
2334 \begin_layout Standard
2335 share/sdcc
2336 \end_layout
2337
2338 \end_inset
2339 </cell>
2340 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2341 \begin_inset Text
2342
2343 \begin_layout Standard
2344
2345 \end_layout
2346
2347 \end_inset
2348 </cell>
2349 </row>
2350 </lyxtabular>
2351
2352 \end_inset
2353
2354
2355 \newline
2356
2357 \end_layout
2358
2359 \begin_layout Standard
2360 \noindent
2361 Examples:
2362 \end_layout
2363
2364 \begin_layout LyX-Code
2365 ./configure
2366 \newline
2367 ./configure -
2368 \begin_inset ERT
2369 status collapsed
2370
2371 \begin_layout Standard
2372
2373
2374 \backslash
2375 /
2376 \end_layout
2377
2378 \end_inset
2379
2380 -prefix=
2381 \begin_inset Quotes srd
2382 \end_inset
2383
2384 /usr/bin
2385 \begin_inset Quotes srd
2386 \end_inset
2387
2388  -
2389 \begin_inset ERT
2390 status collapsed
2391
2392 \begin_layout Standard
2393
2394
2395 \backslash
2396 /
2397 \end_layout
2398
2399 \end_inset
2400
2401 -datarootdir=
2402 \begin_inset Quotes srd
2403 \end_inset
2404
2405 /usr/share
2406 \begin_inset Quotes srd
2407 \end_inset
2408
2409
2410 \newline
2411 ./configure -
2412 \begin_inset ERT
2413 status collapsed
2414
2415 \begin_layout Standard
2416
2417
2418 \backslash
2419 /
2420 \end_layout
2421
2422 \end_inset
2423
2424 -disable-avr-port -
2425 \begin_inset ERT
2426 status collapsed
2427
2428 \begin_layout Standard
2429
2430
2431 \backslash
2432 /
2433 \end_layout
2434
2435 \end_inset
2436
2437 -disable-xa51-port
2438 \end_layout
2439
2440 \begin_layout Standard
2441 To cross compile on linux for Mingw32 (see also 'sdcc/support/scripts/sdcc_mingw
2442 32'):
2443 \end_layout
2444
2445 \begin_layout LyX-Code
2446 ./configure 
2447 \backslash
2448
2449 \newline
2450 CC=
2451 \begin_inset Quotes srd
2452 \end_inset
2453
2454 i586-mingw32msvc-gcc
2455 \begin_inset Quotes srd
2456 \end_inset
2457
2458  CXX=
2459 \begin_inset Quotes srd
2460 \end_inset
2461
2462 i586-mingw32msvc-g++
2463 \begin_inset Quotes srd
2464 \end_inset
2465
2466  
2467 \backslash
2468  
2469 \newline
2470 RANLIB=
2471 \begin_inset Quotes srd
2472 \end_inset
2473
2474 i586-mingw32msvc-ranlib
2475 \begin_inset Quotes srd
2476 \end_inset
2477
2478  
2479 \backslash
2480
2481 \newline
2482 STRIP=
2483 \begin_inset Quotes srd
2484 \end_inset
2485
2486 i586-mingw32msvc-strip
2487 \begin_inset Quotes srd
2488 \end_inset
2489
2490  
2491 \backslash
2492
2493 \newline
2494 -
2495 \begin_inset ERT
2496 status collapsed
2497
2498 \begin_layout Standard
2499
2500
2501 \backslash
2502 /
2503 \end_layout
2504
2505 \end_inset
2506
2507 -prefix=
2508 \begin_inset Quotes srd
2509 \end_inset
2510
2511 /sdcc
2512 \begin_inset Quotes srd
2513 \end_inset
2514
2515  
2516 \backslash
2517
2518 \newline
2519 -
2520 \begin_inset ERT
2521 status collapsed
2522
2523 \begin_layout Standard
2524
2525
2526 \backslash
2527 /
2528 \end_layout
2529
2530 \end_inset
2531
2532 -datarootdir=
2533 \begin_inset Quotes srd
2534 \end_inset
2535
2536 /sdcc
2537 \begin_inset Quotes srd
2538 \end_inset
2539
2540  
2541 \backslash
2542
2543 \newline
2544 docdir=
2545 \begin_inset Quotes srd
2546 \end_inset
2547
2548
2549 \backslash
2550 ${datarootdir}/doc
2551 \begin_inset Quotes srd
2552 \end_inset
2553
2554  
2555 \backslash
2556
2557 \newline
2558 include_dir_suffix=
2559 \begin_inset Quotes srd
2560 \end_inset
2561
2562 include
2563 \begin_inset Quotes srd
2564 \end_inset
2565
2566  
2567 \backslash
2568
2569 \newline
2570 lib_dir_suffix=
2571 \begin_inset Quotes srd
2572 \end_inset
2573
2574 lib
2575 \begin_inset Quotes srd
2576 \end_inset
2577
2578  
2579 \backslash
2580
2581 \newline
2582 sdccconf_h_dir_separator=
2583 \begin_inset Quotes srd
2584 \end_inset
2585
2586
2587 \backslash
2588
2589 \backslash
2590
2591 \backslash
2592
2593 \backslash
2594
2595 \begin_inset Quotes srd
2596 \end_inset
2597
2598  
2599 \backslash
2600
2601 \newline
2602 -
2603 \begin_inset ERT
2604 status collapsed
2605
2606 \begin_layout Standard
2607
2608
2609 \backslash
2610 /
2611 \end_layout
2612
2613 \end_inset
2614
2615 -disable-device-lib
2616 \backslash
2617
2618 \newline
2619 -
2620 \begin_inset ERT
2621 status collapsed
2622
2623 \begin_layout Standard
2624
2625
2626 \backslash
2627 /
2628 \end_layout
2629
2630 \end_inset
2631
2632 -host=i586-mingw32msvc
2633 \backslash
2634
2635 \newline
2636 -
2637 \begin_inset ERT
2638 status collapsed
2639
2640 \begin_layout Standard
2641
2642
2643 \backslash
2644 /
2645 \end_layout
2646
2647 \end_inset
2648
2649 -build=unknown-unknown-linux-gnu
2650 \end_layout
2651
2652 \begin_layout Standard
2653 To 
2654 \begin_inset Quotes sld
2655 \end_inset
2656
2657 cross
2658 \begin_inset Quotes srd
2659 \end_inset
2660
2661 compile on Cygwin for Mingw32 (see also sdcc/support/scripts/sdcc_cygwin_mingw32
2662 ):
2663 \end_layout
2664
2665 \begin_layout LyX-Code
2666 ./configure -C 
2667 \backslash
2668
2669 \newline
2670 -
2671 \begin_inset ERT
2672 status collapsed
2673
2674 \begin_layout Standard
2675
2676
2677 \backslash
2678 /
2679 \end_layout
2680
2681 \end_inset
2682
2683 -prefix=
2684 \begin_inset Quotes srd
2685 \end_inset
2686
2687 /sdcc
2688 \begin_inset Quotes srd
2689 \end_inset
2690
2691  
2692 \backslash
2693
2694 \newline
2695 -
2696 \begin_inset ERT
2697 status collapsed
2698
2699 \begin_layout Standard
2700
2701
2702 \backslash
2703 /
2704 \end_layout
2705
2706 \end_inset
2707
2708 -datarootdir=
2709 \begin_inset Quotes srd
2710 \end_inset
2711
2712 /sdcc
2713 \begin_inset Quotes srd
2714 \end_inset
2715
2716  
2717 \backslash
2718
2719 \newline
2720 docdir=
2721 \begin_inset Quotes srd
2722 \end_inset
2723
2724
2725 \backslash
2726 ${datarootdir}/doc
2727 \begin_inset Quotes srd
2728 \end_inset
2729
2730  
2731 \backslash
2732  
2733 \newline
2734 include_dir_suffix=
2735 \begin_inset Quotes srd
2736 \end_inset
2737
2738 include
2739 \begin_inset Quotes srd
2740 \end_inset
2741
2742  
2743 \backslash
2744
2745 \newline
2746 lib_dir_suffix=
2747 \begin_inset Quotes srd
2748 \end_inset
2749
2750 lib
2751 \begin_inset Quotes srd
2752 \end_inset
2753
2754  
2755 \backslash
2756
2757 \newline
2758 sdccconf_h_dir_separator=
2759 \begin_inset Quotes srd
2760 \end_inset
2761
2762
2763 \backslash
2764
2765 \backslash
2766
2767 \backslash
2768
2769 \backslash
2770
2771 \begin_inset Quotes srd
2772 \end_inset
2773
2774  
2775 \backslash
2776
2777 \newline
2778 CC=
2779 \begin_inset Quotes srd
2780 \end_inset
2781
2782 gcc -mno-cygwin
2783 \begin_inset Quotes srd
2784 \end_inset
2785
2786  
2787 \backslash
2788
2789 \newline
2790 CXX=
2791 \begin_inset Quotes srd
2792 \end_inset
2793
2794 g++ -mno-cygwin
2795 \begin_inset Quotes srd
2796 \end_inset
2797
2798  
2799 \end_layout
2800
2801 \begin_layout Standard
2802 'configure' is quite slow on Cygwin (at least on windows before Win2000/XP).
2803  The option '-
2804 \begin_inset ERT
2805 status collapsed
2806
2807 \begin_layout Standard
2808
2809
2810 \backslash
2811 /
2812 \end_layout
2813
2814 \end_inset
2815
2816 -C' turns on caching, which gives a little bit extra speed.
2817  However if options are changed, it can be necessary to delete the config.cache
2818  file.
2819 \end_layout
2820
2821 \begin_layout Section
2822 Install paths
2823 \begin_inset LatexCommand \label{sub:Install-paths}
2824
2825 \end_inset
2826
2827
2828 \begin_inset LatexCommand \index{Install paths}
2829
2830 \end_inset
2831
2832
2833 \end_layout
2834
2835 \begin_layout Standard
2836 \begin_inset VSpace medskip
2837 \end_inset
2838
2839
2840 \end_layout
2841
2842 \begin_layout Standard
2843 \align center
2844 \begin_inset Tabular
2845 <lyxtabular version="3" rows="5" columns="4">
2846 <features>
2847 <column alignment="left" valignment="top" leftline="true" width="0">
2848 <column alignment="left" valignment="top" leftline="true" width="0">
2849 <column alignment="left" valignment="top" leftline="true" width="0">
2850 <column alignment="left" valignment="top" leftline="true" rightline="true" width="0">
2851 <row topline="true" bottomline="true">
2852 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2853 \begin_inset Text
2854
2855 \begin_layout Standard
2856
2857 \series bold
2858 Description
2859 \end_layout
2860
2861 \end_inset
2862 </cell>
2863 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2864 \begin_inset Text
2865
2866 \begin_layout Standard
2867
2868 \series bold
2869 Path
2870 \end_layout
2871
2872 \end_inset
2873 </cell>
2874 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2875 \begin_inset Text
2876
2877 \begin_layout Standard
2878
2879 \series bold
2880 Default
2881 \end_layout
2882
2883 \end_inset
2884 </cell>
2885 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2886 \begin_inset Text
2887
2888 \begin_layout Standard
2889
2890 \series bold
2891 Win32 builds
2892 \end_layout
2893
2894 \end_inset
2895 </cell>
2896 </row>
2897 <row topline="true">
2898 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2899 \begin_inset Text
2900
2901 \begin_layout Standard
2902 Binary files*
2903 \end_layout
2904
2905 \end_inset
2906 </cell>
2907 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2908 \begin_inset Text
2909
2910 \begin_layout Standard
2911
2912 \emph on
2913 $EXEC_PREFIX
2914 \end_layout
2915
2916 \end_inset
2917 </cell>
2918 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2919 \begin_inset Text
2920
2921 \begin_layout Standard
2922 /usr/local/bin
2923 \end_layout
2924
2925 \end_inset
2926 </cell>
2927 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2928 \begin_inset Text
2929
2930 \begin_layout Standard
2931
2932 \backslash
2933 sdcc
2934 \backslash
2935 bin
2936 \end_layout
2937
2938 \end_inset
2939 </cell>
2940 </row>
2941 <row topline="true">
2942 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2943 \begin_inset Text
2944
2945 \begin_layout Standard
2946 Include files
2947 \end_layout
2948
2949 \end_inset
2950 </cell>
2951 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2952 \begin_inset Text
2953
2954 \begin_layout Standard
2955
2956 \emph on
2957 $DATADIR/ $INCLUDE_DIR_SUFFIX
2958 \end_layout
2959
2960 \end_inset
2961 </cell>
2962 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2963 \begin_inset Text
2964
2965 \begin_layout Standard
2966 /usr/local/share/sdcc/include
2967 \end_layout
2968
2969 \end_inset
2970 </cell>
2971 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2972 \begin_inset Text
2973
2974 \begin_layout Standard
2975
2976 \backslash
2977 sdcc
2978 \backslash
2979 include
2980 \end_layout
2981
2982 \end_inset
2983 </cell>
2984 </row>
2985 <row topline="true">
2986 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2987 \begin_inset Text
2988
2989 \begin_layout Standard
2990 Library file**
2991 \end_layout
2992
2993 \end_inset
2994 </cell>
2995 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2996 \begin_inset Text
2997
2998 \begin_layout Standard
2999
3000 \emph on
3001 $DATADIR/$LIB_DIR_SUFFIX
3002 \end_layout
3003
3004 \end_inset
3005 </cell>
3006 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3007 \begin_inset Text
3008
3009 \begin_layout Standard
3010 /usr/local/share/sdcc/lib
3011 \end_layout
3012
3013 \end_inset
3014 </cell>
3015 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3016 \begin_inset Text
3017
3018 \begin_layout Standard
3019
3020 \backslash
3021 sdcc
3022 \backslash
3023 lib
3024 \end_layout
3025
3026 \end_inset
3027 </cell>
3028 </row>
3029 <row topline="true" bottomline="true">
3030 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3031 \begin_inset Text
3032
3033 \begin_layout Standard
3034 Documentation
3035 \end_layout
3036
3037 \end_inset
3038 </cell>
3039 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3040 \begin_inset Text
3041
3042 \begin_layout Standard
3043
3044 \emph on
3045 $DOCDIR
3046 \end_layout
3047
3048 \end_inset
3049 </cell>
3050 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3051 \begin_inset Text
3052
3053 \begin_layout Standard
3054 /usr/local/share/sdcc/doc
3055 \end_layout
3056
3057 \end_inset
3058 </cell>
3059 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3060 \begin_inset Text
3061
3062 \begin_layout Standard
3063
3064 \backslash
3065 sdcc
3066 \backslash
3067 doc
3068 \end_layout
3069
3070 \end_inset
3071 </cell>
3072 </row>
3073 </lyxtabular>
3074
3075 \end_inset
3076
3077
3078 \end_layout
3079
3080 \begin_layout Verse
3081
3082 \size footnotesize
3083 *compiler, preprocessor, assembler, and linker
3084 \newline
3085 **the 
3086 \shape italic
3087 model
3088 \shape default
3089  is auto-appended by the compiler, e.g.
3090  small, large, z80, ds390 etc
3091 \end_layout
3092
3093 \begin_layout Standard
3094 \noindent
3095 The install paths can still be changed during `make install' with e.g.:
3096 \end_layout
3097
3098 \begin_layout LyX-Code
3099 make install prefix=$(HOME)/local/sdcc
3100 \end_layout
3101
3102 \begin_layout Standard
3103 Of course this doesn't change the search paths compiled into the binaries.
3104 \newline
3105
3106 \newline
3107 Moreove
3108 r the install path can be changed by defining DESTDIR
3109 \begin_inset LatexCommand \index{DESTDIR}
3110
3111 \end_inset
3112
3113 :
3114 \end_layout
3115
3116 \begin_layout LyX-Code
3117 make install DESTDIR=$(HOME)/sdcc.rpm/
3118 \end_layout
3119
3120 \begin_layout Standard
3121 Please note that DESTDIR must have a trailing slash!
3122 \end_layout
3123
3124 \begin_layout Section
3125 Search Paths
3126 \begin_inset LatexCommand \label{sub:Search-Paths}
3127
3128 \end_inset
3129
3130
3131 \begin_inset LatexCommand \index{Search path}
3132
3133 \end_inset
3134
3135
3136 \end_layout
3137
3138 \begin_layout Standard
3139 Some search paths or parts of them are determined by configure variables
3140  (in 
3141 \emph on
3142 italics
3143 \emph default
3144 , see section above).
3145  Further search paths are determined by environment variables during runtime.
3146  
3147 \newline
3148 The paths searched when running the compiler are as follows (the first
3149  catch wins):
3150 \newline
3151
3152 \newline
3153 1.
3154  Binary files (preprocessor, assembler and linker)
3155 \newline
3156
3157 \end_layout
3158
3159 \begin_layout Standard
3160 \align center
3161 \begin_inset Tabular
3162 <lyxtabular version="3" rows="4" columns="3">
3163 <features>
3164 <column alignment="block" valignment="top" leftline="true" width="0in">
3165 <column alignment="block" valignment="top" leftline="true" width="0in">
3166 <column alignment="block" valignment="top" leftline="true" rightline="true" width="0in">
3167 <row topline="true" bottomline="true">
3168 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3169 \begin_inset Text
3170
3171 \begin_layout Standard
3172 Search path
3173 \end_layout
3174
3175 \end_inset
3176 </cell>
3177 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3178 \begin_inset Text
3179
3180 \begin_layout Standard
3181 default
3182 \end_layout
3183
3184 \end_inset
3185 </cell>
3186 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3187 \begin_inset Text
3188
3189 \begin_layout Standard
3190 Win32 builds
3191 \end_layout
3192
3193 \end_inset
3194 </cell>
3195 </row>
3196 <row topline="true">
3197 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3198 \begin_inset Text
3199
3200 \begin_layout Standard
3201 $SDCC_HOME/
3202 \emph on
3203 $PPREFIX2BIN_DIR
3204 \end_layout
3205
3206 \end_inset
3207 </cell>
3208 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3209 \begin_inset Text
3210
3211 \begin_layout Standard
3212 $SDCC_HOME/bin
3213 \end_layout
3214
3215 \end_inset
3216 </cell>
3217 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3218 \begin_inset Text
3219
3220 \begin_layout Standard
3221 $SDCC_HOME
3222 \backslash
3223 bin
3224 \end_layout
3225
3226 \end_inset
3227 </cell>
3228 </row>
3229 <row topline="true">
3230 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3231 \begin_inset Text
3232
3233 \begin_layout Standard
3234 Path of argv[0] (if available)
3235 \end_layout
3236
3237 \end_inset
3238 </cell>
3239 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3240 \begin_inset Text
3241
3242 \begin_layout Standard
3243 Path of argv[0]
3244 \end_layout
3245
3246 \end_inset
3247 </cell>
3248 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3249 \begin_inset Text
3250
3251 \begin_layout Standard
3252 Path of argv[0]
3253 \end_layout
3254
3255 \end_inset
3256 </cell>
3257 </row>
3258 <row topline="true" bottomline="true">
3259 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3260 \begin_inset Text
3261
3262 \begin_layout Standard
3263 $PATH
3264 \end_layout
3265
3266 \end_inset
3267 </cell>
3268 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3269 \begin_inset Text
3270
3271 \begin_layout Standard
3272 $PATH
3273 \end_layout
3274
3275 \end_inset
3276 </cell>
3277 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3278 \begin_inset Text
3279
3280 \begin_layout Standard
3281 $PATH
3282 \end_layout
3283
3284 \end_inset
3285 </cell>
3286 </row>
3287 </lyxtabular>
3288
3289 \end_inset
3290
3291  
3292 \newline
3293
3294 \end_layout
3295
3296 \begin_layout Standard
3297 \noindent
3298 2.
3299  Include files
3300 \newline
3301
3302 \end_layout
3303
3304 \begin_layout Standard
3305 \align center
3306 \begin_inset Tabular
3307 <lyxtabular version="3" rows="6" columns="3">
3308 <features>
3309 <column alignment="block" valignment="top" leftline="true" width="1.5in">
3310 <column alignment="block" valignment="top" leftline="true" width="1.5in">
3311 <column alignment="block" valignment="top" leftline="true" rightline="true" width="0in">
3312 <row topline="true" bottomline="true">
3313 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3314 \begin_inset Text
3315
3316 \begin_layout Standard
3317 Search path
3318 \end_layout
3319
3320 \end_inset
3321 </cell>
3322 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3323 \begin_inset Text
3324
3325 \begin_layout Standard
3326 default
3327 \end_layout
3328
3329 \end_inset
3330 </cell>
3331 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3332 \begin_inset Text
3333
3334 \begin_layout Standard
3335 Win32 builds
3336 \end_layout
3337
3338 \end_inset
3339 </cell>
3340 </row>
3341 <row topline="true">
3342 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3343 \begin_inset Text
3344
3345 \begin_layout Standard
3346 -
3347 \begin_inset ERT
3348 status collapsed
3349
3350 \begin_layout Standard
3351
3352
3353 \backslash
3354 /
3355 \end_layout
3356
3357 \end_inset
3358
3359 -I dir
3360 \end_layout
3361
3362 \end_inset
3363 </cell>
3364 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3365 \begin_inset Text
3366
3367 \begin_layout Standard
3368 -
3369 \begin_inset ERT
3370 status collapsed
3371
3372 \begin_layout Standard
3373
3374
3375 \backslash
3376 /
3377 \end_layout
3378
3379 \end_inset
3380
3381 -I dir
3382 \end_layout
3383
3384 \end_inset
3385 </cell>
3386 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3387 \begin_inset Text
3388
3389 \begin_layout Standard
3390 -
3391 \begin_inset ERT
3392 status collapsed
3393
3394 \begin_layout Standard
3395
3396
3397 \backslash
3398 /
3399 \end_layout
3400
3401 \end_inset
3402
3403 -I dir
3404 \end_layout
3405
3406 \end_inset
3407 </cell>
3408 </row>
3409 <row topline="true">
3410 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
3411 \begin_inset Text
3412
3413 \begin_layout Standard
3414 $SDCC_INCLUDE
3415 \end_layout
3416
3417 \end_inset
3418 </cell>
3419 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3420 \begin_inset Text
3421
3422 \begin_layout Standard
3423 $SDCC_INCLUDE
3424 \end_layout
3425
3426 \end_inset
3427 </cell>
3428 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3429 \begin_inset Text
3430
3431 \begin_layout Standard
3432 $SDCC_INCLUDE
3433 \end_layout
3434
3435 \end_inset
3436 </cell>
3437 </row>
3438 <row topline="true">
3439 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
3440 \begin_inset Text
3441
3442 \begin_layout Standard
3443 $SDCC_HOME/
3444 \newline
3445
3446 \emph on
3447 $PREFIX2DATA_DIR/
3448 \newline
3449 $INCLUDE_DIR_SUFFIX
3450 \end_layout
3451
3452 \end_inset
3453 </cell>
3454 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
3455 \begin_inset Text
3456
3457 \begin_layout Standard
3458 $SDCC_ HOME/
3459 \newline
3460 share/sdcc/
3461 \newline
3462 include
3463 \end_layout
3464
3465 \end_inset
3466 </cell>
3467 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3468 \begin_inset Text
3469
3470 \begin_layout Standard
3471 $SDCC_HOME
3472 \backslash
3473 include
3474 \end_layout
3475
3476 \end_inset
3477 </cell>
3478 </row>
3479 <row topline="true">
3480 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
3481 \begin_inset Text
3482
3483 \begin_layout Standard
3484 path(argv[0])/
3485 \newline
3486
3487 \emph on
3488 $BIN2DATADIR/
3489 \emph default
3490
3491 \newline
3492
3493 \emph on
3494 $INCLUDE_DIR_SUFFIX
3495 \end_layout
3496
3497 \end_inset
3498 </cell>
3499 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3500 \begin_inset Text
3501
3502 \begin_layout Standard
3503 path(argv[0])/
3504 \newline
3505 ../sdcc/include
3506 \newline
3507 \InsetSpace ~
3508 \InsetSpace ~
3509 \InsetSpace ~
3510 \InsetSpace ~
3511 \InsetSpace ~
3512 \InsetSpace ~
3513 \InsetSpace ~
3514 \InsetSpace ~
3515 \InsetSpace ~
3516 \InsetSpace ~
3517 \InsetSpace ~
3518 \InsetSpace ~
3519 \InsetSpace ~
3520 \InsetSpace ~
3521 \InsetSpace ~
3522 \InsetSpace ~
3523 \InsetSpace ~
3524 \InsetSpace ~
3525 \InsetSpace ~
3526 \InsetSpace ~
3527 \InsetSpace ~
3528 \InsetSpace ~
3529 \InsetSpace ~
3530 \InsetSpace ~
3531 \InsetSpace ~
3532 \InsetSpace ~
3533 \InsetSpace ~
3534 \InsetSpace ~
3535 \InsetSpace ~
3536 \InsetSpace ~
3537 \InsetSpace ~
3538 \InsetSpace ~
3539 \InsetSpace ~
3540 \InsetSpace ~
3541 \InsetSpace ~
3542 \InsetSpace ~
3543 \InsetSpace ~
3544 \InsetSpace ~
3545
3546 \end_layout
3547
3548 \end_inset
3549 </cell>
3550 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3551 \begin_inset Text
3552
3553 \begin_layout Standard
3554 path(argv[0])
3555 \backslash
3556 ..
3557 \backslash
3558 include
3559 \end_layout
3560
3561 \end_inset
3562 </cell>
3563 </row>
3564 <row topline="true" bottomline="true">
3565 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
3566 \begin_inset Text
3567
3568 \begin_layout Standard
3569
3570 \emph on
3571 $DATADIR/
3572 \emph default
3573
3574 \newline
3575
3576 \emph on
3577 $INCLUDE_DIR_SUFFIX
3578 \end_layout
3579
3580 \end_inset
3581 </cell>
3582 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
3583 \begin_inset Text
3584
3585 \begin_layout Standard
3586 /usr/local/share/sdcc/
3587 \newline
3588 include
3589 \end_layout
3590
3591 \end_inset
3592 </cell>
3593 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3594 \begin_inset Text
3595
3596 \begin_layout Standard
3597 (not on Win32)
3598 \end_layout
3599
3600 \end_inset
3601 </cell>
3602 </row>
3603 </lyxtabular>
3604
3605 \end_inset
3606
3607  
3608 \newline
3609
3610 \end_layout
3611
3612 \begin_layout Standard
3613 \noindent
3614 The option -
3615 \begin_inset ERT
3616 status collapsed
3617
3618 \begin_layout Standard
3619
3620
3621 \backslash
3622 /
3623 \end_layout
3624
3625 \end_inset
3626
3627 -nostdinc disables the last two search paths.
3628 \newline
3629
3630 \newline
3631 3.
3632  Library files 
3633 \newline
3634
3635 \end_layout
3636
3637 \begin_layout Standard
3638 With the exception of 
3639 \begin_inset Quotes sld
3640 \end_inset
3641
3642 -
3643 \begin_inset ERT
3644 status collapsed
3645
3646 \begin_layout Standard
3647
3648
3649 \backslash
3650 /
3651 \end_layout
3652
3653 \end_inset
3654
3655 -L dir
3656 \begin_inset Quotes srd
3657 \end_inset
3658
3659  the 
3660 \shape italic
3661 model
3662 \shape default
3663  is auto-appended by the compiler (e.g.
3664  small, large, z80, ds390 etc.).
3665  
3666 \newline
3667
3668 \end_layout
3669
3670 \begin_layout Standard
3671 \align center
3672 \begin_inset Tabular
3673 <lyxtabular version="3" rows="6" columns="3">
3674 <features>
3675 <column alignment="block" valignment="top" leftline="true" width="1.7in">
3676 <column alignment="block" valignment="top" leftline="true" width="1.2in">
3677 <column alignment="block" valignment="top" leftline="true" rightline="true" width="1.2in">
3678 <row topline="true" bottomline="true">
3679 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
3680 \begin_inset Text
3681
3682 \begin_layout Standard
3683 Search path
3684 \end_layout
3685
3686 \end_inset
3687 </cell>
3688 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
3689 \begin_inset Text
3690
3691 \begin_layout Standard
3692 default
3693 \end_layout
3694
3695 \end_inset
3696 </cell>
3697 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3698 \begin_inset Text
3699
3700 \begin_layout Standard
3701 Win32 builds
3702 \end_layout
3703
3704 \end_inset
3705 </cell>
3706 </row>
3707 <row topline="true">
3708 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
3709 \begin_inset Text
3710
3711 \begin_layout Standard
3712 -
3713 \begin_inset ERT
3714 status collapsed
3715
3716 \begin_layout Standard
3717
3718
3719 \backslash
3720 /
3721 \end_layout
3722
3723 \end_inset
3724
3725 -L dir
3726 \end_layout
3727
3728 \end_inset
3729 </cell>
3730 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3731 \begin_inset Text
3732
3733 \begin_layout Standard
3734 -
3735 \begin_inset ERT
3736 status collapsed
3737
3738 \begin_layout Standard
3739
3740
3741 \backslash
3742 /
3743 \end_layout
3744
3745 \end_inset
3746
3747 -L dir
3748 \end_layout
3749
3750 \end_inset
3751 </cell>
3752 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3753 \begin_inset Text
3754
3755 \begin_layout Standard
3756 -
3757 \begin_inset ERT
3758 status collapsed
3759
3760 \begin_layout Standard
3761
3762
3763 \backslash
3764 /
3765 \end_layout
3766
3767 \end_inset
3768
3769 -L dir
3770 \end_layout
3771
3772 \end_inset
3773 </cell>
3774 </row>
3775 <row topline="true">
3776 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3777 \begin_inset Text
3778
3779 \begin_layout Standard
3780 $SDCC_LIB/
3781 \newline
3782
3783 \emph on
3784 <model>
3785 \end_layout
3786
3787 \end_inset
3788 </cell>
3789 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
3790 \begin_inset Text
3791
3792 \begin_layout Standard
3793 $SDCC_LIB/
3794 \newline
3795
3796 \emph on
3797 <model>
3798 \end_layout
3799
3800 \end_inset
3801 </cell>
3802 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3803 \begin_inset Text
3804
3805 \begin_layout Standard
3806 $SDCC_LIB
3807 \backslash
3808
3809 \newline
3810
3811 \emph on
3812 <model>
3813 \end_layout
3814
3815 \end_inset
3816 </cell>
3817 </row>
3818 <row topline="true">
3819 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
3820 \begin_inset Text
3821
3822 \begin_layout Standard
3823 $SDCC_HOME/
3824 \newline
3825
3826 \emph on
3827 $PREFIX2DATA_DIR/
3828 \newline
3829 $LIB_DIR_SUFFIX/<model>
3830 \end_layout
3831
3832 \end_inset
3833 </cell>
3834 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
3835 \begin_inset Text
3836
3837 \begin_layout Standard
3838 $SDCC_HOME/
3839 \newline
3840 share/sdcc/
3841 \newline
3842 lib/
3843 \emph on
3844 <model>
3845 \end_layout
3846
3847 \end_inset
3848 </cell>
3849 <cell alignment="left" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3850 \begin_inset Text
3851
3852 \begin_layout Standard
3853 $SDCC_HOME
3854 \backslash
3855 lib
3856 \backslash
3857
3858 \emph on
3859
3860 \newline
3861 <model>
3862 \end_layout
3863
3864 \end_inset
3865 </cell>
3866 </row>
3867 <row topline="true">
3868 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
3869 \begin_inset Text
3870
3871 \begin_layout Standard
3872 path(argv[0])/
3873 \newline
3874
3875 \emph on
3876 $BIN2DATADIR/
3877 \emph default
3878
3879 \newline
3880
3881 \emph on
3882 $LIB_DIR_SUFFIX/<model>
3883 \end_layout
3884
3885 \end_inset
3886 </cell>
3887 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
3888 \begin_inset Text
3889
3890 \begin_layout Standard
3891 path(argv[0])/
3892 \newline
3893 ../sdcc/lib/
3894 \emph on
3895 <model>
3896 \newline
3897 \InsetSpace ~
3898 \InsetSpace ~
3899 \InsetSpace ~
3900 \InsetSpace ~
3901 \InsetSpace ~
3902 \InsetSpace ~
3903 \InsetSpace ~
3904 \InsetSpace ~
3905 \InsetSpace ~
3906 \InsetSpace ~
3907 \InsetSpace ~
3908 \InsetSpace ~
3909 \InsetSpace ~
3910 \InsetSpace ~
3911 \InsetSpace ~
3912 \InsetSpace ~
3913 \InsetSpace ~
3914 \InsetSpace ~
3915 \InsetSpace ~
3916 \InsetSpace ~
3917 \InsetSpace ~
3918 \InsetSpace ~
3919 \InsetSpace ~
3920 \InsetSpace ~
3921 \InsetSpace ~
3922 \InsetSpace ~
3923 \InsetSpace ~
3924 \InsetSpace ~
3925 \InsetSpace ~
3926 \InsetSpace ~
3927 \InsetSpace ~
3928 \InsetSpace ~
3929 \InsetSpace ~
3930 \InsetSpace ~
3931 \InsetSpace ~
3932 \InsetSpace ~
3933 \InsetSpace ~
3934 \InsetSpace ~
3935 \InsetSpace ~
3936
3937 \end_layout
3938
3939 \end_inset
3940 </cell>
3941 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3942 \begin_inset Text
3943
3944 \begin_layout Standard
3945 path(argv[0])
3946 \backslash
3947
3948 \newline
3949 ..
3950 \backslash
3951 lib
3952 \backslash
3953
3954 \emph on
3955 <model>
3956 \newline
3957 \InsetSpace ~
3958 \InsetSpace ~
3959 \InsetSpace ~
3960 \InsetSpace ~
3961 \InsetSpace ~
3962 \InsetSpace ~
3963 \InsetSpace ~
3964 \InsetSpace ~
3965 \InsetSpace ~
3966 \InsetSpace ~
3967 \InsetSpace ~
3968 \InsetSpace ~
3969 \InsetSpace ~
3970 \InsetSpace ~
3971 \InsetSpace ~
3972 \InsetSpace ~
3973 \InsetSpace ~
3974 \InsetSpace ~
3975 \InsetSpace ~
3976 \InsetSpace ~
3977 \InsetSpace ~
3978 \InsetSpace ~
3979 \InsetSpace ~
3980 \InsetSpace ~
3981 \InsetSpace ~
3982 \InsetSpace ~
3983 \InsetSpace ~
3984 \InsetSpace ~
3985 \InsetSpace ~
3986 \InsetSpace ~
3987 \InsetSpace ~
3988 \InsetSpace ~
3989 \InsetSpace ~
3990 \InsetSpace ~
3991 \InsetSpace ~
3992
3993 \end_layout
3994
3995 \end_inset
3996 </cell>
3997 </row>
3998 <row topline="true" bottomline="true">
3999 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
4000 \begin_inset Text
4001
4002 \begin_layout Standard
4003
4004 \emph on
4005 $DATADIR/
4006 \newline
4007 $LIB_DIR_SUFFIX/<model>
4008 \end_layout
4009
4010 \end_inset
4011 </cell>
4012 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
4013 \begin_inset Text
4014
4015 \begin_layout Standard
4016 /usr/local/share/sdcc/
4017 \newline
4018 lib/
4019 \emph on
4020 <model>
4021 \end_layout
4022
4023 \end_inset
4024 </cell>
4025 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
4026 \begin_inset Text
4027
4028 \begin_layout Standard
4029 (not on Win32)
4030 \end_layout
4031
4032 \end_inset
4033 </cell>
4034 </row>
4035 </lyxtabular>
4036
4037 \end_inset
4038
4039
4040 \newline
4041
4042 \end_layout
4043
4044 \begin_layout Standard
4045 \begin_inset Note Note
4046 status collapsed
4047
4048 \begin_layout Standard
4049 Don't delete any of the stray spaces in the table above without checking
4050  the HTML output (last line)!
4051 \end_layout
4052
4053 \end_inset
4054
4055
4056 \end_layout
4057
4058 \begin_layout Standard
4059 \InsetSpace ~
4060
4061 \newline
4062 The option -
4063 \begin_inset ERT
4064 status collapsed
4065
4066 \begin_layout Standard
4067
4068
4069 \backslash
4070 /
4071 \end_layout
4072
4073 \end_inset
4074
4075 -nostdlib disables the last two search paths.
4076 \end_layout
4077
4078 \begin_layout Section
4079 Building SDCC
4080 \begin_inset LatexCommand \index{Building SDCC}
4081
4082 \end_inset
4083
4084
4085 \end_layout
4086
4087 \begin_layout Subsection
4088 Building SDCC on Linux
4089 \begin_inset LatexCommand \label{sub:Building-SDCC-on-Linux}
4090
4091 \end_inset
4092
4093
4094 \end_layout
4095
4096 \begin_layout Enumerate
4097
4098 \series medium
4099 Download the source package
4100 \series default
4101  either from the SDCC Subversion repository or from snapshot builds
4102 \series medium
4103 , it will be named something like sdcc
4104 \series default
4105 -src
4106 \series medium
4107 -yyyymmdd-rrrr.t
4108 \series default
4109 ar.
4110 \series medium
4111 bz2
4112 \series default
4113  
4114 \begin_inset LatexCommand \url{http://sdcc.sourceforge.net/snap.php}
4115
4116 \end_inset
4117
4118 .
4119 \end_layout
4120
4121 \begin_layout Enumerate
4122
4123 \series medium
4124 Bring up a command line terminal, such as xterm.
4125 \end_layout
4126
4127 \begin_layout Enumerate
4128
4129 \series medium
4130 Unpack the file using a command like: 
4131 \family sans
4132 \series bold
4133 "tar -xvzf sdcc-src-yyyymmdd-rrrr.tar.bz2
4134 \begin_inset Quotes srd
4135 \end_inset
4136
4137
4138 \family default
4139 \series medium
4140 , this will create a sub-directory called sdcc with all of the sources.
4141 \end_layout
4142
4143 \begin_layout Enumerate
4144 Change directory into the main SDCC directory, for example type: 
4145 \family sans
4146 \series bold
4147 "cd sdcc
4148 \series default
4149 ".
4150 \end_layout
4151
4152 \begin_layout Enumerate
4153
4154 \series medium
4155 Type 
4156 \family sans
4157 \series bold
4158 "./configure
4159 \family default
4160 \series default
4161 ".
4162  This configures the package for compilation on your system.
4163 \end_layout
4164
4165 \begin_layout Enumerate
4166
4167 \series medium
4168 Type 
4169 \family sans
4170 \series bold
4171 "make
4172 \family default
4173 \series default
4174 "
4175 \series medium
4176 .
4177
4178 \series default
4179  All of the source packages will compile, this can take a while.
4180 \end_layout
4181
4182 \begin_layout Enumerate
4183
4184 \series medium
4185 Type 
4186 \family sans
4187 \series bold
4188 "make install"
4189 \family default
4190 \series default
4191  as root
4192 \series medium
4193 .
4194
4195 \series default
4196  This copies the binary executables, the include files, the libraries and
4197  the documentation to the install directories.
4198  Proceed with section 
4199 \begin_inset LatexCommand \ref{sec:Testing-the-SDCC}
4200
4201 \end_inset
4202
4203 .
4204 \end_layout
4205
4206 \begin_layout Subsection
4207 Building SDCC on Mac OS X
4208 \end_layout
4209
4210 \begin_layout Standard
4211 Follow the instruction for Linux.
4212 \newline
4213
4214 \newline
4215 On Mac OS X 10.2.x it was reported, that the
4216  default gcc (version 3.1 20020420 (prerelease)) fails to compile SDCC.
4217  Fortunately there's also gcc 2.9.x installed, which works fine.
4218  This compiler can be selected by running 'configure' with:
4219 \end_layout
4220
4221 \begin_layout LyX-Code
4222 ./configure CC=gcc2 CXX=g++2
4223 \end_layout
4224
4225 \begin_layout Standard
4226 Universal (ppc and i386) binaries can be produced on Mac OS X 10.4.x with
4227  Xcode.
4228  Run 'configure' with:
4229 \end_layout
4230
4231 \begin_layout LyX-Code
4232 ./configure 
4233 \backslash
4234
4235 \end_layout
4236
4237 \begin_layout LyX-Code
4238 LDFLAGS="-Wl,-syslibroot,/Developer/SDKs/MacOSX10.4u.sdk -arch i386 -arch
4239  ppc" 
4240 \backslash
4241
4242 \end_layout
4243
4244 \begin_layout LyX-Code
4245 CXXFLAGS = "-O2 -isysroot /Developer/SDKs/MacOSX10.4u.sdk -arch i386 -arch
4246  ppc" 
4247 \backslash
4248
4249 \end_layout
4250
4251 \begin_layout LyX-Code
4252 CFLAGS = "-O2 -isysroot /Developer/SDKs/MacOSX10.4u.sdk -arch i386 -arch ppc"
4253 \end_layout
4254
4255 \begin_layout Subsection
4256 Cross compiling SDCC on Linux for Windows
4257 \end_layout
4258
4259 \begin_layout Standard
4260 With the Mingw32 gcc cross compiler it's easy to compile SDCC for Win32.
4261  See section 'Configure Options'.
4262 \end_layout
4263
4264 \begin_layout Subsection
4265 Building SDCC using Cygwin and Mingw32
4266 \end_layout
4267
4268 \begin_layout Standard
4269 For building and installing a Cygwin executable follow the instructions
4270  for Linux.
4271 \newline
4272
4273 \newline
4274 On Cygwin a 
4275 \begin_inset Quotes sld
4276 \end_inset
4277
4278 native
4279 \begin_inset Quotes srd
4280 \end_inset
4281
4282  Win32-binary can be built, which will not need the Cygwin-DLL.
4283  For the necessary 'configure' options see section 'configure options' or
4284  the script 'sdcc/support/scripts/sdcc_cygwin_mingw32'.
4285 \newline
4286
4287 \newline
4288 In order to install
4289  Cygwin on Windows download setup.exe from 
4290 \begin_inset LatexCommand \url[www.cygwin.com]{http://www.cygwin.com/}
4291
4292 \end_inset
4293
4294 .
4295  Run it, set the 
4296 \begin_inset Quotes sld
4297 \end_inset
4298
4299 default text file type
4300 \begin_inset Quotes srd
4301 \end_inset
4302
4303  to 
4304 \begin_inset Quotes sld
4305 \end_inset
4306
4307 unix
4308 \begin_inset Quotes srd
4309 \end_inset
4310
4311  and download/install at least the following packages.
4312  Some packages are selected by default, others will be automatically selected
4313  because of dependencies with the manually selected packages.
4314  Never deselect these packages!
4315 \end_layout
4316
4317 \begin_layout Itemize
4318 flex
4319 \end_layout
4320
4321 \begin_layout Itemize
4322 bison
4323 \end_layout
4324
4325 \begin_layout Itemize
4326 gcc ; version 3.x is fine, no need to use the old 2.9x
4327 \end_layout
4328
4329 \begin_layout Itemize
4330 binutils ; selected with gcc
4331 \end_layout
4332
4333 \begin_layout Itemize
4334 make
4335 \end_layout
4336
4337 \begin_layout Itemize
4338 rxvt ; a nice console, which makes life much easier under windoze (see below)
4339 \end_layout
4340
4341 \begin_layout Itemize
4342 man ; not really needed for building SDCC, but you'll miss it sooner or
4343  later
4344 \end_layout
4345
4346 \begin_layout Itemize
4347 less ; not really needed for building SDCC, but you'll miss it sooner or
4348  later
4349 \end_layout
4350
4351 \begin_layout Itemize
4352 svn ; only if you use Subversion access
4353 \end_layout
4354
4355 \begin_layout Standard
4356 If you want to develop something you'll need:
4357 \end_layout
4358
4359 \begin_layout Itemize
4360 python ; for the regression tests
4361 \end_layout
4362
4363 \begin_layout Itemize
4364 gdb ; the gnu debugger, together with the nice GUI 
4365 \begin_inset Quotes sld
4366 \end_inset
4367
4368 insight
4369 \begin_inset Quotes srd
4370 \end_inset
4371
4372
4373 \end_layout
4374
4375 \begin_layout Itemize
4376 openssh ; to access the CF or commit changes
4377 \end_layout
4378
4379 \begin_layout Itemize
4380 autoconf and autoconf-devel ; if you want to fight with 'configure', don't
4381  use autoconf-stable!
4382 \end_layout
4383
4384 \begin_layout Standard
4385 rxvt is a nice console with history.
4386  Replace in your cygwin.bat the line
4387 \end_layout
4388
4389 \begin_layout LyX-Code
4390 bash -
4391 \begin_inset ERT
4392 status collapsed
4393
4394 \begin_layout Standard
4395
4396
4397 \backslash
4398 /
4399 \end_layout
4400
4401 \end_inset
4402
4403 -login -i 
4404 \end_layout
4405
4406 \begin_layout Standard
4407 with (one line):
4408 \end_layout
4409
4410 \begin_layout LyX-Code
4411 rxvt -sl 1000 -fn "Lucida Console-12" -sr -cr red
4412 \end_layout
4413
4414 \begin_layout LyX-Code
4415      -bg black -fg white -geometry 100x65 -e bash -
4416 \begin_inset ERT
4417 status collapsed
4418
4419 \begin_layout Standard
4420
4421
4422 \backslash
4423 /
4424 \end_layout
4425
4426 \end_inset
4427
4428 -login
4429 \end_layout
4430
4431 \begin_layout Standard
4432 Text selected with the mouse is automatically copied to the clipboard, pasting
4433  works with shift-insert.
4434 \newline
4435
4436 \newline
4437 The other good tip is to make sure you have no //c/-styl
4438 e paths anywhere, use /cygdrive/c/ instead.
4439  Using // invokes a network lookup which is very slow.
4440  If you think 
4441 \begin_inset Quotes sld
4442 \end_inset
4443
4444 cygdrive
4445 \begin_inset Quotes srd
4446 \end_inset
4447
4448  is too long, you can change it with e.g.
4449 \end_layout
4450
4451 \begin_layout LyX-Code
4452 mount -s -u -c /mnt
4453 \end_layout
4454
4455 \begin_layout Standard
4456 SDCC sources use the unix line ending LF.
4457  Life is much easier, if you store the source tree on a drive which is mounted
4458  in binary mode.
4459  And use an editor which can handle LF-only line endings.
4460  Make sure not to commit files with windows line endings.
4461  The tabulator spacing
4462 \begin_inset LatexCommand \index{tabulator spacing (8 columns)}
4463
4464 \end_inset
4465
4466  used in the project is 8.
4467  Although a tabulator spacing of 8 is a sensible choice for programmers
4468  (it's a power of 2 and allows to display 8/16 bit signed variables without
4469  loosing columns) the plan is to move towards using only spaces in the source.
4470 \end_layout
4471
4472 \begin_layout Subsection
4473 Building SDCC Using Microsoft Visual C++ 6.0/NET (MSVC)
4474 \end_layout
4475
4476 \begin_layout Standard
4477
4478 \series medium
4479 Download the source package
4480 \series default
4481  either from the SDCC Subversion repository or from the 
4482 \begin_inset LatexCommand \url[snapshot builds]{http://sdcc.sourceforge.net/snap.php}
4483
4484 \end_inset
4485
4486
4487 \series medium
4488 , it will be named something like sdcc
4489 \series default
4490 -src
4491 \series medium
4492 -yyyymmdd-rrrr.tar.bz2.
4493
4494 \series default
4495  SDCC is distributed with all the projects, workspaces, and files you need
4496  to build it using Visual C++ 6.0/NET (except for SDCDB and ucSim).
4497  The workspace name is 'sdcc.dsw'.
4498  Please note that as it is now, all the executables are created in a folder
4499  called sdcc
4500 \backslash
4501 bin_vc.
4502  Once built you need to copy the executables from sdcc
4503 \backslash
4504 bin_vc to sdcc
4505 \backslash
4506 bin before running SDCC.
4507  
4508 \newline
4509
4510 \newline
4511 WARNING: Visual studio is very picky with line terminations; it expects
4512  the 0x0d, 0x0a DOS style line endings, not the 0x0a Unix style line endings.
4513  When using the Subversion repository it's easiest to configure the svn
4514  client to convert automatically for you.
4515  If however you are getting a message such as "This makefile was not generated
4516  by Developer Studio etc.
4517  etc.
4518 \begin_inset Quotes srd
4519 \end_inset
4520
4521  when opening the sdcc.dsw workspace or any of the *.dsp projects, then you
4522  need to convert the Unix style line endings to DOS style line endings.
4523  To do so you can use the 
4524 \begin_inset Quotes sld
4525 \end_inset
4526
4527 unix2dos
4528 \begin_inset Quotes srd
4529 \end_inset
4530
4531  utility freely available on the internet.
4532  Doug Hawkins reported in the sdcc-user list that this works:
4533 \newline
4534
4535 \newline
4536 C:
4537 \backslash
4538 Programming
4539 \backslash
4540 SDCC> unix2dos sdcc.dsw
4541 \newline
4542 C:
4543 \backslash
4544 Programming
4545 \backslash
4546 SDCC> for /R %I in (*.dsp) do @unix2dos "%I"
4547 \newline
4548
4549 \newline
4550 In order to build SDCC with MSVC
4551  you need win32 executables of bison.exe, flex.exe, and gawk.exe.
4552  One good place to get them is 
4553 \begin_inset LatexCommand \url[here]{http://unxutils.sourceforge.net}
4554
4555 \end_inset
4556
4557
4558 \newline
4559
4560 \newline
4561 Download the file UnxUtils
4562 \begin_inset LatexCommand \index{UnxUtils}
4563
4564 \end_inset
4565
4566 .zip.
4567  Now you have to install the utilities and setup MSVC so it can locate the
4568  required programs.
4569  Here there are two alternatives (choose one!):
4570 \end_layout
4571
4572 \begin_layout Enumerate
4573 The easy way:
4574 \newline
4575
4576 \newline
4577 a) Extract UnxUtils.zip to your C:
4578 \backslash
4579  hard disk PRESERVING the original paths, otherwise bison won't work.
4580  (If you are using WinZip make certain that 'Use folder names' is selected)
4581 \newline
4582
4583 \newline
4584 b)
4585  In the Visual C++ IDE click Tools, Options, select the Directory tab, in
4586  'Show directories for:' select 'Executable files', and in the directories
4587  window add a new path: 'C:
4588 \backslash
4589 user
4590 \backslash
4591 local
4592 \backslash
4593 wbin', click ok.
4594 \newline
4595
4596 \newline
4597 (As a side effect, you get a bunch of Unix utilities that
4598  could be useful, such as diff and patch.)
4599 \end_layout
4600
4601 \begin_layout Enumerate
4602 A more compact way:
4603 \newline
4604
4605 \newline
4606 This one avoids extracting a bunch of files you may not
4607  use, but requires some extra work:
4608 \newline
4609
4610 \newline
4611 a) Create a directory were to put the
4612  tools needed, or use a directory already present.
4613  Say for example 'C:
4614 \backslash
4615 util'.
4616 \newline
4617
4618 \newline
4619 b) Extract 'bison.exe', 'bison.hairy', 'bison.simple', 'flex.exe', and
4620  gawk.exe to such directory WITHOUT preserving the original paths.
4621  (If you are using WinZip make certain that 'Use folder names' is not selected)
4622 \newline
4623
4624 \newline
4625 c
4626 ) Rename bison.exe to '_bison.exe'.
4627 \newline
4628
4629 \newline
4630 d) Create a batch file 'bison.bat' in 'C:
4631 \backslash
4632 util
4633 \backslash
4634 ' and add these lines: 
4635 \newline
4636 \InsetSpace ~
4637 \InsetSpace ~
4638 set BISON_SIMPLE=C:
4639 \backslash
4640 util
4641 \backslash
4642 bison.simple 
4643 \newline
4644 \InsetSpace ~
4645 \InsetSpace ~
4646 set BISON_HAIRY=C:
4647 \backslash
4648 util
4649 \backslash
4650 bison.hairy
4651 \newline
4652 \InsetSpace ~
4653 \InsetSpace ~
4654 _bison %1 %2 %3 %4 %5 %6 %7 %8 %9
4655 \newline
4656
4657 \newline
4658 Steps 'c' and 'd' are needed
4659  because bison requires by default that the files 'bison.simple' and 'bison.hairy'
4660  reside in some weird Unix directory, '/usr/local/share/' I think.
4661  So it is necessary to tell bison where those files are located if they
4662  are not in such directory.
4663  That is the function of the environment variables BISON_SIMPLE and BISON_HAIRY.
4664 \newline
4665
4666 \newline
4667 e
4668 ) In the Visual C++ IDE click Tools, Options, select the Directory tab,
4669  in 'Show directories for:' select 'Executable files', and in the directories
4670  window add a new path: 'c:
4671 \backslash
4672 util', click ok.
4673  Note that you can use any other path instead of 'c:
4674 \backslash
4675 util', even the path where the Visual C++ tools are, probably: 'C:
4676 \backslash
4677 Program Files
4678 \backslash
4679 Microsoft Visual Studio
4680 \backslash
4681 Common
4682 \backslash
4683 Tools'.
4684  So you don't have to execute step 'e' :)
4685 \end_layout
4686
4687 \begin_layout Standard
4688 That is it.
4689  Open 'sdcc.dsw' in Visual Studio, click 'build all', when it finishes copy
4690  the executables from sdcc
4691 \backslash
4692 bin_vc to sdcc
4693 \backslash
4694 bin, and you can compile using SDCC.
4695 \end_layout
4696
4697 \begin_layout Subsection
4698 Building SDCC Using Borland
4699 \end_layout
4700
4701 \begin_layout Enumerate
4702 From the sdcc directory, run the command "make -f Makefile.bcc".
4703  This should regenerate all the .exe files in the bin directory except for
4704  SDCDB and ucSim.
4705 \end_layout
4706
4707 \begin_layout Enumerate
4708 If you modify any source files and need to rebuild, be aware that the dependenci
4709 es may not be correctly calculated.
4710  The safest option is to delete all .obj files and run the build again.
4711  From a Cygwin BASH prompt, this can easily be done with the command (be
4712  sure you are in the sdcc directory):
4713 \newline
4714
4715 \newline
4716
4717 \family sans
4718 \series bold
4719 find .
4720  
4721 \backslash
4722 ( -name '*.obj' -o -name '*.lib' -o -name '*.rul' 
4723 \backslash
4724 ) -print -exec rm {} 
4725 \backslash
4726 ;
4727 \family default
4728 \series default
4729
4730 \newline
4731
4732 \newline
4733 or on Windows NT/2000/XP from the command prompt with the command:
4734 \newline
4735
4736 \family sans
4737 \series bold
4738
4739 \newline
4740 del /s *.obj *.lib *.rul
4741 \family default
4742 \series default
4743  from the sdcc directory.
4744 \end_layout
4745
4746 \begin_layout Subsection
4747 Windows Install Using a ZIP Package
4748 \end_layout
4749
4750 \begin_layout Enumerate
4751 Download the binary zip package from 
4752 \begin_inset LatexCommand \url{http://sdcc.sf.net/snap.php}
4753
4754 \end_inset
4755
4756  and unpack it using your favorite unpacking tool (gunzip, WinZip, etc).
4757  This should unpack to a group of sub-directories.
4758  An example directory structure after unpacking the mingw32 package is:
4759  c:
4760 \backslash
4761 sdcc
4762 \backslash
4763 bin for the executables, c:
4764 \backslash
4765 sdcc
4766 \backslash
4767 include and c:
4768 \backslash
4769 sdcc
4770 \backslash
4771 lib for the include and libraries.
4772 \end_layout
4773
4774 \begin_layout Enumerate
4775 Adjust your environment variable PATH to include the location of the bin
4776  directory or start sdcc using the full path.
4777 \end_layout
4778
4779 \begin_layout Subsection
4780 Windows Install Using the Setup Program
4781 \begin_inset LatexCommand \label{sub:Windows-Install}
4782
4783 \end_inset
4784
4785
4786 \end_layout
4787
4788 \begin_layout Standard
4789 Download the setup program 
4790 \emph on
4791 sdcc-x.y.z-setup.exe
4792 \emph default
4793  for an official release from 
4794 \newline
4795
4796 \begin_inset LatexCommand \url{http://sf.net/project/showfiles.php?group_id=599}
4797
4798 \end_inset
4799
4800  or a setup program for one of the snapshots 
4801 \emph on
4802 sdcc-yyyymmdd-xxxx-setup.exe
4803 \emph default
4804  from 
4805 \begin_inset LatexCommand \url{http://sdcc.sf.net/snap.php}
4806
4807 \end_inset
4808
4809  and execute it.
4810  A windows typical installer will guide you through the installation process.
4811 \end_layout
4812
4813 \begin_layout Subsection
4814 VPATH
4815 \begin_inset LatexCommand \index{VPATH}
4816
4817 \end_inset
4818
4819  feature
4820 \end_layout
4821
4822 \begin_layout Standard
4823 SDCC supports the VPATH feature provided by configure and make.
4824  It allows to separate the source and build trees.
4825  Here's an example:
4826 \end_layout
4827
4828 \begin_layout Standard
4829
4830 \family typewriter
4831 cd ~\InsetSpace ~
4832 \InsetSpace ~
4833 \InsetSpace ~
4834 \InsetSpace ~
4835 \InsetSpace ~
4836 \InsetSpace ~
4837 \InsetSpace ~
4838 \InsetSpace ~
4839 \InsetSpace ~
4840 \InsetSpace ~
4841 \InsetSpace ~
4842 \InsetSpace ~
4843 \InsetSpace ~
4844 \InsetSpace ~
4845 \InsetSpace ~
4846 \InsetSpace ~
4847 \InsetSpace ~
4848 \InsetSpace ~
4849 \InsetSpace ~
4850 \InsetSpace ~
4851 \InsetSpace ~
4852 # cd $HOME
4853 \end_layout
4854
4855 \begin_layout Standard
4856
4857 \family typewriter
4858 tar -xzf sdcc.src.tar.gz\InsetSpace ~
4859 # extract source to directory sdcc
4860 \end_layout
4861
4862 \begin_layout Standard
4863
4864 \family typewriter
4865 mkdir sdcc.build\InsetSpace ~
4866 \InsetSpace ~
4867 \InsetSpace ~
4868 \InsetSpace ~
4869 \InsetSpace ~
4870 \InsetSpace ~
4871 \InsetSpace ~
4872 \InsetSpace ~
4873 \InsetSpace ~
4874 # put output in sdcc.build
4875 \end_layout
4876
4877 \begin_layout Standard
4878
4879 \family typewriter
4880 cd sdcc.build
4881 \end_layout
4882
4883 \begin_layout Standard
4884
4885 \family typewriter
4886 ../sdcc/configure\InsetSpace ~
4887 \InsetSpace ~
4888 \InsetSpace ~
4889 \InsetSpace ~
4890 \InsetSpace ~
4891 \InsetSpace ~
4892 \InsetSpace ~
4893 \InsetSpace ~
4894 # configure is doing all the magic!
4895 \end_layout
4896
4897 \begin_layout Standard
4898
4899 \family typewriter
4900 make
4901 \end_layout
4902
4903 \begin_layout Standard
4904 \noindent
4905 That's it! 
4906 \series bold
4907 configure
4908 \series default
4909  will create the directory tree will all the necessary Makefiles in ~/sdcc.build.
4910  It automagically computes the variables srcdir, top_srcdir and top_buildir
4911  for each directory.
4912  After running 
4913 \series bold
4914 make
4915 \series default
4916  the generated files will be in ~/sdcc.build, while the source files stay
4917  in ~/sdcc.
4918 \newline
4919 This is not only usefull for building different binaries, e.g.
4920  when cross compiling.
4921  It also gives you a much better overview in the source tree when all the
4922  generated files are not scattered between the source files.
4923  And the best thing is: if you want to change a file you can leave the original
4924  file untouched in the source directory.
4925  Simply copy it to the build directory, edit it, enter `make clean', `rm
4926  Makefile.dep' and `make'.
4927  
4928 \series bold
4929 make
4930 \series default
4931  will do the rest for you!
4932 \end_layout
4933
4934 \begin_layout Section
4935 Building the Documentation
4936 \end_layout
4937
4938 \begin_layout Standard
4939 Add -
4940 \begin_inset ERT
4941 status collapsed
4942
4943 \begin_layout Standard
4944
4945
4946 \backslash
4947 /
4948 \end_layout
4949
4950 \end_inset
4951
4952 -enable-doc to the configure arguments to build the documentation together
4953  with all the other stuff.
4954  You will need several tools (LyX, LaTeX, LaTeX2HTML, pdflatex, dvipdf,
4955  dvips and makeindex) to get the job done.
4956  Another possibility is to change to the doc directory and to type 
4957 \family sans
4958 \series bold
4959
4960 \begin_inset Quotes srd
4961 \end_inset
4962
4963 make
4964 \begin_inset Quotes srd
4965 \end_inset
4966
4967
4968 \family default
4969 \series default
4970  there.
4971  You're invited to make changes and additions to this manual (sdcc/doc/sdccman.ly
4972 x).
4973  Using LyX 
4974 \begin_inset LatexCommand \url{http://www.lyx.org}
4975
4976 \end_inset
4977
4978  as editor is straightforward.
4979  Prebuilt documentation in html and pdf format is available from 
4980 \begin_inset LatexCommand \url{http://sdcc.sf.net/snap.php}
4981
4982 \end_inset
4983
4984 .
4985 \end_layout
4986
4987 \begin_layout Section
4988 Reading the Documentation
4989 \begin_inset LatexCommand \index{Documentation}
4990
4991 \end_inset
4992
4993
4994 \end_layout
4995
4996 \begin_layout Standard
4997 Currently reading the document in pdf format is recommended, as for unknown
4998  reason the hyperlinks are working there whereas in the html version they
4999  are not
5000 \begin_inset Foot
5001 status open
5002
5003 \begin_layout Standard
5004 If you should know why please drop us a note
5005 \end_layout
5006
5007 \end_inset
5008
5009 .
5010  
5011 \newline
5012 You'll find the pdf version
5013 \begin_inset LatexCommand \index{PDF version of this document}
5014
5015 \end_inset
5016
5017  at 
5018 \begin_inset LatexCommand \url{http://sdcc.sf.net/doc/sdccman.pdf}
5019
5020 \end_inset
5021
5022 .
5023  
5024 \newline
5025 A html version
5026 \begin_inset LatexCommand \index{HTML version of this document}
5027
5028 \end_inset
5029
5030  should be online at 
5031 \begin_inset LatexCommand \url{http://sdcc.sf.net/doc/sdccman.html/index.html}
5032
5033 \end_inset
5034
5035 .
5036 \newline
5037 This documentation is in some aspects different from a commercial documentation:
5038  
5039 \end_layout
5040
5041 \begin_layout Itemize
5042 It tries to document SDCC for several processor architectures in one document
5043  (commercially these probably would be separate documents/products).
5044  This document
5045 \begin_inset LatexCommand \index{Status of documentation}
5046
5047 \end_inset
5048
5049  currently matches SDCC for mcs51 and DS390 best and does give too few informati
5050 on about f.e.
5051  Z80, PIC14, PIC16 and HC08.
5052 \end_layout
5053
5054 \begin_layout Itemize
5055 There are many references pointing away from this documentation.
5056  Don't let this distract you.
5057  If there f.e.
5058  was a reference like 
5059 \begin_inset LatexCommand \url{http://www.opencores.org}
5060
5061 \end_inset
5062
5063  together with a statement 
5064 \begin_inset Quotes sld
5065 \end_inset
5066
5067 some processors which are targetted by SDCC can be implemented in a 
5068 \emph on
5069 f
5070 \emph default
5071 ield 
5072 \emph on
5073 p
5074 \emph default
5075 rogrammable 
5076 \emph on
5077 g
5078 \emph default
5079 ate 
5080 \emph on
5081 a
5082 \emph default
5083 rray
5084 \begin_inset LatexCommand \index{FPGA (field programmable gate array)}
5085
5086 \end_inset
5087
5088
5089 \begin_inset Quotes srd
5090 \end_inset
5091
5092  or 
5093 \begin_inset LatexCommand \url{http://sf.net/projects/fpgac}
5094
5095 \end_inset
5096
5097
5098 \begin_inset LatexCommand \index{FpgaC ((subset of) C to FPGA compiler)}
5099
5100 \end_inset
5101
5102  
5103 \begin_inset Quotes sld
5104 \end_inset
5105
5106 have you ever heard of an open source compiler that compiles a subset of
5107  C for an FPGA?
5108 \begin_inset Quotes srd
5109 \end_inset
5110
5111  we expect you to have a quick look there and come back.
5112  If you read this you are on the right track.
5113 \end_layout
5114
5115 \begin_layout Itemize
5116 Some sections attribute more space to problems, restrictions and warnings
5117  than to the solution.
5118 \end_layout
5119
5120 \begin_layout Itemize
5121 The installation section and the section about the debugger is intimidating.
5122 \end_layout
5123
5124 \begin_layout Itemize
5125 There are still lots of typos and there are more different writing styles
5126  than pictures.
5127 \end_layout
5128
5129 \begin_layout Section
5130 Testing the SDCC Compiler
5131 \begin_inset LatexCommand \label{sec:Testing-the-SDCC}
5132
5133 \end_inset
5134
5135
5136 \end_layout
5137
5138 \begin_layout Standard
5139 The first thing you should do after installing your SDCC compiler is to
5140  see if it runs.
5141  Type 
5142 \family sans
5143 \series bold
5144 "sdcc -
5145 \begin_inset ERT
5146 status collapsed
5147
5148 \begin_layout Standard
5149
5150
5151 \backslash
5152 /
5153 \end_layout
5154
5155 \end_inset
5156
5157 -version"
5158 \begin_inset LatexCommand \index{version}
5159
5160 \end_inset
5161
5162
5163 \family default
5164 \series default
5165  at the prompt, and the program should run and output its version like:
5166  
5167 \newline
5168
5169 \family typewriter
5170 SDCC : mcs51/z80/avr/ds390/pic16/pic14/ds400/hc08 2.5.6 #4169 (May 8 2006)
5171  (UNIX)
5172 \end_layout
5173
5174 \begin_layout Standard
5175 If it doesn't run, or gives a message about not finding sdcc program, then
5176  you need to check over your installation.
5177  Make sure that the sdcc bin directory is in your executable search path
5178  defined by the PATH environment setting (
5179 \series medium
5180 see 
5181 \series default
5182 section 
5183 \begin_inset LatexCommand \ref{sub:Install-Trouble-shooting}
5184
5185 \end_inset
5186
5187 \InsetSpace ~
5188
5189 \series medium
5190 Install trouble-shooting for suggestions
5191 \series default
5192 ).
5193  Make sure that the sdcc program is in the bin folder, if not perhaps something
5194  did not install correctly.
5195 \newline
5196
5197 \newline
5198
5199 \series medium
5200 SDCC 
5201 \series default
5202 is commonly installed as described in section 
5203 \begin_inset Quotes sld
5204 \end_inset
5205
5206 Install and search paths
5207 \begin_inset Quotes srd
5208 \end_inset
5209
5210 .
5211 \newline
5212
5213 \newline
5214
5215 \series medium
5216 Make sure the compiler works on a very simple example.
5217  Type in the following test.c program using your favorite 
5218 \series default
5219 ASCII 
5220 \series medium
5221 editor:
5222 \end_layout
5223
5224 \begin_layout Verse
5225
5226 \family typewriter
5227 char test;
5228 \newline
5229
5230 \newline
5231 void main(void) {
5232 \newline
5233 \InsetSpace ~
5234 \InsetSpace ~
5235 \InsetSpace ~
5236 \InsetSpace ~
5237 test=0;
5238 \newline
5239 }
5240 \end_layout
5241
5242 \begin_layout Standard
5243
5244 \series medium
5245 Compile this using the following command: 
5246 \family sans
5247 \series bold
5248 "sdcc -c test.c".
5249
5250 \family default
5251 \series default
5252  
5253 \series medium
5254 If all goes well, the compiler will generate a test.asm and test.rel file.
5255  Congratulations, you've just compiled your first program with SDCC.
5256  We used the -c option to tell SDCC not to link the generated code, just
5257  to keep things simple for this step.
5258 \series default
5259
5260 \newline
5261
5262 \newline
5263
5264 \series medium
5265 The next step is to try it with the linker.
5266  Type in 
5267 \family sans
5268 \series bold
5269 "sdcc test.c
5270 \family default
5271 \series default
5272 "
5273 \series medium
5274 .
5275  If all goes well the compiler will link with the libraries and produce
5276  a test.ihx output file.
5277  If this step fails
5278 \series default
5279  
5280 \series medium
5281 (no test.ihx, and the linker generates warnings), then the problem is most
5282  likely that 
5283 \series default
5284 SDCC
5285 \series medium
5286  cannot find the 
5287 \series default
5288 /
5289 \series medium
5290 usr/local/share/sdcc/lib directory
5291 \series default
5292  
5293 \series medium
5294 (see 
5295 \series default
5296 section 
5297 \begin_inset LatexCommand \ref{sub:Install-Trouble-shooting}
5298
5299 \end_inset
5300
5301 \InsetSpace ~
5302
5303 \series medium
5304 Install trouble-shooting for suggestions).
5305 \series default
5306
5307 \newline
5308
5309 \newline
5310
5311 \series medium
5312 The final test is to ensure 
5313 \series default
5314 SDCC
5315 \series medium
5316  can use the 
5317 \series default
5318 standard
5319 \series medium
5320  header files and libraries.
5321  Edit test.c and change it to the following:
5322 \end_layout
5323
5324 \begin_layout Verse
5325
5326 \family typewriter
5327 #include <string.h>
5328 \newline
5329
5330 \newline
5331 char str1[10];
5332 \newline
5333
5334 \newline
5335 void main(void) {
5336 \newline
5337 \InsetSpace ~
5338 \InsetSpace ~
5339 strcpy(str1, "testing");
5340 \newline
5341 }
5342 \end_layout
5343
5344 \begin_layout Standard
5345
5346 \series medium
5347 Compile this by typing 
5348 \family sans
5349 \series bold
5350 "sdcc test.c"
5351 \family default
5352 \series medium
5353 .
5354  This should generate a test.ihx output file, and it should give no warnings
5355  such as not finding the string.h file.
5356  If it cannot find the string.h file, then the problem is that 
5357 \series default
5358 SDCC
5359 \series medium
5360  cannot find the /usr/local/share/sdcc/include directory
5361 \series default
5362  
5363 \series medium
5364 (see the 
5365 \series default
5366 section 
5367 \begin_inset LatexCommand \ref{sub:Install-Trouble-shooting}
5368
5369 \end_inset
5370
5371 \InsetSpace ~
5372
5373 \series medium
5374 Install trouble-shooting section for suggestions).
5375
5376 \series default
5377  Use option 
5378 \series bold
5379 -
5380 \begin_inset ERT
5381 status collapsed
5382
5383 \begin_layout Standard
5384
5385
5386 \backslash
5387 /
5388 \end_layout
5389
5390 \end_inset
5391
5392 -print-search-dirs
5393 \series default
5394
5395 \begin_inset LatexCommand \index{-\/-print-search-dirs}
5396
5397 \end_inset
5398
5399  to find exactly where SDCC is looking for the include and lib files.
5400 \end_layout
5401
5402 \begin_layout Section
5403 Install Trouble-shooting
5404 \begin_inset LatexCommand \label{sub:Install-Trouble-shooting}
5405
5406 \end_inset
5407
5408
5409 \begin_inset LatexCommand \index{Install trouble-shooting}
5410
5411 \end_inset
5412
5413
5414 \end_layout
5415
5416 \begin_layout Subsection
5417 If SDCC does not build correctly
5418 \end_layout
5419
5420 \begin_layout Standard
5421 A thing to try is starting from scratch by unpacking the .tgz source package
5422  again in an empty directory.
5423  Configure it like:
5424 \newline
5425
5426 \newline
5427
5428 \family sans
5429 \series bold
5430 ./configure 2>&1 | tee configure.log
5431 \family default
5432 \series default
5433
5434 \newline
5435
5436 \newline
5437 and build it like:
5438 \newline
5439
5440 \newline
5441
5442 \family sans
5443 \series bold
5444 make 2>&1 | tee make.log
5445 \family default
5446 \series default
5447
5448 \newline
5449
5450 \newline
5451 If anything goes wrong, you can review the log files to locate the problem.
5452  Or a relevant part of this can be attached to an email that could be helpful
5453  when requesting help from the mailing list.
5454 \end_layout
5455
5456 \begin_layout Subsection
5457 What the 
5458 \begin_inset Quotes sld
5459 \end_inset
5460
5461 ./configure
5462 \begin_inset Quotes srd
5463 \end_inset
5464
5465  does
5466 \end_layout
5467
5468 \begin_layout Standard
5469 The 
5470 \begin_inset Quotes sld
5471 \end_inset
5472
5473 ./configure
5474 \begin_inset Quotes srd
5475 \end_inset
5476
5477  command is a script that analyzes your system and performs some configuration
5478  to ensure the source package compiles on your system.
5479  It will take a few minutes to run, and will compile a few tests to determine
5480  what compiler features are installed.
5481 \end_layout
5482
5483 \begin_layout Subsection
5484 What the 
5485 \begin_inset Quotes sld
5486 \end_inset
5487
5488 make
5489 \begin_inset Quotes srd
5490 \end_inset
5491
5492  does
5493 \end_layout
5494
5495 \begin_layout Standard
5496 This runs the GNU make tool, which automatically compiles all the source
5497  packages into the final installed binary executables.
5498 \end_layout
5499
5500 \begin_layout Subsection
5501 What the 
5502 \begin_inset Quotes sld
5503 \end_inset
5504
5505 make install
5506 \begin_inset Quotes erd
5507 \end_inset
5508
5509  command does.
5510 \end_layout
5511
5512 \begin_layout Standard
5513 This will install the compiler, other executables libraries and include
5514  files into the appropriate directories.
5515  See sections 
5516 \begin_inset LatexCommand \ref{sub:Install-paths}
5517
5518 \end_inset
5519
5520 ,\InsetSpace ~
5521
5522 \begin_inset LatexCommand \ref{sub:Search-Paths}
5523
5524 \end_inset
5525
5526 \InsetSpace ~
5527 about install and search paths.
5528 \newline
5529 On most systems you will need super-user privilege
5530 s to do this.
5531 \end_layout
5532
5533 \begin_layout Section
5534 Components of SDCC
5535 \end_layout
5536
5537 \begin_layout Standard
5538 SDCC is not just a compiler, but a collection of tools by various developers.
5539  These include linkers, assemblers, simulators and other components.
5540  Here is a summary of some of the components.
5541  Note that the included simulator and assembler have separate documentation
5542  which you can find in the source package in their respective directories.
5543  As SDCC grows to include support for other processors, other packages from
5544  various developers are included and may have their own sets of documentation.
5545 \newline
5546
5547 \newline
5548 You
5549  might want to look at the files which are installed in <installdir>.
5550  At the time of this writing, we find the following programs for gcc-builds:
5551 \newline
5552
5553  
5554 \newline
5555 In <installdir>/bin:
5556 \end_layout
5557
5558 \begin_layout Itemize
5559 sdcc - The compiler.
5560 \end_layout
5561
5562 \begin_layout Itemize
5563 sdcpp - The C preprocessor.
5564 \end_layout
5565
5566 \begin_layout Itemize
5567 asx8051 - The assembler for 8051 type processors.
5568 \end_layout
5569
5570 \begin_layout Itemize
5571 as-z80
5572 \series bold
5573
5574 \series default
5575 as-gbz80 - The Z80 and GameBoy Z80 assemblers.
5576 \end_layout
5577
5578 \begin_layout Itemize
5579 aslink -The linker for 8051 type processors.
5580 \end_layout
5581
5582 \begin_layout Itemize
5583 link-z80
5584 \series bold
5585
5586 \series default
5587 link-gbz80 - The Z80 and GameBoy Z80 linkers.
5588 \end_layout
5589
5590 \begin_layout Itemize
5591 s51 - The ucSim 8051 simulator.
5592 \end_layout
5593
5594 \begin_layout Itemize
5595 sdcdb - The source debugger.
5596 \end_layout
5597
5598 \begin_layout Itemize
5599 packihx - A tool to pack (compress) Intel hex files.
5600 \end_layout
5601
5602 \begin_layout Standard
5603 In <installdir>/share/sdcc/include
5604 \end_layout
5605
5606 \begin_layout Itemize
5607 the include files
5608 \end_layout
5609
5610 \begin_layout Standard
5611 In <installdir>/share/sdcc/lib
5612 \end_layout
5613
5614 \begin_layout Itemize
5615 the subdirs src and small, large, z80, gbz80 and ds390 with the precompiled
5616  relocatables.
5617 \end_layout
5618
5619 \begin_layout Standard
5620 In <installdir>/share/sdcc/doc
5621 \end_layout
5622
5623 \begin_layout Itemize
5624 the documentation
5625 \end_layout
5626
5627 \begin_layout Standard
5628 As development for other processors proceeds, this list will expand to include
5629  executables to support processors like AVR, PIC, etc.
5630 \end_layout
5631
5632 \begin_layout Subsection
5633 sdcc - The Compiler
5634 \end_layout
5635
5636 \begin_layout Standard
5637 This is the actual compiler, it in turn uses the c-preprocessor and invokes
5638  the assembler and linkage editor.
5639 \end_layout
5640
5641 \begin_layout Subsection
5642 sdcpp - The C-Preprocessor
5643 \end_layout
5644
5645 \begin_layout Standard
5646 The preprocessor
5647 \begin_inset LatexCommand \index{sdcpp (preprocessor)}
5648
5649 \end_inset
5650
5651  is a modified version of the GNU cpp
5652 \begin_inset LatexCommand \index{cpp|see{sdcpp}}
5653
5654 \end_inset
5655
5656  preprocessor 
5657 \begin_inset LatexCommand \url{http://gcc.gnu.org/}
5658
5659 \end_inset
5660
5661 .
5662  The C preprocessor is used to pull in #include sources, process #ifdef
5663  statements, #defines and so on.
5664 \end_layout
5665
5666 \begin_layout Subsection
5667 as
5668 \emph on
5669 xxxx
5670 \emph default
5671 , aslink, link-
5672 \emph on
5673 xxx
5674 \emph default
5675  - The Assemblers and Linkage Editors
5676 \end_layout
5677
5678 \begin_layout Standard
5679 This is retargettable assembler & linkage editor, it was developed by Alan
5680  Baldwin.
5681  John Hartman created the version for 8051, and I (Sandeep) have made some
5682  enhancements and bug fixes for it to work properly with SDCC.
5683 \end_layout
5684
5685 \begin_layout Subsection
5686 s51 - The Simulator
5687 \end_layout
5688
5689 \begin_layout Standard
5690 S51
5691 \begin_inset LatexCommand \index{s51}
5692
5693 \end_inset
5694
5695  is a free open source simulator developed by Daniel Drotos.
5696  The simulator is built as part of the build process.
5697  For more information visit Daniel's web site at: 
5698 \begin_inset LatexCommand \url{http://mazsola.iit.uni-miskolc.hu/~drdani/embedded/s51}
5699
5700 \end_inset
5701
5702 .
5703  It currently supports the core mcs51, the Dallas DS80C390 and the Phillips
5704  XA51 family.
5705 \end_layout
5706
5707 \begin_layout Subsection
5708 sdcdb - Source Level Debugger
5709 \end_layout
5710
5711 \begin_layout Standard
5712 SDCDB
5713 \begin_inset LatexCommand \index{SDCDB (debugger)}
5714
5715 \end_inset
5716
5717  is the companion source level debugger.
5718  More about SDCDB in section 
5719 \begin_inset LatexCommand \ref{cha:Debugging-with-SDCDB}
5720
5721 \end_inset
5722
5723 .
5724  The current version of the debugger uses Daniel's Simulator S51
5725 \begin_inset LatexCommand \index{s51}
5726
5727 \end_inset
5728
5729 , but can be easily changed to use other simulators.
5730 \end_layout
5731
5732 \begin_layout Chapter
5733 Using SDCC
5734 \end_layout
5735
5736 \begin_layout Section
5737 Compiling
5738 \end_layout
5739
5740 \begin_layout Subsection
5741 Single Source File Projects
5742 \end_layout
5743
5744 \begin_layout Standard
5745 For single source file 8051 projects the process is very simple.
5746  Compile your programs with the following command 
5747 \family sans
5748 \series bold
5749 "sdcc sourcefile.c".
5750
5751 \family default
5752 \series default
5753  This will compile, assemble and link your source file.
5754  Output files are as follows:
5755 \end_layout
5756
5757 \begin_layout Itemize
5758 sourcefile.asm
5759 \begin_inset LatexCommand \index{<file>.asm}
5760
5761 \end_inset
5762
5763  - Assembler source
5764 \begin_inset LatexCommand \index{Assembler source}
5765
5766 \end_inset
5767
5768  file created by the compiler
5769 \end_layout
5770
5771 \begin_layout Itemize
5772 sourcefile.lst
5773 \begin_inset LatexCommand \index{<file>.lst}
5774
5775 \end_inset
5776
5777  - Assembler listing
5778 \begin_inset LatexCommand \index{Assembler listing}
5779
5780 \end_inset
5781
5782  file created by the Assembler
5783 \end_layout
5784
5785 \begin_layout Itemize
5786 sourcefile.rst
5787 \begin_inset LatexCommand \index{<file>.rst}
5788
5789 \end_inset
5790
5791  - Assembler listing
5792 \begin_inset LatexCommand \index{Assembler listing}
5793
5794 \end_inset
5795
5796  file updated with linkedit information, created by linkage editor
5797 \end_layout
5798
5799 \begin_layout Itemize
5800 sourcefile.sym
5801 \begin_inset LatexCommand \index{<file>.sym}
5802
5803 \end_inset
5804
5805  - symbol listing
5806 \begin_inset LatexCommand \index{Symbol listing}
5807
5808 \end_inset
5809
5810  for the sourcefile, created by the assembler
5811 \end_layout
5812
5813 \begin_layout Itemize
5814 sourcefile.rel
5815 \begin_inset LatexCommand \index{<file>.rel}
5816
5817 \end_inset
5818
5819  or sourcefile.o
5820 \begin_inset LatexCommand \index{<file>.o}
5821
5822 \end_inset
5823
5824  - Object file
5825 \begin_inset LatexCommand \index{Object file}
5826
5827 \end_inset
5828
5829  created by the assembler, input to Linkage editor
5830 \end_layout
5831
5832 \begin_layout Itemize
5833 sourcefile.map
5834 \begin_inset LatexCommand \index{<file>.map}
5835
5836 \end_inset
5837
5838  - The memory map
5839 \begin_inset LatexCommand \index{Memory map}
5840
5841 \end_inset
5842
5843  for the load module, created by the Linker
5844 \end_layout
5845
5846 \begin_layout Itemize
5847 sourcefile.mem
5848 \begin_inset LatexCommand \index{<file>.mem}
5849
5850 \end_inset
5851
5852  - A file with a summary of the memory usage
5853 \end_layout
5854
5855 \begin_layout Itemize
5856 sourcefile.ihx
5857 \begin_inset LatexCommand \index{<file>.ihx}
5858
5859 \end_inset
5860
5861  - The load module in Intel hex format
5862 \begin_inset LatexCommand \index{Intel hex format}
5863
5864 \end_inset
5865
5866  (you can select the Motorola S19 format
5867 \begin_inset LatexCommand \index{Motorola S19 format}
5868
5869 \end_inset
5870
5871  with -
5872 \begin_inset ERT
5873 status collapsed
5874
5875 \begin_layout Standard
5876
5877
5878 \backslash
5879 /
5880 \end_layout
5881
5882 \end_inset
5883
5884 -out-fmt-s19
5885 \begin_inset LatexCommand \index{-\/-out-fmt-s19}
5886
5887 \end_inset
5888
5889 .
5890  If you need another format you might want to use 
5891 \family sans
5892 \shape italic
5893 objdump
5894 \family default
5895 \shape default
5896
5897 \begin_inset LatexCommand \index{objdump (tool)}
5898
5899 \end_inset
5900
5901  or
5902 \family sans
5903 \shape italic
5904  srecord
5905 \family default
5906 \shape default
5907
5908 \begin_inset LatexCommand \index{srecord (bin, hex, ... tool)}
5909
5910 \end_inset
5911
5912
5913 \begin_inset Note Note
5914 status collapsed
5915
5916 \begin_layout Standard
5917 hyperlinks needed
5918 \end_layout
5919
5920 \end_inset
5921
5922  - see also section 
5923 \begin_inset LatexCommand \vref{sub:Postprocessing-the-Intel}
5924
5925 \end_inset
5926
5927 ).
5928  Both formats are documented in the documentation of srecord
5929 \begin_inset LatexCommand \index{srecord (bin, hex, ... tool)}
5930
5931 \end_inset
5932
5933
5934 \end_layout
5935
5936 \begin_layout Itemize
5937 sourcefile.adb
5938 \begin_inset LatexCommand \index{<file>.adb}
5939
5940 \end_inset
5941
5942  - An intermediate file containing debug information needed to create the
5943  .cdb file (with -
5944 \begin_inset ERT
5945 status collapsed
5946
5947 \begin_layout Standard
5948
5949
5950 \backslash
5951 /
5952 \end_layout
5953
5954 \end_inset
5955
5956 -debug
5957 \begin_inset LatexCommand \index{-\/-debug}
5958
5959 \end_inset
5960
5961
5962 \end_layout
5963
5964 \begin_layout Itemize
5965 sourcefile.cdb
5966 \begin_inset LatexCommand \index{<file>.cdb}
5967
5968 \end_inset
5969
5970  - An optional file (with -
5971 \begin_inset ERT
5972 status collapsed
5973
5974 \begin_layout Standard
5975
5976
5977 \backslash
5978 /
5979 \end_layout
5980
5981 \end_inset
5982
5983 -debug) containing debug information.
5984  The format is documented in cdbfileformat.pdf
5985 \end_layout
5986
5987 \begin_layout Itemize
5988 sourcefile.
5989  - (no extension)
5990 \begin_inset LatexCommand \index{<file> (no extension)}
5991
5992 \end_inset
5993
5994  An optional AOMF or AOMF51
5995 \begin_inset LatexCommand \index{AOMF, AOMF51}
5996
5997 \end_inset
5998
5999  
6000 \begin_inset LatexCommand \label{OMF file}
6001
6002 \end_inset
6003
6004 file containing debug information (generated with option -
6005 \begin_inset ERT
6006 status collapsed
6007
6008 \begin_layout Standard
6009
6010
6011 \backslash
6012 /
6013 \end_layout
6014
6015 \end_inset
6016
6017 -debug).
6018  The (Intel)
6019 \emph on
6020  a
6021 \emph default
6022 bsolute 
6023 \emph on
6024 o
6025 \emph default
6026 bject 
6027 \emph on
6028 m
6029 \emph default
6030 odule 
6031 \emph on
6032 f
6033 \emph default
6034 ormat is a subformat of the OMF51 format and is commonly used by third party
6035  tools (debuggers
6036 \begin_inset LatexCommand \index{Debugger}
6037
6038 \end_inset
6039
6040 , simulators, emulators).
6041 \end_layout
6042
6043 \begin_layout Itemize
6044 sourcefile.dump*
6045 \begin_inset LatexCommand \index{<file>.dump*}
6046
6047 \end_inset
6048
6049  - Dump file to debug the compiler it self (generated with option -
6050 \begin_inset ERT
6051 status collapsed
6052
6053 \begin_layout Standard
6054
6055
6056 \backslash
6057 /
6058 \end_layout
6059
6060 \end_inset
6061
6062 -dumpall) (see section 
6063 \begin_inset LatexCommand \ref{sub:Intermediate-Dump-Options}
6064
6065 \end_inset
6066
6067 \InsetSpace ~
6068  and section 
6069 \begin_inset LatexCommand \ref{sub:The-anatomy-of}
6070
6071 \end_inset
6072
6073 \InsetSpace ~
6074
6075 \begin_inset Quotes sld
6076 \end_inset
6077
6078 Anatomy of the compiler
6079 \begin_inset Quotes srd
6080 \end_inset
6081
6082 ).
6083 \end_layout
6084
6085 \begin_layout Subsection
6086 Postprocessing the Intel Hex
6087 \begin_inset LatexCommand \index{Intel hex format}
6088
6089 \end_inset
6090
6091  file
6092 \begin_inset LatexCommand \label{sub:Postprocessing-the-Intel}
6093
6094 \end_inset
6095
6096
6097 \end_layout
6098
6099 \begin_layout Standard
6100 In most cases this won't be needed but the Intel Hex file
6101 \begin_inset LatexCommand \index{<file>.ihx}
6102
6103 \end_inset
6104
6105  which is generated by SDCC might include lines of varying length and the
6106  addresses within the file are not guaranteed to be strictly ascending.
6107  If your toolchain or a bootloader does not like this you can use the tool
6108  
6109 \family typewriter
6110 packihx
6111 \family default
6112
6113 \begin_inset LatexCommand \index{packihx (tool)}
6114
6115 \end_inset
6116
6117  which is part of the SDCC distribution: 
6118 \newline
6119
6120 \newline
6121
6122 \family sans
6123 \series bold
6124  packihx sourcefile.ihx >sourcefile.hex
6125 \family default
6126 \series default
6127
6128 \newline
6129
6130 \newline
6131 The separately available
6132 \emph on
6133  srecord
6134 \emph default
6135
6136 \begin_inset LatexCommand \index{srecord (bin, hex, ... tool)}
6137
6138 \end_inset
6139
6140  package additionally allows to set undefined locations to a predefined
6141  value, to insert checksums
6142 \begin_inset LatexCommand \index{checksum}
6143
6144 \end_inset
6145
6146  of various flavours (crc, add, xor) and to perform other manipulations
6147  (convert, split, crop, offset, ...).
6148  
6149 \newline
6150
6151 \newline
6152
6153 \family sans
6154 \series bold
6155 srec_cat\InsetSpace ~
6156 \InsetSpace ~
6157 sourcefile.ihx -intel\InsetSpace ~
6158 \InsetSpace ~
6159 -o sourcefile.hex -intel
6160 \newline
6161
6162 \newline
6163
6164 \family default
6165 \series default
6166 An example for a more complex command line
6167 \begin_inset Foot
6168 status open
6169
6170 \begin_layout Standard
6171 the command backfills
6172 \begin_inset LatexCommand \index{backfill unused memory}
6173
6174 \end_inset
6175
6176  unused memory with 0x12 and the overall 16 bit sum of the complete 64 kByte
6177  block is zero.
6178  If the program counter on an mcs51 runs wild the backfill pattern 0x12
6179  will be interpreted as an 
6180 \family typewriter
6181 lcall
6182 \family default
6183  to address 
6184 \family typewriter
6185 0x1212
6186 \family default
6187  (where an emergency routine could sit).
6188 \end_layout
6189
6190 \end_inset
6191
6192  could look like:
6193 \newline
6194
6195 \newline
6196
6197 \family sans
6198 \series bold
6199 \size footnotesize
6200 srec_cat\InsetSpace ~
6201 sourcefile.ihx -intel\InsetSpace ~
6202 \InsetSpace ~
6203 -fill 0x12 0x0000 0xfffe\InsetSpace ~
6204 -little-endian-checksum-nega
6205 tive 0xfffe 0x02 0x02\InsetSpace ~
6206 \InsetSpace ~
6207 -o sourcefile.hex -intel
6208 \size default
6209
6210 \newline
6211
6212 \newline
6213
6214 \family default
6215 \series default
6216 The srecord package is available at 
6217 \begin_inset LatexCommand \url{http://sf.net/projects/srecord}
6218
6219 \end_inset
6220
6221  .
6222 \end_layout
6223
6224 \begin_layout Subsection
6225 Projects with Multiple Source Files
6226 \end_layout
6227
6228 \begin_layout Standard
6229 SDCC can compile only ONE file at a time.
6230  Let us for example assume that you have a project containing the following
6231  files:
6232 \newline
6233
6234 \newline
6235 foo1.c (contains some functions)
6236 \newline
6237 foo2.c (contains some more functions)
6238 \newline
6239 foomai
6240 n.c (contains more functions and the function main)
6241 \newline
6242
6243 \size footnotesize
6244
6245 \newline
6246
6247 \size default
6248 The first two files will need to be compiled separately with the commands:
6249 \size footnotesize
6250  
6251 \size default
6252
6253 \newline
6254
6255 \newline
6256
6257 \family sans
6258 \series bold
6259 sdcc\InsetSpace ~
6260 -c\InsetSpace ~
6261 foo1.c
6262 \family default
6263 \series default
6264 \size footnotesize
6265
6266 \newline
6267
6268 \family sans
6269 \series bold
6270 \size default
6271 sdcc\InsetSpace ~
6272 -c\InsetSpace ~
6273 foo2.c
6274 \family default
6275 \series default
6276
6277 \newline
6278
6279 \newline
6280 Then compile the source file containing the 
6281 \emph on
6282 main()
6283 \emph default
6284  function and link
6285 \begin_inset LatexCommand \index{Linker}
6286
6287 \end_inset
6288
6289  the files together with the following command: 
6290 \newline
6291
6292 \newline
6293
6294 \family sans
6295 \series bold
6296 sdcc\InsetSpace ~
6297 foomain.c\InsetSpace ~
6298 foo1.rel\InsetSpace ~
6299 foo2.rel
6300 \family default
6301 \series default
6302
6303 \begin_inset LatexCommand \index{<file>.rel}
6304
6305 \end_inset
6306
6307
6308 \newline
6309
6310 \newline
6311 Alternatively, 
6312 \emph on
6313 foomain.c 
6314 \emph default
6315 can be separately compiled as well: 
6316 \family sans
6317 \series bold
6318
6319 \newline
6320
6321 \newline
6322 sdcc\InsetSpace ~
6323 -c\InsetSpace ~
6324 foomain.c
6325 \newline
6326 sdcc foomain.rel foo1.rel foo2.rel
6327 \newline
6328
6329 \newline
6330
6331 \family default
6332 \series default
6333 The file containing the 
6334 \emph on
6335 main()
6336 \emph default
6337  function
6338 \emph on
6339  
6340 \emph default
6341 \noun on
6342 must
6343 \noun default
6344  be the 
6345 \noun on
6346 first
6347 \noun default
6348  file specified in the command line, since the linkage editor processes
6349  file in the order they are presented to it.
6350  The linker is invoked from SDCC using a script file with extension .lnk
6351 \begin_inset LatexCommand \index{<file>.lnk}
6352
6353 \end_inset
6354
6355 .
6356  You can view this file to troubleshoot linking problems such as those arising
6357  from missing libraries.
6358 \end_layout
6359
6360 \begin_layout Subsection
6361 Projects with Additional Libraries
6362 \begin_inset LatexCommand \index{Libraries}
6363
6364 \end_inset
6365
6366
6367 \end_layout
6368
6369 \begin_layout Standard
6370 Some reusable routines may be compiled into a library, see the documentation
6371  for the assembler and linkage editor (which are in <installdir>/share/sdcc/doc)
6372  for how to create a 
6373 \emph on
6374 .lib
6375 \begin_inset LatexCommand \index{<file>.lib}
6376
6377 \end_inset
6378
6379
6380 \emph default
6381  library file.
6382  Libraries created in this manner can be included in the command line.
6383  Make sure you include the -L <library-path> option to tell the linker where
6384  to look for these files if they are not in the current directory.
6385  Here is an example, assuming you have the source file 
6386 \emph on
6387 foomain.c
6388 \emph default
6389  and a library
6390 \emph on
6391  foolib.lib
6392 \emph default
6393  in the directory 
6394 \emph on
6395 mylib
6396 \emph default
6397  (if that is not the same as your current project):
6398 \newline
6399
6400 \newline
6401
6402 \family sans
6403 \series bold
6404 sdcc foomain.c foolib.lib -L mylib
6405 \newline
6406
6407 \newline
6408
6409 \family default
6410 \series default
6411 Note here that
6412 \emph on
6413  mylib
6414 \emph default
6415  must be an absolute path name.
6416 \newline
6417
6418 \newline
6419 The most efficient way to use libraries is
6420  to keep separate modules in separate source files.
6421  The lib file now should name all the modules.rel
6422 \begin_inset LatexCommand \index{<file>.rel}
6423
6424 \end_inset
6425
6426  files.
6427  For an example see the standard library file 
6428 \emph on
6429 libsdcc.lib
6430 \emph default
6431  in the directory <installdir>/share/lib/small.
6432 \end_layout
6433
6434 \begin_layout Subsection
6435 Using sdcclib to Create and Manage Libraries
6436 \begin_inset LatexCommand \index{sdcclib}
6437
6438 \end_inset
6439
6440
6441 \end_layout
6442
6443 \begin_layout Standard
6444 Alternatively, instead of having a .rel file for each entry on the library
6445  file as described in the preceding section, sdcclib can be used to embed
6446  all the modules belonging to such library in the library file itself.
6447  This results in a larger library file, but it greatly reduces the number
6448  of disk files accessed by the linker.
6449   Additionally, the packed library file contains an index of all include
6450  modules and symbols that significantly speeds up the linking process.
6451  To display a list of options supported by sdcclib type:
6452 \newline
6453
6454 \end_layout
6455
6456 \begin_layout Standard
6457
6458 \family sans
6459 \series bold
6460 sdcclib -?
6461 \begin_inset LatexCommand \index{sdcclib}
6462
6463 \end_inset
6464
6465
6466 \newline
6467
6468 \newline
6469
6470 \family default
6471 \series default
6472 To create a new library file, start by compiling all the required modules.
6473  For example:
6474 \newline
6475
6476 \end_layout
6477
6478 \begin_layout Standard
6479
6480 \family sans
6481 \series bold
6482 sdcc -c _divsint.c
6483 \end_layout
6484
6485 \begin_layout Standard
6486
6487 \family sans
6488 \series bold
6489 sdcc -c _divuint.c
6490 \end_layout
6491
6492 \begin_layout Standard
6493
6494 \family sans
6495 \series bold
6496 sdcc -c _modsint.c
6497 \end_layout
6498
6499 \begin_layout Standard
6500
6501 \family sans
6502 \series bold
6503 sdcc -c _moduint.c
6504 \end_layout
6505
6506 \begin_layout Standard
6507
6508 \family sans
6509 \series bold
6510 sdcc -c _mulint.c
6511 \newline
6512
6513 \end_layout
6514
6515 \begin_layout Standard
6516 This will create files _divsint.rel, _divuint.rel, _modsint.rel, _moduint.rel,
6517  and _mulint.rel.
6518  The next step is to add the .rel files to the library file:
6519 \newline
6520
6521 \end_layout
6522
6523 \begin_layout Standard
6524
6525 \family sans
6526 \series bold
6527 sdcclib libint.lib _divsint.rel
6528 \family default
6529
6530 \begin_inset LatexCommand \index{sdcclib}
6531
6532 \end_inset
6533
6534
6535 \end_layout
6536
6537 \begin_layout Standard
6538
6539 \family sans
6540 \series bold
6541 sdcclib libint.lib _divuint.rel
6542 \end_layout
6543
6544 \begin_layout Standard
6545
6546 \family sans
6547 \series bold
6548 sdcclib libint.lib _modsint.rel
6549 \end_layout
6550
6551 \begin_layout Standard
6552
6553 \family sans
6554 \series bold
6555 sdcclib libint.lib _moduint.rel
6556 \end_layout
6557
6558 \begin_layout Standard
6559
6560 \family sans
6561 \series bold
6562 sdcclib libint.lib _mulint.rel
6563 \family default
6564 \series default
6565
6566 \newline
6567
6568 \end_layout
6569
6570 \begin_layout Standard
6571 Or, if you preffer:
6572 \family sans
6573 \series bold
6574
6575 \newline
6576
6577 \end_layout
6578
6579 \begin_layout Standard
6580
6581 \family sans
6582 \series bold
6583 sdcclib libint.lib _divsint.rel _divuint.rel _modsint.rel _moduint.rel _mulint.rel
6584 \family default
6585 \series default
6586
6587 \newline
6588
6589 \end_layout
6590
6591 \begin_layout Standard
6592 If the file already exists in the library, it will be replaced.
6593  If a list of .rel files is available, you can tell sdcclib to add those
6594  files to a library.
6595  For example, if the file 'myliblist.txt' contains
6596 \family sans
6597 \series bold
6598
6599 \newline
6600
6601 \end_layout
6602
6603 \begin_layout Standard
6604
6605 \family sans
6606 \series bold
6607 _divsint.rel
6608 \end_layout
6609
6610 \begin_layout Standard
6611
6612 \family sans
6613 \series bold
6614 _divuint.rel
6615 \end_layout
6616
6617 \begin_layout Standard
6618
6619 \family sans
6620 \series bold
6621 _modsint.rel
6622 \end_layout
6623
6624 \begin_layout Standard
6625
6626 \family sans
6627 \series bold
6628 _moduint.rel
6629 \end_layout
6630
6631 \begin_layout Standard
6632
6633 \family sans
6634 \series bold
6635 _mulint.rel
6636 \family default
6637 \series default
6638
6639 \newline
6640
6641 \end_layout
6642
6643 \begin_layout Standard
6644 Use
6645 \family sans
6646 \series bold
6647
6648 \newline
6649
6650 \end_layout
6651
6652 \begin_layout Standard
6653
6654 \family sans
6655 \series bold
6656 sdcclib -l libint.lib myliblist.txt
6657 \family default
6658 \series default
6659
6660 \newline
6661
6662 \end_layout
6663
6664 \begin_layout Standard
6665 Additionally, you can instruct sdcclib to compiles the files before adding
6666  them to the library.
6667  This is achieved using the environment variables SDCCLIB_CC and/or SDCCLIB_AS.
6668  For example:
6669 \family sans
6670 \series bold
6671
6672 \newline
6673
6674 \end_layout
6675
6676 \begin_layout Standard
6677
6678 \family sans
6679 \series bold
6680 set SDCCLIB_CC=sdcc -c
6681 \end_layout
6682
6683 \begin_layout Standard
6684
6685 \family sans
6686 \series bold
6687 sdcclib -l libint.lib myliblist.txt
6688 \family default
6689 \series default
6690
6691 \newline
6692
6693 \end_layout
6694
6695 \begin_layout Standard
6696 To see what modules and symbols are included in the library, options -s
6697  and -m are available.
6698  For example:
6699 \newline
6700
6701 \newline
6702
6703 \family sans
6704 \series bold
6705 sdcclib -s libint.lib
6706 \family default
6707
6708 \begin_inset LatexCommand \index{sdcclib}
6709
6710 \end_inset
6711
6712
6713 \newline
6714
6715 \family typewriter
6716 \series default
6717 _divsint.rel:
6718 \end_layout
6719
6720 \begin_layout Standard
6721
6722 \family typewriter
6723 __divsint_a_1_1
6724 \end_layout
6725
6726 \begin_layout Standard
6727
6728 \family typewriter
6729 __divsint_PARM_2
6730 \end_layout
6731
6732 \begin_layout Standard
6733
6734 \family typewriter
6735 __divsint
6736 \newline
6737 _divuint.rel:
6738 \end_layout
6739
6740 \begin_layout Standard
6741
6742 \family typewriter
6743 __divuint_a_1_1
6744 \end_layout
6745
6746 \begin_layout Standard
6747
6748 \family typewriter
6749 __divuint_PARM_2
6750 \end_layout
6751
6752 \begin_layout Standard
6753
6754 \family typewriter
6755 __divuint_reste_1_1
6756 \end_layout
6757
6758 \begin_layout Standard
6759
6760 \family typewriter
6761 __divuint_count_1_1
6762 \end_layout
6763
6764 \begin_layout Standard
6765
6766 \family typewriter
6767 __divuint
6768 \newline
6769 _modsint.rel:
6770 \end_layout
6771
6772 \begin_layout Standard
6773
6774 \family typewriter
6775 __modsint_a_1_1
6776 \end_layout
6777
6778 \begin_layout Standard
6779
6780 \family typewriter
6781 __modsint_PARM_2
6782 \end_layout
6783
6784 \begin_layout Standard
6785
6786 \family typewriter
6787 __modsint
6788 \newline
6789 _moduint.rel:
6790 \end_layout
6791
6792 \begin_layout Standard
6793
6794 \family typewriter
6795 __moduint_a_1_1
6796 \end_layout
6797
6798 \begin_layout Standard
6799
6800 \family typewriter
6801 __moduint_PARM_2
6802 \end_layout
6803
6804 \begin_layout Standard
6805
6806 \family typewriter
6807 __moduint_count_1_1
6808 \end_layout
6809
6810 \begin_layout Standard
6811
6812 \family typewriter
6813 __moduint
6814 \newline
6815 _mulint.rel:
6816 \end_layout
6817
6818 \begin_layout Standard
6819
6820 \family typewriter
6821 __mulint_PARM_2
6822 \end_layout
6823
6824 \begin_layout Standard
6825
6826 \family typewriter
6827 __mulint
6828 \family default
6829 \series bold
6830
6831 \newline
6832
6833 \end_layout
6834
6835 \begin_layout Standard
6836 If the source files are compiled using -
6837 \begin_inset ERT
6838 status collapsed
6839
6840 \begin_layout Standard
6841
6842
6843 \backslash
6844 /
6845 \end_layout
6846
6847 \end_inset
6848
6849 -debug
6850 \begin_inset LatexCommand \index{-\/-debug}
6851
6852 \end_inset
6853
6854 , the corresponding debug information file .adb will be include in the library
6855  file as well.
6856  The library files created with sdcclib are plain text files, so they can
6857  be viewed with a text editor.
6858  It is not recomended to modify a library file created with sdcclib using
6859  a text editor, as there are file indexes numbers located accross the file
6860  used by the linker to quickly locate the required module to link.
6861  Once a .rel file (as well as a .adb file) is added to a library using sdcclib,
6862  it can be safely deleted, since all the information required for linking
6863  is embedded in the library file itself.
6864  Library files created using sdcclib are used as described in the preceding
6865  sections.
6866 \begin_inset VSpace bigskip
6867 \end_inset
6868
6869
6870 \end_layout
6871
6872 \begin_layout Section
6873 Command Line Options
6874 \begin_inset LatexCommand \index{Command Line Options}
6875
6876 \end_inset
6877
6878
6879 \begin_inset LatexCommand \label{sec:Command-Line-Options}
6880
6881 \end_inset
6882
6883
6884 \end_layout
6885
6886 \begin_layout Subsection
6887 Processor Selection Options
6888 \begin_inset LatexCommand \index{Options processor selection}
6889
6890 \end_inset
6891
6892
6893 \begin_inset LatexCommand \index{Processor selection options}
6894
6895 \end_inset
6896
6897
6898 \end_layout
6899
6900 \begin_layout List
6901 \labelwidthstring 00.00.0000
6902
6903 \series bold
6904 -mmcs51
6905 \begin_inset LatexCommand \index{-mmcs51}
6906
6907 \end_inset
6908
6909
6910 \series default
6911  Generate code for the Intel MCS51
6912 \begin_inset LatexCommand \index{MCS51}
6913
6914 \end_inset
6915
6916  family of processors.
6917  This is the default processor target.
6918 \end_layout
6919
6920 \begin_layout List
6921 \labelwidthstring 00.00.0000
6922
6923 \series bold
6924 -mds390
6925 \begin_inset LatexCommand \index{-mds390}
6926
6927 \end_inset
6928
6929
6930 \series default
6931  Generate code for the Dallas DS80C390
6932 \begin_inset LatexCommand \index{DS80C390}
6933
6934 \end_inset
6935
6936  processor.
6937 \end_layout
6938
6939 \begin_layout List
6940 \labelwidthstring 00.00.0000
6941
6942 \series bold
6943 -mds400
6944 \begin_inset LatexCommand \index{-mds400}
6945
6946 \end_inset
6947
6948
6949 \series default
6950  Generate code for the Dallas DS80C400
6951 \begin_inset LatexCommand \index{DS80C400}
6952
6953 \end_inset
6954
6955  processor.
6956 \end_layout
6957
6958 \begin_layout List
6959 \labelwidthstring 00.00.0000
6960
6961 \series bold
6962 -mhc08
6963 \begin_inset LatexCommand \index{-mhc08}
6964
6965 \end_inset
6966
6967
6968 \series default
6969  Generate code for the Freescale/Motorola HC08
6970 \begin_inset LatexCommand \index{HC08}
6971
6972 \end_inset
6973
6974  family of processors.
6975 \end_layout
6976
6977 \begin_layout List
6978 \labelwidthstring 00.00.0000
6979
6980 \series bold
6981 -mz80
6982 \begin_inset LatexCommand \index{-mz80}
6983
6984 \end_inset
6985
6986
6987 \series default
6988  Generate code for the Zilog Z80
6989 \begin_inset LatexCommand \index{Z80}
6990
6991 \end_inset
6992
6993  family of processors.
6994 \end_layout
6995
6996 \begin_layout List
6997 \labelwidthstring 00.00.0000
6998
6999 \series bold
7000 -mgbz80
7001 \begin_inset LatexCommand \index{-mgbz80}
7002
7003 \end_inset
7004
7005
7006 \series default
7007  Generate code for the GameBoy Z80
7008 \begin_inset LatexCommand \index{gbz80 (GameBoy Z80)}
7009
7010 \end_inset
7011
7012  processor (Not actively maintained).
7013 \end_layout
7014
7015 \begin_layout List
7016 \labelwidthstring 00.00.0000
7017
7018 \series bold
7019 -mavr
7020 \begin_inset LatexCommand \index{-mavr}
7021
7022 \end_inset
7023
7024
7025 \series default
7026  Generate code for the Atmel AVR
7027 \begin_inset LatexCommand \index{AVR}
7028
7029 \end_inset
7030
7031  processor (Not maintained, not complete).
7032  AVR users should probably have a look at winavr 
7033 \begin_inset LatexCommand \url{http://sourceforge.net/projects/winavr}
7034
7035 \end_inset
7036
7037  or 
7038 \begin_inset LatexCommand \url{http://www.avrfreaks.net/index.php?name=PNphpBB2&file=index}
7039
7040 \end_inset
7041
7042 , which is based on AVR-port of the gcc compiler.
7043 \end_layout
7044
7045 \begin_layout Standard
7046 \begin_inset Note Note
7047 status collapsed
7048
7049 \begin_layout Standard
7050 I think it is fair to direct users there for now.
7051  Open source is also about avoiding unnecessary work .
7052  But I didn't find the 'official' link.
7053 \end_layout
7054
7055 \end_inset
7056
7057
7058 \end_layout
7059
7060 \begin_layout List
7061 \labelwidthstring 00.00.0000
7062
7063 \series bold
7064 -mpic14
7065 \begin_inset LatexCommand \index{-mpic14}
7066
7067 \end_inset
7068
7069
7070 \series default
7071  Generate code for the Microchip PIC 14
7072 \begin_inset LatexCommand \index{PIC14}
7073
7074 \end_inset
7075
7076 -bit processors (p16f84 and variants.
7077  In development, not complete).
7078 \end_layout
7079
7080 \begin_layout Standard
7081 \begin_inset Note Note
7082 status collapsed
7083
7084 \begin_layout Standard
7085 p16f627 p16f628 p16f84 p16f873 p16f877?
7086 \end_layout
7087
7088 \end_inset
7089
7090
7091 \end_layout
7092
7093 \begin_layout List
7094 \labelwidthstring 00.00.0000
7095
7096 \series bold
7097 -mpic16
7098 \begin_inset LatexCommand \index{-mpic16}
7099
7100 \end_inset
7101
7102
7103 \series default
7104  Generate code for the Microchip PIC 16
7105 \begin_inset LatexCommand \index{PIC16}
7106
7107 \end_inset
7108
7109 -bit processors (p18f452 and variants.
7110  In development, not complete).
7111 \end_layout
7112
7113 \begin_layout List
7114 \labelwidthstring 00.00.0000
7115
7116 \series bold
7117 -mtlcs900h
7118 \series default
7119  Generate code for the Toshiba TLCS-900H
7120 \begin_inset LatexCommand \index{TLCS-900H}
7121
7122 \end_inset
7123
7124  processor (Not maintained, not complete).
7125 \end_layout
7126
7127 \begin_layout List
7128 \labelwidthstring 00.00.0000
7129
7130 \series bold
7131 -mxa51
7132 \begin_inset LatexCommand \index{-mxa51}
7133
7134 \end_inset
7135
7136
7137 \series default
7138  Generate code for the Phillips XA51
7139 \begin_inset LatexCommand \index{XA51}
7140
7141 \end_inset
7142
7143  processor (Not maintained, not complete).
7144 \end_layout
7145
7146 \begin_layout Standard
7147 \begin_inset VSpace bigskip
7148 \end_inset
7149
7150
7151 \end_layout
7152
7153 \begin_layout Subsection
7154 Preprocessor Options
7155 \begin_inset LatexCommand \index{Options preprocessor}
7156
7157 \end_inset
7158
7159
7160 \begin_inset LatexCommand \index{Preprocessor options}
7161
7162 \end_inset
7163
7164
7165 \begin_inset LatexCommand \index{sdcpp (preprocessor)}
7166
7167 \end_inset
7168
7169
7170 \end_layout
7171
7172 \begin_layout List
7173 \labelwidthstring 00.00.0000
7174
7175 \series bold
7176 -I<path>
7177 \begin_inset LatexCommand \index{-I<path>}
7178
7179 \end_inset
7180
7181
7182 \series default
7183  The additional location where the preprocessor will look for <..h> or 
7184 \begin_inset Quotes eld
7185 \end_inset
7186
7187 ..h
7188 \begin_inset Quotes erd
7189 \end_inset
7190
7191  files.
7192 \end_layout
7193
7194 \begin_layout List
7195 \labelwidthstring 00.00.0000
7196
7197 \series bold
7198 -D<macro[=value]>
7199 \begin_inset LatexCommand \index{-D<macro[=value]>}
7200
7201 \end_inset
7202
7203
7204 \series default
7205  Command line definition of macros.
7206  Passed to the preprocessor.
7207 \end_layout
7208
7209 \begin_layout List
7210 \labelwidthstring 00.00.0000
7211
7212 \series bold
7213 -M
7214 \begin_inset LatexCommand \index{-M}
7215
7216 \end_inset
7217
7218
7219 \series default
7220  Tell the preprocessor to output a rule suitable for make describing the
7221  dependencies of each object file.
7222  For each source file, the preprocessor outputs one make-rule whose target
7223  is the object file name for that source file and whose dependencies are
7224  all the files `#include'd in it.
7225  This rule may be a single line or may be continued with `
7226 \backslash
7227 '-newline if it is long.
7228  The list of rules is printed on standard output instead of the preprocessed
7229  C program.
7230  `-M' implies `-E
7231 \begin_inset LatexCommand \index{-E}
7232
7233 \end_inset
7234
7235 '.
7236 \end_layout
7237
7238 \begin_layout List
7239 \labelwidthstring 00.00.0000
7240
7241 \series bold
7242 -C
7243 \begin_inset LatexCommand \index{-C}
7244
7245 \end_inset
7246
7247
7248 \series default
7249  Tell the preprocessor not to discard comments.
7250  Used with the `-E' option.
7251 \end_layout
7252
7253 \begin_layout List
7254 \labelwidthstring 00.00.0000
7255
7256 \series bold
7257 -MM
7258 \begin_inset LatexCommand \index{-MM}
7259
7260 \end_inset
7261
7262
7263 \size large
7264 \bar under
7265  
7266 \series default
7267 \size default
7268 \bar default
7269 Like `-M' but the output mentions only the user header files included with
7270  `#include 
7271 \begin_inset Quotes eld
7272 \end_inset
7273
7274 file"'.
7275  System header files included with `#include <file>' are omitted.
7276 \end_layout
7277
7278 \begin_layout List
7279 \labelwidthstring 00.00.0000
7280
7281 \series bold
7282 -Aquestion(answer)
7283 \begin_inset LatexCommand \index{-Aquestion(answer)}
7284
7285 \end_inset
7286
7287
7288 \series default
7289  Assert the answer answer for question, in case it is tested with a preprocessor
7290  conditional such as `#if #question(answer)'.
7291  `-A-' disables the standard assertions that normally describe the target
7292  machine.
7293 \end_layout
7294
7295 \begin_layout List
7296 \labelwidthstring 00.00.0000
7297
7298 \series bold
7299 -Umacro
7300 \begin_inset LatexCommand \index{-Umacro}
7301
7302 \end_inset
7303
7304
7305 \series default
7306  Undefine macro macro.
7307  `-U' options are evaluated after all `-D' options, but before any `-include'
7308  and `-imacros' options.
7309 \end_layout
7310
7311 \begin_layout List
7312 \labelwidthstring 00.00.0000
7313
7314 \series bold
7315 -dM
7316 \begin_inset LatexCommand \index{-dM}
7317
7318 \end_inset
7319
7320
7321 \series default
7322  Tell the preprocessor to output only a list of the macro definitions that
7323  are in effect at the end of preprocessing.
7324  Used with the `-E' option.
7325 \end_layout
7326
7327 \begin_layout List
7328 \labelwidthstring 00.00.0000
7329
7330 \series bold
7331 -dD
7332 \begin_inset LatexCommand \index{-dD}
7333
7334 \end_inset
7335
7336
7337 \series default
7338  Tell the preprocessor to pass all macro definitions into the output, in
7339  their proper sequence in the rest of the output.
7340 \end_layout
7341
7342 \begin_layout List
7343 \labelwidthstring 00.00.0000
7344
7345 \series bold
7346 -dN
7347 \begin_inset LatexCommand \index{-dN}
7348
7349 \end_inset
7350
7351
7352 \size large
7353 \bar under
7354  
7355 \series default
7356 \size default
7357 \bar default
7358 Like `-dD' except that the macro arguments and contents are omitted.
7359  Only `#define name' is included in the output.
7360 \end_layout
7361
7362 \begin_layout List
7363 \labelwidthstring 00.00.0000
7364
7365 \series bold
7366 -pedantic-parse-number
7367 \begin_inset LatexCommand \index{pedantic}
7368
7369 \end_inset
7370
7371
7372 \begin_inset LatexCommand \index{-pedantic-parse-number}
7373
7374 \end_inset
7375
7376
7377 \size large
7378 \bar under
7379
7380 \begin_inset LatexCommand \label{lyx:-pedantic-parse-number}
7381
7382 \end_inset
7383
7384  
7385 \series default
7386 \size default
7387 \bar default
7388 Pedantic parse numbers so that situations like 0xfe-LO_B(3) are parsed properly
7389  and the macro LO_B(3) gets expanded.
7390  See also #pragma pedantic_parse_number 
7391 \begin_inset LatexCommand \vpageref{ite:pedantic_parse_number}
7392
7393 \end_inset
7394
7395  in section
7396 \begin_inset LatexCommand \ref{sec:Pragmas}
7397
7398 \end_inset
7399
7400  
7401 \emph on
7402 Note: this functionality is not in conformance with C99 standard!
7403 \end_layout
7404
7405 \begin_layout List
7406 \labelwidthstring 00.00.0000
7407
7408 \series bold
7409 -Wp\InsetSpace ~
7410 preprocessorOption[,preprocessorOption]
7411 \series default
7412
7413 \begin_inset LatexCommand \index{-Wp preprocessorOption[,preprocessorOption]}
7414
7415 \end_inset
7416
7417 ...
7418  Pass the preprocessorOption to the preprocessor 
7419 \family typewriter
7420 sdcpp
7421 \family default
7422
7423 \begin_inset LatexCommand \index{sdcpp (preprocessor)}
7424
7425 \end_inset
7426
7427 .
7428  SDCC uses an adapted version of the preprocessor 
7429 \emph on
7430 cpp
7431 \emph default
7432  of the GNU Compiler Collection
7433 \begin_inset LatexCommand \index{gcc (GNU Compiler Collection)}
7434
7435 \end_inset
7436
7437  (
7438 \emph on
7439 gcc
7440 \emph default
7441  
7442 \begin_inset LatexCommand \url{http://gcc.gnu.org/}
7443
7444 \end_inset
7445
7446 ), if you need more dedicated options please refer to the GCC\InsetSpace ~
7447 4.1.1\InsetSpace ~
7448 CPP\InsetSpace ~
7449 Manual
7450  at 
7451 \begin_inset LatexCommand \htmlurl{http://www.gnu.org/software/gcc/onlinedocs/}
7452
7453 \end_inset
7454
7455 .
7456 \end_layout
7457
7458 \begin_layout Standard
7459 \begin_inset VSpace bigskip
7460 \end_inset
7461
7462
7463 \end_layout
7464
7465 \begin_layout Subsection
7466 Linker Options
7467 \begin_inset LatexCommand \index{Options linker}
7468
7469 \end_inset
7470
7471
7472 \begin_inset LatexCommand \index{Linker options}
7473
7474 \end_inset
7475
7476
7477 \end_layout
7478
7479 \begin_layout List
7480 \labelwidthstring 00.00.0000
7481
7482 \series bold
7483 -L\InsetSpace ~
7484 -
7485 \series default
7486
7487 \begin_inset ERT
7488 status collapsed
7489
7490 \begin_layout Standard
7491
7492
7493 \backslash
7494 /
7495 \end_layout
7496
7497 \end_inset
7498
7499
7500 \series bold
7501 -lib-path
7502 \begin_inset LatexCommand \index{-\/-lib-path <path>}
7503
7504 \end_inset
7505
7506
7507 \begin_inset LatexCommand \index{-L -\/-lib-path}
7508
7509 \end_inset
7510
7511
7512 \series default
7513 \InsetSpace ~
7514 <absolute path to additional libraries> This option is passed to the linkage
7515  editor's additional libraries
7516 \begin_inset LatexCommand \index{Libraries}
7517
7518 \end_inset
7519
7520  search path.
7521  The path name must be absolute.
7522  Additional library files may be specified in the command line.
7523  See section Compiling programs for more details.
7524 \end_layout
7525
7526 \begin_layout List
7527 \labelwidthstring 00.00.0000
7528
7529 \series bold
7530 -
7531 \begin_inset ERT
7532 status collapsed
7533
7534 \begin_layout Standard
7535
7536
7537 \backslash
7538 /
7539 \end_layout
7540
7541 \end_inset
7542
7543 -xram-loc
7544 \series default
7545
7546 \begin_inset LatexCommand \index{-\/-xram-loc <Value>}
7547
7548 \end_inset
7549
7550 \InsetSpace ~
7551 <Value> The start location of the external ram
7552 \begin_inset LatexCommand \index{xdata (mcs51, ds390 storage class)}
7553
7554 \end_inset
7555
7556 , default value is 0.
7557  The value entered can be in Hexadecimal or Decimal format, e.g.: -
7558 \begin_inset ERT
7559 status collapsed
7560
7561 \begin_layout Standard
7562
7563
7564 \backslash
7565 /
7566 \end_layout
7567
7568 \end_inset
7569
7570 -xram-loc 0x8000 or -
7571 \begin_inset ERT
7572 status collapsed
7573
7574 \begin_layout Standard
7575
7576
7577 \backslash
7578 /
7579 \end_layout
7580
7581 \end_inset
7582
7583 -xram-loc 32768.
7584 \end_layout
7585
7586 \begin_layout List
7587 \labelwidthstring 00.00.0000
7588
7589 \series bold
7590 -
7591 \begin_inset ERT
7592 status collapsed
7593
7594 \begin_layout Standard
7595
7596
7597 \backslash
7598 /
7599 \end_layout
7600
7601 \end_inset
7602
7603 -code-loc
7604 \series default
7605
7606 \begin_inset LatexCommand \index{-\/-code-loc <Value>}
7607
7608 \end_inset
7609
7610 \InsetSpace ~
7611 <Value> The start location of the code
7612 \begin_inset LatexCommand \index{code}
7613
7614 \end_inset
7615
7616  segment, default value 0.
7617  Note when this option is used the interrupt vector table
7618 \begin_inset LatexCommand \index{interrupt vector table}
7619
7620 \end_inset
7621
7622  is also relocated to the given address.
7623  The value entered can be in Hexadecimal or Decimal format, e.g.: -
7624 \begin_inset ERT
7625 status collapsed
7626
7627 \begin_layout Standard
7628
7629
7630 \backslash
7631 /
7632 \end_layout
7633
7634 \end_inset
7635
7636 -code-loc 0x8000 or -
7637 \begin_inset ERT
7638 status collapsed
7639
7640 \begin_layout Standard
7641
7642
7643 \backslash
7644 /
7645 \end_layout
7646
7647 \end_inset
7648
7649 -code-loc 32768.
7650 \end_layout
7651
7652 \begin_layout List
7653 \labelwidthstring 00.00.0000
7654
7655 \series bold
7656 -
7657 \begin_inset ERT
7658 status collapsed
7659
7660 \begin_layout Standard
7661
7662
7663 \backslash
7664 /
7665 \end_layout
7666
7667 \end_inset
7668
7669 -stack-loc
7670 \series default
7671
7672 \begin_inset LatexCommand \index{-\/-stack-loc <Value>}
7673
7674 \end_inset
7675
7676 \InsetSpace ~
7677 <Value> By default the stack
7678 \begin_inset LatexCommand \index{stack}
7679
7680 \end_inset
7681
7682  is placed after the data segment.
7683  Using this option the stack can be placed anywhere in the internal memory
7684  space of the 8051.
7685  The value entered can be in Hexadecimal or Decimal format, e.g.
7686  -
7687 \begin_inset ERT
7688 status collapsed
7689
7690 \begin_layout Standard
7691
7692
7693 \backslash
7694 /
7695 \end_layout
7696
7697 \end_inset
7698
7699 -stack-loc 0x20 or -
7700 \begin_inset ERT
7701 status collapsed
7702
7703 \begin_layout Standard
7704
7705
7706 \backslash
7707 /
7708 \end_layout
7709
7710 \end_inset
7711
7712 -stack-loc 32.
7713  Since the sp register is incremented before a push or call, the initial
7714  sp will be set to one byte prior the provided value.
7715  The provided value should not overlap any other memory areas such as used
7716  register banks or the data segment and with enough space for the current
7717  application.
7718  The 
7719 \series bold
7720 -
7721 \begin_inset ERT
7722 status collapsed
7723
7724 \begin_layout Standard
7725
7726
7727 \backslash
7728 /
7729 \end_layout
7730
7731 \end_inset
7732
7733 -pack-iram
7734 \series default
7735 \InsetSpace ~
7736
7737 \begin_inset LatexCommand \index{-\/-pack-iram}
7738
7739 \end_inset
7740
7741  option (which is now a default setting) will override this setting, so
7742  you should also specify the 
7743 \series bold
7744 -
7745 \begin_inset ERT
7746 status collapsed
7747
7748 \begin_layout Standard
7749
7750
7751 \backslash
7752 /
7753 \end_layout
7754
7755 \end_inset
7756
7757 -no-pack-iram
7758 \series default
7759 \InsetSpace ~
7760
7761 \begin_inset LatexCommand \index{-\/-no-pack-iram}
7762
7763 \end_inset
7764
7765  option if you need to manually place the stack.
7766 \end_layout
7767
7768 \begin_layout List
7769 \labelwidthstring 00.00.0000
7770
7771 \series bold
7772 -
7773 \begin_inset ERT
7774 status collapsed
7775
7776 \begin_layout Standard
7777
7778
7779 \backslash
7780 /
7781 \end_layout
7782
7783 \end_inset
7784
7785 -xstack-loc
7786 \series default
7787
7788 \begin_inset LatexCommand \index{-\/-xstack-loc <Value>}
7789
7790 \end_inset
7791
7792 \InsetSpace ~
7793 <Value> By default the external stack
7794 \begin_inset LatexCommand \index{xstack}
7795
7796 \end_inset
7797
7798  is placed after the pdata
7799 \begin_inset LatexCommand \index{pdata (mcs51, ds390 storage class)}
7800
7801 \end_inset
7802
7803  segment.
7804  Using this option the xstack can be placed anywhere in the external memory
7805  space of the 8051.
7806  The value entered can be in Hexadecimal or Decimal format, e.g.
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 -xstack-loc 0x8000 or -
7821 \begin_inset ERT
7822 status collapsed
7823
7824 \begin_layout Standard
7825
7826
7827 \backslash
7828 /
7829 \end_layout
7830
7831 \end_inset
7832
7833 -stack-loc 32768.
7834  The provided value should not overlap any other memory areas such as the
7835  pdata or xdata segment and with enough space for the current application.
7836 \end_layout
7837
7838 \begin_layout List
7839 \labelwidthstring 00.00.0000
7840
7841 \series bold
7842 -
7843 \begin_inset ERT
7844 status collapsed
7845
7846 \begin_layout Standard
7847
7848
7849 \backslash
7850 /
7851 \end_layout
7852
7853 \end_inset
7854
7855 -data-loc
7856 \series default
7857
7858 \begin_inset LatexCommand \index{-\/-data-loc <Value>}
7859
7860 \end_inset
7861
7862 \InsetSpace ~
7863 <Value> The start location of the internal ram data
7864 \begin_inset LatexCommand \index{data (mcs51, ds390 storage class)}
7865
7866 \end_inset
7867
7868  segment.
7869  The value entered can be in Hexadecimal or Decimal format, eg.
7870  -
7871 \begin_inset ERT
7872 status collapsed
7873
7874 \begin_layout Standard
7875
7876
7877 \backslash
7878 /
7879 \end_layout
7880
7881 \end_inset
7882
7883 -data-loc 0x20 or -
7884 \begin_inset ERT
7885 status collapsed
7886
7887 \begin_layout Standard
7888
7889
7890 \backslash
7891 /
7892 \end_layout
7893
7894 \end_inset
7895
7896 -data-loc 32.
7897  (By default, the start location of the internal ram data segment  is set
7898  as low as possible in memory, taking into account the used register banks
7899  and the bit segment at address 0x20.
7900  For example if register banks 0 and 1 are used without bit variables, the
7901  data segment will be set, if -
7902 \begin_inset ERT
7903 status collapsed
7904
7905 \begin_layout Standard
7906
7907
7908 \backslash
7909 /
7910 \end_layout
7911
7912 \end_inset
7913
7914 -data-loc is not used, to location 0x10.)
7915 \end_layout
7916
7917 \begin_layout List
7918 \labelwidthstring 00.00.0000
7919
7920 \series bold
7921 -
7922 \begin_inset ERT
7923 status collapsed
7924
7925 \begin_layout Standard
7926
7927
7928 \backslash
7929 /
7930 \end_layout
7931
7932 \end_inset
7933
7934 -idata-loc
7935 \series default
7936
7937 \begin_inset LatexCommand \index{-\/-idata-loc <Value>}
7938
7939 \end_inset
7940
7941 \InsetSpace ~
7942 <Value> The start location of the indirectly addressable internal ram
7943 \begin_inset LatexCommand \index{idata (mcs51, ds390 storage class)}
7944
7945 \end_inset
7946
7947  of the 8051, default value is 0x80.
7948  The value entered can be in Hexadecimal or Decimal format, eg.
7949  -
7950 \begin_inset ERT
7951 status collapsed
7952
7953 \begin_layout Standard
7954
7955
7956 \backslash
7957 /
7958 \end_layout
7959
7960 \end_inset
7961
7962 -idata-loc 0x88 or -
7963 \begin_inset ERT
7964 status collapsed
7965
7966 \begin_layout Standard
7967
7968
7969 \backslash
7970 /
7971 \end_layout
7972
7973 \end_inset
7974
7975 -idata-loc 136.
7976 \end_layout
7977
7978 \begin_layout List
7979 \labelwidthstring 00.00.0000
7980
7981 \series bold
7982 -
7983 \begin_inset ERT
7984 status collapsed
7985
7986 \begin_layout Standard
7987
7988
7989 \backslash
7990 /
7991 \end_layout
7992
7993 \end_inset
7994
7995 -bit-loc
7996 \series default
7997 \InsetSpace ~
7998 <Value> The start location of the bit
7999 \begin_inset LatexCommand \index{bit}
8000
8001 \end_inset
8002
8003  addressable internal ram of the 8051.
8004  This is 
8005 \emph on
8006 not
8007 \emph default
8008  implemented yet.
8009  Instead an option can be passed directly to the linker: -Wl\InsetSpace ~
8010 -bBSEG=<Value>.
8011 \end_layout
8012
8013 \begin_layout List
8014 \labelwidthstring 00.00.0000
8015
8016 \series bold
8017 -
8018 \begin_inset ERT
8019 status collapsed
8020
8021 \begin_layout Standard
8022
8023
8024 \backslash
8025 /
8026 \end_layout
8027
8028 \end_inset
8029
8030 -out-fmt-ihx
8031 \begin_inset LatexCommand \index{-\/-out-fmt-ihx}
8032
8033 \end_inset
8034
8035
8036 \bar under
8037  
8038 \series default
8039 \bar default
8040 The linker output (final object code) is in Intel Hex format.
8041 \begin_inset LatexCommand \index{Intel hex format}
8042
8043 \end_inset
8044
8045  This is the default option.
8046  The format itself is documented in the documentation of srecord
8047 \begin_inset LatexCommand \index{srecord (bin, hex, ... tool)}
8048
8049 \end_inset
8050
8051 .
8052 \end_layout
8053
8054 \begin_layout List
8055 \labelwidthstring 00.00.0000
8056
8057 \series bold
8058 -
8059 \begin_inset ERT
8060 status collapsed
8061
8062 \begin_layout Standard
8063
8064
8065 \backslash
8066 /
8067 \end_layout
8068
8069 \end_inset
8070
8071 -out-fmt-s19
8072 \begin_inset LatexCommand \index{-\/-out-fmt-s19}
8073
8074 \end_inset
8075
8076
8077 \bar under
8078  
8079 \series default
8080 \bar default
8081 The linker output (final object code) is in Motorola S19 format
8082 \begin_inset LatexCommand \index{Motorola S19 format}
8083
8084 \end_inset
8085
8086 .
8087  The format itself is documented in the documentation of srecord.
8088 \end_layout
8089
8090 \begin_layout List
8091 \labelwidthstring 00.00.0000
8092
8093 \series bold
8094 -
8095 \begin_inset ERT
8096 status collapsed
8097
8098 \begin_layout Standard
8099
8100
8101 \backslash
8102 /
8103 \end_layout
8104
8105 \end_inset
8106
8107 -out-fmt-elf
8108 \begin_inset LatexCommand \index{-\/-out-fmt-s19}
8109
8110 \end_inset
8111
8112
8113 \begin_inset LatexCommand \index{HC08!Options!-\/-out-fmt-elf}
8114
8115 \end_inset
8116
8117
8118 \bar under
8119  
8120 \series default
8121 \bar default
8122 The linker output (final object code) is in ELF format
8123 \begin_inset LatexCommand \index{ELF format}
8124
8125 \end_inset
8126
8127 .
8128  (Currently only supported for the HC08
8129 \begin_inset LatexCommand \index{HC08}
8130
8131 \end_inset
8132
8133  processors)
8134 \end_layout
8135
8136 \begin_layout List
8137 \labelwidthstring 00.00.0000
8138
8139 \series bold
8140 -Wl\InsetSpace ~
8141 linkOption[,linkOption]
8142 \series default
8143
8144 \begin_inset LatexCommand \index{-Wl linkOption[,linkOption]}
8145
8146 \end_inset
8147
8148
8149 \begin_inset LatexCommand \label{lyx:-Wl option}
8150
8151 \end_inset
8152
8153 ...
8154  Pass the linkOption to the linker.
8155  If a bootloader is used an option like 
8156 \begin_inset Quotes sld
8157 \end_inset
8158
8159 -Wl\InsetSpace ~
8160 -bCSEG=0x1000
8161 \begin_inset Quotes srd
8162 \end_inset
8163
8164  would be typical to set the start of the code segment.
8165  Either use the double quotes around this option or use no space (e.g.
8166  -Wl-bCSEG=0x1000).
8167  See also #pragma constseg and #pragma codeseg in section 
8168 \begin_inset LatexCommand \ref{sec:Pragmas}
8169
8170 \end_inset
8171
8172  .
8173  File sdcc/as/doc/asxhtm.html has more on linker options.
8174 \end_layout
8175
8176 \begin_layout Standard
8177 \begin_inset VSpace bigskip
8178 \end_inset
8179
8180
8181 \end_layout
8182
8183 \begin_layout Subsection
8184 MCS51 Options
8185 \begin_inset LatexCommand \index{Options MCS51}
8186
8187 \end_inset
8188
8189
8190 \begin_inset LatexCommand \index{MCS51 options}
8191
8192 \end_inset
8193
8194
8195 \end_layout
8196
8197 \begin_layout List
8198 \labelwidthstring 00.00.0000
8199
8200 \series bold
8201 -
8202 \begin_inset ERT
8203 status collapsed
8204
8205 \begin_layout Standard
8206
8207
8208 \backslash
8209 /
8210 \end_layout
8211
8212 \end_inset
8213
8214 -model-small
8215 \begin_inset LatexCommand \index{-\/-model-small}
8216
8217 \end_inset
8218
8219
8220 \series default
8221 \size large
8222 \emph on
8223  
8224 \size default
8225 \emph default
8226 Generate code for Small Model programs, see section Memory Models for more
8227  details.
8228  This is the default model.
8229 \end_layout
8230
8231 \begin_layout List
8232 \labelwidthstring 00.00.0000
8233
8234 \series bold
8235 -
8236 \begin_inset ERT
8237 status collapsed
8238
8239 \begin_layout Standard
8240
8241
8242 \backslash
8243 /
8244 \end_layout
8245
8246 \end_inset
8247
8248 -model-medium
8249 \begin_inset LatexCommand \index{-\/-model-medium}
8250
8251 \end_inset
8252
8253
8254 \series default
8255  Generate code for Medium model programs, see section Memory Models for
8256  more details.
8257  If this option is used all source files in the project have to be compiled
8258  with this option.
8259  It must also be used when invoking the linker.
8260 \end_layout
8261
8262 \begin_layout List
8263 \labelwidthstring 00.00.0000
8264
8265 \series bold
8266 -
8267 \begin_inset ERT
8268 status collapsed
8269
8270 \begin_layout Standard
8271
8272
8273 \backslash
8274 /
8275 \end_layout
8276
8277 \end_inset
8278
8279 -model-large
8280 \begin_inset LatexCommand \index{-\/-model-large}
8281
8282 \end_inset
8283
8284
8285 \series default
8286  Generate code for Large model programs, see section Memory Models for more
8287  details.
8288  If this option is used all source files in the project have to be compiled
8289  with this option.
8290  It must also be used when invoking the linker.
8291 \end_layout
8292
8293 \begin_layout List
8294 \labelwidthstring 00.00.0000
8295
8296 \series bold
8297 -
8298 \begin_inset ERT
8299 status collapsed
8300
8301 \begin_layout Standard
8302
8303
8304 \backslash
8305 /
8306 \end_layout
8307
8308 \end_inset
8309
8310 -xstack
8311 \begin_inset LatexCommand \index{-\/-xstack}
8312
8313 \end_inset
8314
8315
8316 \series default
8317  Uses a pseudo stack in the pdata
8318 \begin_inset LatexCommand \index{pdata (mcs51, ds390 storage class)}
8319
8320 \end_inset
8321
8322  area (usually the first 256 bytes in the external ram) for allocating variables
8323  and passing parameters.
8324  See section 
8325 \begin_inset LatexCommand \ref{sub:External-Stack}
8326
8327 \end_inset
8328
8329 \InsetSpace ~
8330  External Stack for more details.
8331 \end_layout
8332
8333 \begin_layout List
8334 \labelwidthstring 00.00.0000
8335
8336 \series bold
8337 -
8338 \begin_inset ERT
8339 status collapsed
8340
8341 \begin_layout Standard
8342
8343
8344 \backslash
8345 /
8346 \end_layout
8347
8348 \end_inset
8349
8350 -iram-size
8351 \series default
8352 \InsetSpace ~
8353 <Value>
8354 \begin_inset LatexCommand \index{-\/-iram-size <Value>}
8355
8356 \end_inset
8357
8358  Causes the linker to check if the internal ram usage is within limits of
8359  the given value.
8360 \end_layout
8361
8362 \begin_layout List
8363 \labelwidthstring 00.00.0000
8364
8365 \series bold
8366 -
8367 \begin_inset ERT
8368 status collapsed
8369
8370 \begin_layout Standard
8371
8372
8373 \backslash
8374 /
8375 \end_layout
8376
8377 \end_inset
8378
8379 -xram-size
8380 \series default
8381 \InsetSpace ~
8382 <Value>
8383 \begin_inset LatexCommand \index{-\/-xram-size <Value>}
8384
8385 \end_inset
8386
8387  Causes the linker to check if the external ram usage is within limits of
8388  the given value.
8389 \end_layout
8390
8391 \begin_layout List
8392 \labelwidthstring 00.00.0000
8393
8394 \series bold
8395 -
8396 \begin_inset ERT
8397 status collapsed
8398
8399 \begin_layout Standard
8400
8401
8402 \backslash
8403 /
8404 \end_layout
8405
8406 \end_inset
8407
8408 -code-size
8409 \series default
8410 \InsetSpace ~
8411 <Value>
8412 \begin_inset LatexCommand \index{-\/-code-size <Value>}
8413
8414 \end_inset
8415
8416  Causes the linker to check if the code memory usage is within limits of
8417  the given value.
8418 \end_layout
8419
8420 \begin_layout List
8421 \labelwidthstring 00.00.0000
8422
8423 \series bold
8424 -
8425 \begin_inset ERT
8426 status collapsed
8427
8428 \begin_layout Standard
8429
8430
8431 \backslash
8432 /
8433 \end_layout
8434
8435 \end_inset
8436
8437 -stack-size
8438 \series default
8439 \InsetSpace ~
8440 <Value>
8441 \begin_inset LatexCommand \index{-\/-stack-size <Value>}
8442
8443 \end_inset
8444
8445  Causes the linker to check if there is at minimum <Value> bytes for stack.
8446 \end_layout
8447
8448 \begin_layout List
8449 \labelwidthstring 00.00.0000
8450
8451 \series bold
8452 -
8453 \begin_inset ERT
8454 status collapsed
8455
8456 \begin_layout Standard
8457
8458
8459 \backslash
8460 /
8461 \end_layout
8462
8463 \end_inset
8464
8465 -pack-iram
8466 \series default
8467 \InsetSpace ~
8468
8469 \begin_inset LatexCommand \index{-\/-pack-iram}
8470
8471 \end_inset
8472
8473  Causes the linker to use unused register banks for data variables and pack
8474  data, idata and stack together.
8475  This is the default now.
8476 \end_layout
8477
8478 \begin_layout List
8479 \labelwidthstring 00.00.0000
8480
8481 \series bold
8482 -
8483 \begin_inset ERT
8484 status collapsed
8485
8486 \begin_layout Standard
8487
8488
8489 \backslash
8490 /
8491 \end_layout
8492
8493 \end_inset
8494
8495 -no-pack-iram
8496 \series default
8497 \InsetSpace ~
8498
8499 \begin_inset LatexCommand \index{-\/-no-pack-iram}
8500
8501 \end_inset
8502
8503  Causes the linker to use old style for allocating memory areas.
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 -acall-ajmp
8524 \series default
8525 \InsetSpace ~
8526
8527 \begin_inset LatexCommand \index{-\/-acall-ajmp}
8528
8529 \end_inset
8530
8531  Replaces the three byte instructions lcall/ljmp with the two byte instructions
8532  acall/ajmp.
8533  Only use this option if your code is in the same 2k block of memory.
8534  You may need to use this option for some 8051 derivatives which lack the
8535  lcall/ljmp instructions..
8536 \end_layout
8537
8538 \begin_layout Standard
8539 \begin_inset VSpace bigskip
8540 \end_inset
8541
8542
8543 \end_layout
8544
8545 \begin_layout Subsection
8546 DS390 / DS400 Options
8547 \begin_inset LatexCommand \index{Options DS390}
8548
8549 \end_inset
8550
8551
8552 \begin_inset LatexCommand \index{DS390}
8553
8554 \end_inset
8555
8556
8557 \end_layout
8558
8559 \begin_layout List
8560 \labelwidthstring 00.00.0000
8561
8562 \series bold
8563 -
8564 \begin_inset ERT
8565 status collapsed
8566
8567 \begin_layout Standard
8568
8569
8570 \backslash
8571 /
8572 \end_layout
8573
8574 \end_inset
8575
8576 -model-flat24
8577 \series default
8578
8579 \begin_inset LatexCommand \index{DS390!Options!-\/-model-flat24}
8580
8581 \end_inset
8582
8583
8584 \size large
8585 \emph on
8586  
8587 \size default
8588 \emph default
8589 Generate 24-bit flat mode code.
8590  This is the one and only that the ds390 code generator supports right now
8591  and is default when using 
8592 \emph on
8593 -mds390
8594 \emph default
8595 .
8596  See section Memory Models for more details.
8597 \end_layout
8598
8599 \begin_layout List
8600 \labelwidthstring 00.00.0000
8601
8602 \series bold
8603 -
8604 \begin_inset ERT
8605 status collapsed
8606
8607 \begin_layout Standard
8608
8609
8610 \backslash
8611 /
8612 \end_layout
8613
8614 \end_inset
8615
8616 -protect-sp-update
8617 \begin_inset LatexCommand \index{DS390!Options!-\/-protect-sp-update}
8618
8619 \end_inset
8620
8621
8622 \series default
8623  disable interrupts during ESP:SP updates.
8624 \end_layout
8625
8626 \begin_layout List
8627 \labelwidthstring 00.00.0000
8628
8629 \series bold
8630 -
8631 \begin_inset ERT
8632 status collapsed
8633
8634 \begin_layout Standard
8635
8636
8637 \backslash
8638 /
8639 \end_layout
8640
8641 \end_inset
8642
8643 -stack-10bit
8644 \series default
8645
8646 \begin_inset LatexCommand \index{DS390!Options!-\/-stack-10bit}
8647
8648 \end_inset
8649
8650  Generate code for the 10 bit stack mode of the Dallas DS80C390 part.
8651  This is the one and only that the ds390 code generator supports right now
8652  and is default when using 
8653 \emph on
8654 -mds390
8655 \emph default
8656 .
8657  In this mode, the stack is located in the lower 1K of the internal RAM,
8658  which is mapped to 0x400000.
8659  Note that the support is incomplete, since it still uses a single byte
8660  as the stack pointer.
8661  This means that only the lower 256 bytes of the potential 1K stack space
8662  will actually be used.
8663  However, this does allow you to reclaim the precious 256 bytes of low RAM
8664  for use for the DATA and IDATA segments.
8665  The compiler will not generate any code to put the processor into 10 bit
8666  stack mode.
8667  It is important to ensure that the processor is in this mode before calling
8668  any re-entrant functions compiled with this option.
8669  In principle, this should work with the 
8670 \emph on
8671 -
8672 \begin_inset ERT
8673 status collapsed
8674
8675 \begin_layout Standard
8676
8677
8678 \backslash
8679 /
8680 \end_layout
8681
8682 \end_inset
8683
8684 -stack-auto
8685 \begin_inset LatexCommand \index{-\/-stack-auto}
8686
8687 \end_inset
8688
8689
8690 \emph default
8691  option, but that has not been tested.
8692  It is incompatible with the 
8693 \emph on
8694 -
8695 \begin_inset ERT
8696 status collapsed
8697
8698 \begin_layout Standard
8699
8700
8701 \backslash
8702 /
8703 \end_layout
8704
8705 \end_inset
8706
8707 -xstack
8708 \begin_inset LatexCommand \index{-\/-xstack}
8709
8710 \end_inset
8711
8712
8713 \emph default
8714  option.
8715  It also only makes sense if the processor is in 24 bit contiguous addressing
8716  mode (see the 
8717 \emph on
8718 -
8719 \begin_inset ERT
8720 status collapsed
8721
8722 \begin_layout Standard
8723
8724
8725 \backslash
8726 /
8727 \end_layout
8728
8729 \end_inset
8730
8731 -model-flat24 option
8732 \emph default
8733 ).
8734 \series bold
8735
8736 \begin_inset Note Note
8737 status collapsed
8738
8739 \begin_layout List
8740 \labelwidthstring 00.00.0000
8741
8742 \series bold
8743 -
8744 \begin_inset ERT
8745 status open
8746
8747 \begin_layout Standard
8748
8749
8750 \backslash
8751 /
8752 \end_layout
8753
8754 \end_inset
8755
8756 -stack-8-bit - switches off the 10-bit mode
8757 \end_layout
8758
8759 \end_inset
8760
8761
8762 \end_layout
8763
8764 \begin_layout List
8765 \labelwidthstring 00.00.0000
8766
8767 \series bold
8768 -
8769 \begin_inset ERT
8770 status collapsed
8771
8772 \begin_layout Standard
8773
8774
8775 \backslash
8776 /
8777 \end_layout
8778
8779 \end_inset
8780
8781 -stack-probe
8782 \begin_inset LatexCommand \index{DS390!Options!-\/-stack-probe}
8783
8784 \end_inset
8785
8786
8787 \series default
8788  insert call to function __stack_probe at each function prologue.
8789 \end_layout
8790
8791 \begin_layout List
8792 \labelwidthstring 00.00.0000
8793
8794 \series bold
8795 -
8796 \begin_inset ERT
8797 status open
8798
8799 \begin_layout Standard
8800
8801
8802 \backslash
8803 /
8804 \end_layout
8805
8806 \end_inset
8807
8808 -tini-libid
8809 \begin_inset LatexCommand \index{DS390!Options!-\/-tini-libid}
8810
8811 \end_inset
8812
8813
8814 \series default
8815  <nnnn> LibraryID used in -mTININative.
8816  
8817 \end_layout
8818
8819 \begin_layout List
8820 \labelwidthstring 00.00.0000
8821
8822 \series bold
8823 -
8824 \begin_inset ERT
8825 status collapsed
8826
8827 \begin_layout Standard
8828
8829
8830 \backslash
8831 /
8832 \end_layout
8833
8834 \end_inset
8835
8836 -use-accelerator
8837 \begin_inset LatexCommand \index{DS390!Options!-\/-use-accelerator}
8838
8839 \end_inset
8840
8841
8842 \series default
8843  generate code for DS390 Arithmetic Accelerator.
8844  
8845 \end_layout
8846
8847 \begin_layout Standard
8848 \begin_inset VSpace bigskip
8849 \end_inset
8850
8851
8852 \end_layout
8853
8854 \begin_layout Subsection
8855 Z80 Options
8856 \begin_inset LatexCommand \index{Options Z80}
8857
8858 \end_inset
8859
8860
8861 \begin_inset LatexCommand \index{Z80}
8862
8863 \end_inset
8864
8865
8866 \end_layout
8867
8868 \begin_layout List
8869 \labelwidthstring 00.00.0000
8870
8871 \series bold
8872 -
8873 \begin_inset ERT
8874 status collapsed
8875
8876 \begin_layout Standard
8877
8878
8879 \backslash
8880 /
8881 \end_layout
8882
8883 \end_inset
8884
8885 -callee-saves-bc
8886 \series default
8887
8888 \begin_inset LatexCommand \index{Z80!Options!-\/-callee-saves-bc}
8889
8890 \end_inset
8891
8892
8893 \size large
8894 \emph on
8895  
8896 \size default
8897 \emph default
8898 Force a called function to always save BC.
8899 \end_layout
8900
8901 \begin_layout List
8902 \labelwidthstring 00.00.0000
8903
8904 \series bold
8905 -
8906 \begin_inset ERT
8907 status collapsed
8908
8909 \begin_layout Standard
8910
8911
8912 \backslash
8913 /
8914 \end_layout
8915
8916 \end_inset
8917
8918 -no-std-crt0
8919 \series default
8920
8921 \begin_inset LatexCommand \index{Z80!Options!-\/-no-std-crt0}
8922
8923 \end_inset
8924
8925  When linking, skip the standard crt0.o object file.
8926  You must provide your own crt0.o for your system when linking.
8927 \end_layout
8928
8929 \begin_layout List
8930 \labelwidthstring 00.00.0000
8931
8932 \series bold
8933 -
8934 \begin_inset ERT
8935 status collapsed
8936
8937 \begin_layout Standard
8938
8939
8940 \backslash
8941 /
8942 \end_layout
8943
8944 \end_inset
8945
8946 -portmode=
8947 \series default
8948 <Value>
8949 \begin_inset LatexCommand \index{Z80!Options!-\/-portmode=<Value>}
8950
8951 \end_inset
8952
8953  Determinate PORT I/O mode (<Value> is z80 or z180).
8954 \end_layout
8955
8956 \begin_layout List
8957 \labelwidthstring 00.00.0000
8958
8959 \series bold
8960 -
8961 \begin_inset ERT
8962 status collapsed
8963
8964 \begin_layout Standard
8965
8966
8967 \backslash
8968 /
8969 \end_layout
8970
8971 \end_inset
8972
8973 -asm=
8974 \series default
8975 <Value>
8976 \begin_inset LatexCommand \index{Z80!Options!-\/-asm=<Value>}
8977
8978 \end_inset
8979
8980  Define assembler name (<Value> is rgbds, asxxxx, isas or z80asm).
8981 \end_layout
8982
8983 \begin_layout List
8984 \labelwidthstring 00.00.0000
8985
8986 \series bold
8987 -
8988 \begin_inset ERT
8989 status collapsed
8990
8991 \begin_layout Standard
8992
8993
8994 \backslash
8995 /
8996 \end_layout
8997
8998 \end_inset
8999
9000 -codeseg
9001 \series default
9002 \InsetSpace ~
9003 <Value>
9004 \begin_inset LatexCommand \index{Z80!Options!-\/-codeseg <Value>}
9005
9006 \end_inset
9007
9008  Use <Value> for the code segment name.
9009 \end_layout
9010
9011 \begin_layout List
9012 \labelwidthstring 00.00.0000
9013
9014 \series bold
9015 -
9016 \begin_inset ERT
9017 status collapsed
9018
9019 \begin_layout Standard
9020
9021
9022 \backslash
9023 /
9024 \end_layout
9025
9026 \end_inset
9027
9028 -constseg
9029 \series default
9030 \InsetSpace ~
9031 <Value>
9032 \begin_inset LatexCommand \index{Z80!Options!-\/-constseg <Value>}
9033
9034 \end_inset
9035
9036  Use <Value> for the const segment name.
9037 \end_layout
9038
9039 \begin_layout List
9040 \labelwidthstring 00.00.0000
9041 \begin_inset VSpace bigskip
9042 \end_inset
9043
9044
9045 \end_layout
9046
9047 \begin_layout Subsection
9048 GBZ80 Options
9049 \begin_inset LatexCommand \index{Options GBZ80}
9050
9051 \end_inset
9052
9053
9054 \begin_inset LatexCommand \index{GBZ80}
9055
9056 \end_inset
9057
9058
9059 \end_layout
9060
9061 \begin_layout List
9062 \labelwidthstring 00.00.0000
9063
9064 \series bold
9065 -
9066 \begin_inset ERT
9067 status collapsed
9068
9069 \begin_layout Standard
9070
9071
9072 \backslash
9073 /
9074 \end_layout
9075
9076 \end_inset
9077
9078 -callee-saves-bc
9079 \series default
9080
9081 \begin_inset LatexCommand \index{GBZ80!Options!-\/-callee-saves-bc}
9082
9083 \end_inset
9084
9085
9086 \size large
9087 \emph on
9088  
9089 \size default
9090 \emph default
9091 Force a called function to always save BC.
9092 \end_layout
9093
9094 \begin_layout List
9095 \labelwidthstring 00.00.0000
9096
9097 \series bold
9098 -
9099 \begin_inset ERT
9100 status collapsed
9101
9102 \begin_layout Standard
9103
9104
9105 \backslash
9106 /
9107 \end_layout
9108
9109 \end_inset
9110
9111 -no-std-crt0
9112 \series default
9113
9114 \begin_inset LatexCommand \index{Z80!Options!-\/-no-std-crt0}
9115
9116 \end_inset
9117
9118  When linking, skip the standard crt0.o object file.
9119  You must provide your own crt0.o for your system when linking.
9120 \end_layout
9121
9122 \begin_layout List
9123 \labelwidthstring 00.00.0000
9124
9125 \series bold
9126 -bo
9127 \series default
9128 \InsetSpace ~
9129 <Num>
9130 \begin_inset LatexCommand \index{GBZ80!Options!-bo <Num>}
9131
9132 \end_inset
9133
9134  Use code bank <Num>.
9135 \end_layout
9136
9137 \begin_layout List
9138 \labelwidthstring 00.00.0000
9139
9140 \series bold
9141 -ba
9142 \series default
9143 \InsetSpace ~
9144 <Num>
9145 \begin_inset LatexCommand \index{GBZ80!Options!-ba <Num>}
9146
9147 \end_inset
9148
9149  Use data bank <Num>.
9150 \end_layout
9151
9152 \begin_layout List
9153 \labelwidthstring 00.00.0000
9154
9155 \series bold
9156 -
9157 \begin_inset ERT
9158 status collapsed
9159
9160 \begin_layout Standard
9161
9162
9163 \backslash
9164 /
9165 \end_layout
9166
9167 \end_inset
9168
9169 -codeseg
9170 \series default
9171 \InsetSpace ~
9172 <Value>
9173 \begin_inset LatexCommand \index{GBZ80!Options!-\/-codeseg <Value>}
9174
9175 \end_inset
9176
9177  Use <Value> for the code segment name.
9178 \end_layout
9179
9180 \begin_layout List
9181 \labelwidthstring 00.00.0000
9182
9183 \series bold
9184 -
9185 \begin_inset ERT
9186 status collapsed
9187
9188 \begin_layout Standard
9189
9190
9191 \backslash
9192 /
9193 \end_layout
9194
9195 \end_inset
9196
9197 -constseg
9198 \series default
9199 \InsetSpace ~
9200 <Value>
9201 \begin_inset LatexCommand \index{GBZ80!Options!-\/-constseg <Value>}
9202
9203 \end_inset
9204
9205  Use <Value> for the const segment name.
9206 \end_layout
9207
9208 \begin_layout Standard
9209 \begin_inset VSpace bigskip
9210 \end_inset
9211
9212
9213 \end_layout
9214
9215 \begin_layout Subsection
9216 Optimization Options
9217 \begin_inset LatexCommand \index{Options optimization}
9218
9219 \end_inset
9220
9221
9222 \begin_inset LatexCommand \index{Optimization options}
9223
9224 \end_inset
9225
9226
9227 \end_layout
9228
9229 \begin_layout List
9230 \labelwidthstring 00.00.0000
9231
9232 \series bold
9233 -
9234 \begin_inset ERT
9235 status collapsed
9236
9237 \begin_layout Standard
9238
9239
9240 \backslash
9241 /
9242 \end_layout
9243
9244 \end_inset
9245
9246 -nogcse
9247 \begin_inset LatexCommand \index{-\/-nogcse}
9248
9249 \end_inset
9250
9251
9252 \series default
9253  Will not do global subexpression elimination, this option may be used when
9254  the compiler creates undesirably large stack/data spaces to store compiler
9255  temporaries (
9256 \emph on
9257 s
9258 \emph default
9259 pill 
9260 \emph on
9261 loc
9262 \emph default
9263 ations, sloc
9264 \begin_inset LatexCommand \index{sloc (spill location)}
9265
9266 \end_inset
9267
9268 ).
9269  A warning message will be generated when this happens and the compiler
9270  will indicate the number of extra bytes it allocated.
9271  It is recommended that this option NOT be used, #pragma\InsetSpace ~
9272 nogcse
9273 \begin_inset LatexCommand \index{\#pragma nogcse}
9274
9275 \end_inset
9276
9277  can be used to turn off global subexpression elimination
9278 \begin_inset LatexCommand \index{Subexpression elimination}
9279
9280 \end_inset
9281
9282  for a given function only.
9283 \end_layout
9284
9285 \begin_layout List
9286 \labelwidthstring 00.00.0000
9287
9288 \series bold
9289 -
9290 \begin_inset ERT
9291 status collapsed
9292
9293 \begin_layout Standard
9294
9295
9296 \backslash
9297 /
9298 \end_layout
9299
9300 \end_inset
9301
9302 -noinvariant
9303 \begin_inset LatexCommand \index{-\/-noinvariant}
9304
9305 \end_inset
9306
9307
9308 \series default
9309  Will not do loop invariant optimizations, this may be turned off for reasons
9310  explained for the previous option.
9311  For more details of loop optimizations performed see Loop Invariants in
9312  section 
9313 \begin_inset LatexCommand \ref{sub:Loop-Optimizations}
9314
9315 \end_inset
9316
9317 .
9318  It is recommended that this option NOT be used, #pragma\InsetSpace ~
9319 noinvariant
9320 \begin_inset LatexCommand \index{\#pragma noinvariant}
9321
9322 \end_inset
9323
9324  can be used to turn off invariant optimizations for a given function only.
9325 \end_layout
9326
9327 \begin_layout List
9328 \labelwidthstring 00.00.0000
9329
9330 \series bold
9331 -
9332 \begin_inset ERT
9333 status collapsed
9334
9335 \begin_layout Standard
9336
9337
9338 \backslash
9339 /
9340 \end_layout
9341
9342 \end_inset
9343
9344 -noinduction
9345 \begin_inset LatexCommand \index{-\/-noinduction}
9346
9347 \end_inset
9348
9349
9350 \series default
9351  Will not do loop induction optimizations, see section strength reduction
9352  for more details.
9353  It is recommended that this option is NOT used, #pragma\InsetSpace ~
9354 noinduction
9355 \begin_inset LatexCommand \index{\#pragma noinduction}
9356
9357 \end_inset
9358
9359  can be used to turn off induction optimizations for a given function only.
9360 \end_layout
9361
9362 \begin_layout List
9363 \labelwidthstring 00.00.0000
9364
9365 \series bold
9366 -
9367 \begin_inset ERT
9368 status collapsed
9369
9370 \begin_layout Standard
9371
9372
9373 \backslash
9374 /
9375 \end_layout
9376
9377 \end_inset
9378
9379 -nojtbound
9380 \begin_inset LatexCommand \index{-\/-nojtbound}
9381
9382 \end_inset
9383
9384
9385 \size large
9386 \bar under
9387  
9388 \series default
9389 \size default
9390 \bar default
9391  Will not generate boundary condition check when switch statements
9392 \begin_inset LatexCommand \index{switch statement}
9393
9394 \end_inset
9395
9396  are implemented using jump-tables.
9397  See section 
9398 \begin_inset LatexCommand \ref{sub:'switch'-Statements}
9399
9400 \end_inset
9401
9402 \InsetSpace ~
9403 Switch Statements for more details.
9404  It is recommended that this option is NOT used, #pragma\InsetSpace ~
9405 nojtbound
9406 \begin_inset LatexCommand \index{\#pragma nojtbound}
9407
9408 \end_inset
9409
9410  can be used to turn off boundary checking for jump tables for a given function
9411  only.
9412 \end_layout
9413
9414 \begin_layout List
9415 \labelwidthstring 00.00.0000
9416
9417 \series bold
9418 -
9419 \begin_inset ERT
9420 status collapsed
9421
9422 \begin_layout Standard
9423
9424
9425 \backslash
9426 /
9427 \end_layout
9428
9429 \end_inset
9430
9431 -noloopreverse
9432 \begin_inset LatexCommand \index{-\/-noloopreverse}
9433
9434 \end_inset
9435
9436
9437 \series default
9438 \size large
9439  
9440 \size default
9441 Will not do loop reversal 
9442 \begin_inset LatexCommand \index{Loop reversing}
9443
9444 \end_inset
9445
9446 optimization.
9447 \end_layout
9448
9449 \begin_layout List
9450 \labelwidthstring 00.00.0000
9451 -
9452 \begin_inset ERT
9453 status collapsed
9454
9455 \begin_layout Standard
9456
9457
9458 \backslash
9459 /
9460 \end_layout
9461
9462 \end_inset
9463
9464 -
9465 \series bold
9466 nolabelopt
9467 \series default
9468  
9469 \begin_inset LatexCommand \index{-\/-nolabelopt }
9470
9471 \end_inset
9472
9473 Will not optimize labels (makes the dumpfiles more readable).
9474 \end_layout
9475
9476 \begin_layout List
9477 \labelwidthstring 00.00.0000
9478
9479 \series bold
9480 -
9481 \begin_inset ERT
9482 status collapsed
9483
9484 \begin_layout Standard
9485
9486
9487 \backslash
9488 /
9489 \end_layout
9490
9491 \end_inset
9492
9493 -no-xinit-opt
9494 \begin_inset LatexCommand \index{-\/-no-xinit-opt}
9495
9496 \end_inset
9497
9498
9499 \series default
9500  Will not memcpy initialized data from code space into xdata space.
9501  This saves a few bytes in code space if you don't have initialized data
9502 \begin_inset LatexCommand \index{Variable initialization}
9503
9504 \end_inset
9505
9506 .
9507 \end_layout
9508
9509 \begin_layout List
9510 \labelwidthstring 00.00.0000
9511
9512 \series bold
9513 -
9514 \begin_inset ERT
9515 status collapsed
9516
9517 \begin_layout Standard
9518
9519
9520 \backslash
9521 /
9522 \end_layout
9523
9524 \end_inset
9525
9526 -nooverlay
9527 \begin_inset LatexCommand \index{-\/-nooverlay}
9528
9529 \end_inset
9530
9531
9532 \series default
9533   The compiler will not overlay parameters and local variables of any function,
9534  see section Parameters and local variables for more details.
9535 \end_layout
9536
9537 \begin_layout List
9538 \labelwidthstring 00.00.0000
9539
9540 \series bold
9541 -
9542 \begin_inset ERT
9543 status collapsed
9544
9545 \begin_layout Standard
9546
9547
9548 \backslash
9549 /
9550 \end_layout
9551
9552 \end_inset
9553
9554 -no-peep
9555 \begin_inset LatexCommand \index{-\/-no-peep}
9556
9557 \end_inset
9558
9559
9560 \series default
9561  Disable peep-hole optimization with built-in rules.
9562 \end_layout
9563
9564 \begin_layout List
9565 \labelwidthstring 00.00.0000
9566
9567 \series bold
9568 -
9569 \begin_inset ERT
9570 status collapsed
9571
9572 \begin_layout Standard
9573
9574
9575 \backslash
9576 /
9577 \end_layout
9578
9579 \end_inset
9580
9581 -peep-file
9582 \series default
9583
9584 \begin_inset LatexCommand \index{-\/-peep-file}
9585
9586 \end_inset
9587
9588 \InsetSpace ~
9589 <filename> This option can be used to use additional rules to be used by
9590  the peep hole optimizer.
9591  See section 
9592 \begin_inset LatexCommand \ref{sub:Peephole-Optimizer}
9593
9594 \end_inset
9595
9596 \InsetSpace ~
9597 Peep Hole optimizations for details on how to write these rules.
9598 \end_layout
9599
9600 \begin_layout List
9601 \labelwidthstring 00.00.0000
9602
9603 \series bold
9604 -
9605 \begin_inset ERT
9606 status collapsed
9607
9608 \begin_layout Standard
9609
9610
9611 \backslash
9612 /
9613 \end_layout
9614
9615 \end_inset
9616
9617 -peep-asm
9618 \begin_inset LatexCommand \index{-\/-peep-asm}
9619
9620 \end_inset
9621
9622
9623 \series default
9624  Pass the inline assembler code through the peep hole optimizer.
9625  This can cause unexpected changes to inline assembler code, please go through
9626  the peephole optimizer
9627 \begin_inset LatexCommand \index{Peephole optimizer}
9628
9629 \end_inset
9630
9631  rules defined in the source file tree '<target>/peeph.def' before using
9632  this option.
9633 \end_layout
9634
9635 \begin_layout List
9636 \labelwidthstring 00.00.0000
9637
9638 \series bold
9639 -
9640 \begin_inset ERT
9641 status collapsed
9642
9643 \begin_layout Standard
9644
9645
9646 \backslash
9647 /
9648 \end_layout
9649
9650 \end_inset
9651
9652 -opt-code-speed
9653 \begin_inset LatexCommand \index{-\/-opt-code-speed}
9654
9655 \end_inset
9656
9657
9658 \series default
9659  The compiler will optimize code generation towards fast code, possibly
9660  at the expense of code size.
9661 \end_layout
9662
9663 \begin_layout List
9664 \labelwidthstring 00.00.0000
9665
9666 \series bold
9667 -
9668 \begin_inset ERT
9669 status collapsed
9670
9671 \begin_layout Standard
9672
9673
9674 \backslash
9675 /
9676 \end_layout
9677
9678 \end_inset
9679
9680 -opt-code-size
9681 \begin_inset LatexCommand \index{-\/-opt-code-size}
9682
9683 \end_inset
9684
9685
9686 \series default
9687  The compiler will optimize code generation towards compact code, possibly
9688  at the expense of code speed.
9689 \end_layout
9690
9691 \begin_layout Standard
9692 \begin_inset VSpace bigskip
9693 \end_inset
9694
9695
9696 \end_layout
9697
9698 \begin_layout Subsection
9699 Other Options
9700 \begin_inset LatexCommand \index{Options other}
9701
9702 \end_inset
9703
9704
9705 \end_layout
9706
9707 \begin_layout List
9708 \labelwidthstring 00.00.0000
9709
9710 \series bold
9711 -c\InsetSpace ~
9712 -
9713 \begin_inset ERT
9714 status collapsed
9715
9716 \begin_layout Standard
9717
9718
9719 \backslash
9720 /
9721 \end_layout
9722
9723 \end_inset
9724
9725 -compile-only
9726 \begin_inset LatexCommand \index{-\/-compile-only}
9727
9728 \end_inset
9729
9730
9731 \begin_inset LatexCommand \index{-c -\/-compile-only}
9732
9733 \end_inset
9734
9735
9736 \series default
9737  will compile and assemble the source, but will not call the linkage editor.
9738 \end_layout
9739
9740 \begin_layout List
9741 \labelwidthstring 00.00.0000
9742
9743 \series bold
9744 -
9745 \series default
9746
9747 \begin_inset ERT
9748 status collapsed
9749
9750 \begin_layout Standard
9751
9752
9753 \backslash
9754 /
9755 \end_layout
9756
9757 \end_inset
9758
9759
9760 \series bold
9761 -c1mode
9762 \begin_inset LatexCommand \index{-\/-c1mode}
9763
9764 \end_inset
9765
9766
9767 \series default
9768  reads the preprocessed source from standard input and compiles it.
9769  The file name for the assembler output must be specified using the -o option.
9770 \end_layout
9771
9772 \begin_layout List
9773 \labelwidthstring 00.00.0000
9774
9775 \series bold
9776 -E
9777 \begin_inset LatexCommand \index{-E}
9778
9779 \end_inset
9780
9781
9782 \series default
9783  Run only the C preprocessor.
9784  Preprocess all the C source files specified and output the results to standard
9785  output.
9786 \end_layout
9787
9788 \begin_layout List
9789 \labelwidthstring 00.00.0000
9790
9791 \series bold
9792 -o\InsetSpace ~
9793 <path/file>
9794 \begin_inset LatexCommand \index{-o <path/file>}
9795
9796 \end_inset
9797
9798  
9799 \series default
9800 The output path where everything will be placed or the file name used for
9801  all generated output files.
9802  If the parameter is a path, it must have a trailing slash (or backslash
9803  for the Windows binaries) to be recognized as a path.
9804
9805 \emph on
9806  
9807 \emph default
9808 Note for Windows users: if the path contains spaces, it should be surrounded
9809  by quotes.
9810  The trailing backslash should be doubled in order to prevent escaping the
9811  final quote, for example: 
9812 \emph on
9813 -o 
9814 \begin_inset Quotes sld
9815 \end_inset
9816
9817 F:
9818 \backslash
9819 Projects
9820 \backslash
9821 test3
9822 \backslash
9823 output 1
9824 \backslash
9825
9826 \backslash
9827
9828 \begin_inset Quotes srd
9829 \end_inset
9830
9831
9832 \emph default
9833  or put after the final quote, for example: 
9834 \emph on
9835 -o 
9836 \begin_inset Quotes sld
9837 \end_inset
9838
9839 F:
9840 \backslash
9841 Projects
9842 \backslash
9843 test3
9844 \backslash
9845 output 1
9846 \begin_inset Quotes srd
9847 \end_inset
9848
9849
9850 \backslash
9851
9852 \emph default
9853 .
9854  The path using slashes for directory delimiters can be used too, for example:
9855  
9856 \emph on
9857 -o 
9858 \begin_inset Quotes sld
9859 \end_inset
9860
9861 F:/Projects/test3/output 1/
9862 \begin_inset Quotes srd
9863 \end_inset
9864
9865
9866 \emph default
9867 .
9868 \end_layout
9869
9870 \begin_layout List
9871 \labelwidthstring 00.00.0000
9872
9873 \series bold
9874 -
9875 \begin_inset ERT
9876 status collapsed
9877
9878 \begin_layout Standard
9879
9880
9881 \backslash
9882 /
9883 \end_layout
9884
9885 \end_inset
9886
9887 -stack-auto
9888 \begin_inset LatexCommand \index{-\/-stack-auto}
9889
9890 \end_inset
9891
9892
9893 \series default
9894 \size large
9895 \emph on
9896  
9897 \size default
9898 \emph default
9899 All functions in the source file will be compiled as 
9900 \emph on
9901 reentrant
9902 \emph default
9903
9904 \begin_inset LatexCommand \index{reentrant}
9905
9906 \end_inset
9907
9908 , i.e.
9909  the parameters and local variables will be allocated on the stack
9910 \begin_inset LatexCommand \index{stack}
9911
9912 \end_inset
9913
9914 .
9915  See section 
9916 \begin_inset LatexCommand \ref{sec:Parameters-and-Local-Variables}
9917
9918 \end_inset
9919
9920  Parameters and Local Variables for more details.
9921  If this option is used all source files in the project should be compiled
9922  with this option.
9923  It automatically implies -
9924 \series bold
9925
9926 \begin_inset ERT
9927 status open
9928
9929 \begin_layout Standard
9930
9931
9932 \backslash
9933 /
9934 \end_layout
9935
9936 \end_inset
9937
9938
9939 \series default
9940 -int-long-reent and -
9941 \series bold
9942
9943 \begin_inset ERT
9944 status open
9945
9946 \begin_layout Standard
9947
9948
9949 \backslash
9950 /
9951 \end_layout
9952
9953 \end_inset
9954
9955
9956 \series default
9957 -float-reent.
9958  
9959 \end_layout
9960
9961 \begin_layout List
9962 \labelwidthstring 00.00.0000
9963
9964 \series bold
9965 -
9966 \begin_inset ERT
9967 status collapsed
9968
9969 \begin_layout Standard
9970
9971
9972 \backslash
9973 /
9974 \end_layout
9975
9976 \end_inset
9977
9978 -callee-saves
9979 \begin_inset LatexCommand \index{-\/-callee-saves}
9980
9981 \end_inset
9982
9983  
9984 \begin_inset LatexCommand \label{lyx:--callee-saves-function1[,function2][,function3]...}
9985
9986 \end_inset
9987
9988 function1[,function2][,function3]....
9989
9990 \series default
9991  The compiler by default uses a caller saves convention for register saving
9992  across function calls, however this can cause unnecessary register pushing
9993  and popping when calling small functions from larger functions.
9994  This option can be used to switch the register saving convention for the
9995  function names specified.
9996  The compiler will not save registers when calling these functions, no extra
9997  code will be generated at the entry and exit (function prologue
9998 \series bold
9999
10000 \begin_inset LatexCommand \index{function prologue}
10001
10002 \end_inset
10003
10004
10005 \series default
10006  and epilogue
10007 \series bold
10008
10009 \begin_inset LatexCommand \index{function epilogue}
10010
10011 \end_inset
10012
10013
10014 \series default
10015 ) for these functions to save and restore the registers used by these functions,
10016  this can SUBSTANTIALLY reduce code and improve run time performance of
10017  the generated code.
10018  In the future the compiler (with inter procedural analysis) will be able
10019  to determine the appropriate scheme to use for each function call.
10020  DO NOT use this option for built-in functions such as _mulint..., if this
10021  option is used for a library function the appropriate library function
10022  needs to be recompiled with the same option.
10023  If the project consists of multiple source files then all the source file
10024  should be compiled with the same -
10025 \begin_inset ERT
10026 status collapsed
10027
10028 \begin_layout Standard
10029
10030
10031 \backslash
10032 /
10033 \end_layout
10034
10035 \end_inset
10036
10037 -callee-saves option string.
10038  Also see #pragma\InsetSpace ~
10039 callee_saves 
10040 \begin_inset LatexCommand \index{\#pragma callee\_saves}
10041
10042 \end_inset
10043
10044  
10045 \begin_inset LatexCommand \vpageref{ite:callee_saves-function1[,function2[,function3...]]--}
10046
10047 \end_inset
10048
10049 .
10050 \end_layout
10051
10052 \begin_layout List
10053 \labelwidthstring 00.00.0000
10054
10055 \series bold
10056 -
10057 \begin_inset ERT
10058 status collapsed
10059
10060 \begin_layout Standard
10061
10062
10063 \backslash
10064 /
10065 \end_layout
10066
10067 \end_inset
10068
10069 -all-callee-saves
10070 \begin_inset LatexCommand \index{-\/-all-callee-saves}
10071
10072 \end_inset
10073
10074  
10075 \series default
10076 Function of
10077 \series bold
10078  
10079 \series default
10080 -
10081 \begin_inset ERT
10082 status collapsed
10083
10084 \begin_layout Standard
10085
10086
10087 \backslash
10088 /
10089 \end_layout
10090
10091 \end_inset
10092
10093 -callee-saves will be applied to all functions by default.
10094 \end_layout
10095
10096 \begin_layout List
10097 \labelwidthstring 00.00.0000
10098
10099 \series bold
10100 -
10101 \begin_inset ERT
10102 status collapsed
10103
10104 \begin_layout Standard
10105
10106
10107 \backslash
10108 /
10109 \end_layout
10110
10111 \end_inset
10112
10113 -debug
10114 \begin_inset LatexCommand \index{-\/-debug}
10115
10116 \end_inset
10117
10118
10119 \bar under
10120  
10121 \series default
10122 \bar default
10123 When this option is used the compiler will generate debug information.
10124  The debug information collected in a file with .cdb extension can be used
10125  with the SDCDB.
10126  For more information see documentation for SDCDB.
10127  Another file with no extension contains debug information in AOMF or AOMF51
10128 \begin_inset LatexCommand \index{AOMF, AOMF51}
10129
10130 \end_inset
10131
10132  format which is commonly used by third party tools.
10133 \end_layout
10134
10135 \begin_layout List
10136 \labelwidthstring 00.00.0000
10137
10138 \series bold
10139 -S
10140 \begin_inset LatexCommand \index{-S}
10141
10142 \end_inset
10143
10144
10145 \size large
10146 \bar under
10147  
10148 \series default
10149 \size default
10150 \bar default
10151 Stop after the stage of compilation proper; do not assemble.
10152  The output is an assembler code file for the input file specified.
10153 \end_layout
10154
10155 \begin_layout List
10156 \labelwidthstring 00.00.0000
10157
10158 \series bold
10159 -
10160 \begin_inset ERT
10161 status collapsed
10162
10163 \begin_layout Standard
10164
10165
10166 \backslash
10167 /
10168 \end_layout
10169
10170 \end_inset
10171
10172 -int-long-reent
10173 \begin_inset LatexCommand \index{-\/-int-long-reent}
10174
10175 \end_inset
10176
10177
10178 \series default
10179  Integer (16 bit) and long (32 bit) libraries have been compiled as reentrant.
10180  Note by default these libraries are compiled as non-reentrant.
10181  See section Installation for more details.
10182 \end_layout
10183
10184 \begin_layout List
10185 \labelwidthstring 00.00.0000
10186
10187 \series bold
10188 -
10189 \begin_inset ERT
10190 status collapsed
10191
10192 \begin_layout Standard
10193
10194
10195 \backslash
10196 /
10197 \end_layout
10198
10199 \end_inset
10200
10201 -cyclomatic
10202 \begin_inset LatexCommand \index{-\/-cyclomatic}
10203
10204 \end_inset
10205
10206
10207 \bar under
10208  
10209 \series default
10210 \bar default
10211 This option will cause the compiler to generate an information message for
10212  each function in the source file.
10213  The message contains some 
10214 \emph on
10215 important
10216 \emph default
10217  information about the function.
10218  The number of edges and nodes the compiler detected in the control flow
10219  graph of the function, and most importantly the 
10220 \emph on
10221 cyclomatic complexity
10222 \begin_inset LatexCommand \index{Cyclomatic complexity}
10223
10224 \end_inset
10225
10226
10227 \emph default
10228  see section on Cyclomatic Complexity for more details.
10229 \end_layout
10230
10231 \begin_layout List
10232 \labelwidthstring 00.00.0000
10233
10234 \series bold
10235 -
10236 \begin_inset ERT
10237 status collapsed
10238
10239 \begin_layout Standard
10240
10241
10242 \backslash
10243 /
10244 \end_layout
10245
10246 \end_inset
10247
10248 -float-reent
10249 \begin_inset LatexCommand \index{-\/-float-reent}
10250
10251 \end_inset
10252
10253
10254 \series default
10255  Floating point library is compiled as reentrant
10256 \begin_inset LatexCommand \index{reentrant}
10257
10258 \end_inset
10259
10260 .
10261  See section Installation for more details.
10262 \end_layout
10263
10264 \begin_layout List
10265 \labelwidthstring 00.00.0000
10266
10267 \series bold
10268 -
10269 \begin_inset ERT
10270 status collapsed
10271
10272 \begin_layout Standard
10273
10274
10275 \backslash
10276 /
10277 \end_layout
10278
10279 \end_inset
10280
10281 -funsigned-char
10282 \begin_inset LatexCommand \index{-\/-funsigned-char}
10283
10284 \end_inset
10285
10286
10287 \series default
10288  The default signedness for every type is
10289 \family typewriter
10290  signed
10291 \family default
10292 .
10293  In some embedded environments the default signedness of
10294 \family typewriter
10295  char
10296 \family default
10297  is
10298 \family typewriter
10299  unsigned
10300 \family default
10301 .
10302  To set the signess for characters to unsigned, use the option -
10303 \series bold
10304
10305 \begin_inset ERT
10306 status open
10307
10308 \begin_layout Standard
10309
10310
10311 \backslash
10312 /
10313 \end_layout
10314
10315 \end_inset
10316
10317
10318 \series default
10319 -funsigned-char.
10320  If this option is set and no signedness keyword (unsigned/signed) is given,
10321  a char will be signed.
10322  All other types are unaffected.
10323 \end_layout
10324
10325 \begin_layout List
10326 \labelwidthstring 00.00.0000
10327
10328 \series bold
10329 -
10330 \begin_inset ERT
10331 status collapsed
10332
10333 \begin_layout Standard
10334
10335
10336 \backslash
10337 /
10338 \end_layout
10339
10340 \end_inset
10341
10342 -main-return
10343 \begin_inset LatexCommand \index{-\/-main-return}
10344
10345 \end_inset
10346
10347
10348 \series default
10349  This option can be used if the code generated is called by a monitor program
10350  or if the main routine includes an endless loop.
10351  This option results in slightly smaller code and saves two bytes of stack
10352  space.
10353  The return from the 'main'
10354 \begin_inset LatexCommand \index{main return}
10355
10356 \end_inset
10357
10358  function will return to the function calling main.
10359  The default setting is to lock up i.e.
10360  generate a '
10361 \family typewriter
10362 sjmp .
10363 \family default
10364 '.
10365 \end_layout
10366
10367 \begin_layout List
10368 \labelwidthstring 00.00.0000
10369
10370 \series bold
10371 -
10372 \begin_inset ERT
10373 status collapsed
10374
10375 \begin_layout Standard
10376
10377
10378 \backslash
10379 /
10380 \end_layout
10381
10382 \end_inset
10383
10384 -nostdinc
10385 \begin_inset LatexCommand \index{-\/-nostdinc}
10386
10387 \end_inset
10388
10389
10390 \series default
10391  This will prevent the compiler from passing on the default include path
10392  to the preprocessor.
10393 \end_layout
10394
10395 \begin_layout List
10396 \labelwidthstring 00.00.0000
10397
10398 \series bold
10399 -
10400 \begin_inset ERT
10401 status collapsed
10402
10403 \begin_layout Standard
10404
10405
10406 \backslash
10407 /
10408 \end_layout
10409
10410 \end_inset
10411
10412 -nostdlib
10413 \begin_inset LatexCommand \index{-\/-nostdlib}
10414
10415 \end_inset
10416
10417
10418 \series default
10419  This will prevent the compiler from passing on the default library
10420 \begin_inset LatexCommand \index{Libraries}
10421
10422 \end_inset
10423
10424  path to the linker.
10425 \end_layout
10426
10427 \begin_layout List
10428 \labelwidthstring 00.00.0000
10429
10430 \series bold
10431 -
10432 \begin_inset ERT
10433 status collapsed
10434
10435 \begin_layout Standard
10436
10437
10438 \backslash
10439 /
10440 \end_layout
10441
10442 \end_inset
10443
10444 -verbose
10445 \begin_inset LatexCommand \index{-\/-verbose}
10446
10447 \end_inset
10448
10449
10450 \series default
10451  Shows the various actions the compiler is performing.
10452 \end_layout
10453
10454 \begin_layout List
10455 \labelwidthstring 00.00.0000
10456
10457 \series bold
10458 -V
10459 \begin_inset LatexCommand \index{-V}
10460
10461 \end_inset
10462
10463
10464 \series default
10465  Shows the actual commands the compiler is executing.
10466 \end_layout
10467
10468 \begin_layout List
10469 \labelwidthstring 00.00.0000
10470
10471 \series bold
10472 -
10473 \begin_inset ERT
10474 status collapsed
10475
10476 \begin_layout Standard
10477
10478
10479 \backslash
10480 /
10481 \end_layout
10482
10483 \end_inset
10484
10485 -no-c-code-in-asm
10486 \begin_inset LatexCommand \index{-\/-no-c-code-in-asm}
10487
10488 \end_inset
10489
10490
10491 \series default
10492  Hides your ugly and inefficient c-code from the asm file, so you can always
10493  blame the compiler :)
10494 \end_layout
10495
10496 \begin_layout List
10497 \labelwidthstring 00.00.0000
10498
10499 \series bold
10500 -
10501 \begin_inset ERT
10502 status collapsed
10503
10504 \begin_layout Standard
10505
10506
10507 \backslash
10508 /
10509 \end_layout
10510
10511 \end_inset
10512
10513 -fverbose-asm
10514 \begin_inset LatexCommand \index{-\/-no-gen-comments}
10515
10516 \end_inset
10517
10518
10519 \series default
10520  Include code generator and peep-hole comments in the generated asm files.
10521 \end_layout
10522
10523 \begin_layout List
10524 \labelwidthstring 00.00.0000
10525
10526 \series bold
10527 -
10528 \begin_inset ERT
10529 status collapsed
10530
10531 \begin_layout Standard
10532
10533
10534 \backslash
10535 /
10536 \end_layout
10537
10538 \end_inset
10539
10540 -no-peep-comments
10541 \begin_inset LatexCommand \index{-\/-no-peep-comments}
10542
10543 \end_inset
10544
10545
10546 \series default
10547  Don't include peep-hole comments in the generated asm files even if -
10548 \series bold
10549
10550 \begin_inset ERT
10551 status open
10552
10553 \begin_layout Standard
10554
10555
10556 \backslash
10557 /
10558 \end_layout
10559
10560 \end_inset
10561
10562
10563 \series default
10564 -fverbose-asm option is specified.
10565 \end_layout
10566
10567 \begin_layout List
10568 \labelwidthstring 00.00.0000
10569
10570 \series bold
10571 -
10572 \begin_inset ERT
10573 status collapsed
10574
10575 \begin_layout Standard
10576
10577
10578 \backslash
10579 /
10580 \end_layout
10581
10582 \end_inset
10583
10584 -i-code-in-asm
10585 \begin_inset LatexCommand \index{-\/-i-code-in-asm}
10586
10587 \end_inset
10588
10589
10590 \series default
10591  Include i-codes in the asm file.
10592  Sounds like noise but is most helpful for debugging the compiler itself.
10593 \end_layout
10594
10595 \begin_layout List
10596 \labelwidthstring 00.00.0000
10597
10598 \series bold
10599 -
10600 \begin_inset ERT
10601 status collapsed
10602
10603 \begin_layout Standard
10604
10605
10606 \backslash
10607 /
10608 \end_layout
10609
10610 \end_inset
10611
10612 -less-pedantic
10613 \begin_inset LatexCommand \index{pedantic}
10614
10615 \end_inset
10616
10617
10618 \begin_inset LatexCommand \index{-\/-less-pedantic}
10619
10620 \end_inset
10621
10622
10623 \series default
10624
10625 \begin_inset LatexCommand \label{lyx:--less-pedantic}
10626
10627 \end_inset
10628
10629  Disable some of the more pedantic warnings
10630 \begin_inset LatexCommand \index{Warnings}
10631
10632 \end_inset
10633
10634 .
10635  For more details, see the less_pedantic pragma 
10636 \begin_inset LatexCommand \vpageref{ite:less_pedantic}
10637
10638 \end_inset
10639
10640 .
10641 \end_layout
10642
10643 \begin_layout List
10644 \labelwidthstring 00.00.0000
10645
10646 \series bold
10647 -
10648 \begin_inset ERT
10649 status collapsed
10650
10651 \begin_layout Standard
10652
10653
10654 \backslash
10655 /
10656 \end_layout
10657
10658 \end_inset
10659
10660 -disable-warning\InsetSpace ~
10661 <nnnn>
10662 \begin_inset LatexCommand \index{-\/-disable-warning}
10663
10664 \end_inset
10665
10666
10667 \series default
10668  Disable specific warning with number <nnnn>.
10669 \end_layout
10670
10671 \begin_layout List
10672 \labelwidthstring 00.00.0000
10673
10674 \series bold
10675 -
10676 \begin_inset ERT
10677 status collapsed
10678
10679 \begin_layout Standard
10680
10681
10682 \backslash
10683 /
10684 \end_layout
10685
10686 \end_inset
10687
10688 -Werror
10689 \begin_inset LatexCommand \index{-\/-Werror}
10690
10691 \end_inset
10692
10693
10694 \series default
10695  Treat all warnings as errors.
10696 \end_layout
10697
10698 \begin_layout List
10699 \labelwidthstring 00.00.0000
10700
10701 \series bold
10702 -
10703 \begin_inset ERT
10704 status collapsed
10705
10706 \begin_layout Standard
10707
10708
10709 \backslash
10710 /
10711 \end_layout
10712
10713 \end_inset
10714
10715 -print-search-dirs
10716 \begin_inset LatexCommand \index{-\/-print-search-dirs}
10717
10718 \end_inset
10719
10720
10721 \series default
10722  Display the directories in the compiler's search path
10723 \end_layout
10724
10725 \begin_layout List
10726 \labelwidthstring 00.00.0000
10727
10728 \series bold
10729 -
10730 \begin_inset ERT
10731 status collapsed
10732
10733 \begin_layout Standard
10734
10735
10736 \backslash
10737 /
10738 \end_layout
10739
10740 \end_inset
10741
10742 -vc
10743 \begin_inset LatexCommand \index{-\/-vc}
10744
10745 \end_inset
10746
10747
10748 \series default
10749  Display errors and warnings using MSVC style, so you can use SDCC with
10750  the visual studio IDE
10751 \begin_inset LatexCommand \index{IDE}
10752
10753 \end_inset
10754
10755 .
10756  With SDCC both offering a GCC-like (the default) and a MSVC-like
10757 \begin_inset LatexCommand \index{MSVC output style}
10758
10759 \end_inset
10760
10761  output style, integration into most programming editors should be straightforwa
10762 rd.
10763 \end_layout
10764
10765 \begin_layout List
10766 \labelwidthstring 00.00.0000
10767
10768 \series bold
10769 -
10770 \begin_inset ERT
10771 status collapsed
10772
10773 \begin_layout Standard
10774
10775
10776 \backslash
10777 /
10778 \end_layout
10779
10780 \end_inset
10781
10782 -use-stdout
10783 \begin_inset LatexCommand \index{-\/-use-stdout}
10784
10785 \end_inset
10786
10787
10788 \series default
10789  Send errors and warnings to stdout instead of stderr.
10790 \end_layout
10791
10792 \begin_layout List
10793 \labelwidthstring 00.00.0000
10794
10795 \series bold
10796 -Wa\InsetSpace ~
10797 asmOption[,asmOption]
10798 \series default
10799
10800 \begin_inset LatexCommand \index{-Wa asmOption[,asmOption]}
10801
10802 \end_inset
10803
10804 ...
10805  Pass the asmOption to the assembler
10806 \begin_inset LatexCommand \index{Options assembler}
10807
10808 \end_inset
10809
10810
10811 \begin_inset LatexCommand \index{Assembler options}
10812
10813 \end_inset
10814
10815 .
10816  See file sdcc/as/doc/asxhtm.html for assembler options.cd
10817 \end_layout
10818
10819 \begin_layout List
10820 \labelwidthstring 00.00.0000
10821
10822 \series bold
10823 -
10824 \begin_inset ERT
10825 status collapsed
10826
10827 \begin_layout Standard
10828
10829
10830 \backslash
10831 /
10832 \end_layout
10833
10834 \end_inset
10835
10836 -std-sdcc89
10837 \begin_inset LatexCommand \index{-\/-std-sdcc89}
10838
10839 \end_inset
10840
10841
10842 \series default
10843  Generally follow the C89 standard, but allow SDCC features that conflict
10844  with the standard (default).
10845 \end_layout
10846
10847 \begin_layout List
10848 \labelwidthstring 00.00.0000
10849
10850 \series bold
10851 -
10852 \begin_inset ERT
10853 status collapsed
10854
10855 \begin_layout Standard
10856
10857
10858 \backslash
10859 /
10860 \end_layout
10861
10862 \end_inset
10863
10864 -std-c89
10865 \begin_inset LatexCommand \index{-\/-std-c89}
10866
10867 \end_inset
10868
10869
10870 \series default
10871  Follow the C89 standard and disable SDCC features that conflict with the
10872  standard.
10873 \end_layout
10874
10875 \begin_layout List
10876 \labelwidthstring 00.00.0000
10877
10878 \series bold
10879 -
10880 \begin_inset ERT
10881 status collapsed
10882
10883 \begin_layout Standard
10884
10885
10886 \backslash
10887 /
10888 \end_layout
10889
10890 \end_inset
10891
10892 -std-sdcc99
10893 \begin_inset LatexCommand \index{-\/-std-sdcc99}
10894
10895 \end_inset
10896
10897
10898 \series default
10899  Generally follow the C99 standard, but allow SDCC features that conflict
10900  with the standard (incomplete support).
10901 \end_layout
10902
10903 \begin_layout List
10904 \labelwidthstring 00.00.0000
10905
10906 \series bold
10907 -
10908 \begin_inset ERT
10909 status collapsed
10910
10911 \begin_layout Standard
10912
10913
10914 \backslash
10915 /
10916 \end_layout
10917
10918 \end_inset
10919
10920 -std-c99
10921 \begin_inset LatexCommand \index{-\/-std-sdcc99}
10922
10923 \end_inset
10924
10925
10926 \series default
10927  Follow the C99 standard and disable SDCC features that conflict with the
10928  standard (incomplete support).
10929 \end_layout
10930
10931 \begin_layout List
10932 \labelwidthstring 00.00.0000
10933
10934 \series bold
10935 -
10936 \begin_inset ERT
10937 status collapsed
10938
10939 \begin_layout Standard
10940
10941
10942 \backslash
10943 /
10944 \end_layout
10945
10946 \end_inset
10947
10948 -codeseg
10949 \series default
10950
10951 \begin_inset LatexCommand \index{-\/-codeseg <Value>}
10952
10953 \end_inset
10954
10955
10956 \begin_inset LatexCommand \label{lyx:-codeseg}
10957
10958 \end_inset
10959
10960 \InsetSpace ~
10961 <Name> The name to be used for the code
10962 \begin_inset LatexCommand \index{code}
10963
10964 \end_inset
10965
10966  segment, default CSEG.
10967  This is useful if you need to tell the compiler to put the code in a special
10968  segment so you can later on tell the linker to put this segment in a special
10969  place in memory.
10970  Can be used for instance when using bank switching to put the code in a
10971  bank.
10972 \end_layout
10973
10974 \begin_layout List
10975 \labelwidthstring 00.00.0000
10976
10977 \series bold
10978 -
10979 \begin_inset ERT
10980 status collapsed
10981
10982 \begin_layout Standard
10983
10984
10985 \backslash
10986 /
10987 \end_layout
10988
10989 \end_inset
10990
10991 -constseg
10992 \series default
10993
10994 \begin_inset LatexCommand \index{-\/-constseg <Value>}
10995
10996 \end_inset
10997
10998 \InsetSpace ~
10999 <Name> The name to be used for the const
11000 \begin_inset LatexCommand \index{const}
11001
11002 \end_inset
11003
11004  segment, default CONST.
11005  This is useful if you need to tell the compiler to put the const data in
11006  a special segment so you can later on tell the linker to put this segment
11007  in a special place in memory.
11008  Can be used for instance when using bank switching to put the const data
11009  in a bank.
11010 \end_layout
11011
11012 \begin_layout List
11013 \labelwidthstring 00.00.0000
11014
11015 \series bold
11016 -
11017 \begin_inset ERT
11018 status collapsed
11019
11020 \begin_layout Standard
11021
11022
11023 \backslash
11024 /
11025 \end_layout
11026
11027 \end_inset
11028
11029 -fdollars-in-identifiers
11030 \begin_inset LatexCommand \index{-\/-fdollars-in-identifiers}
11031
11032 \end_inset
11033
11034
11035 \series default
11036  Permit '$' as an identifier character.
11037 \end_layout
11038
11039 \begin_layout List
11040 \labelwidthstring 00.00.0000
11041
11042 \series bold
11043 -
11044 \begin_inset ERT
11045 status collapsed
11046
11047 \begin_layout Standard
11048
11049
11050 \backslash
11051 /
11052 \end_layout
11053
11054 \end_inset
11055
11056 -more-pedantic
11057 \series default
11058
11059 \begin_inset LatexCommand \index{-\/-more-pedantic}
11060
11061 \end_inset
11062
11063
11064 \begin_inset LatexCommand \index{pedantic}
11065
11066 \end_inset
11067
11068  Actually this is 
11069 \series bold
11070 \emph on
11071 not
11072 \series default
11073 \emph default
11074  a SDCC compiler option but if you want 
11075 \emph on
11076 more
11077 \emph default
11078  warnings you can use a separate tool dedicated to syntax checking like
11079  splint
11080 \begin_inset LatexCommand \label{lyx:more-pedantic-SPLINT}
11081
11082 \end_inset
11083
11084
11085 \begin_inset LatexCommand \index{lint (syntax checking tool)}
11086
11087 \end_inset
11088
11089  
11090 \begin_inset LatexCommand \url{http://www.splint.org}
11091
11092 \end_inset
11093
11094 .
11095  To make your source files parseable by splint you will have to include
11096  
11097 \family sans
11098 lint.h
11099 \family default
11100
11101 \begin_inset LatexCommand \index{splint (syntax checking tool)}
11102
11103 \end_inset
11104
11105  in your source file and add brackets around extended keywords (like 
11106 \family sans
11107
11108 \begin_inset Quotes sld
11109 \end_inset
11110
11111 __at\InsetSpace ~
11112
11113 \series bold
11114 (
11115 \series default
11116 0xab
11117 \series bold
11118 )
11119 \series default
11120
11121 \begin_inset Quotes srd
11122 \end_inset
11123
11124
11125 \family default
11126  and 
11127 \family sans
11128
11129 \begin_inset Quotes sld
11130 \end_inset
11131
11132 __interrupt\InsetSpace ~
11133 (2)
11134 \begin_inset Quotes srd
11135 \end_inset
11136
11137
11138 \family default
11139 ).
11140  
11141 \newline
11142 Splint has an excellent on line manual at 
11143 \begin_inset LatexCommand \url{http://www.splint.org/manual/}
11144
11145 \end_inset
11146
11147  and it's capabilities go beyond pure syntax checking.
11148  You'll need to tell splint the location of SDCC's include files so a typical
11149  command line could look like this: 
11150 \newline
11151
11152 \family sans
11153 splint\InsetSpace ~
11154 -I\InsetSpace ~
11155 /usr/local/share/sdcc/include/mcs51/\InsetSpace ~
11156 \InsetSpace ~
11157 myprogram.c
11158 \end_layout
11159
11160 \begin_layout List
11161 \labelwidthstring 00.00.0000
11162
11163 \series bold
11164 -
11165 \begin_inset ERT
11166 status collapsed
11167
11168 \begin_layout Standard
11169
11170
11171 \backslash
11172 /
11173 \end_layout
11174
11175 \end_inset
11176
11177 -short-is-8bits
11178 \series default
11179
11180 \begin_inset LatexCommand \index{-\/-short-is-8bits}
11181
11182 \end_inset
11183
11184
11185 \begin_inset LatexCommand \label{lyx:--short-is-8bits}
11186
11187 \end_inset
11188
11189  Treat short as 8-bit (for backward compatibility with older versions of
11190  compiler - see section 
11191 \begin_inset LatexCommand \ref{sec:Compatibility-with-previous}
11192
11193 \end_inset
11194
11195 )
11196 \end_layout
11197
11198 \begin_layout Standard
11199 \begin_inset VSpace bigskip
11200 \end_inset
11201
11202
11203 \end_layout
11204
11205 \begin_layout Subsection
11206 Intermediate Dump Options
11207 \begin_inset LatexCommand \label{sub:Intermediate-Dump-Options}
11208
11209 \end_inset
11210
11211
11212 \begin_inset LatexCommand \index{Options intermediate dump}
11213
11214 \end_inset
11215
11216
11217 \begin_inset LatexCommand \index{Intermediate dump options}
11218
11219 \end_inset
11220
11221
11222 \end_layout
11223
11224 \begin_layout Standard
11225 The following options are provided for the purpose of retargetting and debugging
11226  the compiler.
11227  They provide a means to dump the intermediate code (iCode
11228 \begin_inset LatexCommand \index{iCode}
11229
11230 \end_inset
11231
11232 ) generated by the compiler in human readable form at various stages of
11233  the compilation process.
11234  More on iCodes see chapter 
11235 \begin_inset LatexCommand \ref{sub:The-anatomy-of}
11236
11237 \end_inset
11238
11239  
11240 \begin_inset Quotes srd
11241 \end_inset
11242
11243 The anatomy of the compiler
11244 \begin_inset Quotes srd
11245 \end_inset
11246
11247 .
11248 \end_layout
11249
11250 \begin_layout List
11251 \labelwidthstring 00.00.0000
11252
11253 \series bold
11254 -
11255 \begin_inset ERT
11256 status collapsed
11257
11258 \begin_layout Standard
11259
11260
11261 \backslash
11262 /
11263 \end_layout
11264
11265 \end_inset
11266
11267 -dumpraw
11268 \begin_inset LatexCommand \index{-\/-dumpraw}
11269
11270 \end_inset
11271
11272
11273 \series default
11274  This option will cause the compiler to dump the intermediate code into
11275  a file of named 
11276 \emph on
11277 <source filename>.dumpraw
11278 \emph default
11279  just after the intermediate code has been generated for a function, i.e.
11280  before any optimizations are done.
11281  The basic blocks
11282 \begin_inset LatexCommand \index{Basic blocks}
11283
11284 \end_inset
11285
11286  at this stage ordered in the depth first number, so they may not be in
11287  sequence of execution.
11288 \end_layout
11289
11290 \begin_layout List
11291 \labelwidthstring 00.00.0000
11292
11293 \series bold
11294 -
11295 \begin_inset ERT
11296 status collapsed
11297
11298 \begin_layout Standard
11299
11300
11301 \backslash
11302 /
11303 \end_layout
11304
11305 \end_inset
11306
11307 -dumpgcse
11308 \begin_inset LatexCommand \index{-\/-dumpgcse}
11309
11310 \end_inset
11311
11312
11313 \series default
11314  Will create a dump of iCodes, after global subexpression elimination
11315 \begin_inset LatexCommand \index{Global subexpression elimination}
11316
11317 \end_inset
11318
11319 , into a file named 
11320 \emph on
11321 <source filename>.dumpgcse.
11322 \end_layout
11323
11324 \begin_layout List
11325 \labelwidthstring 00.00.0000
11326
11327 \series bold
11328 -
11329 \begin_inset ERT
11330 status collapsed
11331
11332 \begin_layout Standard
11333
11334
11335 \backslash
11336 /
11337 \end_layout
11338
11339 \end_inset
11340
11341 -dumpdeadcode
11342 \begin_inset LatexCommand \index{-\/-dumpdeadcode}
11343
11344 \end_inset
11345
11346
11347 \series default
11348  Will create a dump of iCodes, after deadcode elimination
11349 \begin_inset LatexCommand \index{Dead-code elimination}
11350
11351 \end_inset
11352
11353 , into a file named 
11354 \emph on
11355 <source filename>.dumpdeadcode.
11356 \end_layout
11357
11358 \begin_layout List
11359 \labelwidthstring 00.00.0000
11360
11361 \series bold
11362 -
11363 \begin_inset ERT
11364 status collapsed
11365
11366 \begin_layout Standard
11367
11368
11369 \backslash
11370 /
11371 \end_layout
11372
11373 \end_inset
11374
11375 -dumploop
11376 \begin_inset LatexCommand \index{-\/-dumploop}
11377
11378 \end_inset
11379
11380
11381 \series default
11382 \size large
11383  
11384 \size default
11385 Will create a dump of iCodes, after loop optimizations
11386 \begin_inset LatexCommand \index{Loop optimization}
11387
11388 \end_inset
11389
11390 , into a file named 
11391 \emph on
11392 <source filename>.dumploop.
11393 \end_layout
11394
11395 \begin_layout List
11396 \labelwidthstring 00.00.0000
11397
11398 \series bold
11399 -
11400 \begin_inset ERT
11401 status collapsed
11402
11403 \begin_layout Standard
11404
11405
11406 \backslash
11407 /
11408 \end_layout
11409
11410 \end_inset
11411
11412 -dumprange
11413 \begin_inset LatexCommand \index{-\/-dumprange}
11414
11415 \end_inset
11416
11417
11418 \series default
11419 \size large
11420  
11421 \size default
11422 Will create a dump of iCodes, after live range analysis
11423 \begin_inset LatexCommand \index{Live range analysis}
11424
11425 \end_inset
11426
11427 , into a file named 
11428 \emph on
11429 <source filename>.dumprange.
11430 \end_layout
11431
11432 \begin_layout List
11433 \labelwidthstring 00.00.0000
11434
11435 \series bold
11436 -
11437 \begin_inset ERT
11438 status collapsed
11439
11440 \begin_layout Standard
11441
11442
11443 \backslash
11444 /
11445 \end_layout
11446
11447 \end_inset
11448
11449 -dumlrange
11450 \begin_inset LatexCommand \index{-\/-dumlrange}
11451
11452 \end_inset
11453
11454
11455 \series default
11456  Will dump the life ranges
11457 \begin_inset LatexCommand \index{Live range analysis}
11458
11459 \end_inset
11460
11461  for all symbols.
11462 \end_layout
11463
11464 \begin_layout List
11465 \labelwidthstring 00.00.0000
11466
11467 \series bold
11468 -
11469 \begin_inset ERT
11470 status collapsed
11471
11472 \begin_layout Standard
11473
11474
11475 \backslash
11476 /
11477 \end_layout
11478
11479 \end_inset
11480
11481 -dumpregassign
11482 \begin_inset LatexCommand \index{-\/-dumpregassign}
11483
11484 \end_inset
11485
11486
11487 \bar under
11488  
11489 \series default
11490 \bar default
11491 Will create a dump of iCodes, after register assignment
11492 \begin_inset LatexCommand \index{Register assignment}
11493
11494 \end_inset
11495
11496 , into a file named 
11497 \emph on
11498 <source filename>.dumprassgn.
11499 \end_layout
11500
11501 \begin_layout List
11502 \labelwidthstring 00.00.0000
11503
11504 \series bold
11505 -
11506 \begin_inset ERT
11507 status collapsed
11508
11509 \begin_layout Standard
11510
11511
11512 \backslash
11513 /
11514 \end_layout
11515
11516 \end_inset
11517
11518 -dumplrange
11519 \begin_inset LatexCommand \index{-\/-dumplrange}
11520
11521 \end_inset
11522
11523
11524 \series default
11525  Will create a dump of the live ranges of iTemp's
11526 \end_layout
11527
11528 \begin_layout List
11529 \labelwidthstring 00.00.0000
11530
11531 \series bold
11532 -
11533 \begin_inset ERT
11534 status collapsed
11535
11536 \begin_layout Standard
11537
11538
11539 \backslash
11540 /
11541 \end_layout
11542
11543 \end_inset
11544
11545 -dumpall
11546 \begin_inset LatexCommand \index{-\/-dumpall}
11547
11548 \end_inset
11549
11550
11551 \size large
11552 \bar under
11553  
11554 \series default
11555 \size default
11556 \bar default
11557 Will cause all the above mentioned dumps to be created.
11558 \end_layout
11559
11560 \begin_layout Standard
11561 \begin_inset VSpace bigskip
11562 \end_inset
11563
11564
11565 \end_layout
11566
11567 \begin_layout Subsection
11568 Redirecting output on Windows Shells
11569 \end_layout
11570
11571 \begin_layout Standard
11572 By default SDCC writes its error messages to 
11573 \begin_inset Quotes sld
11574 \end_inset
11575
11576 standard error
11577 \begin_inset Quotes srd
11578 \end_inset
11579
11580 .
11581  To force all messages to 
11582 \begin_inset Quotes sld
11583 \end_inset
11584
11585 standard output
11586 \begin_inset Quotes srd
11587 \end_inset
11588
11589  use 
11590 \series bold
11591 -
11592 \series default
11593 \emph on
11594
11595 \begin_inset ERT
11596 status collapsed
11597
11598 \begin_layout Standard
11599
11600
11601 \backslash
11602 /
11603 \end_layout
11604
11605 \end_inset
11606
11607
11608 \series bold
11609 \emph default
11610 -
11611 \series default
11612 use-stdout
11613 \begin_inset LatexCommand \index{-\/-use-stdout}
11614
11615 \end_inset
11616
11617 .
11618  Additionally, if you happen to have visual studio installed in your windows
11619  machine, you can use it to compile your sources using a custom build and
11620  the SDCC -
11621 \emph on
11622
11623 \begin_inset ERT
11624 status collapsed
11625
11626 \begin_layout Standard
11627
11628
11629 \backslash
11630 /
11631 \end_layout
11632
11633 \end_inset
11634
11635
11636 \emph default
11637 -vc
11638 \begin_inset LatexCommand \index{-\/-vc}
11639
11640 \end_inset
11641
11642  option.
11643  Something like this should work:
11644 \newline
11645
11646 \newline
11647
11648 \series bold
11649 c:
11650 \backslash
11651 sdcc
11652 \backslash
11653 bin
11654 \backslash
11655 sdcc.exe -
11656 \series default
11657 \emph on
11658
11659 \begin_inset ERT
11660 status collapsed
11661
11662 \begin_layout Standard
11663
11664
11665 \backslash
11666 /
11667 \end_layout
11668
11669 \end_inset
11670
11671
11672 \series bold
11673 \emph default
11674 -vc -
11675 \series default
11676 \emph on
11677
11678 \begin_inset ERT
11679 status collapsed
11680
11681 \begin_layout Standard
11682
11683
11684 \backslash
11685 /
11686 \end_layout
11687
11688 \end_inset
11689
11690
11691 \series bold
11692 \emph default
11693 -model-large -c $(InputPath)
11694 \series default
11695
11696 \begin_inset VSpace bigskip
11697 \end_inset
11698
11699
11700 \end_layout
11701
11702 \begin_layout Section
11703 Environment variables
11704 \begin_inset LatexCommand \index{Environment variables}
11705
11706 \end_inset
11707
11708
11709 \end_layout
11710
11711 \begin_layout Standard
11712 SDCC recognizes the following environment variables:
11713 \end_layout
11714
11715 \begin_layout List
11716 \labelwidthstring 00.00.0000
11717
11718 \series bold
11719 SDCC_LEAVE_SIGNALS
11720 \begin_inset LatexCommand \index{SDCC\_LEAVE\_SIGNALS}
11721
11722 \end_inset
11723
11724
11725 \series default
11726  SDCC installs a signal handler
11727 \begin_inset LatexCommand \index{signal handler}
11728
11729 \end_inset
11730
11731  to be able to delete temporary files after an user break (^C) or an exception.
11732  If this environment variable is set, SDCC won't install the signal handler
11733  in order to be able to debug SDCC.
11734 \end_layout
11735
11736 \begin_layout List
11737 \labelwidthstring 00.00.0000
11738
11739 \series bold
11740 TMP,\InsetSpace ~
11741 TEMP,\InsetSpace ~
11742 TMPDIR
11743 \begin_inset LatexCommand \index{TMP, TEMP, TMPDIR}
11744
11745 \end_inset
11746
11747
11748 \series default
11749  Path, where temporary files will be created.
11750  The order of the variables is the search order.
11751  In a standard *nix environment these variables are not set, and there's
11752  no need to set them.
11753  On Windows it's recommended to set one of them.
11754 \end_layout
11755
11756 \begin_layout List
11757 \labelwidthstring 00.00.0000
11758
11759 \series bold
11760 SDCC_HOME
11761 \begin_inset LatexCommand \index{SDCC\_HOME}
11762
11763 \end_inset
11764
11765
11766 \series default
11767  Path, see section 
11768 \begin_inset LatexCommand \ref{sub:Install-paths}
11769
11770 \end_inset
11771
11772 \InsetSpace ~
11773
11774 \begin_inset Quotes sld
11775 \end_inset
11776
11777  Install Paths
11778 \begin_inset Quotes srd
11779 \end_inset
11780
11781 .
11782 \end_layout
11783
11784 \begin_layout List
11785 \labelwidthstring 00.00.0000
11786
11787 \series bold
11788 SDCC_INCLUDE
11789 \begin_inset LatexCommand \index{SDCC\_INCLUDE}
11790
11791 \end_inset
11792
11793
11794 \series default
11795  Path, see section 
11796 \begin_inset LatexCommand \ref{sub:Search-Paths}
11797
11798 \end_inset
11799
11800 \InsetSpace ~
11801
11802 \begin_inset Quotes sld
11803 \end_inset
11804
11805 Search Paths
11806 \begin_inset Quotes srd
11807 \end_inset
11808
11809 .
11810 \end_layout
11811
11812 \begin_layout List
11813 \labelwidthstring 00.00.0000
11814
11815 \series bold
11816 SDCC_LIB
11817 \begin_inset LatexCommand \index{SDCC\_LIB}
11818
11819 \end_inset
11820
11821
11822 \series default
11823  Path, see section 
11824 \begin_inset LatexCommand \ref{sub:Search-Paths}
11825
11826 \end_inset
11827
11828 \InsetSpace ~
11829
11830 \begin_inset Quotes sld
11831 \end_inset
11832
11833 Search Paths
11834 \begin_inset Quotes srd
11835 \end_inset
11836
11837 ..
11838 \end_layout
11839
11840 \begin_layout Standard
11841 There are some more environment variables recognized by SDCC, but these
11842  are solely used for debugging purposes.
11843  They can change or disappear very quickly, and will never be documented.
11844 \begin_inset VSpace bigskip
11845 \end_inset
11846
11847
11848 \end_layout
11849
11850 \begin_layout Section
11851 Storage Class Language Extensions
11852 \end_layout
11853
11854 \begin_layout Subsection
11855 MCS51/DS390 Storage Class
11856 \begin_inset LatexCommand \index{Storage class}
11857
11858 \end_inset
11859
11860  Language Extensions
11861 \end_layout
11862
11863 \begin_layout Standard
11864 In addition to the ANSI storage classes SDCC allows the following MCS51
11865  specific storage classes:
11866 \end_layout
11867
11868 \begin_layout Subsubsection
11869 data
11870 \begin_inset LatexCommand \index{data (mcs51, ds390 storage class)}
11871
11872 \end_inset
11873
11874
11875 \begin_inset LatexCommand \index{\_\_data (mcs51, ds390 storage class)}
11876
11877 \end_inset
11878
11879  / near
11880 \begin_inset LatexCommand \index{near (storage class)}
11881
11882 \end_inset
11883
11884
11885 \begin_inset LatexCommand \index{\_\_near (storage class)}
11886
11887 \end_inset
11888
11889
11890 \end_layout
11891
11892 \begin_layout Standard
11893 This is the 
11894 \series bold
11895 default
11896 \series default
11897  storage class for the Small Memory model (
11898 \emph on
11899 data
11900 \emph default
11901  and 
11902 \emph on
11903 near
11904 \emph default
11905  or the more ANSI-C compliant forms 
11906 \emph on
11907 __data
11908 \emph default
11909  and 
11910 \emph on
11911 __near
11912 \emph default
11913  can be used synonymously).
11914  Variables declared with this storage class will be allocated in the directly
11915  addressable portion of the internal RAM of a 8051, e.g.:
11916 \end_layout
11917
11918 \begin_layout Verse
11919
11920 \family typewriter
11921 __data unsigned char test_data;
11922 \end_layout
11923
11924 \begin_layout Standard
11925 Writing 0x01 to this variable generates the assembly code:
11926 \end_layout
11927
11928 \begin_layout Verse
11929
11930 \family typewriter
11931 75*00 01\InsetSpace ~
11932 \InsetSpace ~
11933 \InsetSpace ~
11934 mov\InsetSpace ~
11935 \InsetSpace ~
11936 _test_data,#0x01
11937 \end_layout
11938
11939 \begin_layout Subsubsection
11940 xdata
11941 \begin_inset LatexCommand \index{xdata (mcs51, ds390 storage class)}
11942
11943 \end_inset
11944
11945
11946 \begin_inset LatexCommand \index{\_\_xdata (mcs51, ds390 storage class)}
11947
11948 \end_inset
11949
11950  / far
11951 \begin_inset LatexCommand \index{far (storage class)}
11952
11953 \end_inset
11954
11955
11956 \begin_inset LatexCommand \index{\_\_far (storage class)}
11957
11958 \end_inset
11959
11960
11961 \end_layout
11962
11963 \begin_layout Standard
11964 Variables declared with this storage class will be placed in the external
11965  RAM.
11966  This is the 
11967 \series bold
11968 default
11969 \series default
11970  storage class for the Large Memory model, e.g.:
11971 \end_layout
11972
11973 \begin_layout Verse
11974
11975 \family typewriter
11976 __xdata unsigned char test_xdata;
11977 \end_layout
11978
11979 \begin_layout Standard
11980 Writing 0x01 to this variable generates the assembly code:
11981 \end_layout
11982
11983 \begin_layout Verse
11984
11985 \family typewriter
11986 90s00r00\InsetSpace ~
11987 \InsetSpace ~
11988 \InsetSpace ~
11989 mov\InsetSpace ~
11990 \InsetSpace ~
11991 dptr,#_test_xdata 
11992 \newline
11993 74\InsetSpace ~
11994 01\InsetSpace ~
11995 \InsetSpace ~
11996 \InsetSpace ~
11997 \InsetSpace ~
11998 \InsetSpace ~
11999 \InsetSpace ~
12000 mov\InsetSpace ~
12001 \InsetSpace ~
12002 a,#0x01 
12003 \newline
12004 F0\InsetSpace ~
12005 \InsetSpace ~
12006 \InsetSpace ~
12007 \InsetSpace ~
12008 \InsetSpace ~
12009 \InsetSpace ~
12010 \InsetSpace ~
12011 \InsetSpace ~
12012 \InsetSpace ~
12013 movx\InsetSpace ~
12014 @dptr,a 
12015 \end_layout
12016
12017 \begin_layout Subsubsection
12018 idata
12019 \begin_inset LatexCommand \index{idata (mcs51, ds390 storage class)}
12020
12021 \end_inset
12022
12023
12024 \begin_inset LatexCommand \index{\_\_idata (mcs51, ds390 storage class)}
12025
12026 \end_inset
12027
12028
12029 \end_layout
12030
12031 \begin_layout Standard
12032 Variables declared with this storage class will be allocated into the indirectly
12033  addressable portion of the internal ram of a 8051, e.g.:
12034 \end_layout
12035
12036 \begin_layout Verse
12037
12038 \family typewriter
12039 __idata unsigned char test_idata;
12040 \end_layout
12041
12042 \begin_layout Standard
12043 Writing 0x01 to this variable generates the assembly code:
12044 \end_layout
12045
12046 \begin_layout Verse
12047
12048 \family typewriter
12049 78r00\InsetSpace ~
12050 \InsetSpace ~
12051 \InsetSpace ~
12052 \InsetSpace ~
12053 \InsetSpace ~
12054 \InsetSpace ~
12055 \InsetSpace ~
12056 mov\InsetSpace ~
12057 \InsetSpace ~
12058 r0,#_test_idata
12059 \newline
12060 76\InsetSpace ~
12061 01\InsetSpace ~
12062 \InsetSpace ~
12063 \InsetSpace ~
12064 \InsetSpace ~
12065 \InsetSpace ~
12066 \InsetSpace ~
12067 \InsetSpace ~
12068 mov\InsetSpace ~
12069 \InsetSpace ~
12070 @r0,#0x01
12071 \end_layout
12072
12073 \begin_layout Standard
12074 Please note, the first 128 byte of idata physically access the same RAM
12075  as the data memory.
12076  The original 8051 had 128 byte idata memory, nowadays most devices have
12077  256 byte idata memory.
12078  The stack
12079 \begin_inset LatexCommand \index{stack}
12080
12081 \end_inset
12082
12083  is located in idata memory.
12084 \end_layout
12085
12086 \begin_layout Subsubsection
12087 pdata
12088 \begin_inset LatexCommand \index{pdata (mcs51, ds390 storage class)}
12089
12090 \end_inset
12091
12092
12093 \begin_inset LatexCommand \index{\_\_pdata (mcs51, ds390 storage class)}
12094
12095 \end_inset
12096
12097
12098 \end_layout
12099
12100 \begin_layout Standard
12101 Paged xdata access is just as straightforward as using the other addressing
12102  modes of a 8051.
12103  It is typically located at the start of xdata and has a maximum size of
12104  256 bytes.
12105  The following example writes 0x01 to the pdata variable.
12106  Please note, pdata access physically accesses xdata memory.
12107  The high byte of the address is determined by port P2 
12108 \begin_inset LatexCommand \index{P2 (mcs51 sfr)}
12109
12110 \end_inset
12111
12112 (or in case of some 8051 variants by a separate Special Function Register,
12113  see section 
12114 \begin_inset LatexCommand \ref{sub:MCS51-variants}
12115
12116 \end_inset
12117
12118 ).
12119  This is the 
12120 \series bold
12121 default
12122 \series default
12123  storage class for the Medium Memory model, e.g.:
12124 \end_layout
12125
12126 \begin_layout Verse
12127
12128 \family typewriter
12129 __pdata unsigned char test_pdata;
12130 \end_layout
12131
12132 \begin_layout Standard
12133 Writing 0x01 to this variable generates the assembly code:
12134 \end_layout
12135
12136 \begin_layout Verse
12137
12138 \family typewriter
12139 78r00\InsetSpace ~
12140 \InsetSpace ~
12141 \InsetSpace ~
12142 \InsetSpace ~
12143 \InsetSpace ~
12144 \InsetSpace ~
12145 mov r0,#_test_pdata
12146 \newline
12147 74 01\InsetSpace ~
12148 \InsetSpace ~
12149 \InsetSpace ~
12150 \InsetSpace ~
12151 \InsetSpace ~
12152 \InsetSpace ~
12153 mov a,#0x01 
12154 \newline
12155 F2\InsetSpace ~
12156 \InsetSpace ~
12157 \InsetSpace ~
12158 \InsetSpace ~
12159 \InsetSpace ~
12160 \InsetSpace ~
12161 \InsetSpace ~
12162 \InsetSpace ~
12163 \InsetSpace ~
12164 movx @r0,a
12165 \end_layout
12166
12167 \begin_layout Standard
12168 If the -
12169 \begin_inset ERT
12170 status collapsed
12171
12172 \begin_layout Standard
12173
12174
12175 \backslash
12176 /
12177 \end_layout
12178
12179 \end_inset
12180
12181 -xstack
12182 \begin_inset LatexCommand \index{-\/-xstack}
12183
12184 \end_inset
12185
12186  option is used the pdata memory area is followed by the xstack memory area
12187  and the sum of their sizes is limited to 256 bytes.
12188 \end_layout
12189
12190 \begin_layout Subsubsection
12191 code
12192 \begin_inset LatexCommand \index{code}
12193
12194 \end_inset
12195
12196
12197 \begin_inset LatexCommand \index{\_\_code}
12198
12199 \end_inset
12200
12201
12202 \end_layout
12203
12204 \begin_layout Standard
12205 'Variables' declared with this storage class will be placed in the code
12206  memory:
12207 \end_layout
12208
12209 \begin_layout Verse
12210
12211 \family typewriter
12212 __code unsigned char test_code;
12213 \end_layout
12214
12215 \begin_layout Standard
12216 Read access to this variable generates the assembly code:
12217 \end_layout
12218
12219 \begin_layout Verse
12220
12221 \family typewriter
12222 90s00r6F\InsetSpace ~
12223 \InsetSpace ~
12224 \InsetSpace ~
12225 mov dptr,#_test_code
12226 \newline
12227 E4\InsetSpace ~
12228 \InsetSpace ~
12229 \InsetSpace ~
12230 \InsetSpace ~
12231 \InsetSpace ~
12232 \InsetSpace ~
12233 \InsetSpace ~
12234 \InsetSpace ~
12235 \InsetSpace ~
12236 clr a
12237 \newline
12238 93\InsetSpace ~
12239 \InsetSpace ~
12240 \InsetSpace ~
12241 \InsetSpace ~
12242 \InsetSpace ~
12243 \InsetSpace ~
12244 \InsetSpace ~
12245 \InsetSpace ~
12246 \InsetSpace ~
12247 movc a,@a+dptr 
12248 \end_layout
12249
12250 \begin_layout Standard
12251
12252 \family typewriter
12253 char
12254 \family default
12255  indexed arrays of characters in code memory can be accessed efficiently:
12256 \end_layout
12257
12258 \begin_layout Verse
12259
12260 \family typewriter
12261 __code char test_array[] = {'c','h','e','a','p'}; 
12262 \end_layout
12263
12264 \begin_layout Standard
12265 Read access to this array using an 8-bit unsigned index generates the assembly
12266  code:
12267 \end_layout
12268
12269 \begin_layout Verse
12270
12271 \family typewriter
12272 E5*00\InsetSpace ~
12273 \InsetSpace ~
12274 \InsetSpace ~
12275 \InsetSpace ~
12276 \InsetSpace ~
12277 \InsetSpace ~
12278 mov a,_index 
12279 \end_layout
12280
12281 \begin_layout Verse
12282
12283 \family typewriter
12284 90s00r41\InsetSpace ~
12285 \InsetSpace ~
12286 \InsetSpace ~
12287 mov dptr,#_test_array
12288 \end_layout
12289
12290 \begin_layout Verse
12291
12292 \family typewriter
12293 93\InsetSpace ~
12294 \InsetSpace ~
12295 \InsetSpace ~
12296 \InsetSpace ~
12297 \InsetSpace ~
12298 \InsetSpace ~
12299 \InsetSpace ~
12300 \InsetSpace ~
12301 \InsetSpace ~
12302 movc a,@a+dptr 
12303 \end_layout
12304
12305 \begin_layout Subsubsection
12306 bit
12307 \begin_inset LatexCommand \index{bit}
12308
12309 \end_inset
12310
12311
12312 \begin_inset LatexCommand \index{\_\_bit}
12313
12314 \end_inset
12315
12316
12317 \end_layout
12318
12319 \begin_layout Standard
12320 This is a data-type and a storage class specifier.
12321  When a variable is declared as a bit, it is allocated into the bit addressable
12322  memory of 8051, e.g.:
12323 \end_layout
12324
12325 \begin_layout Verse
12326
12327 \family typewriter
12328 __bit test_bit;
12329 \end_layout
12330
12331 \begin_layout Standard
12332 Writing 1 to this variable generates the assembly code:
12333 \end_layout
12334
12335 \begin_layout Verse
12336
12337 \family typewriter
12338 D2*00\InsetSpace ~
12339 \InsetSpace ~
12340 \InsetSpace ~
12341 \InsetSpace ~
12342 \InsetSpace ~
12343 \InsetSpace ~
12344 \InsetSpace ~
12345 setb\InsetSpace ~
12346 _test_bit
12347 \end_layout
12348
12349 \begin_layout Standard
12350 The bit addressable memory consists of 128 bits which are located from 0x20
12351  to 0x2f in data memory.
12352  
12353 \newline
12354 Apart from this 8051 specific storage class most architectures support
12355  ANSI-C bitfields
12356 \begin_inset LatexCommand \index{bitfields}
12357
12358 \end_inset
12359
12360
12361 \begin_inset Foot
12362 status open
12363
12364 \begin_layout Standard
12365 Not really meant as examples, but nevertheless showing what bitfields are
12366  about: device/include/mc68hc908qy.h and support/regression/tests/bitfields.c
12367 \end_layout
12368
12369 \end_inset
12370
12371 .
12372  In accordance with ISO/IEC 9899 bits and bitfields without an explicit
12373  signed modifier are implemented as unsigned.
12374 \end_layout
12375
12376 \begin_layout Subsubsection
12377 sfr
12378 \begin_inset LatexCommand \index{sfr}
12379
12380 \end_inset
12381
12382
12383 \begin_inset LatexCommand \index{\_\_sfr}
12384
12385 \end_inset
12386
12387  / sfr16
12388 \begin_inset LatexCommand \index{sfr16}
12389
12390 \end_inset
12391
12392
12393 \begin_inset LatexCommand \index{\_\_sfr16}
12394
12395 \end_inset
12396
12397  / sfr32
12398 \begin_inset LatexCommand \index{sfr32}
12399
12400 \end_inset
12401
12402
12403 \begin_inset LatexCommand \index{\_\_sfr32}
12404
12405 \end_inset
12406
12407  / sbit
12408 \begin_inset LatexCommand \index{\_\_sbit}
12409
12410 \end_inset
12411
12412
12413 \begin_inset LatexCommand \index{sbit}
12414
12415 \end_inset
12416
12417
12418 \end_layout
12419
12420 \begin_layout Standard
12421 Like the bit keyword, 
12422 \emph on
12423 sfr / sfr16 / sfr32 / sbit 
12424 \emph default
12425 signify both a data-type and storage class, they are used to describe the
12426  
12427 \emph on
12428 s
12429 \emph default
12430 pecial 
12431 \emph on
12432 f
12433 \emph default
12434 unction 
12435 \emph on
12436 r
12437 \emph default
12438 egisters and 
12439 \emph on
12440 s
12441 \emph default
12442 pecial 
12443 \emph on
12444 bit
12445 \emph default
12446  variables of a 8051, eg:
12447 \end_layout
12448
12449 \begin_layout Verse
12450
12451 \family typewriter
12452 __sfr __at
12453 \begin_inset LatexCommand \index{at}
12454
12455 \end_inset
12456
12457
12458 \begin_inset LatexCommand \index{\_\_at}
12459
12460 \end_inset
12461
12462  (0x80) P0;\InsetSpace ~
12463  /* special function register P0 at location 0x80 */
12464 \newline
12465
12466 \newline
12467 /* 16 bit
12468  special function register combination for timer 0
12469 \newline
12470 \InsetSpace ~
12471 \InsetSpace ~
12472  with the high byte at
12473  location 0x8C and the low byte at location 0x8A */
12474 \newline
12475 __sfr16 __at (0x8C8A)
12476  TMR0;
12477 \newline
12478
12479 \newline
12480 __sbit __at
12481 \begin_inset LatexCommand \index{at}
12482
12483 \end_inset
12484
12485
12486 \begin_inset LatexCommand \index{\_\_at}
12487
12488 \end_inset
12489
12490  (0xd7) CY;\InsetSpace ~
12491  /* CY (Carry Flag
12492 \begin_inset LatexCommand \index{Flags}
12493
12494 \end_inset
12495
12496
12497 \begin_inset LatexCommand \index{Carry flag}
12498
12499 \end_inset
12500
12501 ) */
12502 \end_layout
12503
12504 \begin_layout Standard
12505 Special function registers which are located on an address dividable by
12506  8 are bit-addressable, an
12507 \emph on
12508  sbit
12509 \emph default
12510  addresses a specific bit within these sfr.
12511 \newline
12512 16 Bit and 32 bit special function
12513  register combinations which require a certain access order are better not
12514  declared using 
12515 \emph on
12516 sfr16
12517 \emph default
12518  or 
12519 \emph on
12520 sfr32.
12521
12522 \emph default
12523  Allthough SDCC usually accesses them Least Significant Byte (LSB) first,
12524  this is not guaranteed.
12525 \newline
12526
12527 \end_layout
12528
12529 \begin_layout Standard
12530 Please note, if you use a header file which was written for another compiler
12531  then the sfr / sfr16 / sfr32 / sbit Storage Class extensions will most
12532  likely be 
12533 \emph on
12534 not 
12535 \emph default
12536 compatible.
12537  Specifically the syntax 
12538 \family typewriter
12539 \InsetSpace ~
12540 sfr P0 = 0x80;\InsetSpace ~
12541
12542 \family default
12543  is compiled 
12544 \emph on
12545 without warning
12546 \emph default
12547  by SDCC to an assignment of 0x80 to a variable called P0 
12548 \family typewriter
12549
12550 \begin_inset Marginal
12551 status collapsed
12552
12553 \begin_layout Standard
12554
12555 \series bold
12556 \InsetSpace ~
12557 !
12558 \end_layout
12559
12560 \end_inset
12561
12562 .
12563  
12564 \family default
12565 Nevertheless it is possible to write header files
12566 \begin_inset LatexCommand \index{Header files}
12567
12568 \end_inset
12569
12570
12571 \begin_inset LatexCommand \index{Include files}
12572
12573 \end_inset
12574
12575  which can be shared among different compilers (see section 
12576 \begin_inset LatexCommand \ref{sec:Porting-code-to-other-compilers}
12577
12578 \end_inset
12579
12580 ).
12581  
12582 \end_layout
12583
12584 \begin_layout Subsubsection
12585 Pointers
12586 \begin_inset LatexCommand \index{Pointer}
12587
12588 \end_inset
12589
12590  to MCS51/DS390 specific memory spaces
12591 \end_layout
12592
12593 \begin_layout Standard
12594 SDCC allows (via language extensions) pointers to explicitly point to any
12595  of the memory spaces
12596 \begin_inset LatexCommand \index{Memory model}
12597
12598 \end_inset
12599
12600  of the 8051.
12601  In addition to the explicit pointers, the compiler uses (by default) generic
12602  pointers which can be used to point to any of the memory spaces.
12603 \newline
12604
12605 \newline
12606 Pointer
12607  declaration examples:
12608 \end_layout
12609
12610 \begin_layout Verse
12611
12612 \family typewriter
12613 /* pointer physically in internal ram pointing to object in external ram
12614  */ 
12615 \newline
12616 __xdata unsigned char * __data p;
12617 \newline
12618
12619 \newline
12620 /* pointer physically in external ram
12621  pointing to object in internal ram */ 
12622 \newline
12623 __data unsigned char * __xdata p;
12624 \newline
12625
12626 \newline
12627 /*
12628  pointer physically in code rom pointing to data in xdata space */ 
12629 \newline
12630 __xdata
12631  unsigned char * __code p;
12632 \newline
12633
12634 \newline
12635 /* pointer physically in code space pointing to
12636  data in code space */ 
12637 \newline
12638 __code unsigned char * __code p;
12639 \newline
12640
12641 \newline
12642 /* generic pointer
12643  physically located in xdata space */
12644 \newline
12645 unsigned char * __xdata p;
12646 \newline
12647
12648 \newline
12649 /* generic
12650  pointer physically located in default memory space */
12651 \newline
12652 unsigned char * p;
12653 \newline
12654
12655 \newline
12656 /*
12657  the following is a function pointer
12658 \begin_inset LatexCommand \index{function pointer}
12659
12660 \end_inset
12661
12662  physically located in data space */
12663 \newline
12664 char (* __data fp)(void);
12665 \end_layout
12666
12667 \begin_layout Standard
12668 Well you get the idea.
12669  
12670 \newline
12671
12672 \newline
12673 All unqualified pointers are treated as 3-byte (4-byte for the ds390) 
12674 \emph on
12675 generic
12676 \emph default
12677  pointers.
12678  
12679 \size small
12680
12681 \newline
12682
12683 \newline
12684
12685 \size default
12686 The highest order byte of the 
12687 \emph on
12688 generic
12689 \emph default
12690  pointers contains the data space information.
12691  Assembler support routines are called whenever data is stored or retrieved
12692  using 
12693 \emph on
12694 generic
12695 \emph default
12696  pointers.
12697  These are useful for developing reusable library
12698 \begin_inset LatexCommand \index{Libraries}
12699
12700 \end_inset
12701
12702  routines.
12703  Explicitly specifying the pointer
12704 \begin_inset LatexCommand \index{pointer}
12705
12706 \end_inset
12707
12708  type will generate the most efficient code.
12709 \end_layout
12710
12711 \begin_layout Subsubsection
12712 Notes on MCS51 memory
12713 \begin_inset LatexCommand \index{MCS51 memory}
12714
12715 \end_inset
12716
12717  layout
12718 \end_layout
12719
12720 \begin_layout Standard
12721 The 8051 family of microcontrollers have a minimum of 128 bytes of internal
12722  RAM memory which is structured as follows:
12723 \newline
12724
12725 \newline
12726 - Bytes 00-1F - 32 bytes to hold
12727  up to 4 banks of the registers R0 to R7, 
12728 \newline
12729 - Bytes 20-2F - 16 bytes to hold
12730  128 bit
12731 \begin_inset LatexCommand \index{bit}
12732
12733 \end_inset
12734
12735  variables and, 
12736 \newline
12737 - Bytes 30-7F - 80 bytes for general purpose use.
12738 \newline
12739
12740 \end_layout
12741
12742 \begin_layout Standard
12743 Additionally some members of the MCS51 family may have up to 128 bytes of
12744  additional, indirectly addressable, internal RAM memory (
12745 \emph on
12746 idata
12747 \emph default
12748
12749 \begin_inset LatexCommand \index{idata (mcs51, ds390 storage class)}
12750
12751 \end_inset
12752
12753
12754 \begin_inset LatexCommand \index{\_\_idata (mcs51, ds390 storage class)}
12755
12756 \end_inset
12757
12758 ).
12759  Furthermore, some chips may have some built in external memory (
12760 \emph on
12761 xdata
12762 \emph default
12763
12764 \begin_inset LatexCommand \index{xdata (mcs51, ds390 storage class)}
12765
12766 \end_inset
12767
12768
12769 \begin_inset LatexCommand \index{\_\_xdata (mcs51, ds390 storage class)}
12770
12771 \end_inset
12772
12773 ) which should not be confused with the internal, directly addressable RAM
12774  memory (
12775 \emph on
12776 data
12777 \emph default
12778
12779 \begin_inset LatexCommand \index{data (mcs51, ds390 storage class)}
12780
12781 \end_inset
12782
12783
12784 \begin_inset LatexCommand \index{\_\_data (mcs51, ds390 storage class)}
12785
12786 \end_inset
12787
12788 ).
12789  Sometimes this built in 
12790 \emph on
12791 xdata
12792 \emph default
12793  memory has to be activated before using it (you can probably find this
12794  information on the datasheet of the microcontroller your are using, see
12795  also section 
12796 \begin_inset LatexCommand \ref{sub:Startup-Code}
12797
12798 \end_inset
12799
12800 \InsetSpace ~
12801 Startup-Code).
12802 \end_layout
12803
12804 \begin_layout Standard
12805 Normally SDCC will only use the first bank
12806 \begin_inset LatexCommand \index{register bank (mcs51, ds390)}
12807
12808 \end_inset
12809
12810  of registers (register bank 0), but it is possible to specify that other
12811  banks of registers (keyword 
12812 \emph on
12813 using
12814 \emph default
12815  
12816 \emph on
12817
12818 \begin_inset LatexCommand \index{using (mcs51, ds390 register bank)}
12819
12820 \end_inset
12821
12822
12823 \begin_inset LatexCommand \index{\_\_using (mcs51, ds390 register bank)}
12824
12825 \end_inset
12826
12827
12828 \emph default
12829 ) should be used for example in interrupt
12830 \begin_inset LatexCommand \index{interrupt}
12831
12832 \end_inset
12833
12834
12835 \begin_inset LatexCommand \index{\_\_interrupt}
12836
12837 \end_inset
12838
12839  routines.
12840  By default, the compiler will place the stack after the last byte of allocated
12841  memory for variables.
12842  For example, if the first 2 banks of registers are used, and only four
12843  bytes are used for 
12844 \emph on
12845 data
12846 \emph default
12847  variables, it will position the base of the internal stack at address 20
12848  (0x14).
12849  This implies that as the stack
12850 \begin_inset LatexCommand \index{stack}
12851
12852 \end_inset
12853
12854  grows, it will use up the remaining register banks, and the 16 bytes used
12855  by the 128 bit variables, and 80 bytes for general purpose use.
12856  If any bit variables are used, the data variables will be placed in unused
12857  register banks and after the byte holding the last bit variable.
12858  For example, if register banks 0 and 1 are used, and there are 9 bit variables
12859  (two bytes used), 
12860 \emph on
12861 data
12862 \emph default
12863  variables will be placed starting from address 0x10 to 0x20 and continue
12864  at address 0x22.
12865  You can also use -
12866 \begin_inset ERT
12867 status collapsed
12868
12869 \begin_layout Standard
12870
12871
12872 \backslash
12873 /
12874 \end_layout
12875
12876 \end_inset
12877
12878 -data-loc
12879 \begin_inset LatexCommand \index{-\/-data-loc <Value>}
12880
12881 \end_inset
12882
12883  to specify the start address of the 
12884 \emph on
12885 data
12886 \emph default
12887  and -
12888 \begin_inset ERT
12889 status collapsed
12890
12891 \begin_layout Standard
12892
12893
12894 \backslash
12895 /
12896 \end_layout
12897
12898 \end_inset
12899
12900 -iram-size
12901 \begin_inset LatexCommand \index{-\/-iram-size <Value>}
12902
12903 \end_inset
12904
12905  to specify the size of the total internal RAM (
12906 \emph on
12907 data
12908 \emph default
12909 +
12910 \emph on
12911 idata
12912 \emph default
12913 ).
12914  
12915 \newline
12916
12917 \end_layout
12918
12919 \begin_layout Standard
12920 By default the 8051 linker will place the stack after the last byte of (i)data
12921  variables.
12922  Option -
12923 \begin_inset ERT
12924 status collapsed
12925
12926 \begin_layout Standard
12927
12928
12929 \backslash
12930 /
12931 \end_layout
12932
12933 \end_inset
12934
12935 -stack-loc
12936 \begin_inset LatexCommand \index{-\/-stack-loc <Value>}
12937
12938 \end_inset
12939
12940  allows you to specify the start of the stack, i.e.
12941  you could start it after any data in the general purpose area.
12942  If your microcontroller has additional indirectly addressable internal
12943  RAM (
12944 \emph on
12945 idata
12946 \emph default
12947 ) you can place the stack on it.
12948  You may also need to use -
12949 \begin_inset ERT
12950 status collapsed
12951
12952 \begin_layout Standard
12953
12954
12955 \backslash
12956 /
12957 \end_layout
12958
12959 \end_inset
12960
12961 -xdata-loc
12962 \begin_inset LatexCommand \index{-\/-xdata-loc<Value>}
12963
12964 \end_inset
12965
12966  to set the start address of the external RAM (
12967 \emph on
12968 xdata
12969 \emph default
12970 ) and -
12971 \begin_inset ERT
12972 status collapsed
12973
12974 \begin_layout Standard
12975
12976
12977 \backslash
12978 /
12979 \end_layout
12980
12981 \end_inset
12982
12983 -xram-size
12984 \begin_inset LatexCommand \index{-\/-xram-size <Value>}
12985
12986 \end_inset
12987
12988  to specify its size.
12989  Same goes for the code memory, using -
12990 \begin_inset ERT
12991 status collapsed
12992
12993 \begin_layout Standard
12994
12995
12996 \backslash
12997 /
12998 \end_layout
12999
13000 \end_inset
13001
13002 -code-loc
13003 \begin_inset LatexCommand \index{-\/-code-loc <Value>}
13004
13005 \end_inset
13006
13007  and -
13008 \begin_inset ERT
13009 status collapsed
13010
13011 \begin_layout Standard
13012
13013
13014 \backslash
13015 /
13016 \end_layout
13017
13018 \end_inset
13019
13020 -code-size
13021 \begin_inset LatexCommand \index{-\/-code-size <Value>}
13022
13023 \end_inset
13024
13025 .
13026  If in doubt, don't specify any options and see if the resulting memory
13027  layout is appropriate, then you can adjust it.
13028 \end_layout
13029
13030 \begin_layout Standard
13031 The linker generates two files with memory allocation information.
13032  The first, with extension .map
13033 \begin_inset LatexCommand \index{<file>.map}
13034
13035 \end_inset
13036
13037  shows all the variables and segments.
13038  The second with extension .mem
13039 \begin_inset LatexCommand \index{<file>.mem}
13040
13041 \end_inset
13042
13043  shows the final memory layout.
13044  The linker will complain either if memory segments overlap, there is not
13045  enough memory, or there is not enough space for stack.
13046  If you get any linking warnings and/or errors related to stack or segments
13047  allocation, take a look at either the .map or .mem files to find out what
13048  the problem is.
13049  The .mem file may even suggest a solution to the problem.
13050 \begin_inset VSpace bigskip
13051 \end_inset
13052
13053
13054 \end_layout
13055
13056 \begin_layout Subsection
13057 Z80/Z180 Storage Class
13058 \begin_inset LatexCommand \index{Z80!Storage class}
13059
13060 \end_inset
13061
13062  Language Extensions
13063 \end_layout
13064
13065 \begin_layout Subsubsection
13066 sfr
13067 \begin_inset LatexCommand \index{sfr}
13068
13069 \end_inset
13070
13071
13072 \begin_inset LatexCommand \index{\_\_sfr}
13073
13074 \end_inset
13075
13076  (in/out to 8-bit addresses)
13077 \end_layout
13078
13079 \begin_layout Standard
13080 The Z80
13081 \begin_inset LatexCommand \index{Z80}
13082
13083 \end_inset
13084
13085  family has separate address spaces for memory and 
13086 \emph on
13087 i
13088 \emph default
13089 nput/
13090 \emph on
13091 o
13092 \emph default
13093 utput memory.
13094  I/O memory
13095 \begin_inset LatexCommand \index{I/O memory (Z80, Z180)}
13096
13097 \end_inset
13098
13099
13100 \begin_inset LatexCommand \index{Z80!I/O memory}
13101
13102 \end_inset
13103
13104
13105 \begin_inset LatexCommand \index{Z180!I/O memory}
13106
13107 \end_inset
13108
13109  is accessed with special instructions, e.g.:
13110 \end_layout
13111
13112 \begin_layout Verse
13113
13114 \family typewriter
13115 sfr at 0x78 IoPort;\InsetSpace ~
13116 \InsetSpace ~
13117 /* define a var in I/O space at 78h called IoPort */
13118  
13119 \end_layout
13120
13121 \begin_layout Standard
13122 Writing 0x01 to this variable generates the assembly code:
13123 \end_layout
13124
13125 \begin_layout Verse
13126
13127 \family typewriter
13128 3E 01\InsetSpace ~
13129 \InsetSpace ~
13130 \InsetSpace ~
13131 \InsetSpace ~
13132 \InsetSpace ~
13133 \InsetSpace ~
13134 ld a,#0x01
13135 \newline
13136 D3 78\InsetSpace ~
13137 \InsetSpace ~
13138 \InsetSpace ~
13139 \InsetSpace ~
13140 \InsetSpace ~
13141 \InsetSpace ~
13142 out (_IoPort),a 
13143 \end_layout
13144
13145 \begin_layout Subsubsection
13146 banked sfr
13147 \begin_inset LatexCommand \index{sfr}
13148
13149 \end_inset
13150
13151
13152 \begin_inset LatexCommand \index{\_\_sfr}
13153
13154 \end_inset
13155
13156  (in/out to 16-bit addresses)
13157 \end_layout
13158
13159 \begin_layout Standard
13160 The keyword 
13161 \emph on
13162 banked
13163 \emph default
13164  is used to support 16 bit addresses in I/O memory e.g.:
13165 \end_layout
13166
13167 \begin_layout Verse
13168
13169 \family typewriter
13170 sfr banked at
13171 \begin_inset LatexCommand \index{at}
13172
13173 \end_inset
13174
13175
13176 \begin_inset LatexCommand \index{\_\_at}
13177
13178 \end_inset
13179
13180  0x123 IoPort; 
13181 \end_layout
13182
13183 \begin_layout Standard
13184 Writing 0x01 to this variable generates the assembly code:
13185 \end_layout
13186
13187 \begin_layout Verse
13188
13189 \family typewriter
13190 01 23 01\InsetSpace ~
13191 \InsetSpace ~
13192 \InsetSpace ~
13193 ld bc,#_IoPort
13194 \newline
13195 3E 01\InsetSpace ~
13196 \InsetSpace ~
13197 \InsetSpace ~
13198 \InsetSpace ~
13199 \InsetSpace ~
13200 \InsetSpace ~
13201 ld a,#0x01 
13202 \newline
13203 ED 79\InsetSpace ~
13204 \InsetSpace ~
13205 \InsetSpace ~
13206 \InsetSpace ~
13207 \InsetSpace ~
13208 \InsetSpace ~
13209 out (c),a 
13210 \end_layout
13211
13212 \begin_layout Subsubsection
13213 sfr
13214 \begin_inset LatexCommand \index{sfr}
13215
13216 \end_inset
13217
13218
13219 \begin_inset LatexCommand \index{\_\_sfr}
13220
13221 \end_inset
13222
13223  (in0/out0 to 8 bit addresses on Z180
13224 \begin_inset LatexCommand \index{Z180}
13225
13226 \end_inset
13227
13228 /HD64180
13229 \begin_inset LatexCommand \index{HD64180 (see Z180)}
13230
13231 \end_inset
13232
13233 )
13234 \end_layout
13235
13236 \begin_layout Standard
13237 The compiler option -
13238 \begin_inset ERT
13239 status collapsed
13240
13241 \begin_layout Standard
13242
13243
13244 \backslash
13245 /
13246 \end_layout
13247
13248 \end_inset
13249
13250 -portmode
13251 \begin_inset LatexCommand \index{Z180!Options!-\/-portmode}
13252
13253 \end_inset
13254
13255 =180 (80) and a compiler #pragma\InsetSpace ~
13256 portmode
13257 \begin_inset LatexCommand \index{Z180!Pragmas!\#pragma portmode}
13258
13259 \end_inset
13260
13261  z180 (z80) is used to turn on (off) the Z180/HD64180 port addressing instructio
13262 ns 
13263 \family typewriter
13264 in0/out0
13265 \family default
13266  instead of 
13267 \family typewriter
13268 in/out
13269 \family default
13270 .
13271  If you include the file z180.h this will be set automatically.
13272 \begin_inset VSpace bigskip
13273 \end_inset
13274
13275
13276 \end_layout
13277
13278 \begin_layout Subsection
13279 HC08 Storage Class
13280 \begin_inset LatexCommand \index{HC08!Storage class}
13281
13282 \end_inset
13283
13284  Language Extensions
13285 \end_layout
13286
13287 \begin_layout Subsubsection
13288 data
13289 \begin_inset LatexCommand \index{data (hc08 storage class)}
13290
13291 \end_inset
13292
13293
13294 \begin_inset LatexCommand \index{\_\_data (hc08 storage class)}
13295
13296 \end_inset
13297
13298  
13299 \end_layout
13300
13301 \begin_layout Standard
13302 The data storage class declares a variable that resides in the first 256
13303  bytes of memory (the direct page).
13304  The HC08
13305 \begin_inset LatexCommand \index{HC08}
13306
13307 \end_inset
13308
13309  is most efficient at accessing variables (especially pointers) stored here.
13310 \end_layout
13311
13312 \begin_layout Subsubsection
13313 xdata
13314 \begin_inset LatexCommand \index{xdata (hc08 storage class)}
13315
13316 \end_inset
13317
13318
13319 \begin_inset LatexCommand \index{\_\_xdata (hc08 storage class)}
13320
13321 \end_inset
13322
13323  
13324 \end_layout
13325
13326 \begin_layout Standard
13327 The xdata storage class declares a variable that can reside anywhere in
13328  memory.
13329  This is the default if no storage class is specified.
13330  
13331 \begin_inset VSpace bigskip
13332 \end_inset
13333
13334
13335 \end_layout
13336
13337 \begin_layout Section
13338 Other SDCC language extensions
13339 \begin_inset LatexCommand \index{Other SDCC language extensions}
13340
13341 \end_inset
13342
13343
13344 \end_layout
13345
13346 \begin_layout Subsection
13347 Binary constants
13348 \end_layout
13349
13350 \begin_layout Standard
13351 SDCC supports the use of binary constants, such as 0b01100010.
13352  This feature is only enabled when the compiler is invoked using --std-sdccxx.
13353 \end_layout
13354
13355 \begin_layout Standard
13356 \begin_inset VSpace bigskip
13357 \end_inset
13358
13359
13360 \end_layout
13361
13362 \begin_layout Section
13363 Absolute Addressing
13364 \begin_inset LatexCommand \index{Absolute addressing}
13365
13366 \end_inset
13367
13368
13369 \end_layout
13370
13371 \begin_layout Standard
13372 Data items can be assigned an absolute address with the 
13373 \emph on
13374 at
13375 \begin_inset LatexCommand \index{at}
13376
13377 \end_inset
13378
13379
13380 \begin_inset LatexCommand \index{\_\_at}
13381
13382 \end_inset
13383
13384  <address>
13385 \emph default
13386  keyword, in addition to a storage class, e.g.:
13387 \end_layout
13388
13389 \begin_layout Verse
13390
13391 \family typewriter
13392 xdata
13393 \begin_inset LatexCommand \index{xdata (mcs51, ds390 storage class)}
13394
13395 \end_inset
13396
13397
13398 \begin_inset LatexCommand \index{\_\_xdata (mcs51, ds390 storage class)}
13399
13400 \end_inset
13401
13402  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  0x7ffe unsigned int chksum;
13413 \end_layout
13414
13415 \begin_layout Standard
13416 or, better conforming to ISO/IEC 9899 C:
13417 \end_layout
13418
13419 \begin_layout Verse
13420
13421 \family typewriter
13422 __xdata __at (0x7ffe) unsigned int chksum;
13423 \end_layout
13424
13425 \begin_layout Standard
13426 In the above example the variable chksum will be located at 0x7ffe and 0x7fff
13427  of the external ram.
13428  The compiler does 
13429 \emph on
13430 not
13431 \emph default
13432  reserve any space for variables declared in this way
13433 \begin_inset Marginal
13434 status collapsed
13435
13436 \begin_layout Standard
13437
13438 \series bold
13439 \InsetSpace ~
13440 !
13441 \end_layout
13442
13443 \end_inset
13444
13445  (they are implemented with an equate in the assembler).
13446  Thus it is left to the programmer to make sure there are no overlaps with
13447  other variables that are declared without the absolute address.
13448  The assembler listing file (.lst
13449 \begin_inset LatexCommand \index{<file>.lst}
13450
13451 \end_inset
13452
13453 ) and the linker output files (.rst
13454 \begin_inset LatexCommand \index{<file>.rst}
13455
13456 \end_inset
13457
13458 ) and (.map
13459 \begin_inset LatexCommand \index{<file>.map}
13460
13461 \end_inset
13462
13463 ) are good places to look for such overlaps.
13464 \end_layout
13465
13466 \begin_layout Standard
13467 If however you provide an initializer
13468 \begin_inset LatexCommand \index{Variable initialization}
13469
13470 \end_inset
13471
13472  actual memory allocation will take place and overlaps will be detected
13473  by the linker.
13474  E.g.:
13475 \end_layout
13476
13477 \begin_layout Verse
13478
13479 \family typewriter
13480 __code __at (0x7ff0) char Id[5] = 
13481 \begin_inset Quotes sld
13482 \end_inset
13483
13484 SDCC
13485 \begin_inset Quotes srd
13486 \end_inset
13487
13488 ;
13489 \end_layout
13490
13491 \begin_layout Standard
13492 In the above example the variable Id will be located from 0x7ff0 to 0x7ff4
13493  in code memory.
13494 \end_layout
13495
13496 \begin_layout Standard
13497 In case of memory mapped I/O devices the keyword 
13498 \emph on
13499 volatile
13500 \emph default
13501  has to be used to tell the compiler that accesses might not be removed:
13502 \end_layout
13503
13504 \begin_layout Verse
13505
13506 \family typewriter
13507 volatile
13508 \begin_inset LatexCommand \index{volatile}
13509
13510 \end_inset
13511
13512  __xdata
13513 \begin_inset LatexCommand \index{xdata (mcs51, ds390 storage class)}
13514
13515 \end_inset
13516
13517  __at
13518 \begin_inset LatexCommand \index{at}
13519
13520 \end_inset
13521
13522  (0x8000) unsigned char PORTA_8255;
13523 \end_layout
13524
13525 \begin_layout Standard
13526 For some architectures (mcs51) array accesses are more efficient if an (xdata/fa
13527 r) array
13528 \family typewriter
13529 \size footnotesize
13530
13531 \begin_inset LatexCommand \index{Aligned array}
13532
13533 \end_inset
13534
13535
13536 \family default
13537 \size default
13538  starts at a block (256 byte) boundary
13539 \begin_inset LatexCommand \index{block boundary}
13540
13541 \end_inset
13542
13543  (section 
13544 \begin_inset LatexCommand \ref{sub:A-Step-by Assembler Introduction}
13545
13546 \end_inset
13547
13548  has an example).
13549 \newline
13550 Absolute addresses can be specified for variables in all
13551  storage classes, e.g.:
13552 \end_layout
13553
13554 \begin_layout Verse
13555
13556 \family typewriter
13557 __bit
13558 \begin_inset LatexCommand \index{bit}
13559
13560 \end_inset
13561
13562  __at
13563 \begin_inset LatexCommand \index{at}
13564
13565 \end_inset
13566
13567  (0x02) bvar;
13568 \end_layout
13569
13570 \begin_layout Standard
13571 The above example will allocate the variable at offset 0x02 in the bit-addressab
13572 le space.
13573  There is no real advantage to assigning absolute addresses to variables
13574  in this manner, unless you want strict control over all the variables allocated.
13575  One possible use would be to write hardware portable code.
13576  For example, if you have a routine that uses one or more of the microcontroller
13577  I/O pins, and such pins are different for two different hardwares, you
13578  can declare the I/O pins in your routine using:
13579 \end_layout
13580
13581 \begin_layout Verse
13582
13583 \family typewriter
13584 extern volatile
13585 \begin_inset LatexCommand \index{volatile}
13586
13587 \end_inset
13588
13589  __bit MOSI;\InsetSpace ~
13590 \InsetSpace ~
13591 \InsetSpace ~
13592 \InsetSpace ~
13593 /* master out, slave in */
13594 \newline
13595 extern volatile __bit MISO;\InsetSpace ~
13596 \InsetSpace ~
13597 \InsetSpace ~
13598 \InsetSpace ~
13599 /* master
13600  in, slave out */
13601 \newline
13602 extern volatile __bit MCLK;\InsetSpace ~
13603 \InsetSpace ~
13604 \InsetSpace ~
13605 \InsetSpace ~
13606 /* master clock */
13607 \newline
13608
13609 \newline
13610 /* Input and
13611  Output of a byte on a 3-wire serial bus.
13612 \newline
13613 \InsetSpace ~
13614 \InsetSpace ~
13615 \InsetSpace ~
13616 If needed adapt polarity of clock,
13617  polarity of data and bit order
13618 \newline
13619 \InsetSpace ~
13620 */
13621 \newline
13622 unsigned char spi_io(unsigned char out_byte)
13623  
13624 \newline
13625
13626 \newline
13627 \InsetSpace ~
13628 \InsetSpace ~
13629 \InsetSpace ~
13630 \InsetSpace ~
13631 unsigned char i=8;
13632 \newline
13633 \InsetSpace ~
13634 \InsetSpace ~
13635 \InsetSpace ~
13636 \InsetSpace ~
13637 do { 
13638 \newline
13639 \InsetSpace ~
13640 \InsetSpace ~
13641 \InsetSpace ~
13642 \InsetSpace ~
13643 \InsetSpace ~
13644 \InsetSpace ~
13645 \InsetSpace ~
13646 \InsetSpace ~
13647 MOSI = out_byte & 0x80; 
13648 \newline
13649 \InsetSpace ~
13650 \InsetSpace ~
13651 \InsetSpace ~
13652 \InsetSpace ~
13653 \InsetSpace ~
13654 \InsetSpace ~
13655 \InsetSpace ~
13656 \InsetSpace ~
13657 out_byte <<= 1;
13658 \newline
13659 \InsetSpace ~
13660 \InsetSpace ~
13661 \InsetSpace ~
13662 \InsetSpace ~
13663 \InsetSpace ~
13664 \InsetSpace ~
13665 \InsetSpace ~
13666 \InsetSpace ~
13667 MCLK =
13668  1; 
13669 \newline
13670 \InsetSpace ~
13671 \InsetSpace ~
13672 \InsetSpace ~
13673 \InsetSpace ~
13674 \InsetSpace ~
13675 \InsetSpace ~
13676 \InsetSpace ~
13677 \InsetSpace ~
13678 /* _asm nop _endasm; */\InsetSpace ~
13679 \InsetSpace ~
13680 \InsetSpace ~
13681 \InsetSpace ~
13682 \InsetSpace ~
13683 \InsetSpace ~
13684 \InsetSpace ~
13685 \InsetSpace ~
13686 /* for slow peripherals */
13687 \newline
13688 \InsetSpace ~
13689 \InsetSpace ~
13690 \InsetSpace ~
13691 \InsetSpace ~
13692 \InsetSpace ~
13693 \InsetSpace ~
13694 \InsetSpace ~
13695 \InsetSpace ~
13696 if(MISO) 
13697 \newline
13698 \InsetSpace ~
13699 \InsetSpace ~
13700 \InsetSpace ~
13701 \InsetSpace ~
13702 \InsetSpace ~
13703 \InsetSpace ~
13704 \InsetSpace ~
13705 \InsetSpace ~
13706 \InsetSpace ~
13707 \InsetSpace ~
13708 \InsetSpace ~
13709 \InsetSpace ~
13710 out_byte +=
13711  1; 
13712 \newline
13713 \InsetSpace ~
13714 \InsetSpace ~
13715 \InsetSpace ~
13716 \InsetSpace ~
13717 \InsetSpace ~
13718 \InsetSpace ~
13719 \InsetSpace ~
13720 \InsetSpace ~
13721 MCLK = 0; 
13722 \newline
13723 \InsetSpace ~
13724 \InsetSpace ~
13725 \InsetSpace ~
13726 \InsetSpace ~
13727 } while(--i);
13728 \newline
13729 \InsetSpace ~
13730 \InsetSpace ~
13731 \InsetSpace ~
13732 \InsetSpace ~
13733 return out_byte; 
13734 \newline
13735 }
13736 \end_layout
13737
13738 \begin_layout Standard
13739 Then, someplace in the code for the first hardware you would use
13740 \end_layout
13741
13742 \begin_layout Verse
13743
13744 \family typewriter
13745 __bit __at
13746 \begin_inset LatexCommand \index{at}
13747
13748 \end_inset
13749
13750
13751 \begin_inset LatexCommand \index{\_\_at}
13752
13753 \end_inset
13754
13755  (0x80) MOSI;\InsetSpace ~
13756 \InsetSpace ~
13757 \InsetSpace ~
13758 \InsetSpace ~
13759 /* I/O port 0, bit 0 */
13760 \newline
13761 __bit __at (0x81) MISO;\InsetSpace ~
13762 \InsetSpace ~
13763 \InsetSpace ~
13764 \InsetSpace ~
13765 /* I/O port 0,
13766  bit 1 */
13767 \newline
13768 __bit __at (0x82) MCLK;\InsetSpace ~
13769 \InsetSpace ~
13770 \InsetSpace ~
13771 \InsetSpace ~
13772 /* I/O port 0, bit 2 */
13773 \end_layout
13774
13775 \begin_layout Standard
13776 Similarly, for the second hardware you would use
13777 \end_layout
13778
13779 \begin_layout Verse
13780
13781 \family typewriter
13782 __bit __at (0x83) MOSI;\InsetSpace ~
13783 \InsetSpace ~
13784 \InsetSpace ~
13785 \InsetSpace ~
13786 /* I/O port 0, bit 3 */
13787 \newline
13788 __bit __at (0x91) MISO;\InsetSpace ~
13789 \InsetSpace ~
13790 \InsetSpace ~
13791 \InsetSpace ~
13792 /*
13793  I/O port 1, bit 1 */
13794 \newline
13795 __bit
13796 \begin_inset LatexCommand \index{bit}
13797
13798 \end_inset
13799
13800  __at (0x92) MCLK;\InsetSpace ~
13801 \InsetSpace ~
13802 \InsetSpace ~
13803 \InsetSpace ~
13804 /* I/O port 1, bit 2 */
13805 \end_layout
13806
13807 \begin_layout Standard
13808 and you can use the same hardware dependent routine without changes, as
13809  for example in a library.
13810  This is somehow similar to sbit, but only one absolute address has to be
13811  specified in the whole project.
13812 \begin_inset VSpace bigskip
13813 \end_inset
13814
13815
13816 \end_layout
13817
13818 \begin_layout Section
13819 Parameters
13820 \begin_inset LatexCommand \index{Parameters}
13821
13822 \end_inset
13823
13824
13825 \begin_inset LatexCommand \index{function parameter}
13826
13827 \end_inset
13828
13829  & Local Variables
13830 \begin_inset LatexCommand \index{local variables}
13831
13832 \end_inset
13833
13834
13835 \begin_inset LatexCommand \label{sec:Parameters-and-Local-Variables}
13836
13837 \end_inset
13838
13839
13840 \end_layout
13841
13842 \begin_layout Standard
13843 Automatic (local) variables and parameters to functions can either be placed
13844  on the stack or in data-space.
13845  The default action of the compiler is to place these variables in the internal
13846  RAM (for small model) or external RAM (for medium or large model).
13847  This in fact makes them similar to 
13848 \emph on
13849 static
13850 \begin_inset LatexCommand \index{static}
13851
13852 \end_inset
13853
13854
13855 \emph default
13856  so by default functions are non-reentrant
13857 \begin_inset LatexCommand \index{reentrant}
13858
13859 \end_inset
13860
13861 .
13862  
13863 \newline
13864
13865 \newline
13866 They can be placed on the stack
13867 \begin_inset LatexCommand \index{stack}
13868
13869 \end_inset
13870
13871  by using the
13872 \emph on
13873  -
13874 \begin_inset ERT
13875 status collapsed
13876
13877 \begin_layout Standard
13878
13879
13880 \backslash
13881 /
13882 \end_layout
13883
13884 \end_inset
13885
13886 -stack-auto
13887 \begin_inset LatexCommand \index{-\/-stack-auto}
13888
13889 \end_inset
13890
13891
13892 \emph default
13893  option, by using 
13894 \emph on
13895 #pragma\InsetSpace ~
13896 stackauto
13897 \emph default
13898
13899 \begin_inset LatexCommand \index{\#pragma stackauto}
13900
13901 \end_inset
13902
13903  or by using the 
13904 \emph on
13905 reentrant
13906 \begin_inset LatexCommand \index{reentrant}
13907
13908 \end_inset
13909
13910
13911 \emph default
13912  keyword in the function declaration, e.g.:
13913 \end_layout
13914
13915 \begin_layout Verse
13916
13917 \family typewriter
13918 unsigned char foo(char i) __reentrant 
13919 \newline
13920
13921 \newline
13922 \InsetSpace ~
13923 \InsetSpace ~
13924 \InsetSpace ~
13925 \InsetSpace ~
13926 ...
13927  
13928 \newline
13929 }
13930 \end_layout
13931
13932 \begin_layout Standard
13933 Since stack space on 8051 is limited, the 
13934 \emph on
13935 reentrant 
13936 \emph default
13937 keyword or the
13938 \emph on
13939  -
13940 \begin_inset ERT
13941 status collapsed
13942
13943 \begin_layout Standard
13944
13945
13946 \backslash
13947 /
13948 \end_layout
13949
13950 \end_inset
13951
13952 -stack-auto
13953 \emph default
13954  option should be used sparingly.
13955  Note that the reentrant keyword just means that the parameters & local
13956  variables will be allocated to the stack, it 
13957 \emph on
13958 does not
13959 \emph default
13960  mean that the function is register bank
13961 \begin_inset LatexCommand \index{register bank (mcs51, ds390)}
13962
13963 \end_inset
13964
13965  independent.
13966 \newline
13967
13968 \newline
13969 Local variables
13970 \begin_inset LatexCommand \index{local variables}
13971
13972 \end_inset
13973
13974  can be assigned storage classes and absolute
13975 \begin_inset LatexCommand \index{Absolute addressing}
13976
13977 \end_inset
13978
13979  addresses, e.g.: 
13980 \end_layout
13981
13982 \begin_layout Verse
13983
13984 \family typewriter
13985 unsigned char foo() 
13986 \newline
13987 {
13988 \newline
13989 \InsetSpace ~
13990 \InsetSpace ~
13991 \InsetSpace ~
13992 \InsetSpace ~
13993 __xdata unsigned char i;
13994 \newline
13995 \InsetSpace ~
13996 \InsetSpace ~
13997 \InsetSpace ~
13998 \InsetSpace ~
13999 __bit bvar;
14000 \newline
14001 \InsetSpace ~
14002 \InsetSpace ~
14003 \InsetSpace ~
14004 \InsetSpace ~
14005 __data __at
14006 \begin_inset LatexCommand \index{at}
14007
14008 \end_inset
14009
14010  (0x31) unsigned char j;
14011 \newline
14012 \InsetSpace ~
14013 \InsetSpace ~
14014 \InsetSpace ~
14015 \InsetSpace ~
14016 ...
14017  
14018 \newline
14019 }
14020 \end_layout
14021
14022 \begin_layout Standard
14023 In the above example the variable 
14024 \emph on
14025 i
14026 \emph default
14027  will be allocated in the external ram, 
14028 \emph on
14029 bvar
14030 \emph default
14031  in bit addressable space and
14032 \emph on
14033  j
14034 \emph default
14035  in internal ram.
14036  When compiled with 
14037 \emph on
14038 -
14039 \begin_inset ERT
14040 status collapsed
14041
14042 \begin_layout Standard
14043
14044
14045 \backslash
14046 /
14047 \end_layout
14048
14049 \end_inset
14050
14051 -stack-auto
14052 \emph default
14053  or when a function is declared as 
14054 \emph on
14055 reentrant
14056 \emph default
14057  this should only be done for static variables.
14058 \end_layout
14059
14060 \begin_layout Standard
14061 Parameters
14062 \begin_inset LatexCommand \index{function parameter}
14063
14064 \end_inset
14065
14066  however are not allowed any storage class
14067 \begin_inset LatexCommand \index{Storage class}
14068
14069 \end_inset
14070
14071 , (storage classes for parameters will be ignored), their allocation is
14072  governed by the memory model in use, and the reentrancy options.
14073 \end_layout
14074
14075 \begin_layout Standard
14076 It is however allowed to use bit parameters in reentrant functions and also
14077  non-static local bit variables are supported.
14078  Efficient use is limited to 8 semi-bitregisters in bit space.
14079  They are pushed and popped to stack
14080 \begin_inset LatexCommand \index{stack}
14081
14082 \end_inset
14083
14084  as a single byte just like the normal registers.
14085 \end_layout
14086
14087 \begin_layout Section
14088 Overlaying
14089 \begin_inset LatexCommand \label{sub:Overlaying}
14090
14091 \end_inset
14092
14093
14094 \begin_inset LatexCommand \index{Overlaying}
14095
14096 \end_inset
14097
14098
14099 \end_layout
14100
14101 \begin_layout Standard
14102 For non-reentrant
14103 \begin_inset LatexCommand \index{reentrant}
14104
14105 \end_inset
14106
14107  functions SDCC will try to reduce internal ram space usage by overlaying
14108  parameters and local variables of a function (if possible).
14109  Parameters and local variables
14110 \begin_inset LatexCommand \index{local variables}
14111
14112 \end_inset
14113
14114  of a function will be allocated to an overlayable segment if the function
14115  has 
14116 \emph on
14117 no other function calls and the function is non-reentrant and the memory
14118  model
14119 \begin_inset LatexCommand \index{Memory model}
14120
14121 \end_inset
14122
14123  is small.
14124
14125 \emph default
14126  If an explicit storage class
14127 \begin_inset LatexCommand \index{Storage class}
14128
14129 \end_inset
14130
14131  is specified for a local variable, it will NOT be overlayed.
14132 \end_layout
14133
14134 \begin_layout Standard
14135 Note that the compiler (not the linkage editor) makes the decision for overlayin
14136 g the data items.
14137  Functions that are called from an interrupt service routine
14138 \begin_inset Marginal
14139 status collapsed
14140
14141 \begin_layout Standard
14142
14143 \series bold
14144 !
14145 \end_layout
14146
14147 \end_inset
14148
14149  should be preceded by a #pragma\InsetSpace ~
14150 nooverlay
14151 \begin_inset LatexCommand \index{\#pragma nooverlay}
14152
14153 \end_inset
14154
14155  if they are not reentrant.
14156 \end_layout
14157
14158 \begin_layout Standard
14159 Also note that the compiler does not do any processing of inline assembler
14160  code, so the compiler might incorrectly assign local variables and parameters
14161  of a function into the overlay segment if the inline assembler code calls
14162  other c-functions that might use the overlay.
14163  In that case the #pragma\InsetSpace ~
14164 nooverlay should be used.
14165 \end_layout
14166
14167 \begin_layout Standard
14168 Parameters and local variables of functions that contain 16 or 32 bit multiplica
14169 tion
14170 \begin_inset LatexCommand \index{Multiplication}
14171
14172 \end_inset
14173
14174  or division
14175 \begin_inset LatexCommand \index{Division}
14176
14177 \end_inset
14178
14179  will NOT be overlayed since these are implemented using external functions,
14180  e.g.:
14181 \end_layout
14182
14183 \begin_layout Verse
14184
14185 \family typewriter
14186 #pragma save 
14187 \newline
14188 #pragma nooverlay
14189 \begin_inset LatexCommand \index{\#pragma nooverlay}
14190
14191 \end_inset
14192
14193  
14194 \newline
14195 void set_error(unsigned char errcd) 
14196 \newline
14197 {
14198 \newline
14199 \InsetSpace ~
14200 \InsetSpace ~
14201 \InsetSpace ~
14202 \InsetSpace ~
14203 P3 = errcd;
14204 \newline
14205
14206 \newline
14207 #pragma restore 
14208 \newline
14209
14210 \newline
14211 void
14212  some_isr () __interrupt
14213 \begin_inset LatexCommand \index{interrupt}
14214
14215 \end_inset
14216
14217  (2)
14218 \newline
14219 {
14220 \newline
14221 \InsetSpace ~
14222 \InsetSpace ~
14223 \InsetSpace ~
14224 \InsetSpace ~
14225 ...
14226 \newline
14227 \InsetSpace ~
14228 \InsetSpace ~
14229 \InsetSpace ~
14230 \InsetSpace ~
14231 set_error(10);
14232 \newline
14233 \InsetSpace ~
14234 \InsetSpace ~
14235 \InsetSpace ~
14236 \InsetSpace ~
14237 ...
14238  
14239 \newline
14240 }
14241 \end_layout
14242
14243 \begin_layout Standard
14244 In the above example the parameter 
14245 \emph on
14246 errcd
14247 \emph default
14248  for the function 
14249 \emph on
14250 set_error
14251 \emph default
14252  would be assigned to the overlayable segment if the #pragma\InsetSpace ~
14253 nooverlay was
14254  not present, this could cause unpredictable runtime behavior when called
14255  from an interrupt service routine.
14256  The #pragma\InsetSpace ~
14257 nooverlay ensures that the parameters and local variables for
14258  the function are NOT overlayed.
14259 \begin_inset VSpace bigskip
14260 \end_inset
14261
14262
14263 \end_layout
14264
14265 \begin_layout Section
14266 Interrupt Service Routines
14267 \begin_inset LatexCommand \label{sub:Interrupt-Service-Routines}
14268
14269 \end_inset
14270
14271
14272 \end_layout
14273
14274 \begin_layout Subsection
14275 General Information
14276 \end_layout
14277
14278 \begin_layout Standard
14279 SDCC allows 
14280 \emph on
14281 i
14282 \emph default
14283 nterrupt 
14284 \emph on
14285 s
14286 \emph default
14287 ervice 
14288 \emph on
14289 r
14290 \emph default
14291 outines to be coded in C, with some extended keywords.
14292 \end_layout
14293
14294 \begin_layout Verse
14295
14296 \family typewriter
14297 void timer_isr (void) __interrupt (1) __using (1) 
14298 \newline
14299
14300 \newline
14301 \InsetSpace ~
14302 \InsetSpace ~
14303 \InsetSpace ~
14304 \InsetSpace ~
14305 ...
14306  
14307 \newline
14308 }
14309 \end_layout
14310
14311 \begin_layout Standard
14312 The optional number following the 
14313 \emph on
14314 interrupt
14315 \begin_inset LatexCommand \index{interrupt}
14316
14317 \end_inset
14318
14319
14320 \begin_inset LatexCommand \index{\_\_interrupt}
14321
14322 \end_inset
14323
14324
14325 \emph default
14326  keyword is the interrupt number this routine will service.
14327  When present, the compiler will insert a call to this routine in the interrupt
14328  vector table
14329 \begin_inset LatexCommand \index{interrupt vector table}
14330
14331 \end_inset
14332
14333  for the interrupt number specified.
14334  If you have multiple source files in your project, interrupt service routines
14335  can be present in any of them, but a prototype of the isr MUST be present
14336  or included in the file that contains the function 
14337 \emph on
14338 main
14339 \emph default
14340 .
14341  The optional (8051 specific) keyword 
14342 \emph on
14343 using
14344 \begin_inset LatexCommand \index{using (mcs51, ds390 register bank)}
14345
14346 \end_inset
14347
14348
14349 \begin_inset LatexCommand \index{\_\_using (mcs51, ds390 register bank)}
14350
14351 \end_inset
14352
14353
14354 \emph default
14355  can be used to tell the compiler to use the specified register bank when
14356  generating code for this function.
14357  
14358 \newline
14359 Interrupt service routines open the door for some very interesting bugs:
14360 \end_layout
14361
14362 \begin_layout Subsubsection
14363 \begin_inset LatexCommand \label{sub:Common-interrupt-pitfall-volatile}
14364
14365 \end_inset
14366
14367 Common interrupt pitfall: variable not declared 
14368 \emph on
14369 volatile
14370 \end_layout
14371
14372 \begin_layout Standard
14373 If an interrupt service routine changes variables which are accessed by
14374  other functions these variables have to be declared 
14375 \emph on
14376 volatile
14377 \emph default
14378
14379 \begin_inset LatexCommand \index{volatile}
14380
14381 \end_inset
14382
14383 .
14384  See 
14385 \begin_inset LatexCommand \url{http://en.wikipedia.org/wiki/Volatile_variable}
14386
14387 \end_inset
14388
14389  .
14390 \end_layout
14391
14392 \begin_layout Subsubsection
14393 \begin_inset LatexCommand \label{sub:Common-interrupt-pitfall-non-atomic}
14394
14395 \end_inset
14396
14397 Common interrupt pitfall: 
14398 \emph on
14399 non-atomic access
14400 \end_layout
14401
14402 \begin_layout Standard
14403 If the access to these variables is not 
14404 \emph on
14405 atomic
14406 \begin_inset LatexCommand \index{atomic}
14407
14408 \end_inset
14409
14410
14411 \emph default
14412  (i.e.
14413  the processor needs more than one instruction for the access and could
14414  be interrupted while accessing the variable) the interrupt must be disabled
14415  during the access to avoid inconsistent data.
14416  
14417 \newline
14418 Access to 16 or 32 bit variables is obviously not atomic on 8 bit CPUs
14419  and should be protected by disabling interrupts.
14420  You're not automatically on the safe side if you use 8 bit variables though.
14421  We need an example here: f.e.
14422  on the 8051 the harmless looking 
14423 \begin_inset Quotes srd
14424 \end_inset
14425
14426
14427 \family typewriter
14428 flags\InsetSpace ~
14429 |=\InsetSpace ~
14430 0x80;
14431 \family default
14432
14433 \begin_inset Quotes sld
14434 \end_inset
14435
14436  is not atomic if 
14437 \family typewriter
14438 flags
14439 \family default
14440  resides in xdata.
14441  Setting 
14442 \begin_inset Quotes srd
14443 \end_inset
14444
14445
14446 \family typewriter
14447 flags\InsetSpace ~
14448 |=\InsetSpace ~
14449 0x40;
14450 \family default
14451
14452 \begin_inset Quotes sld
14453 \end_inset
14454
14455  from within an interrupt routine might get lost if the interrupt occurs
14456  at the wrong time.
14457  
14458 \begin_inset Quotes sld
14459 \end_inset
14460
14461
14462 \family typewriter
14463 counter\InsetSpace ~
14464 +=\InsetSpace ~
14465 8;
14466 \family default
14467
14468 \begin_inset Quotes srd
14469 \end_inset
14470
14471  is not atomic on the 8051 even if 
14472 \family typewriter
14473 counter
14474 \family default
14475  is located in data memory.
14476 \newline
14477 Bugs like these are hard to reproduce and can
14478  cause a lot of trouble.
14479  
14480 \end_layout
14481
14482 \begin_layout Subsubsection
14483 \begin_inset LatexCommand \label{sub:Common-interrupt-pitfall-stack-overflow}
14484
14485 \end_inset
14486
14487 Common interrupt pitfall: 
14488 \emph on
14489 stack overflow
14490 \end_layout
14491
14492 \begin_layout Standard
14493 The return address and the registers used in the interrupt service routine
14494  are saved on the stack
14495 \begin_inset LatexCommand \index{stack}
14496
14497 \end_inset
14498
14499  so there must be sufficient stack space.
14500  If there isn't variables or registers (or even the return address itself)
14501  will be corrupted.
14502  This 
14503 \emph on
14504 stack overflow
14505 \emph default
14506
14507 \begin_inset LatexCommand \index{stack overflow}
14508
14509 \end_inset
14510
14511  is most likely to happen if the interrupt occurs during the 
14512 \begin_inset Quotes sld
14513 \end_inset
14514
14515 deepest
14516 \begin_inset Quotes srd
14517 \end_inset
14518
14519  subroutine when the stack is already in use for f.e.
14520  many return addresses.
14521 \end_layout
14522
14523 \begin_layout Subsubsection
14524 \begin_inset LatexCommand \label{sub:Common-interrupt-pitfall-non-reentrant}
14525
14526 \end_inset
14527
14528 Common interrupt pitfall: 
14529 \emph on
14530 use of non-reentrant functions
14531 \end_layout
14532
14533 \begin_layout Standard
14534 A special note here, int (16 bit) and long (32 bit) integer division
14535 \begin_inset LatexCommand \index{Division}
14536
14537 \end_inset
14538
14539 , multiplication
14540 \begin_inset LatexCommand \index{Multiplication}
14541
14542 \end_inset
14543
14544  & modulus
14545 \begin_inset LatexCommand \index{Modulus}
14546
14547 \end_inset
14548
14549  and floating-point
14550 \begin_inset LatexCommand \index{Floating point support}
14551
14552 \end_inset
14553
14554  operations are implemented using external support routines.
14555  If an interrupt service routine needs to do any of these operations then
14556  the support routines (as mentioned in a following section) will have to
14557  be recompiled using the
14558 \emph on
14559  -
14560 \begin_inset ERT
14561 status collapsed
14562
14563 \begin_layout Standard
14564
14565
14566 \backslash
14567 /
14568 \end_layout
14569
14570 \end_inset
14571
14572 -stack-auto
14573 \begin_inset LatexCommand \index{-\/-stack-auto}
14574
14575 \end_inset
14576
14577
14578 \emph default
14579  option and the source file will need to be compiled using the 
14580 \emph on
14581 -
14582 \begin_inset ERT
14583 status collapsed
14584
14585 \begin_layout Standard
14586
14587
14588 \backslash
14589 /
14590 \end_layout
14591
14592 \end_inset
14593
14594 -int-long-reent
14595 \emph default
14596
14597 \begin_inset LatexCommand \index{-\/-int-long-reent}
14598
14599 \end_inset
14600
14601  compiler option.
14602  
14603 \newline
14604 Note, the type promotion
14605 \begin_inset LatexCommand \index{type promotion}
14606
14607 \end_inset
14608
14609  required by ANSI C can cause 16 bit routines to be used
14610 \begin_inset Marginal
14611 status collapsed
14612
14613 \begin_layout Standard
14614
14615 \series bold
14616 \InsetSpace ~
14617 !
14618 \end_layout
14619
14620 \end_inset
14621
14622  without the programmer being aware of it.
14623  See f.e.
14624  the cast 
14625 \family typewriter
14626 (unsigned char)(tail-1)
14627 \family default
14628  within the if clause in section 
14629 \begin_inset LatexCommand \ref{sub:A-Step-by Assembler Introduction}
14630
14631 \end_inset
14632
14633 .
14634 \end_layout
14635
14636 \begin_layout Standard
14637 Calling other functions from an interrupt service routine is not recommended,
14638  avoid it if possible.
14639  Note that when some function is called from an interrupt service routine
14640  it should be preceded by a #pragma\InsetSpace ~
14641 nooverlay
14642 \begin_inset LatexCommand \index{\#pragma nooverlay}
14643
14644 \end_inset
14645
14646  if it is not reentrant.
14647  Furthermore nonreentrant functions should not be called from the main program
14648  while the interrupt service routine might be active.
14649  They also must not be called from low priority interrupt service routines
14650  while a high priority interrupt service routine might be active.
14651  You could use semaphores or make the function
14652 \emph on
14653  critical
14654 \emph default
14655  if all parameters are passed in registers.
14656 \newline
14657  Also see section 
14658 \begin_inset LatexCommand \ref{sub:Overlaying}
14659
14660 \end_inset
14661
14662 \InsetSpace ~
14663 about Overlaying and section 
14664 \begin_inset LatexCommand \ref{sub:Functions-using-private-banks}
14665
14666 \end_inset
14667
14668 \InsetSpace ~
14669 about Functions using private register banks.
14670 \begin_inset VSpace bigskip
14671 \end_inset
14672
14673
14674 \end_layout
14675
14676 \begin_layout Subsection
14677 MCS51/DS390 Interrupt Service Routines
14678 \end_layout
14679
14680 \begin_layout Standard
14681 Interrupt
14682 \begin_inset LatexCommand \index{interrupt}
14683
14684 \end_inset
14685
14686  numbers and the corresponding address & descriptions for the Standard 8051/8052
14687  are listed below.
14688  SDCC will automatically adjust the 
14689 \begin_inset LatexCommand \index{interrupt vector table}
14690
14691 \end_inset
14692
14693  to the maximum interrupt number specified.
14694 \newline
14695
14696 \end_layout
14697
14698 \begin_layout Standard
14699 \align center
14700 \begin_inset Tabular
14701 <lyxtabular version="3" rows="9" columns="3">
14702 <features>
14703 <column alignment="center" valignment="top" leftline="true" width="0in">
14704 <column alignment="left" valignment="top" leftline="true" width="0in">
14705 <column alignment="left" valignment="top" leftline="true" rightline="true" width="0in">
14706 <row topline="true" bottomline="true">
14707 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14708 \begin_inset Text
14709
14710 \begin_layout Standard
14711 Interrupt #
14712 \end_layout
14713
14714 \end_inset
14715 </cell>
14716 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14717 \begin_inset Text
14718
14719 \begin_layout Standard
14720 Description
14721 \end_layout
14722
14723 \end_inset
14724 </cell>
14725 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
14726 \begin_inset Text
14727
14728 \begin_layout Standard
14729 Vector Address
14730 \end_layout
14731
14732 \end_inset
14733 </cell>
14734 </row>
14735 <row topline="true">
14736 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14737 \begin_inset Text
14738
14739 \begin_layout Standard
14740 0
14741 \end_layout
14742
14743 \end_inset
14744 </cell>
14745 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14746 \begin_inset Text
14747
14748 \begin_layout Standard
14749 External 0
14750 \end_layout
14751
14752 \end_inset
14753 </cell>
14754 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
14755 \begin_inset Text
14756
14757 \begin_layout Standard
14758 0x0003
14759 \end_layout
14760
14761 \end_inset
14762 </cell>
14763 </row>
14764 <row topline="true">
14765 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14766 \begin_inset Text
14767
14768 \begin_layout Standard
14769 1
14770 \end_layout
14771
14772 \end_inset
14773 </cell>
14774 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14775 \begin_inset Text
14776
14777 \begin_layout Standard
14778 Timer 0
14779 \end_layout
14780
14781 \end_inset
14782 </cell>
14783 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
14784 \begin_inset Text
14785
14786 \begin_layout Standard
14787 0x000b
14788 \end_layout
14789
14790 \end_inset
14791 </cell>
14792 </row>
14793 <row topline="true">
14794 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14795 \begin_inset Text
14796
14797 \begin_layout Standard
14798 2
14799 \end_layout
14800
14801 \end_inset
14802 </cell>
14803 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14804 \begin_inset Text
14805
14806 \begin_layout Standard
14807 External 1
14808 \end_layout
14809
14810 \end_inset
14811 </cell>
14812 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
14813 \begin_inset Text
14814
14815 \begin_layout Standard
14816 0x0013
14817 \end_layout
14818
14819 \end_inset
14820 </cell>
14821 </row>
14822 <row topline="true">
14823 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14824 \begin_inset Text
14825
14826 \begin_layout Standard
14827 3
14828 \end_layout
14829
14830 \end_inset
14831 </cell>
14832 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14833 \begin_inset Text
14834
14835 \begin_layout Standard
14836 Timer 1
14837 \end_layout
14838
14839 \end_inset
14840 </cell>
14841 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
14842 \begin_inset Text
14843
14844 \begin_layout Standard
14845 0x001b
14846 \end_layout
14847
14848 \end_inset
14849 </cell>
14850 </row>
14851 <row topline="true">
14852 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14853 \begin_inset Text
14854
14855 \begin_layout Standard
14856 4
14857 \end_layout
14858
14859 \end_inset
14860 </cell>
14861 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14862 \begin_inset Text
14863
14864 \begin_layout Standard
14865 Serial
14866 \end_layout
14867
14868 \end_inset
14869 </cell>
14870 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
14871 \begin_inset Text
14872
14873 \begin_layout Standard
14874 0x0023
14875 \end_layout
14876
14877 \end_inset
14878 </cell>
14879 </row>
14880 <row topline="true">
14881 <cell multicolumn="1" alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14882 \begin_inset Text
14883
14884 \begin_layout Standard
14885 5
14886 \end_layout
14887
14888 \end_inset
14889 </cell>
14890 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14891 \begin_inset Text
14892
14893 \begin_layout Standard
14894 Timer 2 (8052)
14895 \end_layout
14896
14897 \end_inset
14898 </cell>
14899 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
14900 \begin_inset Text
14901
14902 \begin_layout Standard
14903 0x002b
14904 \end_layout
14905
14906 \end_inset
14907 </cell>
14908 </row>
14909 <row topline="true">
14910 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14911 \begin_inset Text
14912
14913 \begin_layout Standard
14914 ...
14915 \end_layout
14916
14917 \end_inset
14918 </cell>
14919 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14920 \begin_inset Text
14921
14922 \begin_layout Standard
14923
14924 \end_layout
14925
14926 \end_inset
14927 </cell>
14928 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
14929 \begin_inset Text
14930
14931 \begin_layout Standard
14932 ...
14933 \end_layout
14934
14935 \end_inset
14936 </cell>
14937 </row>
14938 <row topline="true" bottomline="true">
14939 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14940 \begin_inset Text
14941
14942 \begin_layout Standard
14943 n
14944 \end_layout
14945
14946 \end_inset
14947 </cell>
14948 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14949 \begin_inset Text
14950
14951 \begin_layout Standard
14952
14953 \end_layout
14954
14955 \end_inset
14956 </cell>
14957 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
14958 \begin_inset Text
14959
14960 \begin_layout Standard
14961 0x0003 + 8*n
14962 \end_layout
14963
14964 \end_inset
14965 </cell>
14966 </row>
14967 </lyxtabular>
14968
14969 \end_inset
14970
14971
14972 \newline
14973
14974 \end_layout
14975
14976 \begin_layout Standard
14977 If the interrupt service routine is defined without 
14978 \emph on
14979 using
14980 \begin_inset LatexCommand \index{using (mcs51, ds390 register bank)}
14981
14982 \end_inset
14983
14984
14985 \begin_inset LatexCommand \index{\_\_using (mcs51, ds390 register bank)}
14986
14987 \end_inset
14988
14989
14990 \emph default
14991  a register bank or with register bank 0 (
14992 \emph on
14993 using
14994 \emph default
14995  0), the compiler will save the registers used by itself on the stack upon
14996  entry and restore them at exit, however if such an interrupt service routine
14997  calls another function then the entire register bank will be saved on the
14998  stack.
14999  This scheme may be advantageous for small interrupt service routines which
15000  have low register usage.
15001 \end_layout
15002
15003 \begin_layout Standard
15004 If the interrupt service routine is defined to be using a specific register
15005  bank then only 
15006 \emph on
15007 a, b, dptr
15008 \emph default
15009  & psw are saved and restored, if such an interrupt service routine calls
15010  another function (using another register bank) then the entire register
15011  bank of the called function will be saved on the stack
15012 \begin_inset LatexCommand \index{stack}
15013
15014 \end_inset
15015
15016 .
15017  This scheme is recommended for larger interrupt service routines.
15018 \begin_inset VSpace bigskip
15019 \end_inset
15020
15021
15022 \end_layout
15023
15024 \begin_layout Subsection
15025 HC08
15026 \begin_inset LatexCommand \index{HC08}
15027
15028 \end_inset
15029
15030  Interrupt Service Routines
15031 \end_layout
15032
15033 \begin_layout Standard
15034 Since the number of interrupts
15035 \begin_inset LatexCommand \index{HC08!interrupt}
15036
15037 \end_inset
15038
15039  available is chip specific and the interrupt vector table always ends at
15040  the last byte of memory, the interrupt numbers corresponds to the interrupt
15041  vectors in reverse order of address.
15042  For example, interrupt 1 will use the interrupt vector at 0xfffc, interrupt
15043  2 will use the interrupt vector at 0xfffa, and so on.
15044  However, interrupt 0 (the reset vector at 0xfffe) is not redefinable in
15045  this way; instead see section 
15046 \begin_inset LatexCommand \ref{sub:Startup-Code}
15047
15048 \end_inset
15049
15050  for details on customizing startup.
15051 \begin_inset VSpace bigskip
15052 \end_inset
15053
15054
15055 \end_layout
15056
15057 \begin_layout Subsection
15058 Z80 Interrupt Service Routines
15059 \end_layout
15060
15061 \begin_layout Standard
15062 The Z80
15063 \begin_inset LatexCommand \index{Z80}
15064
15065 \end_inset
15066
15067  uses several different methods for determining the correct interrupt
15068 \begin_inset LatexCommand \index{Z80!interrupt}
15069
15070 \end_inset
15071
15072  vector depending on the hardware implementation.
15073  Therefore, SDCC ignores the optional interrupt number and does not attempt
15074  to generate an interrupt vector table.
15075 \end_layout
15076
15077 \begin_layout Standard
15078 By default, SDCC generates code for a maskable interrupt, which uses a RETI
15079  instruction to return from the interrupt.
15080  To write an interrupt handler for the non-maskable interrupt, which needs
15081  a RETN instruction instead, add the 
15082 \emph on
15083 critical
15084 \emph default
15085  keyword:
15086 \end_layout
15087
15088 \begin_layout Verse
15089
15090 \family typewriter
15091 void nmi_isr (void) critical interrupt
15092 \newline
15093
15094 \newline
15095 \InsetSpace ~
15096 \InsetSpace ~
15097 \InsetSpace ~
15098 \InsetSpace ~
15099 ...
15100  
15101 \newline
15102 }
15103 \end_layout
15104
15105 \begin_layout Standard
15106 However if you need to create a non-interruptable interrupt service routine
15107  you would also require the 
15108 \emph on
15109 critical
15110 \emph default
15111  keyword.
15112  To distinguish between this and an nmi_isr you must provide an interrupt
15113  number.
15114 \begin_inset VSpace bigskip
15115 \end_inset
15116
15117
15118 \end_layout
15119
15120 \begin_layout Section
15121 Enabling and Disabling Interrupts
15122 \end_layout
15123
15124 \begin_layout Subsection
15125 Critical Functions and Critical Statements
15126 \end_layout
15127
15128 \begin_layout Standard
15129 A special keyword may be associated with a block or a function declaring
15130  it as 
15131 \emph on
15132 critical
15133 \emph default
15134 .
15135  SDCC will generate code to disable all interrupts
15136 \begin_inset LatexCommand \index{interrupt}
15137
15138 \end_inset
15139
15140  upon entry to a critical function and restore the interrupt enable to the
15141  previous state before returning.
15142  Nesting critical functions will need one additional byte on the stack
15143 \begin_inset LatexCommand \index{stack}
15144
15145 \end_inset
15146
15147  for each call.
15148 \end_layout
15149
15150 \begin_layout Verse
15151
15152 \family typewriter
15153 int foo () __critical
15154 \begin_inset LatexCommand \index{critical}
15155
15156 \end_inset
15157
15158
15159 \begin_inset LatexCommand \index{\_\_critical}
15160
15161 \end_inset
15162
15163  
15164 \newline
15165
15166 \newline
15167 \InsetSpace ~
15168 \InsetSpace ~
15169 \InsetSpace ~
15170 \InsetSpace ~
15171 ...
15172  
15173 \newline
15174 \InsetSpace ~
15175 \InsetSpace ~
15176 \InsetSpace ~
15177 \InsetSpace ~
15178 ...
15179  
15180 \newline
15181 }
15182 \end_layout
15183
15184 \begin_layout Standard
15185 The critical attribute maybe used with other attributes like 
15186 \emph on
15187 reentrant.
15188 \emph default
15189
15190 \newline
15191 The keyword 
15192 \emph on
15193 critical
15194 \emph default
15195  may also be used to disable interrupts more locally:
15196 \end_layout
15197
15198 \begin_layout Verse
15199
15200 \family typewriter
15201 __critical{ i++; }
15202 \end_layout
15203
15204 \begin_layout Standard
15205 More than one statement could have been included in the block.
15206 \end_layout
15207
15208 \begin_layout Subsection
15209 Enabling and Disabling Interrupts directly
15210 \end_layout
15211
15212 \begin_layout Standard
15213 Interrupts
15214 \begin_inset LatexCommand \index{interrupt}
15215
15216 \end_inset
15217
15218  can also be disabled and enabled directly (8051):
15219 \end_layout
15220
15221 \begin_layout Verse
15222
15223 \family typewriter
15224 EA = 0;\InsetSpace ~
15225 \InsetSpace ~
15226 \InsetSpace ~
15227 \InsetSpace ~
15228 \InsetSpace ~
15229 \InsetSpace ~
15230 \InsetSpace ~
15231 \InsetSpace ~
15232 \InsetSpace ~
15233 \InsetSpace ~
15234 \InsetSpace ~
15235 \InsetSpace ~
15236 or:\InsetSpace ~
15237 \InsetSpace ~
15238 \InsetSpace ~
15239 \InsetSpace ~
15240 \InsetSpace ~
15241 \InsetSpace ~
15242 \InsetSpace ~
15243 \InsetSpace ~
15244 \InsetSpace ~
15245 \InsetSpace ~
15246 \InsetSpace ~
15247 EA_SAVE = EA;
15248 \end_layout
15249
15250 \begin_layout Verse
15251
15252 \family typewriter
15253 ...\InsetSpace ~
15254 \InsetSpace ~
15255 \InsetSpace ~
15256 \InsetSpace ~
15257 \InsetSpace ~
15258 \InsetSpace ~
15259 \InsetSpace ~
15260 \InsetSpace ~
15261 \InsetSpace ~
15262 \InsetSpace ~
15263 \InsetSpace ~
15264 \InsetSpace ~
15265 \InsetSpace ~
15266 \InsetSpace ~
15267 \InsetSpace ~
15268 \InsetSpace ~
15269 \InsetSpace ~
15270 \InsetSpace ~
15271 \InsetSpace ~
15272 \InsetSpace ~
15273 \InsetSpace ~
15274 \InsetSpace ~
15275 \InsetSpace ~
15276 \InsetSpace ~
15277 \InsetSpace ~
15278 \InsetSpace ~
15279 \InsetSpace ~
15280 \InsetSpace ~
15281 \InsetSpace ~
15282 \InsetSpace ~
15283 EA = 0;
15284 \end_layout
15285
15286 \begin_layout Verse
15287
15288 \family typewriter
15289 EA = 1;\InsetSpace ~
15290 \InsetSpace ~
15291 \InsetSpace ~
15292 \InsetSpace ~
15293 \InsetSpace ~
15294 \InsetSpace ~
15295 \InsetSpace ~
15296 \InsetSpace ~
15297 \InsetSpace ~
15298 \InsetSpace ~
15299 \InsetSpace ~
15300 \InsetSpace ~
15301 \InsetSpace ~
15302 \InsetSpace ~
15303 \InsetSpace ~
15304 \InsetSpace ~
15305 \InsetSpace ~
15306 \InsetSpace ~
15307 \InsetSpace ~
15308 \InsetSpace ~
15309 \InsetSpace ~
15310 \InsetSpace ~
15311 \InsetSpace ~
15312 \InsetSpace ~
15313 \InsetSpace ~
15314 \InsetSpace ~
15315 ...
15316 \end_layout
15317
15318 \begin_layout Verse
15319
15320 \family typewriter
15321 \InsetSpace ~
15322 \InsetSpace ~
15323 \InsetSpace ~
15324 \InsetSpace ~
15325 \InsetSpace ~
15326 \InsetSpace ~
15327 \InsetSpace ~
15328 \InsetSpace ~
15329 \InsetSpace ~
15330 \InsetSpace ~
15331 \InsetSpace ~
15332 \InsetSpace ~
15333 \InsetSpace ~
15334 \InsetSpace ~
15335 \InsetSpace ~
15336 \InsetSpace ~
15337 \InsetSpace ~
15338 \InsetSpace ~
15339 \InsetSpace ~
15340 \InsetSpace ~
15341 \InsetSpace ~
15342 \InsetSpace ~
15343 \InsetSpace ~
15344 \InsetSpace ~
15345 \InsetSpace ~
15346 \InsetSpace ~
15347 \InsetSpace ~
15348 \InsetSpace ~
15349 \InsetSpace ~
15350 \InsetSpace ~
15351 \InsetSpace ~
15352 \InsetSpace ~
15353 \InsetSpace ~
15354 EA = EA_SAVE;
15355 \end_layout
15356
15357 \begin_layout Standard
15358 On other architectures which have seperate opcodes for enabling and disabling
15359  interrupts you might want to make use of defines with inline assembly
15360 \begin_inset LatexCommand \index{Assembler routines}
15361
15362 \end_inset
15363
15364  (HC08
15365 \begin_inset LatexCommand \index{HC08!interrupt}
15366
15367 \end_inset
15368
15369 ):
15370 \end_layout
15371
15372 \begin_layout Verse
15373
15374 \family typewriter
15375 #define CLI _asm
15376 \begin_inset LatexCommand \index{\_asm}
15377
15378 \end_inset
15379
15380 \InsetSpace ~
15381 \InsetSpace ~
15382 cli\InsetSpace ~
15383 \InsetSpace ~
15384 _endasm
15385 \begin_inset LatexCommand \index{\_endasm}
15386
15387 \end_inset
15388
15389
15390 \end_layout
15391
15392 \begin_layout Verse
15393
15394 \family typewriter
15395 #define SEI _asm\InsetSpace ~
15396 \InsetSpace ~
15397 sei\InsetSpace ~
15398 \InsetSpace ~
15399 _endasm; 
15400 \end_layout
15401
15402 \begin_layout Verse
15403
15404 \family typewriter
15405 ...
15406 \end_layout
15407
15408 \begin_layout Standard
15409 Note: it is sometimes sufficient to disable only a specific interrupt source
15410  like f.e.
15411  a timer or serial interrupt by manipulating an 
15412 \emph on
15413 interrupt mask
15414 \begin_inset LatexCommand \index{interrupt mask}
15415
15416 \end_inset
15417
15418
15419 \emph default
15420  register.
15421  
15422 \end_layout
15423
15424 \begin_layout Standard
15425 Usually the time during which interrupts are disabled should be kept as
15426  short as possible.
15427  This minimizes both 
15428 \emph on
15429 interrupt latency
15430 \emph default
15431
15432 \begin_inset LatexCommand \index{interrupt latency}
15433
15434 \end_inset
15435
15436  (the time between the occurrence of the interrupt and the execution of
15437  the first code in the interrupt routine) and 
15438 \emph on
15439 interrupt jitter
15440 \emph default
15441
15442 \begin_inset LatexCommand \index{interrupt jitter}
15443
15444 \end_inset
15445
15446  (the difference between the shortest and the longest interrupt latency).
15447  These really are something different, f.e.
15448  a serial interrupt has to be served before its buffer overruns so it cares
15449  for the maximum interrupt latency, whereas it does not care about jitter.
15450  On a loudspeaker driven via a digital to analog converter which is fed
15451  by an interrupt a latency of a few milliseconds might be tolerable, whereas
15452  a much smaller jitter will be very audible.
15453 \end_layout
15454
15455 \begin_layout Standard
15456 You can reenable interrupts within an interrupt routine and on some architecture
15457 s you can make use of two (or more) levels of 
15458 \emph on
15459 interrupt priorities
15460 \emph default
15461
15462 \begin_inset LatexCommand \index{interrupt priority}
15463
15464 \end_inset
15465
15466 .
15467  On some architectures which don't support interrupt priorities these can
15468  be implemented by manipulating the interrupt mask and reenabling interrupts
15469  within the interrupt routine.
15470  Check there is sufficient space on the stack
15471 \begin_inset LatexCommand \index{stack}
15472
15473 \end_inset
15474
15475  and don't add complexity unless you have to.
15476  
15477 \end_layout
15478
15479 \begin_layout Subsection
15480 Semaphore
15481 \begin_inset LatexCommand \index{semaphore}
15482
15483 \end_inset
15484
15485  locking (mcs51/ds390)
15486 \end_layout
15487
15488 \begin_layout Standard
15489 Some architectures (mcs51/ds390) have an atomic
15490 \begin_inset LatexCommand \index{atomic}
15491
15492 \end_inset
15493
15494  bit test and
15495 \emph on
15496  
15497 \emph default
15498 clear
15499 \emph on
15500  
15501 \emph default
15502 instruction.
15503  These type of instructions are typically used in preemptive multitasking
15504  systems, where a routine f.e.
15505  claims the use of a data structure ('acquires a lock
15506 \begin_inset LatexCommand \index{lock}
15507
15508 \end_inset
15509
15510  on it'), makes some modifications and then releases the lock when the data
15511  structure is consistent again.
15512  The instruction may also be used if interrupt and non-interrupt code have
15513  to compete for a resource.
15514  With the atomic bit test and clear instruction interrupts
15515 \begin_inset LatexCommand \index{interrupt}
15516
15517 \end_inset
15518
15519  don't have to be disabled for the locking operation.
15520  
15521 \end_layout
15522
15523 \begin_layout Standard
15524 SDCC generates this instruction if the source follows this pattern:
15525 \end_layout
15526
15527 \begin_layout Verse
15528
15529 \family typewriter
15530 volatile
15531 \begin_inset LatexCommand \index{volatile}
15532
15533 \end_inset
15534
15535  bit resource_is_free; 
15536 \newline
15537
15538 \newline
15539 if (resource_is_free) 
15540 \newline
15541 \InsetSpace ~
15542 \InsetSpace ~
15543
15544 \newline
15545 \InsetSpace ~
15546 \InsetSpace ~
15547 \InsetSpace ~
15548 \InsetSpace ~
15549 resource_is_free=0; 
15550 \newline
15551 \InsetSpace ~
15552 \InsetSpace ~
15553 \InsetSpace ~
15554 \InsetSpace ~
15555 ...
15556  
15557 \newline
15558 \InsetSpace ~
15559 \InsetSpace ~
15560 \InsetSpace ~
15561 \InsetSpace ~
15562 resource_is_free=1;
15563 \newline
15564 \InsetSpace ~
15565 \InsetSpace ~
15566
15567 \end_layout
15568
15569 \begin_layout Standard
15570 Note, mcs51 and ds390 support only an atomic
15571 \begin_inset LatexCommand \index{atomic}
15572
15573 \end_inset
15574
15575  bit test and 
15576 \emph on
15577 clear
15578 \emph default
15579  instruction (as opposed to atomic bit test and 
15580 \emph on
15581 set).
15582 \end_layout
15583
15584 \begin_layout Section
15585 Functions using private register banks
15586 \begin_inset LatexCommand \label{sub:Functions-using-private-banks}
15587
15588 \end_inset
15589
15590  (mcs51/ds390)
15591 \end_layout
15592
15593 \begin_layout Standard
15594 Some architectures have support for quickly changing register sets.
15595  SDCC supports this feature with the 
15596 \emph on
15597 using
15598 \begin_inset LatexCommand \index{using (mcs51, ds390 register bank)}
15599
15600 \end_inset
15601
15602
15603 \begin_inset LatexCommand \index{\_\_using (mcs51, ds390 register bank)}
15604
15605 \end_inset
15606
15607
15608 \emph default
15609  attribute (which tells the compiler to use a register bank
15610 \begin_inset LatexCommand \index{register bank (mcs51, ds390)}
15611
15612 \end_inset
15613
15614  other than the default bank zero).
15615  It should only be applied to 
15616 \emph on
15617 interrupt
15618 \begin_inset LatexCommand \index{interrupt}
15619
15620 \end_inset
15621
15622
15623 \emph default
15624  functions (see footnote below).
15625  This will in most circumstances make the generated ISR code more efficient
15626  since it will not have to save registers on the stack.
15627 \end_layout
15628
15629 \begin_layout Standard
15630 The 
15631 \emph on
15632 using
15633 \emph default
15634  attribute will have no effect on the generated code for a 
15635 \emph on
15636 non-interrupt
15637 \emph default
15638  function (but may occasionally be useful anyway
15639 \begin_inset Foot
15640 status open
15641
15642 \begin_layout Standard
15643 possible exception: if a function is called ONLY from 'interrupt' functions
15644  using a particular bank, it can be declared with the same 'using' attribute
15645  as the calling 'interrupt' functions.
15646  For instance, if you have several ISRs using bank one, and all of them
15647  call memcpy(), it might make sense to create a specialized version of memcpy()
15648  'using 1', since this would prevent the ISR from having to save bank zero
15649  to the stack on entry and switch to bank zero before calling the function
15650 \end_layout
15651
15652 \end_inset
15653
15654 ).
15655 \newline
15656
15657 \emph on
15658 (pending: Note, nowadays the 
15659 \emph default
15660 using
15661 \emph on
15662  attribute has an effect on
15663 \emph default
15664  
15665 \emph on
15666 the generated code for a 
15667 \emph default
15668 non-interrupt
15669 \emph on
15670  function
15671 \emph default
15672 .
15673 \emph on
15674 )
15675 \end_layout
15676
15677 \begin_layout Standard
15678 An 
15679 \emph on
15680 interrupt
15681 \emph default
15682  function using a non-zero bank will assume that it can trash that register
15683  bank, and will not save it.
15684  Since high-priority interrupts
15685 \begin_inset LatexCommand \index{interrupts}
15686
15687 \end_inset
15688
15689
15690 \begin_inset LatexCommand \index{interrupt priority}
15691
15692 \end_inset
15693
15694  can interrupt low-priority ones on the 8051 and friends, this means that
15695  if a high-priority ISR 
15696 \emph on
15697 using
15698 \emph default
15699  a particular bank occurs while processing a low-priority ISR 
15700 \emph on
15701 using
15702 \emph default
15703  the same bank, terrible and bad things can happen.
15704  To prevent this, no single register bank should be 
15705 \emph on
15706 used
15707 \emph default
15708  by both a high priority and a low priority ISR.
15709  This is probably most easily done by having all high priority ISRs use
15710  one bank and all low priority ISRs use another.
15711  If you have an ISR which can change priority at runtime, you're on your
15712  own: I suggest using the default bank zero and taking the small performance
15713  hit.
15714 \end_layout
15715
15716 \begin_layout Standard
15717 It is most efficient if your ISR calls no other functions.
15718  If your ISR must call other functions, it is most efficient if those functions
15719  use the same bank as the ISR (see note 1 below); the next best is if the
15720  called functions use bank zero.
15721  It is very inefficient to call a function using a different, non-zero bank
15722  from an ISR.
15723  
15724 \begin_inset VSpace bigskip
15725 \end_inset
15726
15727
15728 \end_layout
15729
15730 \begin_layout Section
15731 Startup Code
15732 \begin_inset LatexCommand \label{sub:Startup-Code}
15733
15734 \end_inset
15735
15736
15737 \begin_inset LatexCommand \index{Startup code}
15738
15739 \end_inset
15740
15741
15742 \end_layout
15743
15744 \begin_layout Subsection
15745 MCS51/DS390 Startup Code
15746 \end_layout
15747
15748 \begin_layout Standard
15749 The compiler triggers the linker to link certain initialization modules
15750  from the runtime library
15751 \begin_inset LatexCommand \index{Runtime library}
15752
15753 \end_inset
15754
15755  called crt<something>.
15756  Only the necessary ones are linked, for instance crtxstack.asm (GSINIT1,
15757  GSINIT5) is not linked unless the -
15758 \series bold
15759
15760 \begin_inset ERT
15761 status open
15762
15763 \begin_layout Standard
15764
15765
15766 \backslash
15767 /
15768 \end_layout
15769
15770 \end_inset
15771
15772
15773 \series default
15774 -xstack option is used.
15775  These modules are highly entangled by the use of special segments/areas,
15776  but a common layout is shown below:
15777 \end_layout
15778
15779 \begin_layout Verse
15780
15781 \family typewriter
15782 \series bold
15783 \size footnotesize
15784 (main.asm)
15785 \end_layout
15786
15787 \begin_layout Verse
15788
15789 \family typewriter
15790 \size footnotesize
15791 \InsetSpace ~
15792 \InsetSpace ~
15793 \InsetSpace ~
15794 \InsetSpace ~
15795 \InsetSpace ~
15796 \InsetSpace ~
15797 \InsetSpace ~
15798 \InsetSpace ~
15799 .area HOME (CODE)
15800 \newline
15801 __interrupt_vect:
15802 \newline
15803 \InsetSpace ~
15804 \InsetSpace ~
15805 \InsetSpace ~
15806 \InsetSpace ~
15807 \InsetSpace ~
15808 \InsetSpace ~
15809 \InsetSpace ~
15810 \InsetSpace ~
15811 ljmp __sdcc_gsinit_startup
15812 \end_layout
15813
15814 \begin_layout Verse
15815
15816 \family typewriter
15817 \series bold
15818 \size footnotesize
15819 (crtstart.asm)
15820 \end_layout
15821
15822 \begin_layout Verse
15823
15824 \family typewriter
15825 \size footnotesize
15826 \InsetSpace ~
15827 \InsetSpace ~
15828 \InsetSpace ~
15829 \InsetSpace ~
15830 \InsetSpace ~
15831 \InsetSpace ~
15832 \InsetSpace ~
15833 \InsetSpace ~
15834 .area GSINIT0 (CODE)
15835 \newline
15836 __sdcc_gsinit_startup::
15837 \newline
15838 \InsetSpace ~
15839 \InsetSpace ~
15840 \InsetSpace ~
15841 \InsetSpace ~
15842 \InsetSpace ~
15843 \InsetSpace ~
15844 \InsetSpace ~
15845 \InsetSpace ~
15846 mov sp,#__start__stack - 1
15847 \end_layout
15848
15849 \begin_layout Verse
15850
15851 \family typewriter
15852 \series bold
15853 \size footnotesize
15854 (crtxstack.asm)
15855 \end_layout
15856
15857 \begin_layout Verse
15858
15859 \family typewriter
15860 \size footnotesize
15861 \InsetSpace ~
15862 \InsetSpace ~
15863 \InsetSpace ~
15864 \InsetSpace ~
15865 \InsetSpace ~
15866 \InsetSpace ~
15867 \InsetSpace ~
15868 \InsetSpace ~
15869 .area GSINIT1 (CODE)
15870 \newline
15871 __sdcc_init_xstack::
15872 \newline
15873 ; Need to initialize in GSINIT1 in
15874  case the user's __sdcc_external_startup uses the xstack.
15875 \newline
15876 \InsetSpace ~
15877 \InsetSpace ~
15878 \InsetSpace ~
15879 \InsetSpace ~
15880 \InsetSpace ~
15881 \InsetSpace ~
15882 \InsetSpace ~
15883 \InsetSpace ~
15884 mov __XPAGE,#(__start__x
15885 stack >> 8)
15886 \newline
15887 \InsetSpace ~
15888 \InsetSpace ~
15889 \InsetSpace ~
15890 \InsetSpace ~
15891 \InsetSpace ~
15892 \InsetSpace ~
15893 \InsetSpace ~
15894 \InsetSpace ~
15895 mov _spx,#__start__xstack
15896 \end_layout
15897
15898 \begin_layout Verse
15899
15900 \family typewriter
15901 \series bold
15902 \size footnotesize
15903 (crtstart.asm)
15904 \end_layout
15905
15906 \begin_layout Verse
15907
15908 \family typewriter
15909 \size footnotesize
15910 \InsetSpace ~
15911 \InsetSpace ~
15912 \InsetSpace ~
15913 \InsetSpace ~
15914 \InsetSpace ~
15915 \InsetSpace ~
15916 \InsetSpace ~
15917 \InsetSpace ~
15918 .area GSINIT2 (CODE)
15919 \newline
15920 \InsetSpace ~
15921 \InsetSpace ~
15922 \InsetSpace ~
15923 \InsetSpace ~
15924 \InsetSpace ~
15925 \InsetSpace ~
15926 \InsetSpace ~
15927 \InsetSpace ~
15928 lcall __sdcc_external_startup
15929 \newline
15930 \InsetSpace ~
15931 \InsetSpace ~
15932 \InsetSpace ~
15933 \InsetSpace ~
15934 \InsetSpace ~
15935 \InsetSpace ~
15936 \InsetSpace ~
15937 \InsetSpace ~
15938 mov a,dpl
15939 \newline
15940 \InsetSpace ~
15941 \InsetSpace ~
15942 \InsetSpace ~
15943 \InsetSpace ~
15944 \InsetSpace ~
15945 \InsetSpace ~
15946 \InsetSpace ~
15947 \InsetSpace ~
15948 jz __sdcc_init_data
15949 \newline
15950 \InsetSpace ~
15951 \InsetSpace ~
15952 \InsetSpace ~
15953 \InsetSpace ~
15954 \InsetSpace ~
15955 \InsetSpace ~
15956 \InsetSpace ~
15957 \InsetSpace ~
15958 ljmp
15959  __sdcc_program_startup
15960 \newline
15961 __sdcc_init_data:
15962 \end_layout
15963
15964 \begin_layout Verse
15965
15966 \family typewriter
15967 \series bold
15968 \size footnotesize
15969 (crtxinit.asm)
15970 \end_layout
15971
15972 \begin_layout Verse
15973
15974 \family typewriter
15975 \size footnotesize
15976 \InsetSpace ~
15977 \InsetSpace ~
15978 \InsetSpace ~
15979 \InsetSpace ~
15980 \InsetSpace ~
15981 \InsetSpace ~
15982 \InsetSpace ~
15983 \InsetSpace ~
15984 .area GSINIT3 (CODE)
15985 \newline
15986 __mcs51_genXINIT::
15987 \newline
15988 \InsetSpace ~
15989 \InsetSpace ~
15990 \InsetSpace ~
15991 \InsetSpace ~
15992 \InsetSpace ~
15993 \InsetSpace ~
15994 \InsetSpace ~
15995 \InsetSpace ~
15996 mov r1,#l_XINIT
15997 \newline
15998 \InsetSpace ~
15999 \InsetSpace ~
16000 \InsetSpace ~
16001 \InsetSpace ~
16002 \InsetSpace ~
16003 \InsetSpace ~
16004 \InsetSpace ~
16005 \InsetSpace ~
16006 mov a,r1
16007 \newline
16008 \InsetSpace ~
16009 \InsetSpace ~
16010 \InsetSpace ~
16011 \InsetSpace ~
16012 \InsetSpace ~
16013 \InsetSpace ~
16014 \InsetSpace ~
16015 \InsetSpace ~
16016 orl a,#(l_XINIT
16017  >> 8)
16018 \newline
16019 \InsetSpace ~
16020 \InsetSpace ~
16021 \InsetSpace ~
16022 \InsetSpace ~
16023 \InsetSpace ~
16024 \InsetSpace ~
16025 \InsetSpace ~
16026 \InsetSpace ~
16027 jz 00003$
16028 \newline
16029 \InsetSpace ~
16030 \InsetSpace ~
16031 \InsetSpace ~
16032 \InsetSpace ~
16033 \InsetSpace ~
16034 \InsetSpace ~
16035 \InsetSpace ~
16036 \InsetSpace ~
16037 mov r2,#((l_XINIT+255) >> 8)
16038 \newline
16039 \InsetSpace ~
16040 \InsetSpace ~
16041 \InsetSpace ~
16042 \InsetSpace ~
16043 \InsetSpace ~
16044 \InsetSpace ~
16045 \InsetSpace ~
16046 \InsetSpace ~
16047 mov dptr,#s_XINIT
16048 \newline
16049 \InsetSpace ~
16050 \InsetSpace ~
16051 \InsetSpace ~
16052 \InsetSpace ~
16053 \InsetSpace ~
16054 \InsetSpace ~
16055 \InsetSpace ~
16056 \InsetSpace ~
16057 mov r0,#s_XISEG
16058 \newline
16059 \InsetSpace ~
16060 \InsetSpace ~
16061 \InsetSpace ~
16062 \InsetSpace ~
16063 \InsetSpace ~
16064 \InsetSpace ~
16065 \InsetSpace ~
16066 \InsetSpace ~
16067 mov
16068  __XPAGE,#(s_XISEG >> 8)
16069 \newline
16070 00001$:\InsetSpace ~
16071 clr a
16072 \newline
16073 \InsetSpace ~
16074 \InsetSpace ~
16075 \InsetSpace ~
16076 \InsetSpace ~
16077 \InsetSpace ~
16078 \InsetSpace ~
16079 \InsetSpace ~
16080 \InsetSpace ~
16081 movc a,@a+dptr
16082 \newline
16083 \InsetSpace ~
16084 \InsetSpace ~
16085 \InsetSpace ~
16086 \InsetSpace ~
16087 \InsetSpace ~
16088 \InsetSpace ~
16089 \InsetSpace ~
16090 \InsetSpace ~
16091 movx @r0,a
16092 \newline
16093 \InsetSpace ~
16094 \InsetSpace ~
16095 \InsetSpace ~
16096 \InsetSpace ~
16097 \InsetSpace ~
16098 \InsetSpace ~
16099 \InsetSpace ~
16100 \InsetSpace ~
16101 inc dptr
16102 \newline
16103 \InsetSpace ~
16104 \InsetSpace ~
16105 \InsetSpace ~
16106 \InsetSpace ~
16107 \InsetSpace ~
16108 \InsetSpace ~
16109 \InsetSpace ~
16110 \InsetSpace ~
16111 inc
16112  r0
16113 \newline
16114 \InsetSpace ~
16115 \InsetSpace ~
16116 \InsetSpace ~
16117 \InsetSpace ~
16118 \InsetSpace ~
16119 \InsetSpace ~
16120 \InsetSpace ~
16121 \InsetSpace ~
16122 cjne r0,#0,00002$
16123 \newline
16124 \InsetSpace ~
16125 \InsetSpace ~
16126 \InsetSpace ~
16127 \InsetSpace ~
16128 \InsetSpace ~
16129 \InsetSpace ~
16130 \InsetSpace ~
16131 \InsetSpace ~
16132 inc __XPAGE
16133 \newline
16134 00002$:\InsetSpace ~
16135 djnz r1,00001$
16136 \newline
16137 \InsetSpace ~
16138 \InsetSpace ~
16139 \InsetSpace ~
16140 \InsetSpace ~
16141 \InsetSpace ~
16142 \InsetSpace ~
16143 \InsetSpace ~
16144 \InsetSpace ~
16145 djnz r2,00001$
16146 \newline
16147 \InsetSpace ~
16148 \InsetSpace ~
16149 \InsetSpace ~
16150 \InsetSpace ~
16151 \InsetSpace ~
16152 \InsetSpace ~
16153 \InsetSpace ~
16154 \InsetSpace ~
16155 mov __XPAGE,#0
16156 xFF
16157 \newline
16158 00003$:
16159 \end_layout
16160
16161 \begin_layout Verse
16162
16163 \family typewriter
16164 \series bold
16165 \size footnotesize
16166 (crtclear.asm)
16167 \end_layout
16168
16169 \begin_layout Verse
16170
16171 \family typewriter
16172 \size footnotesize
16173 \InsetSpace ~
16174 \InsetSpace ~
16175 \InsetSpace ~
16176 \InsetSpace ~
16177 \InsetSpace ~
16178 \InsetSpace ~
16179 \InsetSpace ~
16180 \InsetSpace ~
16181 .area GSINIT4 (CODE)
16182 \newline
16183 __mcs51_genRAMCLEAR::
16184 \newline
16185 \InsetSpace ~
16186 \InsetSpace ~
16187 \InsetSpace ~
16188 \InsetSpace ~
16189 \InsetSpace ~
16190 \InsetSpace ~
16191 \InsetSpace ~
16192 \InsetSpace ~
16193 clr a
16194 \newline
16195 \InsetSpace ~
16196 \InsetSpace ~
16197 \InsetSpace ~
16198 \InsetSpace ~
16199 \InsetSpace ~
16200 \InsetSpace ~
16201 \InsetSpace ~
16202 \InsetSpace ~
16203 mov r0,#(l_IRAM-1)
16204 \newline
16205 00004$:\InsetSpace ~
16206 mov
16207  @r0,a
16208 \newline
16209 \InsetSpace ~
16210 \InsetSpace ~
16211 \InsetSpace ~
16212 \InsetSpace ~
16213 \InsetSpace ~
16214 \InsetSpace ~
16215 \InsetSpace ~
16216 \InsetSpace ~
16217 djnz r0,00004$
16218 \newline
16219 ; _mcs51_genRAMCLEAR() end
16220 \end_layout
16221
16222 \begin_layout Verse
16223
16224 \family typewriter
16225 \series bold
16226 \size footnotesize
16227 (crtxclear.asm)
16228 \end_layout
16229
16230 \begin_layout Verse
16231
16232 \family typewriter
16233 \size footnotesize
16234 \InsetSpace ~
16235 \InsetSpace ~
16236 \InsetSpace ~
16237 \InsetSpace ~
16238 \InsetSpace ~
16239 \InsetSpace ~
16240 \InsetSpace ~
16241 \InsetSpace ~
16242 .area GSINIT4 (CODE)
16243 \newline
16244 __mcs51_genXRAMCLEAR::
16245 \newline
16246 \InsetSpace ~
16247 \InsetSpace ~
16248 \InsetSpace ~
16249 \InsetSpace ~
16250 \InsetSpace ~
16251 \InsetSpace ~
16252 \InsetSpace ~
16253 \InsetSpace ~
16254 mov r0,#l_PSEG
16255 \newline
16256 \InsetSpace ~
16257 \InsetSpace ~
16258 \InsetSpace ~
16259 \InsetSpace ~
16260 \InsetSpace ~
16261 \InsetSpace ~
16262 \InsetSpace ~
16263 \InsetSpace ~
16264 mov a,r0
16265 \newline
16266 \InsetSpace ~
16267 \InsetSpace ~
16268 \InsetSpace ~
16269 \InsetSpace ~
16270 \InsetSpace ~
16271 \InsetSpace ~
16272 \InsetSpace ~
16273 \InsetSpace ~
16274 orl a,#(l_PSEG
16275  >> 8)
16276 \newline
16277 \InsetSpace ~
16278 \InsetSpace ~
16279 \InsetSpace ~
16280 \InsetSpace ~
16281 \InsetSpace ~
16282 \InsetSpace ~
16283 \InsetSpace ~
16284 \InsetSpace ~
16285 jz 00006$
16286 \newline
16287 \InsetSpace ~
16288 \InsetSpace ~
16289 \InsetSpace ~
16290 \InsetSpace ~
16291 \InsetSpace ~
16292 \InsetSpace ~
16293 \InsetSpace ~
16294 \InsetSpace ~
16295 mov r1,#s_PSEG
16296 \newline
16297 \InsetSpace ~
16298 \InsetSpace ~
16299 \InsetSpace ~
16300 \InsetSpace ~
16301 \InsetSpace ~
16302 \InsetSpace ~
16303 \InsetSpace ~
16304 \InsetSpace ~
16305 mov __XPAGE,#(s_PSEG >> 8)
16306 \newline
16307 \InsetSpace ~
16308 \InsetSpace ~
16309 \InsetSpace ~
16310 \InsetSpace ~
16311 \InsetSpace ~
16312 \InsetSpace ~
16313 \InsetSpace ~
16314 \InsetSpace ~
16315 clr a
16316 \newline
16317 00005$:\InsetSpace ~
16318 movx
16319  @r1,a
16320 \newline
16321 \InsetSpace ~
16322 \InsetSpace ~
16323 \InsetSpace ~
16324 \InsetSpace ~
16325 \InsetSpace ~
16326 \InsetSpace ~
16327 \InsetSpace ~
16328 \InsetSpace ~
16329 inc r1
16330 \newline
16331 \InsetSpace ~
16332 \InsetSpace ~
16333 \InsetSpace ~
16334 \InsetSpace ~
16335 \InsetSpace ~
16336 \InsetSpace ~
16337 \InsetSpace ~
16338 \InsetSpace ~
16339 djnz r0,00005$
16340 \newline
16341 00006$:
16342 \newline
16343 \InsetSpace ~
16344 \InsetSpace ~
16345 \InsetSpace ~
16346 \InsetSpace ~
16347 \InsetSpace ~
16348 \InsetSpace ~
16349 \InsetSpace ~
16350 \InsetSpace ~
16351 mov r0,#l_XSEG
16352 \newline
16353 \InsetSpace ~
16354 \InsetSpace ~
16355 \InsetSpace ~
16356 \InsetSpace ~
16357 \InsetSpace ~
16358 \InsetSpace ~
16359 \InsetSpace ~
16360 \InsetSpace ~
16361 mov a,r0
16362 \newline
16363 \InsetSpace ~
16364 \InsetSpace ~
16365 \InsetSpace ~
16366 \InsetSpace ~
16367 \InsetSpace ~
16368 \InsetSpace ~
16369 \InsetSpace ~
16370 \InsetSpace ~
16371 orl a,#(l_XSEG >>
16372  8)
16373 \newline
16374 \InsetSpace ~
16375 \InsetSpace ~
16376 \InsetSpace ~
16377 \InsetSpace ~
16378 \InsetSpace ~
16379 \InsetSpace ~
16380 \InsetSpace ~
16381 \InsetSpace ~
16382 jz 00008$
16383 \newline
16384 \InsetSpace ~
16385 \InsetSpace ~
16386 \InsetSpace ~
16387 \InsetSpace ~
16388 \InsetSpace ~
16389 \InsetSpace ~
16390 \InsetSpace ~
16391 \InsetSpace ~
16392 mov r1,#((l_XSEG + 255) >> 8)
16393 \newline
16394 \InsetSpace ~
16395 \InsetSpace ~
16396 \InsetSpace ~
16397 \InsetSpace ~
16398 \InsetSpace ~
16399 \InsetSpace ~
16400 \InsetSpace ~
16401 \InsetSpace ~
16402 mov dptr,#s_XSEG
16403 \newline
16404 \InsetSpace ~
16405 \InsetSpace ~
16406 \InsetSpace ~
16407 \InsetSpace ~
16408 \InsetSpace ~
16409 \InsetSpace ~
16410 \InsetSpace ~
16411 \InsetSpace ~
16412 clr a
16413 \newline
16414 00007$:\InsetSpace ~
16415 movx
16416  @dptr,a
16417 \newline
16418 \InsetSpace ~
16419 \InsetSpace ~
16420 \InsetSpace ~
16421 \InsetSpace ~
16422 \InsetSpace ~
16423 \InsetSpace ~
16424 \InsetSpace ~
16425 \InsetSpace ~
16426 inc dptr
16427 \newline
16428 \InsetSpace ~
16429 \InsetSpace ~
16430 \InsetSpace ~
16431 \InsetSpace ~
16432 \InsetSpace ~
16433 \InsetSpace ~
16434 \InsetSpace ~
16435 \InsetSpace ~
16436 djnz r0,00007$
16437 \newline
16438 \InsetSpace ~
16439 \InsetSpace ~
16440 \InsetSpace ~
16441 \InsetSpace ~
16442 \InsetSpace ~
16443 \InsetSpace ~
16444 \InsetSpace ~
16445 \InsetSpace ~
16446 djnz r1,00007$
16447 \newline
16448 00008$:
16449 \end_layout
16450
16451 \begin_layout Verse
16452
16453 \family typewriter
16454 \series bold
16455 \size footnotesize
16456 (crtxstack.asm)
16457 \end_layout
16458
16459 \begin_layout Verse
16460
16461 \family typewriter
16462 \size footnotesize
16463 \InsetSpace ~
16464 \InsetSpace ~
16465 \InsetSpace ~
16466 \InsetSpace ~
16467 \InsetSpace ~
16468 \InsetSpace ~
16469 \InsetSpace ~
16470 \InsetSpace ~
16471 .area GSINIT5 (CODE)
16472 \newline
16473 ; Need to initialize in GSINIT5 because __mcs51_genXINIT
16474  modifies __XPAGE
16475 \newline
16476 ; and __mcs51_genRAMCLEAR modifies _spx.
16477 \newline
16478 \InsetSpace ~
16479 \InsetSpace ~
16480 \InsetSpace ~
16481 \InsetSpace ~
16482 \InsetSpace ~
16483 \InsetSpace ~
16484 \InsetSpace ~
16485 \InsetSpace ~
16486 mov __XPAGE,#(__start__x
16487 stack >> 8)
16488 \newline
16489 \InsetSpace ~
16490 \InsetSpace ~
16491 \InsetSpace ~
16492 \InsetSpace ~
16493 \InsetSpace ~
16494 \InsetSpace ~
16495 \InsetSpace ~
16496 \InsetSpace ~
16497 mov _spx,#__start__xstack
16498 \end_layout
16499
16500 \begin_layout Verse
16501
16502 \family typewriter
16503 \series bold
16504 \size footnotesize
16505 (application modules)
16506 \end_layout
16507
16508 \begin_layout Verse
16509
16510 \family typewriter
16511 \size footnotesize
16512 \InsetSpace ~
16513 \InsetSpace ~
16514 \InsetSpace ~
16515 \InsetSpace ~
16516 \InsetSpace ~
16517 \InsetSpace ~
16518 \InsetSpace ~
16519 \InsetSpace ~
16520 .area GSINIT (CODE)
16521 \end_layout
16522
16523 \begin_layout Verse
16524
16525 \family typewriter
16526 \series bold
16527 \size footnotesize
16528 (main.asm)
16529 \end_layout
16530
16531 \begin_layout Verse
16532
16533 \family typewriter
16534 \size footnotesize
16535 \InsetSpace ~
16536 \InsetSpace ~
16537 \InsetSpace ~
16538 \InsetSpace ~
16539 \InsetSpace ~
16540 \InsetSpace ~
16541 \InsetSpace ~
16542 \InsetSpace ~
16543 .area GSFINAL (CODE)
16544 \newline
16545 \InsetSpace ~
16546 \InsetSpace ~
16547 \InsetSpace ~
16548 \InsetSpace ~
16549 \InsetSpace ~
16550 \InsetSpace ~
16551 \InsetSpace ~
16552 \InsetSpace ~
16553 ljmp __sdcc_program_startup
16554 \newline
16555 ;---------------------------------
16556 -----------------------
16557 \newline
16558 ; Home
16559 \newline
16560 ;--------------------------------------------------
16561 ------
16562 \newline
16563 \InsetSpace ~
16564 \InsetSpace ~
16565 \InsetSpace ~
16566 \InsetSpace ~
16567 \InsetSpace ~
16568 \InsetSpace ~
16569 \InsetSpace ~
16570 \InsetSpace ~
16571 .area HOME (CODE)
16572 \newline
16573 \InsetSpace ~
16574 \InsetSpace ~
16575 \InsetSpace ~
16576 \InsetSpace ~
16577 \InsetSpace ~
16578 \InsetSpace ~
16579 \InsetSpace ~
16580 \InsetSpace ~
16581 .area CSEG (CODE)
16582 \newline
16583 __sdcc_program_startup:
16584 \newline
16585 \InsetSpace ~
16586 \InsetSpace ~
16587 \InsetSpace ~
16588 \InsetSpace ~
16589 \InsetSpace ~
16590 \InsetSpace ~
16591 \InsetSpace ~
16592 \InsetSpace ~
16593 lcall _main
16594 \newline
16595 ;
16596  return from main will lock up
16597 \newline
16598 \InsetSpace ~
16599 \InsetSpace ~
16600 \InsetSpace ~
16601 \InsetSpace ~
16602 \InsetSpace ~
16603 \InsetSpace ~
16604 \InsetSpace ~
16605 \InsetSpace ~
16606 sjmp .
16607 \end_layout
16608
16609 \begin_layout Standard
16610 One of these modules (crtstart.asm) contains a call to the C routine 
16611 \emph on
16612 _sdcc_external_startup()
16613 \begin_inset LatexCommand \index{\_sdcc\_external\_startup()}
16614
16615 \end_inset
16616
16617
16618 \series bold
16619 \emph default
16620  
16621 \series default
16622 at the start of the CODE area.
16623  This routine is also in the runtime library
16624 \begin_inset LatexCommand \index{Runtime library}
16625
16626 \end_inset
16627
16628  and returns 0 by default.
16629  If this routine returns a non-zero value, the static & global variable
16630  initialization will be skipped and the function main will be invoked.
16631  Otherwise static & global variables will be initialized before the function
16632  main is invoked.
16633  You could add an 
16634 \emph on
16635 _sdcc_external_startup()
16636 \emph default
16637  routine to your program to override the default if you need to setup hardware
16638  or perform some other critical operation prior to static & global variable
16639  initialization
16640 \begin_inset LatexCommand \index{Variable initialization}
16641
16642 \end_inset
16643
16644 .
16645  On some mcs51 variants xdata
16646 \begin_inset LatexCommand \index{xdata (mcs51, ds390 storage class)}
16647
16648 \end_inset
16649
16650  memory has to be explicitly enabled before it can be accessed or if the
16651  watchdog
16652 \begin_inset LatexCommand \index{watchdog}
16653
16654 \end_inset
16655
16656  needs to be disabled, this is the place to do it.
16657  The startup code clears all internal data memory, 256 bytes by default,
16658  but from 0 to n-1 if 
16659 \emph on
16660 -
16661 \begin_inset ERT
16662 status collapsed
16663
16664 \begin_layout Standard
16665
16666
16667 \backslash
16668 /
16669 \end_layout
16670
16671 \end_inset
16672
16673 -iram-size
16674 \begin_inset LatexCommand \index{-\/-iram-size <Value>}
16675
16676 \end_inset
16677
16678 n
16679 \emph default
16680  is used.
16681  (recommended for Chipcon CC1010).
16682 \end_layout
16683
16684 \begin_layout Standard
16685 See also the compiler options 
16686 \emph on
16687 -
16688 \begin_inset ERT
16689 status collapsed
16690
16691 \begin_layout Standard
16692
16693
16694 \backslash
16695 /
16696 \end_layout
16697
16698 \end_inset
16699
16700 -no-xinit
16701 \emph default
16702 -
16703 \emph on
16704 opt
16705 \emph default
16706
16707 \begin_inset LatexCommand \index{-\/-no-xinit-opt}
16708
16709 \end_inset
16710
16711
16712 \emph on
16713 -
16714 \begin_inset ERT
16715 status collapsed
16716
16717 \begin_layout Standard
16718
16719
16720 \backslash
16721 /
16722 \end_layout
16723
16724 \end_inset
16725
16726 -main-return
16727 \emph default
16728
16729 \begin_inset LatexCommand \index{-\/-main-return}
16730
16731 \end_inset
16732
16733  and section 
16734 \begin_inset LatexCommand \ref{sub:MCS51-variants}
16735
16736 \end_inset
16737
16738  about MCS51-variants.
16739 \newline
16740
16741 \end_layout
16742
16743 \begin_layout Standard
16744 While these initialization modules are meant as generic startup code there
16745  might be the need for customization.
16746  Let's assume the return value of 
16747 \emph on
16748 _sdcc_external_startup()
16749 \emph default
16750  in 
16751 \emph on
16752 crtstart.asm
16753 \emph default
16754  should not be checked (or 
16755 \emph on
16756 _sdcc_external_startup()
16757 \emph default
16758  should not be called at all).
16759  The recommended way would be to copy 
16760 \emph on
16761 crtstart.asm
16762 \emph default
16763  (f.e.
16764  from 
16765 \begin_inset LatexCommand \url{http://sdcc.svn.sourceforge.net/viewvc/*checkout*/sdcc/trunk/sdcc/device/lib/mcs51/crtstart.asm}
16766
16767 \end_inset
16768
16769 ) into the source directory, adapt it there, then assemble it with 
16770 \emph on
16771 asx8051 -plosgff
16772 \begin_inset Foot
16773 status open
16774
16775 \begin_layout Standard
16776 \begin_inset Quotes sld
16777 \end_inset
16778
16779 -plosgff
16780 \begin_inset Quotes srd
16781 \end_inset
16782
16783  are the assembler options used in 
16784 \begin_inset LatexCommand \url{http://sdcc.svn.sourceforge.net/viewvc/sdcc/trunk/sdcc/device/lib/mcs51/Makefile.in?view=markup }
16785
16786 \end_inset
16787
16788
16789 \end_layout
16790
16791 \end_inset
16792
16793  crtstart.asm
16794 \emph default
16795  and when linking your project explicitely specify 
16796 \emph on
16797 crtstart.rel
16798 \emph default
16799 .
16800  As a bonus a listing of the relocated object file 
16801 \emph on
16802 crtstart.rst
16803 \emph default
16804  is generated.
16805 \end_layout
16806
16807 \begin_layout Standard
16808 \begin_inset VSpace bigskip
16809 \end_inset
16810
16811
16812 \end_layout
16813
16814 \begin_layout Subsection
16815 HC08 Startup Code
16816 \end_layout
16817
16818 \begin_layout Standard
16819 The HC08
16820 \begin_inset LatexCommand \index{HC08}
16821
16822 \end_inset
16823
16824  startup code follows the same scheme as the MCS51 startup code.
16825 \begin_inset VSpace bigskip
16826 \end_inset
16827
16828
16829 \end_layout
16830
16831 \begin_layout Subsection
16832 Z80 Startup Code
16833 \end_layout
16834
16835 \begin_layout Standard
16836 On the Z80
16837 \begin_inset LatexCommand \index{Z80}
16838
16839 \end_inset
16840
16841  the startup code is inserted by linking with crt0.o which is generated from
16842  sdcc/device/lib/z80/crt0.s.
16843  If you need a different startup code you can use the compiler option 
16844 \emph on
16845 -
16846 \series bold
16847 \emph default
16848
16849 \begin_inset ERT
16850 status collapsed
16851
16852 \begin_layout Standard
16853
16854
16855 \backslash
16856 /
16857 \end_layout
16858
16859 \end_inset
16860
16861
16862 \series default
16863 \emph on
16864 -no-std-crt0
16865 \emph default
16866
16867 \begin_inset LatexCommand \index{-\/-no-std-crt0}
16868
16869 \end_inset
16870
16871  and provide your own crt0.o.
16872  
16873 \begin_inset VSpace bigskip
16874 \end_inset
16875
16876
16877 \end_layout
16878
16879 \begin_layout Section
16880 Inline Assembler Code
16881 \begin_inset LatexCommand \index{Assembler routines}
16882
16883 \end_inset
16884
16885
16886 \end_layout
16887
16888 \begin_layout Subsection
16889 A Step by Step Introduction
16890 \begin_inset LatexCommand \label{sub:A-Step-by Assembler Introduction}
16891
16892 \end_inset
16893
16894
16895 \end_layout
16896
16897 \begin_layout Standard
16898 Starting from a small snippet of c-code this example shows for the MCS51
16899  how to use inline assembly, access variables, a function parameter and
16900  an array in xdata memory.
16901  The example uses an MCS51 here but is easily adapted for other architectures.
16902  This is a buffer routine which should be optimized:
16903 \end_layout
16904
16905 \begin_layout Verse
16906
16907 \family typewriter
16908 \size footnotesize
16909 unsigned char __far
16910 \begin_inset LatexCommand \index{far (storage class)}
16911
16912 \end_inset
16913
16914
16915 \begin_inset LatexCommand \index{\_\_far (storage class)}
16916
16917 \end_inset
16918
16919  __at
16920 \begin_inset LatexCommand \index{at}
16921
16922 \end_inset
16923
16924
16925 \begin_inset LatexCommand \index{\_\_at}
16926
16927 \end_inset
16928
16929 (0x7f00) buf[0x100];
16930 \begin_inset LatexCommand \index{Aligned array}
16931
16932 \end_inset
16933
16934
16935 \newline
16936 unsigned char head, tail;\InsetSpace ~
16937 \InsetSpace ~
16938 \InsetSpace ~
16939 \InsetSpace ~
16940 \InsetSpace ~
16941 \InsetSpace ~
16942 \InsetSpace ~
16943 \InsetSpace ~
16944 \InsetSpace ~
16945 \InsetSpace ~
16946 \InsetSpace ~
16947 \InsetSpace ~
16948 \InsetSpace ~
16949 \InsetSpace ~
16950 \InsetSpace ~
16951 \InsetSpace ~
16952 \InsetSpace ~
16953 /* if interrupts
16954 \begin_inset LatexCommand \index{interrupt}
16955
16956 \end_inset
16957
16958  are involved see
16959 \newline
16960 \InsetSpace ~
16961 \InsetSpace ~
16962 \InsetSpace ~
16963 \InsetSpace ~
16964 \InsetSpace ~
16965 \InsetSpace ~
16966 \InsetSpace ~
16967 \InsetSpace ~
16968 \InsetSpace ~
16969 \InsetSpace ~
16970 \InsetSpace ~
16971 \InsetSpace ~
16972 \InsetSpace ~
16973 \InsetSpace ~
16974 \InsetSpace ~
16975 \InsetSpace ~
16976 \InsetSpace ~
16977 \InsetSpace ~
16978 \InsetSpace ~
16979 \InsetSpace ~
16980 \InsetSpace ~
16981 \InsetSpace ~
16982 \InsetSpace ~
16983 \InsetSpace ~
16984 \InsetSpace ~
16985 \InsetSpace ~
16986 \InsetSpace ~
16987 \InsetSpace ~
16988 \InsetSpace ~
16989 \InsetSpace ~
16990 \InsetSpace ~
16991 \InsetSpace ~
16992 \InsetSpace ~
16993 \InsetSpace ~
16994 \InsetSpace ~
16995 \InsetSpace ~
16996 \InsetSpace ~
16997 \InsetSpace ~
16998 \InsetSpace ~
16999 \InsetSpace ~
17000 \InsetSpace ~
17001 \InsetSpace ~
17002 \InsetSpace ~
17003 \InsetSpace ~
17004 \InsetSpace ~
17005 section 
17006 \begin_inset LatexCommand \ref{sub:Common-interrupt-pitfall-volatile}
17007
17008 \end_inset
17009
17010  about
17011 \series bold
17012  volatile
17013 \series default
17014  */
17015 \newline
17016
17017 \newline
17018 void to_buffer( unsigned char c ) 
17019 \newline
17020 {
17021 \newline
17022 \InsetSpace ~
17023 \InsetSpace ~
17024 \InsetSpace ~
17025 \InsetSpace ~
17026 if( head != (unsigned char)(tail-1)
17027  )\InsetSpace ~
17028 /* cast 
17029 \series bold
17030 needed
17031 \series default
17032  to avoid promotion
17033 \begin_inset LatexCommand \index{promotion to signed int}
17034
17035 \end_inset
17036
17037
17038 \begin_inset LatexCommand \index{type promotion}
17039
17040 \end_inset
17041
17042  to integer */
17043 \begin_inset Marginal
17044 status collapsed
17045
17046 \begin_layout Standard
17047
17048 \series bold
17049 \InsetSpace ~
17050 !
17051 \end_layout
17052
17053 \end_inset
17054
17055
17056 \newline
17057 \InsetSpace ~
17058 \InsetSpace ~
17059 \InsetSpace ~
17060 \InsetSpace ~
17061 \InsetSpace ~
17062 \InsetSpace ~
17063 \InsetSpace ~
17064 \InsetSpace ~
17065 buf[ head++ ] = c;\InsetSpace ~
17066 \InsetSpace ~
17067 \InsetSpace ~
17068 \InsetSpace ~
17069 \InsetSpace ~
17070 \InsetSpace ~
17071 \InsetSpace ~
17072 \InsetSpace ~
17073 \InsetSpace ~
17074 \InsetSpace ~
17075 \InsetSpace ~
17076 \InsetSpace ~
17077 \InsetSpace ~
17078 \InsetSpace ~
17079 \InsetSpace ~
17080 \InsetSpace ~
17081 /* access to a 256 byte aligned array */
17082 \newline
17083
17084 \end_layout
17085
17086 \begin_layout Standard
17087 If the code snippet (assume it is saved in buffer.c) is compiled with SDCC
17088  then a corresponding buffer.asm file is generated.
17089  We define a new function 
17090 \family typewriter
17091 to_buffer_asm()
17092 \family default
17093  in file buffer.c in which we cut and paste the generated code, removing
17094  unwanted comments and some ':'.
17095  Then add 
17096 \begin_inset Quotes sld
17097 \end_inset
17098
17099
17100 \series bold
17101 _asm
17102 \series default
17103
17104 \begin_inset Quotes srd
17105 \end_inset
17106
17107  and 
17108 \begin_inset Quotes sld
17109 \end_inset
17110
17111
17112 \series bold
17113 _endasm;
17114 \series default
17115
17116 \begin_inset Quotes srd
17117 \end_inset
17118
17119
17120 \begin_inset Foot
17121 status open
17122
17123 \begin_layout Standard
17124 Note, that the single underscore form (_asm and _endasm) are not C99-compatible,
17125  and for C-99 compatibility, the double-underscore form (__asm and __endasm)
17126  has to be used.
17127  The latter is also used in the library functions.
17128 \end_layout
17129
17130 \end_inset
17131
17132  to the beginning and the end of the function body:
17133 \end_layout
17134
17135 \begin_layout Verse
17136
17137 \family typewriter
17138 \size footnotesize
17139 /* With a cut and paste from the .asm file, we have something to start with.
17140 \newline
17141 \InsetSpace ~
17142 \InsetSpace ~
17143 \InsetSpace ~
17144 The
17145  function is not yet OK! (registers aren't saved) */ 
17146 \newline
17147 void to_buffer_asm(
17148  unsigned char c ) 
17149 \newline
17150
17151 \newline
17152 \InsetSpace ~
17153 \InsetSpace ~
17154 \InsetSpace ~
17155 \InsetSpace ~
17156 _asm
17157 \begin_inset LatexCommand \index{\_asm}
17158
17159 \end_inset
17160
17161
17162 \begin_inset LatexCommand \index{\_\_asm}
17163
17164 \end_inset
17165
17166
17167 \newline
17168 \InsetSpace ~
17169 \InsetSpace ~
17170 \InsetSpace ~
17171 \InsetSpace ~
17172 mov\InsetSpace ~
17173 \InsetSpace ~
17174 r2,dpl 
17175 \newline
17176 ;buffer.c if( head != (unsigned char)(tail-1) ) \InsetSpace ~
17177 /* cast 
17178 \series bold
17179 needed
17180 \series default
17181  to avoid promotion
17182 \begin_inset LatexCommand \index{promotion to signed int}
17183
17184 \end_inset
17185
17186
17187 \begin_inset LatexCommand \index{type promotion}
17188
17189 \end_inset
17190
17191  to integer */
17192 \newline
17193 \InsetSpace ~
17194 \InsetSpace ~
17195 \InsetSpace ~
17196 \InsetSpace ~
17197 mov\InsetSpace ~
17198 \InsetSpace ~
17199 a,_tail 
17200 \newline
17201 \InsetSpace ~
17202 \InsetSpace ~
17203 \InsetSpace ~
17204 \InsetSpace ~
17205 dec\InsetSpace ~
17206 \InsetSpace ~
17207
17208 \newline
17209 \InsetSpace ~
17210 \InsetSpace ~
17211 \InsetSpace ~
17212 \InsetSpace ~
17213 mov\InsetSpace ~
17214 \InsetSpace ~
17215 r3,a 
17216 \newline
17217 \InsetSpace ~
17218 \InsetSpace ~
17219 \InsetSpace ~
17220 \InsetSpace ~
17221 mov\InsetSpace ~
17222 \InsetSpace ~
17223 a,_head 
17224 \newline
17225 \InsetSpace ~
17226 \InsetSpace ~
17227 \InsetSpace ~
17228 \InsetSpace ~
17229 cjne a,ar3,00106$ 
17230 \newline
17231 \InsetSpace ~
17232 \InsetSpace ~
17233 \InsetSpace ~
17234 \InsetSpace ~
17235 ret
17236 \newline
17237 00106$:
17238  
17239 \newline
17240 ;buffer.c buf[ head++ ] = c; /* access to a 256 byte aligned array */
17241 \begin_inset LatexCommand \index{Aligned array}
17242
17243 \end_inset
17244
17245
17246 \newline
17247 \InsetSpace ~
17248 \InsetSpace ~
17249 \InsetSpace ~
17250 \InsetSpace ~
17251 mov\InsetSpace ~
17252 \InsetSpace ~
17253 r3,_head 
17254 \newline
17255 \InsetSpace ~
17256 \InsetSpace ~
17257 \InsetSpace ~
17258 \InsetSpace ~
17259 inc\InsetSpace ~
17260 \InsetSpace ~
17261 _head 
17262 \newline
17263 \InsetSpace ~
17264 \InsetSpace ~
17265 \InsetSpace ~
17266 \InsetSpace ~
17267 mov\InsetSpace ~
17268 \InsetSpace ~
17269 dpl,r3 
17270 \newline
17271 \InsetSpace ~
17272 \InsetSpace ~
17273 \InsetSpace ~
17274 \InsetSpace ~
17275 mov\InsetSpace ~
17276 \InsetSpace ~
17277 dph,#(_buf >> 8) 
17278 \newline
17279 \InsetSpace ~
17280 \InsetSpace ~
17281 \InsetSpace ~
17282 \InsetSpace ~
17283 mov\InsetSpace ~
17284 \InsetSpace ~
17285 a,r2 
17286 \newline
17287 \InsetSpace ~
17288 \InsetSpace ~
17289 \InsetSpace ~
17290 \InsetSpace ~
17291 movx @dptr,a
17292  
17293 \newline
17294 00103$: 
17295 \newline
17296 \InsetSpace ~
17297 \InsetSpace ~
17298 \InsetSpace ~
17299 \InsetSpace ~
17300 ret
17301 \newline
17302 \InsetSpace ~
17303 \InsetSpace ~
17304 \InsetSpace ~
17305 \InsetSpace ~
17306 _endasm
17307 \begin_inset LatexCommand \index{\_endasm}
17308
17309 \end_inset
17310
17311
17312 \begin_inset LatexCommand \index{\_\_endasm}
17313
17314 \end_inset
17315
17316 ;
17317 \newline
17318
17319 \end_layout
17320
17321 \begin_layout Standard
17322 The new file buffer.c should compile with only one warning about the unreferenced
17323  function argument 'c'.
17324  Now we hand-optimize the assembly code and insert an #define USE_ASSEMBLY
17325  (1) and finally have:
17326 \end_layout
17327
17328 \begin_layout Verse
17329
17330 \family typewriter
17331 \size footnotesize
17332 unsigned char __far __at(0x7f00) buf[0x100];
17333 \newline
17334 unsigned char head, tail;
17335 \newline
17336 #define
17337  USE_ASSEMBLY (1)
17338 \newline
17339
17340 \newline
17341 #if !USE_ASSEMBLY
17342 \newline
17343
17344 \newline
17345 void to_buffer( unsigned char c )
17346 \newline
17347 {
17348 \newline
17349 \InsetSpace ~
17350 \InsetSpace ~
17351 \InsetSpace ~
17352 \InsetSpace ~
17353 if(
17354  head != (unsigned char)(tail-1) )
17355 \newline
17356 \InsetSpace ~
17357 \InsetSpace ~
17358 \InsetSpace ~
17359 \InsetSpace ~
17360 \InsetSpace ~
17361 \InsetSpace ~
17362 \InsetSpace ~
17363 \InsetSpace ~
17364 buf[ head++ ] = c;
17365 \newline
17366 }
17367 \newline
17368
17369 \newline
17370 #else
17371 \newline
17372
17373 \newline
17374 void to_buffer(
17375  unsigned char c )
17376 \newline
17377 {
17378 \newline
17379 \InsetSpace ~
17380 \InsetSpace ~
17381 \InsetSpace ~
17382 \InsetSpace ~
17383 c; // to avoid warning: unreferenced function argument
17384 \newline
17385 \InsetSpace ~
17386 \InsetSpace ~
17387 \InsetSpace ~
17388 \InsetSpace ~
17389 _asm
17390 \begin_inset LatexCommand \index{\_asm}
17391
17392 \end_inset
17393
17394
17395 \begin_inset LatexCommand \index{\_\_asm}
17396
17397 \end_inset
17398
17399
17400 \newline
17401 \InsetSpace ~
17402 \InsetSpace ~
17403 \InsetSpace ~
17404 \InsetSpace ~
17405 \InsetSpace ~
17406 \InsetSpace ~
17407 \InsetSpace ~
17408 \InsetSpace ~
17409 ; save used registers here.
17410  
17411 \newline
17412 \InsetSpace ~
17413 \InsetSpace ~
17414 \InsetSpace ~
17415 \InsetSpace ~
17416 \InsetSpace ~
17417 \InsetSpace ~
17418 \InsetSpace ~
17419 \InsetSpace ~
17420 ; If we were still using r2,r3 we would have to push them here.
17421  
17422 \newline
17423 ; if( head != (unsigned char)(tail-1) )
17424 \newline
17425 \InsetSpace ~
17426 \InsetSpace ~
17427 \InsetSpace ~
17428 \InsetSpace ~
17429 \InsetSpace ~
17430 \InsetSpace ~
17431 \InsetSpace ~
17432 \InsetSpace ~
17433 mov\InsetSpace ~
17434  a,_tail
17435 \newline
17436 \InsetSpace ~
17437 \InsetSpace ~
17438 \InsetSpace ~
17439 \InsetSpace ~
17440 \InsetSpace ~
17441 \InsetSpace ~
17442 \InsetSpace ~
17443 \InsetSpace ~
17444 dec\InsetSpace ~
17445  a
17446 \newline
17447 \InsetSpace ~
17448 \InsetSpace ~
17449 \InsetSpace ~
17450 \InsetSpace ~
17451 \InsetSpace ~
17452 \InsetSpace ~
17453 \InsetSpace ~
17454 \InsetSpace ~
17455 xrl\InsetSpace ~
17456  a,_head
17457 \newline
17458 \InsetSpace ~
17459 \InsetSpace ~
17460 \InsetSpace ~
17461 \InsetSpace ~
17462 \InsetSpace ~
17463 \InsetSpace ~
17464 \InsetSpace ~
17465 \InsetSpace ~
17466 ; we
17467  could do an ANL a,#0x0f here to use a smaller buffer (see below)
17468 \newline
17469 \InsetSpace ~
17470 \InsetSpace ~
17471 \InsetSpace ~
17472 \InsetSpace ~
17473 \InsetSpace ~
17474 \InsetSpace ~
17475 \InsetSpace ~
17476 \InsetSpace ~
17477 jz\InsetSpace ~
17478 \InsetSpace ~
17479  t_b_end$
17480 \newline
17481 \InsetSpace ~
17482 \InsetSpace ~
17483 \InsetSpace ~
17484 \InsetSpace ~
17485 \InsetSpace ~
17486 \InsetSpace ~
17487 \InsetSpace ~
17488 \InsetSpace ~
17489 ;
17490 \newline
17491 ;
17492  buf[ head++ ] = c;
17493 \newline
17494 \InsetSpace ~
17495 \InsetSpace ~
17496 \InsetSpace ~
17497 \InsetSpace ~
17498 \InsetSpace ~
17499 \InsetSpace ~
17500 \InsetSpace ~
17501 \InsetSpace ~
17502 mov\InsetSpace ~
17503  a,dpl \InsetSpace ~
17504 \InsetSpace ~
17505 \InsetSpace ~
17506 \InsetSpace ~
17507 \InsetSpace ~
17508 \InsetSpace ~
17509 \InsetSpace ~
17510 ; dpl holds lower byte of function argument
17511 \newline
17512 \InsetSpace ~
17513 \InsetSpace ~
17514 \InsetSpace ~
17515 \InsetSpace ~
17516 \InsetSpace ~
17517 \InsetSpace ~
17518 \InsetSpace ~
17519 \InsetSpace ~
17520 mov\InsetSpace ~
17521
17522  dpl,_head \InsetSpace ~
17523 \InsetSpace ~
17524 \InsetSpace ~
17525 ; buf is 0x100 byte aligned so head can be used directly
17526 \newline
17527 \InsetSpace ~
17528 \InsetSpace ~
17529 \InsetSpace ~
17530 \InsetSpace ~
17531 \InsetSpace ~
17532 \InsetSpace ~
17533 \InsetSpace ~
17534 \InsetSpace ~
17535 mov\InsetSpace ~
17536  dph,#(_bu
17537 f>>8)
17538 \newline
17539 \InsetSpace ~
17540 \InsetSpace ~
17541 \InsetSpace ~
17542 \InsetSpace ~
17543 \InsetSpace ~
17544 \InsetSpace ~
17545 \InsetSpace ~
17546 \InsetSpace ~
17547 movx @dptr,a
17548 \newline
17549 \InsetSpace ~
17550 \InsetSpace ~
17551 \InsetSpace ~
17552 \InsetSpace ~
17553 \InsetSpace ~
17554 \InsetSpace ~
17555 \InsetSpace ~
17556 \InsetSpace ~
17557 inc \InsetSpace ~
17558 _head
17559 \newline
17560 \InsetSpace ~
17561 \InsetSpace ~
17562 \InsetSpace ~
17563 \InsetSpace ~
17564 \InsetSpace ~
17565 \InsetSpace ~
17566 \InsetSpace ~
17567 \InsetSpace ~
17568 ; we could do an ANL _head,#0x0f here to use a
17569  smaller buffer (see above)
17570 \newline
17571 t_b_end$:
17572 \newline
17573 \InsetSpace ~
17574 \InsetSpace ~
17575 \InsetSpace ~
17576 \InsetSpace ~
17577 \InsetSpace ~
17578 \InsetSpace ~
17579 \InsetSpace ~
17580 \InsetSpace ~
17581 ; restore used registers here 
17582 \newline
17583 \InsetSpace ~
17584 \InsetSpace ~
17585 \InsetSpace ~
17586 \InsetSpace ~
17587 _endasm
17588 \begin_inset LatexCommand \index{\_endasm}
17589
17590 \end_inset
17591
17592
17593 \begin_inset LatexCommand \index{\_\_endasm}
17594
17595 \end_inset
17596
17597 ;
17598 \newline
17599 }
17600 \newline
17601 #endif
17602 \end_layout
17603
17604 \begin_layout Standard
17605 The inline assembler code can contain any valid code understood by the assembler
17606 , this includes any assembler directives and comment lines.
17607  The assembler does not like some characters like ':' or ''' in comments.
17608  You'll find an 100+ pages assembler manual in sdcc/as/doc/asxhtm.html
17609 \begin_inset LatexCommand \index{asXXXX (as-gbz80, as-hc08, asx8051, as-z80)}
17610
17611 \end_inset
17612
17613
17614 \begin_inset LatexCommand \index{Assembler documentation}
17615
17616 \end_inset
17617
17618  or online at 
17619 \begin_inset LatexCommand \url{http://sdcc.svn.sourceforge.net/viewvc/*checkout*/sdcc/trunk/sdcc/as/doc/asxhtm.html}
17620
17621 \end_inset
17622
17623 \InsetSpace ~
17624 .
17625 \end_layout
17626
17627 \begin_layout Standard
17628 The compiler does not do any validation of the code within the 
17629 \family typewriter
17630 _asm
17631 \begin_inset LatexCommand \index{\_asm}
17632
17633 \end_inset
17634
17635
17636 \begin_inset LatexCommand \index{\_\_asm}
17637
17638 \end_inset
17639
17640  ...
17641  _endasm
17642 \size footnotesize
17643
17644 \begin_inset LatexCommand \index{\_endasm}
17645
17646 \end_inset
17647
17648
17649 \begin_inset LatexCommand \index{\_\_endasm}
17650
17651 \end_inset
17652
17653
17654 \size default
17655 ;
17656 \family default
17657  keyword pair.
17658  Specifically it will not know which registers are used and thus register
17659  pushing/popping
17660 \begin_inset LatexCommand \index{push/pop}
17661
17662 \end_inset
17663
17664  has to be done manually.
17665  
17666 \end_layout
17667
17668 \begin_layout Standard
17669 It is recommended that each assembly instruction (including labels) be placed
17670  in a separate line (as the example shows).
17671  When the -
17672 \begin_inset ERT
17673 status collapsed
17674
17675 \begin_layout Standard
17676
17677
17678 \backslash
17679 /
17680 \end_layout
17681
17682 \end_inset
17683
17684 -
17685 \emph on
17686 peep-asm
17687 \begin_inset LatexCommand \index{-\/-peep-asm}
17688
17689 \end_inset
17690
17691
17692 \emph default
17693  command line option is used, the inline assembler code will be passed through
17694  the peephole optimizer
17695 \begin_inset LatexCommand \index{Peephole optimizer}
17696
17697 \end_inset
17698
17699 .
17700  There are only a few (if any) cases where this option makes sense, it might
17701  cause some unexpected changes in the inline assembler code.
17702  Please go through the peephole optimizer rules defined in file 
17703 \emph on
17704 SDCCpeeph.def
17705 \emph default
17706  before using this option.
17707 \end_layout
17708
17709 \begin_layout Subsection
17710 Naked Functions
17711 \begin_inset LatexCommand \label{sub:Naked-Functions}
17712
17713 \end_inset
17714
17715
17716 \begin_inset LatexCommand \index{Naked functions}
17717
17718 \end_inset
17719
17720
17721 \end_layout
17722
17723 \begin_layout Standard
17724 A special keyword may be associated with a function declaring it as 
17725 \emph on
17726 _naked
17727 \begin_inset LatexCommand \index{\_naked}
17728
17729 \end_inset
17730
17731
17732 \begin_inset LatexCommand \index{\_\_naked}
17733
17734 \end_inset
17735
17736 .
17737  
17738 \emph default
17739 The 
17740 \emph on
17741 _naked
17742 \emph default
17743  function modifier attribute prevents the compiler from generating prologue
17744 \begin_inset LatexCommand \index{function prologue}
17745
17746 \end_inset
17747
17748  and epilogue
17749 \begin_inset LatexCommand \index{function epilogue}
17750
17751 \end_inset
17752
17753  code for that function.
17754  This means that the user is entirely responsible for such things as saving
17755  any registers that may need to be preserved, selecting the proper register
17756  bank, generating the 
17757 \emph on
17758 return
17759 \emph default
17760  instruction at the end, etc.
17761  Practically, this means that the contents of the function must be written
17762  in inline assembler.
17763  This is particularly useful for interrupt functions, which can have a large
17764  (and often unnecessary) prologue/epilogue.
17765  For example, compare the code generated by these two functions:
17766 \end_layout
17767
17768 \begin_layout Verse
17769
17770 \family typewriter
17771 volatile
17772 \begin_inset LatexCommand \index{volatile}
17773
17774 \end_inset
17775
17776  data unsigned char counter;
17777 \newline
17778
17779 \newline
17780 void simpleInterrupt(void) __interrupt
17781 \begin_inset LatexCommand \index{interrupt}
17782
17783 \end_inset
17784
17785
17786 \begin_inset LatexCommand \index{\_\_interrupt}
17787
17788 \end_inset
17789
17790  (1)
17791 \newline
17792 {
17793 \newline
17794 \InsetSpace ~
17795 \InsetSpace ~
17796 \InsetSpace ~
17797 \InsetSpace ~
17798 counter++;
17799 \newline
17800 }
17801 \newline
17802
17803 \newline
17804 void nakedInterrupt(void) __interrupt (2) __naked
17805 \newline
17806 {
17807 \newline
17808 \InsetSpace ~
17809 \InsetSpace ~
17810 \InsetSpace ~
17811 \InsetSpace ~
17812 _asm
17813 \begin_inset LatexCommand \index{\_asm}
17814
17815 \end_inset
17816
17817
17818 \begin_inset LatexCommand \index{\_\_asm}
17819
17820 \end_inset
17821
17822
17823 \newline
17824 \InsetSpace ~
17825 \InsetSpace ~
17826 \InsetSpace ~
17827 \InsetSpace ~
17828 \InsetSpace ~
17829 \InsetSpace ~
17830 inc\InsetSpace ~
17831 \InsetSpace ~
17832 \InsetSpace ~
17833 \InsetSpace ~
17834 \InsetSpace ~
17835 _counter ; does not change flags, no need to save psw
17836 \newline
17837 \InsetSpace ~
17838 \InsetSpace ~
17839 \InsetSpace ~
17840 \InsetSpace ~
17841 \InsetSpace ~
17842 \InsetSpace ~
17843 reti\InsetSpace ~
17844 \InsetSpace ~
17845 \InsetSpace ~
17846 \InsetSpace ~
17847 ; MUST explicitly
17848  include ret or reti in _naked function.
17849 \newline
17850 \InsetSpace ~
17851 \InsetSpace ~
17852 \InsetSpace ~
17853 \InsetSpace ~
17854 _endasm
17855 \begin_inset LatexCommand \index{\_endasm}
17856
17857 \end_inset
17858
17859
17860 \begin_inset LatexCommand \index{\_\_endasm}
17861
17862 \end_inset
17863
17864 ;
17865 \newline
17866 }
17867 \end_layout
17868
17869 \begin_layout Standard
17870 For an 8051 target, the generated simpleInterrupt looks like:
17871 \end_layout
17872
17873 \begin_layout Verse
17874
17875 \family typewriter
17876 Note, this is an 
17877 \emph on
17878 outdated
17879 \emph default
17880  example, recent versions of SDCC generate
17881 \newline
17882 the 
17883 \emph on
17884 same
17885 \emph default
17886  code for simpleInterrupt() and nakedInterrupt()!
17887 \newline
17888
17889 \newline
17890 _simpleInterrupt:
17891 \newline
17892 \InsetSpace ~
17893 \InsetSpace ~
17894 \InsetSpace ~
17895 \InsetSpace ~
17896 push\InsetSpace ~
17897 \InsetSpace ~
17898 \InsetSpace ~
17899 \InsetSpace ~
17900 acc
17901 \newline
17902 \InsetSpace ~
17903 \InsetSpace ~
17904 \InsetSpace ~
17905 \InsetSpace ~
17906 push\InsetSpace ~
17907 \InsetSpace ~
17908 \InsetSpace ~
17909 \InsetSpace ~
17910 b
17911 \newline
17912 \InsetSpace ~
17913 \InsetSpace ~
17914 \InsetSpace ~
17915 \InsetSpace ~
17916 pu
17917 sh\InsetSpace ~
17918 \InsetSpace ~
17919 \InsetSpace ~
17920 \InsetSpace ~
17921 dpl
17922 \newline
17923 \InsetSpace ~
17924 \InsetSpace ~
17925 \InsetSpace ~
17926 \InsetSpace ~
17927 push\InsetSpace ~
17928 \InsetSpace ~
17929 \InsetSpace ~
17930 \InsetSpace ~
17931 dph
17932 \newline
17933 \InsetSpace ~
17934 \InsetSpace ~
17935 \InsetSpace ~
17936 \InsetSpace ~
17937 push\InsetSpace ~
17938 \InsetSpace ~
17939 \InsetSpace ~
17940 \InsetSpace ~
17941 psw
17942 \newline
17943 \InsetSpace ~
17944 \InsetSpace ~
17945 \InsetSpace ~
17946 \InsetSpace ~
17947 mov\InsetSpace ~
17948 \InsetSpace ~
17949 \InsetSpace ~
17950 \InsetSpace ~
17951 \InsetSpace ~
17952 psw,#0x00
17953 \newline
17954 \InsetSpace ~
17955 \InsetSpace ~
17956 \InsetSpace ~
17957 \InsetSpace ~
17958 inc\InsetSpace ~
17959 \InsetSpace ~
17960 \InsetSpace ~
17961 \InsetSpace ~
17962 \InsetSpace ~
17963 _counter
17964 \newline
17965 \InsetSpace ~
17966 \InsetSpace ~
17967 \InsetSpace ~
17968 \InsetSpace ~
17969 pop\InsetSpace ~
17970 \InsetSpace ~
17971 \InsetSpace ~
17972 \InsetSpace ~
17973 \InsetSpace ~
17974 psw
17975 \newline
17976 \InsetSpace ~
17977 \InsetSpace ~
17978 \InsetSpace ~
17979 \InsetSpace ~
17980 pop\InsetSpace ~
17981 \InsetSpace ~
17982 \InsetSpace ~
17983 \InsetSpace ~
17984 \InsetSpace ~
17985 dph
17986 \newline
17987 \InsetSpace ~
17988 \InsetSpace ~
17989 \InsetSpace ~
17990 \InsetSpace ~
17991 pop\InsetSpace ~
17992 \InsetSpace ~
17993 \InsetSpace ~
17994 \InsetSpace ~
17995 \InsetSpace ~
17996 dpl
17997 \newline
17998 \InsetSpace ~
17999 \InsetSpace ~
18000 \InsetSpace ~
18001 \InsetSpace ~
18002 pop\InsetSpace ~
18003 \InsetSpace ~
18004 \InsetSpace ~
18005 \InsetSpace ~
18006 \InsetSpace ~
18007 b
18008 \newline
18009 \InsetSpace ~
18010 \InsetSpace ~
18011 \InsetSpace ~
18012 \InsetSpace ~
18013 pop\InsetSpace ~
18014 \InsetSpace ~
18015 \InsetSpace ~
18016 \InsetSpace ~
18017 \InsetSpace ~
18018 acc
18019 \newline
18020 \InsetSpace ~
18021 \InsetSpace ~
18022 \InsetSpace ~
18023 \InsetSpace ~
18024 reti
18025 \end_layout
18026
18027 \begin_layout Standard
18028 whereas nakedInterrupt looks like:
18029 \end_layout
18030
18031 \begin_layout Verse
18032
18033 \family typewriter
18034 _nakedInterrupt:
18035 \newline
18036 \InsetSpace ~
18037 \InsetSpace ~
18038 \InsetSpace ~
18039 \InsetSpace ~
18040 inc\InsetSpace ~
18041 \InsetSpace ~
18042 \InsetSpace ~
18043 \InsetSpace ~
18044 _counter ; does not change flags, no need to save psw
18045 \newline
18046 \InsetSpace ~
18047 \InsetSpace ~
18048 \InsetSpace ~
18049 \InsetSpace ~
18050 reti\InsetSpace ~
18051 \InsetSpace ~
18052 \InsetSpace ~
18053 \InsetSpace ~
18054 \InsetSpace ~
18055 \InsetSpace ~
18056 \InsetSpace ~
18057 \InsetSpace ~
18058 \InsetSpace ~
18059 \InsetSpace ~
18060 \InsetSpace ~
18061 \InsetSpace ~
18062 ;
18063  MUST explicitly include ret or reti in _naked function
18064 \end_layout
18065
18066 \begin_layout Standard
18067 The related directive #pragma exclude
18068 \begin_inset LatexCommand \index{\#pragma exclude}
18069
18070 \end_inset
18071
18072  allows a more fine grained control over pushing & popping
18073 \begin_inset LatexCommand \index{push/pop}
18074
18075 \end_inset
18076
18077  the registers.
18078 \end_layout
18079
18080 \begin_layout Standard
18081 While there is nothing preventing you from writing C code inside a 
18082 \family typewriter
18083 _naked
18084 \family default
18085  function, there are many ways to shoot yourself in the foot doing this,
18086  and it is recommended that you stick to inline assembler.
18087 \end_layout
18088
18089 \begin_layout Subsection
18090 Use of Labels within Inline Assembler
18091 \end_layout
18092
18093 \begin_layout Standard
18094 SDCC allows the use of in-line assembler with a few restrictions regarding
18095  labels.
18096  All labels defined within inline assembler code have to be of the form
18097  
18098 \emph on
18099 nnnnn$
18100 \emph default
18101  where nnnnn is a number less than 100 (which implies a limit of utmost
18102  100 inline assembler labels 
18103 \emph on
18104 per function
18105 \emph default
18106 \noun on
18107 )
18108 \noun default
18109 .
18110 \begin_inset Foot
18111 status open
18112
18113 \begin_layout Standard
18114 This is a slightly more stringent rule than absolutely necessary, but stays
18115  always on the safe side.
18116  Labels in the form of nnnnn$ are local labels in the assembler, locality
18117  of which is confined within two labels of the standard form.
18118  The compiler uses the same form for labels within a function (but starting
18119  from nnnnn=00100); and places always a standard label at the beginning
18120  of a function, thus limiting the locality of labels within the scope of
18121  the function.
18122  So, if the inline assembler part would be embedded into C-code, an improperly
18123  placed non-local label in the assembler would break up the reference space
18124  for labels created by the compiler for the C-code, leading to an assembling
18125  error.
18126 \end_layout
18127
18128 \begin_layout Standard
18129 The numeric part of local labels does not need to have 5 digits (although
18130  this is the form of labels output by the compiler), any valid integer will
18131  do.
18132  Please refer to the assemblers documentation for further details.
18133 \end_layout
18134
18135 \end_inset
18136
18137  
18138 \end_layout
18139
18140 \begin_layout Verse
18141
18142 \family typewriter
18143 _asm
18144 \begin_inset LatexCommand \index{\_asm}
18145
18146 \end_inset
18147
18148
18149 \begin_inset LatexCommand \index{\_\_asm}
18150
18151 \end_inset
18152
18153  
18154 \newline
18155 \InsetSpace ~
18156 \InsetSpace ~
18157 \InsetSpace ~
18158 \InsetSpace ~
18159 mov\InsetSpace ~
18160 \InsetSpace ~
18161 \InsetSpace ~
18162 \InsetSpace ~
18163 \InsetSpace ~
18164 b,#10 
18165 \newline
18166 00001$: 
18167 \newline
18168 \InsetSpace ~
18169 \InsetSpace ~
18170 \InsetSpace ~
18171 \InsetSpace ~
18172 djnz\InsetSpace ~
18173 \InsetSpace ~
18174 \InsetSpace ~
18175 \InsetSpace ~
18176 b,00001$ 
18177 \newline
18178 _endasm
18179 \begin_inset LatexCommand \index{\_endasm}
18180
18181 \end_inset
18182
18183
18184 \begin_inset LatexCommand \index{\_\_endasm}
18185
18186 \end_inset
18187
18188  ;
18189 \end_layout
18190
18191 \begin_layout Standard
18192 Inline assembler code cannot reference any C-labels, however it can reference
18193  labels
18194 \begin_inset LatexCommand \index{Labels}
18195
18196 \end_inset
18197
18198  defined by the inline assembler, e.g.:
18199 \end_layout
18200
18201 \begin_layout Verse
18202
18203 \family typewriter
18204 foo() { 
18205 \newline
18206 \InsetSpace ~
18207 \InsetSpace ~
18208 \InsetSpace ~
18209 \InsetSpace ~
18210 /* some c code */ 
18211 \newline
18212 \InsetSpace ~
18213 \InsetSpace ~
18214 \InsetSpace ~
18215 \InsetSpace ~
18216 _asm 
18217 \newline
18218 \InsetSpace ~
18219 \InsetSpace ~
18220 \InsetSpace ~
18221 \InsetSpace ~
18222 \InsetSpace ~
18223 \InsetSpace ~
18224 ; some assembler code 
18225 \newline
18226 \InsetSpace ~
18227 \InsetSpace ~
18228 \InsetSpace ~
18229 \InsetSpace ~
18230 \InsetSpace ~
18231 \InsetSpace ~
18232 ljmp 0003$ 
18233 \newline
18234 \InsetSpace ~
18235 \InsetSpace ~
18236 \InsetSpace ~
18237 \InsetSpace ~
18238 _endasm;
18239  
18240 \newline
18241 \InsetSpace ~
18242 \InsetSpace ~
18243 \InsetSpace ~
18244 \InsetSpace ~
18245 /* some more c code */ 
18246 \newline
18247 clabel:\InsetSpace ~
18248 \InsetSpace ~
18249 /* inline assembler cannot reference this
18250  label */ 
18251 \begin_inset Foot
18252 status open
18253
18254 \begin_layout Standard
18255 Here, the C-label 
18256 \family typewriter
18257 clabel
18258 \family default
18259  is translated by the compiler into a local label, so the locality of labels
18260  within the function is not broken.
18261 \end_layout
18262
18263 \end_inset
18264
18265
18266 \newline
18267 \InsetSpace ~
18268 \InsetSpace ~
18269 \InsetSpace ~
18270 \InsetSpace ~
18271 _asm
18272 \newline
18273 \InsetSpace ~
18274 \InsetSpace ~
18275 \InsetSpace ~
18276 \InsetSpace ~
18277 0003$: ;label (can be referenced by inline assembler only) 
18278 \newline
18279 \InsetSpace ~
18280 \InsetSpace ~
18281 \InsetSpace ~
18282 \InsetSpace ~
18283 _endasm
18284 \begin_inset LatexCommand \index{\_endasm}
18285
18286 \end_inset
18287
18288
18289 \begin_inset LatexCommand \index{\_\_endasm}
18290
18291 \end_inset
18292
18293  ; 
18294 \newline
18295 \InsetSpace ~
18296 \InsetSpace ~
18297 \InsetSpace ~
18298 \InsetSpace ~
18299 /* some more c code */
18300 \newline
18301 }
18302 \end_layout
18303
18304 \begin_layout Standard
18305 In other words inline assembly code can access labels defined in inline
18306  assembly within the scope of the function.
18307  The same goes the other way, i.e.
18308  labels defines in inline assembly can not be accessed by C statements.
18309 \end_layout
18310
18311 \begin_layout Section
18312 Interfacing with Assembler Code
18313 \begin_inset LatexCommand \index{Assembler routines}
18314
18315 \end_inset
18316
18317
18318 \end_layout
18319
18320 \begin_layout Subsection
18321 Global Registers used for Parameter Passing
18322 \begin_inset LatexCommand \index{Parameter passing}
18323
18324 \end_inset
18325
18326
18327 \end_layout
18328
18329 \begin_layout Standard
18330 The compiler always uses the global registers 
18331 \emph on
18332 DPL, DPH
18333 \begin_inset LatexCommand \index{DPTR, DPH, DPL}
18334
18335 \end_inset
18336
18337
18338 \begin_inset LatexCommand \index{DPTR}
18339
18340 \end_inset
18341
18342 , B
18343 \begin_inset LatexCommand \index{B (mcs51, ds390 register)}
18344
18345 \end_inset
18346
18347  
18348 \emph default
18349 and
18350 \emph on
18351  ACC
18352 \begin_inset LatexCommand \index{ACC (mcs51, ds390 register)}
18353
18354 \end_inset
18355
18356
18357 \emph default
18358  to pass the first (non-bit) parameter to a function, and also to pass the
18359  return value 
18360 \begin_inset LatexCommand \index{return value}
18361
18362 \end_inset
18363
18364 of function; according to the following scheme: one byte return value in
18365  
18366 \emph on
18367 DPL
18368 \emph default
18369 , two byte value in 
18370 \emph on
18371 DPL
18372 \emph default
18373  (LSB) and 
18374 \emph on
18375 DPH
18376 \emph default
18377  (MSB).
18378  three byte values (generic pointers) in 
18379 \emph on
18380 DPH
18381 \emph default
18382
18383 \emph on
18384 DPL
18385 \emph default
18386  and 
18387 \emph on
18388 B
18389 \emph default
18390 , and four byte values in 
18391 \emph on
18392 DPH
18393 \emph default
18394
18395 \emph on
18396 DPL
18397 \emph default
18398 ,
18399 \emph on
18400  B
18401 \emph default
18402  and 
18403 \emph on
18404 ACC
18405 \emph default
18406 .
18407  Generic pointers
18408 \begin_inset LatexCommand \index{generic pointer}
18409
18410 \end_inset
18411
18412  contain type of accessed memory in 
18413 \emph on
18414 B
18415 \emph default
18416
18417 \series bold
18418 0x00
18419 \series default
18420  -- xdata/far, 
18421 \series bold
18422 0x40
18423 \series default
18424  -- idata/near -- , 
18425 \series bold
18426 0x60
18427 \series default
18428  -- pdata, 
18429 \series bold
18430 0x80
18431 \series default
18432  -- code
18433 \begin_inset Note Note
18434 status collapsed
18435
18436 \begin_layout Standard
18437 This might not be the case of certain memory models (medium???)
18438 \end_layout
18439
18440 \end_inset
18441
18442 .
18443 \end_layout
18444
18445 \begin_layout Standard
18446 The second parameter onwards is either allocated on the stack (for reentrant
18447  routines or if -
18448 \begin_inset ERT
18449 status collapsed
18450
18451 \begin_layout Standard
18452
18453
18454 \backslash
18455 /
18456 \end_layout
18457
18458 \end_inset
18459
18460 -stack-auto is used) or in data/xdata memory (depending on the memory model).
18461 \end_layout
18462
18463 \begin_layout Standard
18464 Bit parameters are passed in a virtual register called 'bits' in bit-addressable
18465  space for reentrant functions or allocated directly in bit memory otherwise.
18466 \end_layout
18467
18468 \begin_layout Standard
18469 Functions (with two or more parameters or bit parameters) that are called
18470  through function pointers
18471 \begin_inset LatexCommand \index{function pointers}
18472
18473 \end_inset
18474
18475  must therefor be reentrant so the compiler knows how to pass the parameters.
18476 \end_layout
18477
18478 \begin_layout Subsection
18479 Registers usage
18480 \end_layout
18481
18482 \begin_layout Standard
18483 Unless the called function is declared as 
18484 \family typewriter
18485 _naked
18486 \family default
18487
18488 \begin_inset LatexCommand \index{naked}
18489
18490 \end_inset
18491
18492 , or the -
18493 \begin_inset ERT
18494 status collapsed
18495
18496 \begin_layout Standard
18497
18498
18499 \backslash
18500 /
18501 \end_layout
18502
18503 \end_inset
18504
18505 -callee-saves
18506 \begin_inset LatexCommand \index{-\/-callee-saves}
18507
18508 \end_inset
18509
18510 /-
18511 \begin_inset ERT
18512 status collapsed
18513
18514 \begin_layout Standard
18515
18516
18517 \backslash
18518 /
18519 \end_layout
18520
18521 \end_inset
18522
18523 -all-callee-saves command line option or the corresponding callee_saves
18524  pragma are used, the caller will save the registers (
18525 \emph on
18526 R0-R7
18527 \emph default
18528 ) around the call, so the called function can destroy they content freely.
18529 \end_layout
18530
18531 \begin_layout Standard
18532 If the called function is not declared as 
18533 \family typewriter
18534 _naked
18535 \family default
18536 , the caller will swap register banks around the call, if caller and callee
18537  use different register banks (having them defined by the 
18538 \family typewriter
18539 _using
18540 \family default
18541  modifier).
18542  
18543 \end_layout
18544
18545 \begin_layout Standard
18546 The called function can also use 
18547 \emph on
18548 DPL
18549 \emph default
18550
18551 \emph on
18552 DPH
18553 \emph default
18554
18555 \emph on
18556 B
18557 \emph default
18558  and 
18559 \emph on
18560 ACC
18561 \emph default
18562  observing that they are used for parameter/return value passing.
18563 \end_layout
18564
18565 \begin_layout Subsection
18566 Assembler Routine (non-reentrant)
18567 \end_layout
18568
18569 \begin_layout Standard
18570 In the following example
18571 \begin_inset LatexCommand \index{reentrant}
18572
18573 \end_inset
18574
18575
18576 \begin_inset LatexCommand \index{Assembler routines (non-reentrant)}
18577
18578 \end_inset
18579
18580  the function c_func calls an assembler routine asm_func, which takes two
18581  parameters
18582 \begin_inset LatexCommand \index{function parameter}
18583
18584 \end_inset
18585
18586 .
18587 \end_layout
18588
18589 \begin_layout Verse
18590
18591 \family typewriter
18592 extern int asm_func(unsigned char, unsigned char);
18593 \newline
18594
18595 \newline
18596 int c_func (unsigned char
18597  i, unsigned char j)
18598 \newline
18599 {
18600 \newline
18601 \InsetSpace ~
18602 \InsetSpace ~
18603 \InsetSpace ~
18604 \InsetSpace ~
18605 return asm_func(i,j);
18606 \newline
18607 }
18608 \newline
18609
18610 \newline
18611 int main()
18612 \newline
18613 {
18614 \newline
18615 \InsetSpace ~
18616 \InsetSpace ~
18617 \InsetSpace ~
18618 \InsetSpace ~
18619 return c_func(10,9);
18620 \newline
18621 }
18622 \end_layout
18623
18624 \begin_layout Standard
18625 The corresponding assembler function is:
18626 \end_layout
18627
18628 \begin_layout Verse
18629
18630 \family typewriter
18631 .globl _asm_func_PARM_2 
18632 \newline
18633 \InsetSpace ~
18634 \InsetSpace ~
18635 \InsetSpace ~
18636 \InsetSpace ~
18637 \InsetSpace ~
18638 \InsetSpace ~
18639 \InsetSpace ~
18640 \InsetSpace ~
18641 .globl _asm_func 
18642 \newline
18643 \InsetSpace ~
18644 \InsetSpace ~
18645 \InsetSpace ~
18646 \InsetSpace ~
18647 \InsetSpace ~
18648 \InsetSpace ~
18649 \InsetSpace ~
18650 \InsetSpace ~
18651 .area OSEG 
18652 \newline
18653 _asm_func_PARM_2:
18654 \newline
18655 \InsetSpace ~
18656 \InsetSpace ~
18657 \InsetSpace ~
18658 \InsetSpace ~
18659 \InsetSpace ~
18660 \InsetSpace ~
18661 \InsetSpace ~
18662 \InsetSpace ~
18663 .ds   
18664  1 
18665 \newline
18666 \InsetSpace ~
18667 \InsetSpace ~
18668 \InsetSpace ~
18669 \InsetSpace ~
18670 \InsetSpace ~
18671 \InsetSpace ~
18672 \InsetSpace ~
18673 \InsetSpace ~
18674 .area CSEG 
18675 \newline
18676 _asm_func: 
18677 \newline
18678 \InsetSpace ~
18679 \InsetSpace ~
18680 \InsetSpace ~
18681 \InsetSpace ~
18682 \InsetSpace ~
18683 \InsetSpace ~
18684 \InsetSpace ~
18685 \InsetSpace ~
18686 mov\InsetSpace ~
18687 \InsetSpace ~
18688 \InsetSpace ~
18689 \InsetSpace ~
18690 a,dpl 
18691 \newline
18692 \InsetSpace ~
18693 \InsetSpace ~
18694 \InsetSpace ~
18695 \InsetSpace ~
18696 \InsetSpace ~
18697 \InsetSpace ~
18698 \InsetSpace ~
18699 \InsetSpace ~
18700 add\InsetSpace ~
18701 \InsetSpace ~
18702 \InsetSpace ~
18703 \InsetSpace ~
18704 a,_asm_func_PARM_2 
18705 \newline
18706 \InsetSpace ~
18707 \InsetSpace ~
18708 \InsetSpace ~
18709 \InsetSpace ~
18710 \InsetSpace ~
18711 \InsetSpace ~
18712 \InsetSpace ~
18713 \InsetSpace ~
18714 mov\InsetSpace ~
18715 \InsetSpace ~
18716 \InsetSpace ~
18717 \InsetSpace ~
18718 dpl,a 
18719 \newline
18720 \InsetSpace ~
18721 \InsetSpace ~
18722 \InsetSpace ~
18723 \InsetSpace ~
18724 \InsetSpace ~
18725 \InsetSpace ~
18726 \InsetSpace ~
18727 \InsetSpace ~
18728 mov\InsetSpace ~
18729 \InsetSpace ~
18730 \InsetSpace ~
18731 \InsetSpace ~
18732 dph
18733 \begin_inset LatexCommand \index{DPTR, DPH, DPL}
18734
18735 \end_inset
18736
18737 ,#0x00 
18738 \newline
18739 \InsetSpace ~
18740 \InsetSpace ~
18741 \InsetSpace ~
18742 \InsetSpace ~
18743 \InsetSpace ~
18744 \InsetSpace ~
18745 \InsetSpace ~
18746 \InsetSpace ~
18747 ret
18748 \end_layout
18749
18750 \begin_layout Standard
18751 The parameter naming convention is _<function_name>_PARM_<n>, where n is
18752  the parameter number starting from 1, and counting from the left.
18753  The first parameter is passed in 
18754 \emph on
18755 DPH
18756 \emph default
18757
18758 \emph on
18759 DPL
18760 \emph default
18761
18762 \emph on
18763 B
18764 \emph default
18765  and 
18766 \emph on
18767 ACC
18768 \emph default
18769  according to the description above.
18770  The variable name for the second parameter will be _<function_name>_PARM_2.
18771 \newline
18772
18773 \newline
18774 Assem
18775 ble the assembler routine with the following command:
18776 \newline
18777
18778 \newline
18779
18780 \family sans
18781 \series bold
18782 asx8051 -losg asmfunc.asm
18783 \newline
18784
18785 \newline
18786
18787 \family default
18788 \series default
18789 Then compile and link the assembler routine to the C source file with the
18790  following command:
18791 \newline
18792
18793 \newline
18794
18795 \family sans
18796 \series bold
18797 sdcc cfunc.c asmfunc.rel
18798 \end_layout
18799
18800 \begin_layout Subsection
18801 Assembler Routine (reentrant)
18802 \end_layout
18803
18804 \begin_layout Standard
18805 In this case
18806 \begin_inset LatexCommand \index{reentrant}
18807
18808 \end_inset
18809
18810
18811 \begin_inset LatexCommand \index{Assembler routines (reentrant)}
18812
18813 \end_inset
18814
18815  the second parameter
18816 \begin_inset LatexCommand \index{function parameter}
18817
18818 \end_inset
18819
18820  onwards will be passed on the stack, the parameters are pushed from right
18821  to left i.e.
18822  before the call the second leftmost parameter will be on the top of the
18823  stack (the leftmost parameter is passed in registers).
18824  Here is an example:
18825 \end_layout
18826
18827 \begin_layout Verse
18828
18829 \family typewriter
18830 extern int asm_func(unsigned char, unsigned char, unsigned char) reentrant;
18831 \newline
18832
18833 \newline
18834 int
18835  c_func (unsigned char i, unsigned char j, unsigned char k) reentrant 
18836 \newline
18837 {
18838  
18839 \newline
18840 \InsetSpace ~
18841 \InsetSpace ~
18842 \InsetSpace ~
18843 \InsetSpace ~
18844 return asm_func(i,j,k); 
18845 \newline
18846
18847 \newline
18848
18849 \newline
18850 int main() 
18851 \newline
18852
18853 \newline
18854 \InsetSpace ~
18855 \InsetSpace ~
18856 \InsetSpace ~
18857 \InsetSpace ~
18858 return c_func(10,9,8); 
18859 \newline
18860 }
18861 \end_layout
18862
18863 \begin_layout Standard
18864 The corresponding (unoptimized) assembler routine is:
18865 \end_layout
18866
18867 \begin_layout Verse
18868
18869 \family typewriter
18870 .globl _asm_func 
18871 \newline
18872 _asm_func: 
18873 \newline
18874 \InsetSpace ~
18875 \InsetSpace ~
18876 \InsetSpace ~
18877 \InsetSpace ~
18878 push\InsetSpace ~
18879 _bp 
18880 \newline
18881 \InsetSpace ~
18882 \InsetSpace ~
18883 \InsetSpace ~
18884 \InsetSpace ~
18885 mov\InsetSpace ~
18886 \InsetSpace ~
18887 _bp,sp\InsetSpace ~
18888 \InsetSpace ~
18889 \InsetSpace ~
18890 \InsetSpace ~
18891 \InsetSpace ~
18892 \InsetSpace ~
18893 ;stack contains: _bp, return
18894  address, second parameter, third parameter
18895 \newline
18896 \InsetSpace ~
18897 \InsetSpace ~
18898 \InsetSpace ~
18899 \InsetSpace ~
18900 mov\InsetSpace ~
18901 \InsetSpace ~
18902 r2,dpl
18903 \newline
18904 \InsetSpace ~
18905 \InsetSpace ~
18906 \InsetSpace ~
18907 \InsetSpace ~
18908 mov\InsetSpace ~
18909 \InsetSpace ~
18910 a,_bp
18911 \newline
18912 \InsetSpace ~
18913 \InsetSpace ~
18914 \InsetSpace ~
18915 \InsetSpace ~
18916 add\InsetSpace ~
18917 \InsetSpace ~
18918 a,#0xfd\InsetSpace ~
18919 \InsetSpace ~
18920 \InsetSpace ~
18921 \InsetSpace ~
18922 \InsetSpace ~
18923 ;calculate
18924  pointer to the second parameter
18925 \newline
18926 \InsetSpace ~
18927 \InsetSpace ~
18928 \InsetSpace ~
18929 \InsetSpace ~
18930 mov\InsetSpace ~
18931 \InsetSpace ~
18932 r0,a 
18933 \newline
18934 \InsetSpace ~
18935 \InsetSpace ~
18936 \InsetSpace ~
18937 \InsetSpace ~
18938 mov\InsetSpace ~
18939 \InsetSpace ~
18940 a,_bp 
18941 \newline
18942 \InsetSpace ~
18943 \InsetSpace ~
18944 \InsetSpace ~
18945 \InsetSpace ~
18946 add\InsetSpace ~
18947 \InsetSpace ~
18948 a,#0xfc\InsetSpace ~
18949 \InsetSpace ~
18950 \InsetSpace ~
18951 \InsetSpace ~
18952 \InsetSpace ~
18953 ;calculate pointer
18954  to the rightmost parameter
18955 \newline
18956 \InsetSpace ~
18957 \InsetSpace ~
18958 \InsetSpace ~
18959 \InsetSpace ~
18960 mov\InsetSpace ~
18961 \InsetSpace ~
18962 r1,a 
18963 \newline
18964 \InsetSpace ~
18965 \InsetSpace ~
18966 \InsetSpace ~
18967 \InsetSpace ~
18968 mov\InsetSpace ~
18969 \InsetSpace ~
18970 a,@r0
18971 \newline
18972 \InsetSpace ~
18973 \InsetSpace ~
18974 \InsetSpace ~
18975 \InsetSpace ~
18976 add\InsetSpace ~
18977 \InsetSpace ~
18978 a,@r1
18979 \newline
18980 \InsetSpace ~
18981 \InsetSpace ~
18982 \InsetSpace ~
18983 \InsetSpace ~
18984 add\InsetSpace ~
18985 \InsetSpace ~
18986 a,r2\InsetSpace ~
18987 \InsetSpace ~
18988 \InsetSpace ~
18989 \InsetSpace ~
18990 \InsetSpace ~
18991 \InsetSpace ~
18992 \InsetSpace ~
18993 \InsetSpace ~
18994 ;calculate the
18995  result (= sum of all three parameters)
18996 \newline
18997 \InsetSpace ~
18998 \InsetSpace ~
18999 \InsetSpace ~
19000 \InsetSpace ~
19001 mov\InsetSpace ~
19002 \InsetSpace ~
19003 dpl,a\InsetSpace ~
19004 \InsetSpace ~
19005 \InsetSpace ~
19006 \InsetSpace ~
19007 \InsetSpace ~
19008 \InsetSpace ~
19009 \InsetSpace ~
19010 ;return value goes into dptr
19011  (cast into int)
19012 \newline
19013 \InsetSpace ~
19014 \InsetSpace ~
19015 \InsetSpace ~
19016 \InsetSpace ~
19017 mov\InsetSpace ~
19018 \InsetSpace ~
19019 dph,#0x00 
19020 \newline
19021 \InsetSpace ~
19022 \InsetSpace ~
19023 \InsetSpace ~
19024 \InsetSpace ~
19025 mov\InsetSpace ~
19026 \InsetSpace ~
19027 sp,_bp 
19028 \newline
19029 \InsetSpace ~
19030 \InsetSpace ~
19031 \InsetSpace ~
19032 \InsetSpace ~
19033 pop\InsetSpace ~
19034 \InsetSpace ~
19035 _bp 
19036 \newline
19037 \InsetSpace ~
19038 \InsetSpace ~
19039 \InsetSpace ~
19040 \InsetSpace ~
19041 ret
19042 \end_layout
19043
19044 \begin_layout Standard
19045 The compiling and linking procedure remains the same, however note the extra
19046  entry & exit linkage required for the assembler code, _bp is the stack
19047  frame pointer and is used to compute the offset into the stack for parameters
19048  and local variables.
19049 \begin_inset VSpace bigskip
19050 \end_inset
19051
19052
19053 \end_layout
19054
19055 \begin_layout Section
19056 int (16 bit)
19057 \begin_inset LatexCommand \index{int (16 bit)}
19058
19059 \end_inset
19060
19061  and long (32 bit)
19062 \begin_inset LatexCommand \index{long (32 bit)}
19063
19064 \end_inset
19065
19066  Support
19067 \end_layout
19068
19069 \begin_layout Standard
19070 For signed & unsigned int (16 bit) and long (32 bit) variables, division,
19071  multiplication and modulus operations are implemented by support routines.
19072  These support routines are all developed in ANSI-C to facilitate porting
19073  to other MCUs, although some model specific assembler optimizations are
19074  used.
19075  The following files contain the described routines, all of them can be
19076  found in <installdir>/share/sdcc/lib.
19077 \newline
19078
19079 \end_layout
19080
19081 \begin_layout Standard
19082 \align center
19083 \begin_inset Tabular
19084 <lyxtabular version="3" rows="11" columns="2">
19085 <features>
19086 <column alignment="left" valignment="top" leftline="true" width="0">
19087 <column alignment="left" valignment="top" leftline="true" rightline="true" width="0">
19088 <row topline="true" bottomline="true">
19089 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19090 \begin_inset Text
19091
19092 \begin_layout Standard
19093
19094 \series bold
19095 Function
19096 \end_layout
19097
19098 \end_inset
19099 </cell>
19100 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19101 \begin_inset Text
19102
19103 \begin_layout Standard
19104
19105 \series bold
19106 Description
19107 \end_layout
19108
19109 \end_inset
19110 </cell>
19111 </row>
19112 <row topline="true">
19113 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19114 \begin_inset Text
19115
19116 \begin_layout Standard
19117 _mulint.c 
19118 \end_layout
19119
19120 \end_inset
19121 </cell>
19122 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19123 \begin_inset Text
19124
19125 \begin_layout Standard
19126 16 bit multiplication
19127 \end_layout
19128
19129 \end_inset
19130 </cell>
19131 </row>
19132 <row topline="true">
19133 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19134 \begin_inset Text
19135
19136 \begin_layout Standard
19137 _divsint.c 
19138 \end_layout
19139
19140 \end_inset
19141 </cell>
19142 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19143 \begin_inset Text
19144
19145 \begin_layout Standard
19146  signed 16 bit division (calls _divuint)
19147 \end_layout
19148
19149 \end_inset
19150 </cell>
19151 </row>
19152 <row topline="true">
19153 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19154 \begin_inset Text
19155
19156 \begin_layout Standard
19157 _divuint.c 
19158 \end_layout
19159
19160 \end_inset
19161 </cell>
19162 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19163 \begin_inset Text
19164
19165 \begin_layout Standard
19166  unsigned 16 bit division
19167 \end_layout
19168
19169 \end_inset
19170 </cell>
19171 </row>
19172 <row topline="true">
19173 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19174 \begin_inset Text
19175
19176 \begin_layout Standard
19177 _modsint.c
19178 \end_layout
19179
19180 \end_inset
19181 </cell>
19182 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19183 \begin_inset Text
19184
19185 \begin_layout Standard
19186 signed 16 bit modulus (calls _moduint)
19187 \end_layout
19188
19189 \end_inset
19190 </cell>
19191 </row>
19192 <row topline="true">
19193 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19194 \begin_inset Text
19195
19196 \begin_layout Standard
19197 _moduint.c
19198 \end_layout
19199
19200 \end_inset
19201 </cell>
19202 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19203 \begin_inset Text
19204
19205 \begin_layout Standard
19206 unsigned 16 bit modulus
19207 \end_layout
19208
19209 \end_inset
19210 </cell>
19211 </row>
19212 <row topline="true">
19213 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19214 \begin_inset Text
19215
19216 \begin_layout Standard
19217 _mullong.c
19218 \end_layout
19219
19220 \end_inset
19221 </cell>
19222 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19223 \begin_inset Text
19224
19225 \begin_layout Standard
19226 32 bit multiplication
19227 \end_layout
19228
19229 \end_inset
19230 </cell>
19231 </row>
19232 <row topline="true">
19233 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19234 \begin_inset Text
19235
19236 \begin_layout Standard
19237 _divslong.c 
19238 \end_layout
19239
19240 \end_inset
19241 </cell>
19242 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19243 \begin_inset Text
19244
19245 \begin_layout Standard
19246  signed 32 division (calls _divulong)
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 _divulong.c 
19258 \end_layout
19259
19260 \end_inset
19261 </cell>
19262 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19263 \begin_inset Text
19264
19265 \begin_layout Standard
19266 unsigned 32 division
19267 \end_layout
19268
19269 \end_inset
19270 </cell>
19271 </row>
19272 <row topline="true">
19273 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19274 \begin_inset Text
19275
19276 \begin_layout Standard
19277 _modslong.c
19278 \end_layout
19279
19280 \end_inset
19281 </cell>
19282 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19283 \begin_inset Text
19284
19285 \begin_layout Standard
19286  signed 32 bit modulus (calls _modulong)
19287 \end_layout
19288
19289 \end_inset
19290 </cell>
19291 </row>
19292 <row topline="true" bottomline="true">
19293 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19294 \begin_inset Text
19295
19296 \begin_layout Standard
19297 _modulong.c
19298 \end_layout
19299
19300 \end_inset
19301 </cell>
19302 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19303 \begin_inset Text
19304
19305 \begin_layout Standard
19306 unsigned 32 bit modulus
19307 \end_layout
19308
19309 \end_inset
19310 </cell>
19311 </row>
19312 </lyxtabular>
19313
19314 \end_inset
19315
19316
19317 \newline
19318
19319 \end_layout
19320
19321 \begin_layout Standard
19322 Since they are compiled as 
19323 \emph on
19324 non-reentrant
19325 \emph default
19326
19327 \begin_inset LatexCommand \index{reentrant}
19328
19329 \end_inset
19330
19331 , interrupt
19332 \begin_inset LatexCommand \index{interrupt}
19333
19334 \end_inset
19335
19336  service routines should not do any of the above operations.
19337  If this is unavoidable then the above routines will need to be compiled
19338  with the 
19339 \emph on
19340 -
19341 \begin_inset ERT
19342 status collapsed
19343
19344 \begin_layout Standard
19345
19346
19347 \backslash
19348 /
19349 \end_layout
19350
19351 \end_inset
19352
19353 -stack-auto
19354 \begin_inset LatexCommand \index{-\/-stack-auto}
19355
19356 \end_inset
19357
19358
19359 \emph default
19360  option, after which the source program will have to be compiled with 
19361 \emph on
19362 -
19363 \begin_inset ERT
19364 status collapsed
19365
19366 \begin_layout Standard
19367
19368
19369 \backslash
19370 /
19371 \end_layout
19372
19373 \end_inset
19374
19375 -int-long-reent
19376 \begin_inset LatexCommand \index{-\/-int-long-reent}
19377
19378 \end_inset
19379
19380
19381 \emph default
19382  option.
19383  Notice that you don't have to call these routines directly.
19384  The compiler will use them automatically every time an integer operation
19385  is required.
19386 \end_layout
19387
19388 \begin_layout Section
19389 Floating Point Support
19390 \begin_inset LatexCommand \index{Floating point support}
19391
19392 \end_inset
19393
19394
19395 \end_layout
19396
19397 \begin_layout Standard
19398 SDCC supports IEEE (single precision 4 bytes) floating point numbers.
19399  The floating point support routines are derived from gcc's floatlib.c and
19400  consist of the following routines:
19401 \newline
19402
19403 \end_layout
19404
19405 \begin_layout Standard
19406 \align center
19407
19408 \size footnotesize
19409 \begin_inset Tabular
19410 <lyxtabular version="3" rows="17" columns="2">
19411 <features>
19412 <column alignment="left" valignment="top" leftline="true" width="0">
19413 <column alignment="left" valignment="top" leftline="true" rightline="true" width="0">
19414 <row topline="true" bottomline="true">
19415 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19416 \begin_inset Text
19417
19418 \begin_layout Standard
19419
19420 \family roman
19421 \series medium
19422 \shape up
19423 \size normal
19424 \emph off
19425 \bar no
19426 \noun off
19427 \color none
19428 Function 
19429 \end_layout
19430
19431 \end_inset
19432 </cell>
19433 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19434 \begin_inset Text
19435
19436 \begin_layout Standard
19437 Description
19438 \end_layout
19439
19440 \end_inset
19441 </cell>
19442 </row>
19443 <row topline="true">
19444 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19445 \begin_inset Text
19446
19447 \begin_layout Standard
19448
19449 \family roman
19450 \series medium
19451 \shape up
19452 \size normal
19453 \emph off
19454 \bar no
19455 \noun off
19456 \color none
19457 _fsadd.c
19458 \end_layout
19459
19460 \end_inset
19461 </cell>
19462 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19463 \begin_inset Text
19464
19465 \begin_layout Standard
19466
19467 \family roman
19468 \series medium
19469 \shape up
19470 \size normal
19471 \emph off
19472 \bar no
19473 \noun off
19474 \color none
19475 add floating point numbers
19476 \end_layout
19477
19478 \end_inset
19479 </cell>
19480 </row>
19481 <row topline="true">
19482 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19483 \begin_inset Text
19484
19485 \begin_layout Standard
19486
19487 \family roman
19488 \series medium
19489 \shape up
19490 \size normal
19491 \emph off
19492 \bar no
19493 \noun off
19494 \color none
19495 _fssub.c 
19496 \end_layout
19497
19498 \end_inset
19499 </cell>
19500 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19501 \begin_inset Text
19502
19503 \begin_layout Standard
19504
19505 \family roman
19506 \series medium
19507 \shape up
19508 \size normal
19509 \emph off
19510 \bar no
19511 \noun off
19512 \color none
19513 subtract floating point numbers 
19514 \end_layout
19515
19516 \end_inset
19517 </cell>
19518 </row>
19519 <row topline="true">
19520 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19521 \begin_inset Text
19522
19523 \begin_layout Standard
19524
19525 \family roman
19526 \series medium
19527 \shape up
19528 \size normal
19529 \emph off
19530 \bar no
19531 \noun off
19532 \color none
19533 _fsdiv.c 
19534 \end_layout
19535
19536 \end_inset
19537 </cell>
19538 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19539 \begin_inset Text
19540
19541 \begin_layout Standard
19542
19543 \family roman
19544 \series medium
19545 \shape up
19546 \size normal
19547 \emph off
19548 \bar no
19549 \noun off
19550 \color none
19551 divide floating point numbers 
19552 \end_layout
19553
19554 \end_inset
19555 </cell>
19556 </row>
19557 <row topline="true">
19558 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19559 \begin_inset Text
19560
19561 \begin_layout Standard
19562
19563 \family roman
19564 \series medium
19565 \shape up
19566 \size normal
19567 \emph off
19568 \bar no
19569 \noun off
19570 \color none
19571 _fsmul.c 
19572 \end_layout
19573
19574 \end_inset
19575 </cell>
19576 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19577 \begin_inset Text
19578
19579 \begin_layout Standard
19580
19581 \family roman
19582 \series medium
19583 \shape up
19584 \size normal
19585 \emph off
19586 \bar no
19587 \noun off
19588 \color none
19589 multiply floating point numbers 
19590 \end_layout
19591
19592 \end_inset
19593 </cell>
19594 </row>
19595 <row topline="true">
19596 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19597 \begin_inset Text
19598
19599 \begin_layout Standard
19600
19601 \family roman
19602 \series medium
19603 \shape up
19604 \size normal
19605 \emph off
19606 \bar no
19607 \noun off
19608 \color none
19609 _fs2uchar.c
19610 \end_layout
19611
19612 \end_inset
19613 </cell>
19614 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19615 \begin_inset Text
19616
19617 \begin_layout Standard
19618
19619 \family roman
19620 \series medium
19621 \shape up
19622 \size normal
19623 \emph off
19624 \bar no
19625 \noun off
19626 \color none
19627 convert floating point to unsigned char
19628 \end_layout
19629
19630 \end_inset
19631 </cell>
19632 </row>
19633 <row topline="true">
19634 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19635 \begin_inset Text
19636
19637 \begin_layout Standard
19638
19639 \family roman
19640 \series medium
19641 \shape up
19642 \size normal
19643 \emph off
19644 \bar no
19645 \noun off
19646 \color none
19647 _fs2char.c
19648 \end_layout
19649
19650 \end_inset
19651 </cell>
19652 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19653 \begin_inset Text
19654
19655 \begin_layout Standard
19656
19657 \family roman
19658 \series medium
19659 \shape up
19660 \size normal
19661 \emph off
19662 \bar no
19663 \noun off
19664 \color none
19665 convert floating point to signed char
19666 \end_layout
19667
19668 \end_inset
19669 </cell>
19670 </row>
19671 <row topline="true">
19672 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19673 \begin_inset Text
19674
19675 \begin_layout Standard
19676
19677 \family roman
19678 \series medium
19679 \shape up
19680 \size normal
19681 \emph off
19682 \bar no
19683 \noun off
19684 \color none
19685 _fs2uint.c
19686 \end_layout
19687
19688 \end_inset
19689 </cell>
19690 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19691 \begin_inset Text
19692
19693 \begin_layout Standard
19694
19695 \family roman
19696 \series medium
19697 \shape up
19698 \size normal
19699 \emph off
19700 \bar no
19701 \noun off
19702 \color none
19703 convert floating point to unsigned int
19704 \end_layout
19705
19706 \end_inset
19707 </cell>
19708 </row>
19709 <row topline="true">
19710 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19711 \begin_inset Text
19712
19713 \begin_layout Standard
19714
19715 \family roman
19716 \series medium
19717 \shape up
19718 \size normal
19719 \emph off
19720 \bar no
19721 \noun off
19722 \color none
19723 _fs2int.c
19724 \end_layout
19725
19726 \end_inset
19727 </cell>
19728 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19729 \begin_inset Text
19730
19731 \begin_layout Standard
19732
19733 \family roman
19734 \series medium
19735 \shape up
19736 \size normal
19737 \emph off
19738 \bar no
19739 \noun off
19740 \color none
19741 convert floating point to signed int
19742 \end_layout
19743
19744 \end_inset
19745 </cell>
19746 </row>
19747 <row topline="true">
19748 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19749 \begin_inset Text
19750
19751 \begin_layout Standard
19752
19753 \family roman
19754 \series medium
19755 \shape up
19756 \size normal
19757 \emph off
19758 \bar no
19759 \noun off
19760 \color none
19761 _fs2ulong.
19762 \family default
19763 \series default
19764 \shape default
19765 \size default
19766 \emph default
19767 \bar default
19768 \noun default
19769 c
19770 \end_layout
19771
19772 \end_inset
19773 </cell>
19774 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19775 \begin_inset Text
19776
19777 \begin_layout Standard
19778
19779 \family roman
19780 \series medium
19781 \shape up
19782 \size normal
19783 \emph off
19784 \bar no
19785 \noun off
19786 \color none
19787 convert floating point to unsigned long
19788 \end_layout
19789
19790 \end_inset
19791 </cell>
19792 </row>
19793 <row topline="true">
19794 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19795 \begin_inset Text
19796
19797 \begin_layout Standard
19798
19799 \family roman
19800 \series medium
19801 \shape up
19802 \size normal
19803 \emph off
19804 \bar no
19805 \noun off
19806 \color none
19807 _fs2long.c
19808 \end_layout
19809
19810 \end_inset
19811 </cell>
19812 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19813 \begin_inset Text
19814
19815 \begin_layout Standard
19816
19817 \family roman
19818 \series medium
19819 \shape up
19820 \size normal
19821 \emph off
19822 \bar no
19823 \noun off
19824 \color none
19825 convert floating point to signed long
19826 \end_layout
19827
19828 \end_inset
19829 </cell>
19830 </row>
19831 <row topline="true">
19832 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19833 \begin_inset Text
19834
19835 \begin_layout Standard
19836
19837 \family roman
19838 \series medium
19839 \shape up
19840 \size normal
19841 \emph off
19842 \bar no
19843 \noun off
19844 \color none
19845 _uchar2fs.c
19846 \end_layout
19847
19848 \end_inset
19849 </cell>
19850 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19851 \begin_inset Text
19852
19853 \begin_layout Standard
19854
19855 \family roman
19856 \series medium
19857 \shape up
19858 \size normal
19859 \emph off
19860 \bar no
19861 \noun off
19862 \color none
19863 convert unsigned char to floating point
19864 \end_layout
19865
19866 \end_inset
19867 </cell>
19868 </row>
19869 <row topline="true">
19870 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19871 \begin_inset Text
19872
19873 \begin_layout Standard
19874
19875 \family roman
19876 \series medium
19877 \shape up
19878 \size normal
19879 \emph off
19880 \bar no
19881 \noun off
19882 \color none
19883 _char2fs.c
19884 \end_layout
19885
19886 \end_inset
19887 </cell>
19888 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19889 \begin_inset Text
19890
19891 \begin_layout Standard
19892
19893 \family roman
19894 \series medium
19895 \shape up
19896 \size normal
19897 \emph off
19898 \bar no
19899 \noun off
19900 \color none
19901 convert char to floating point number
19902 \end_layout
19903
19904 \end_inset
19905 </cell>
19906 </row>
19907 <row topline="true">
19908 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19909 \begin_inset Text
19910
19911 \begin_layout Standard
19912
19913 \family roman
19914 \series medium
19915 \shape up
19916 \size normal
19917 \emph off
19918 \bar no
19919 \noun off
19920 \color none
19921 _uint2fs.c
19922 \end_layout
19923
19924 \end_inset
19925 </cell>
19926 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19927 \begin_inset Text
19928
19929 \begin_layout Standard
19930
19931 \family roman
19932 \series medium
19933 \shape up
19934 \size normal
19935 \emph off
19936 \bar no
19937 \noun off
19938 \color none
19939 convert unsigned int to floating point
19940 \end_layout
19941
19942 \end_inset
19943 </cell>
19944 </row>
19945 <row topline="true">
19946 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19947 \begin_inset Text
19948
19949 \begin_layout Standard
19950
19951 \family roman
19952 \series medium
19953 \shape up
19954 \size normal
19955 \emph off
19956 \bar no
19957 \noun off
19958 \color none
19959 _int2fs.c
19960 \end_layout
19961
19962 \end_inset
19963 </cell>
19964 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19965 \begin_inset Text
19966
19967 \begin_layout Standard
19968
19969 \family roman
19970 \series medium
19971 \shape up
19972 \size normal
19973 \emph off
19974 \bar no
19975 \noun off
19976 \color none
19977 convert int to floating point numbers
19978 \end_layout
19979
19980 \end_inset
19981 </cell>
19982 </row>
19983 <row topline="true">
19984 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19985 \begin_inset Text
19986
19987 \begin_layout Standard
19988
19989 \family roman
19990 \series medium
19991 \shape up
19992 \size normal
19993 \emph off
19994 \bar no
19995 \noun off
19996 \color none
19997 _ulong2fs.c
19998 \end_layout
19999
20000 \end_inset
20001 </cell>
20002 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20003 \begin_inset Text
20004
20005 \begin_layout Standard
20006
20007 \family roman
20008 \series medium
20009 \shape up
20010 \size normal
20011 \emph off
20012 \bar no
20013 \noun off
20014 \color none
20015 convert unsigned long to floating point number
20016 \end_layout
20017
20018 \end_inset
20019 </cell>
20020 </row>
20021 <row topline="true" bottomline="true">
20022 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20023 \begin_inset Text
20024
20025 \begin_layout Standard
20026
20027 \family roman
20028 \series medium
20029 \shape up
20030 \size normal
20031 \emph off
20032 \bar no
20033 \noun off
20034 \color none
20035 _long2fs.c
20036 \end_layout
20037
20038 \end_inset
20039 </cell>
20040 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20041 \begin_inset Text
20042
20043 \begin_layout Standard
20044
20045 \family roman
20046 \series medium
20047 \shape up
20048 \size normal
20049 \emph off
20050 \bar no
20051 \noun off
20052 \color none
20053 convert long to floating point number
20054 \end_layout
20055
20056 \end_inset
20057 </cell>
20058 </row>
20059 </lyxtabular>
20060
20061 \end_inset
20062
20063
20064 \newline
20065
20066 \end_layout
20067
20068 \begin_layout Standard
20069 These support routines are developed in ANSI-C so there is room for space
20070  and speed improvement
20071 \begin_inset Foot
20072 status open
20073
20074 \begin_layout Standard
20075 These floating point routines (
20076 \emph on
20077 not
20078 \emph default
20079  sinf(), cosf(), ...) for the mcs51 are implemented in assembler.
20080  
20081 \end_layout
20082
20083 \end_inset
20084
20085 .
20086  Note if all these routines are used simultaneously the data space might
20087  overflow.
20088  For serious floating point usage the large model might be needed.
20089  Also notice that you don't have to call this routines directly.
20090  The compiler will use them automatically every time a floating point operation
20091  is required.
20092 \begin_inset VSpace bigskip
20093 \end_inset
20094
20095
20096 \end_layout
20097
20098 \begin_layout Section
20099 Library Routines
20100 \begin_inset LatexCommand \index{Libraries}
20101
20102 \end_inset
20103
20104
20105 \end_layout
20106
20107 \begin_layout Standard
20108
20109 \emph on
20110 <pending: this is messy and incomplete - a little more information is in
20111  sdcc/doc/libdoc.txt
20112 \emph default
20113  >
20114 \end_layout
20115
20116 \begin_layout Subsection
20117 Compiler support routines (_gptrget, _mulint etc.)
20118 \end_layout
20119
20120 \begin_layout Subsection
20121 Stdclib functions (puts, printf, strcat etc.)
20122 \end_layout
20123
20124 \begin_layout Subsubsection
20125 <stdio.h>
20126 \end_layout
20127
20128 \begin_layout Paragraph
20129 getchar(), putchar()
20130 \end_layout
20131
20132 \begin_layout Standard
20133 \begin_inset LatexCommand \index{<stdio.h>}
20134
20135 \end_inset
20136
20137 As usual on embedded systems you have to provide your own 
20138 \family typewriter
20139 getchar()
20140 \begin_inset LatexCommand \index{getchar()}
20141
20142 \end_inset
20143
20144  
20145 \family default
20146 and 
20147 \family typewriter
20148 putchar()
20149 \begin_inset LatexCommand \index{putchar()}
20150
20151 \end_inset
20152
20153
20154 \family default
20155  routines.
20156  SDCC does not know whether the system connects to a serial line with or
20157  without handshake, LCD, keyboard or other device.
20158  And whether a 
20159 \family typewriter
20160 lf
20161 \family default
20162  to 
20163 \family typewriter
20164 crlf
20165 \family default
20166  conversion within 
20167 \family typewriter
20168 putchar()
20169 \family default
20170  is intended.
20171  You'll find examples for serial routines f.e.
20172  in sdcc/device/lib.
20173  For the mcs51 this minimalistic polling 
20174 \family typewriter
20175 putchar()
20176 \family default
20177  routine might be a start:
20178 \end_layout
20179
20180 \begin_layout Verse
20181
20182 \family typewriter
20183 void putchar (char c) { 
20184 \newline
20185 \InsetSpace ~
20186 \InsetSpace ~
20187 \InsetSpace ~
20188 \InsetSpace ~
20189 while (!TI)\InsetSpace ~
20190 \InsetSpace ~
20191 \InsetSpace ~
20192  /* assumes UART is initialized */
20193 \newline
20194 \InsetSpace ~
20195 \InsetSpace ~
20196 \InsetSpace ~
20197 \InsetSpace ~
20198 \InsetSpace ~
20199 \InsetSpace ~
20200 \InsetSpace ~
20201 \InsetSpace ~
20202 ;
20203 \newline
20204 \InsetSpace ~
20205 \InsetSpace ~
20206 \InsetSpace ~
20207 \InsetSpace ~
20208 TI
20209  = 0;
20210 \newline
20211 \InsetSpace ~
20212 \InsetSpace ~
20213 \InsetSpace ~
20214 \InsetSpace ~
20215 SBUF = c;
20216 \newline
20217 }
20218 \end_layout
20219
20220 \begin_layout Paragraph
20221 printf()
20222 \end_layout
20223
20224 \begin_layout Standard
20225 The default
20226 \family typewriter
20227  printf()
20228 \begin_inset LatexCommand \index{printf()}
20229
20230 \end_inset
20231
20232
20233 \family default
20234  implementation in
20235 \family typewriter
20236  printf_large.c
20237 \family default
20238  does not support float (except on ds390).
20239  To enable this recompile it with the option 
20240 \emph on
20241 -
20242 \begin_inset ERT
20243 status collapsed
20244
20245 \begin_layout Standard
20246
20247
20248 \backslash
20249 /
20250 \end_layout
20251
20252 \end_inset
20253
20254 DUSE_FLOATS=1
20255 \begin_inset LatexCommand \index{USE\_FLOATS}
20256
20257 \end_inset
20258
20259
20260 \emph default
20261  on the command line.
20262  Use
20263 \emph on
20264  -
20265 \begin_inset ERT
20266 status collapsed
20267
20268 \begin_layout Standard
20269
20270
20271 \backslash
20272 /
20273 \end_layout
20274
20275 \end_inset
20276
20277 -model-large
20278 \begin_inset LatexCommand \index{-\/-model-large}
20279
20280 \end_inset
20281
20282
20283 \emph default
20284  for the mcs51 port, since this uses a lot of memory.
20285 \end_layout
20286
20287 \begin_layout Standard
20288 If you're short on code memory you might want to use 
20289 \family typewriter
20290 printf_small()
20291 \begin_inset LatexCommand \index{printf\_small()}
20292
20293 \end_inset
20294
20295
20296 \family default
20297  
20298 \emph on
20299 instead
20300 \emph default
20301  of
20302 \family typewriter
20303  printf().
20304
20305 \family default
20306  For the mcs51 there additionally are assembly versions 
20307 \family typewriter
20308 printf_tiny()
20309 \begin_inset LatexCommand \index{printf\_tiny() (mcs51)}
20310
20311 \end_inset
20312
20313
20314 \family default
20315  (subset of printf using less than 270 bytes) and 
20316 \family typewriter
20317 printf_fast()
20318 \begin_inset LatexCommand \index{printf\_fast() (mcs51)}
20319
20320 \end_inset
20321
20322  
20323 \family default
20324 and
20325 \family typewriter
20326  printf_fast_f()
20327 \begin_inset LatexCommand \index{printf\_fast\_f() (mcs51)}
20328
20329 \end_inset
20330
20331
20332 \family default
20333  (floating-point aware version of printf_fast) which should fit the requirements
20334  of many embedded systems (printf_fast() can be customized by unsetting
20335  #defines to 
20336 \emph on
20337 not
20338 \emph default
20339  support long variables and field widths).
20340  Be sure to use only one of these printf options within a project.
20341 \newline
20342
20343 \end_layout
20344
20345 \begin_layout Standard
20346 Feature matrix of different 
20347 \emph on
20348 printf
20349 \emph default
20350  options on mcs51.
20351 \end_layout
20352
20353 \begin_layout Standard
20354 \begin_inset Tabular
20355 <lyxtabular version="3" rows="14" columns="7">
20356 <features islongtable="true">
20357 <column alignment="left" valignment="middle" leftline="true" width="14col%">
20358 <column alignment="center" valignment="top" leftline="true" width="0">
20359 <column alignment="center" valignment="top" leftline="true" width="12col%">
20360 <column alignment="center" valignment="top" leftline="true" width="10col%">
20361 <column alignment="center" valignment="top" leftline="true" width="0">
20362 <column alignment="center" valignment="top" leftline="true" rightline="true" width="12col%">
20363 <column alignment="center" valignment="top" rightline="true" width="0">
20364 <row topline="true" bottomline="true" endhead="true">
20365 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20366 \begin_inset Text
20367
20368 \begin_layout Standard
20369
20370 \series bold
20371 \size large
20372 mcs51
20373 \end_layout
20374
20375 \end_inset
20376 </cell>
20377 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20378 \begin_inset Text
20379
20380 \begin_layout Standard
20381 printf
20382 \begin_inset LatexCommand \index{printf}
20383
20384 \end_inset
20385
20386
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 printf 
20396 \size scriptsize
20397 USE_FLOATS=1
20398 \end_layout
20399
20400 \end_inset
20401 </cell>
20402 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20403 \begin_inset Text
20404
20405 \begin_layout Standard
20406 printf_small
20407 \end_layout
20408
20409 \end_inset
20410 </cell>
20411 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20412 \begin_inset Text
20413
20414 \begin_layout Standard
20415 printf_fast
20416 \end_layout
20417
20418 \end_inset
20419 </cell>
20420 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20421 \begin_inset Text
20422
20423 \begin_layout Standard
20424 printf_fast_f
20425 \end_layout
20426
20427 \end_inset
20428 </cell>
20429 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20430 \begin_inset Text
20431
20432 \begin_layout Standard
20433 printf_tiny
20434 \end_layout
20435
20436 \end_inset
20437 </cell>
20438 </row>
20439 <row topline="true" endhead="true">
20440 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20441 \begin_inset Text
20442
20443 \begin_layout Standard
20444 filename
20445 \end_layout
20446
20447 \end_inset
20448 </cell>
20449 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20450 \begin_inset Text
20451
20452 \begin_layout Standard
20453
20454 \size scriptsize
20455 printf_large.c
20456 \end_layout
20457
20458 \end_inset
20459 </cell>
20460 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20461 \begin_inset Text
20462
20463 \begin_layout Standard
20464
20465 \size scriptsize
20466 printf_large.c
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
20476 \size scriptsize
20477 printfl.c
20478 \end_layout
20479
20480 \end_inset
20481 </cell>
20482 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20483 \begin_inset Text
20484
20485 \begin_layout Standard
20486
20487 \size scriptsize
20488 printf_fast.c
20489 \end_layout
20490
20491 \end_inset
20492 </cell>
20493 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20494 \begin_inset Text
20495
20496 \begin_layout Standard
20497
20498 \size scriptsize
20499 printf_fast_f.c
20500 \end_layout
20501
20502 \end_inset
20503 </cell>
20504 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20505 \begin_inset Text
20506
20507 \begin_layout Standard
20508
20509 \size scriptsize
20510 printf_tiny.c
20511 \end_layout
20512
20513 \end_inset
20514 </cell>
20515 </row>
20516 <row topline="true" endhead="true">
20517 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20518 \begin_inset Text
20519
20520 \begin_layout Standard
20521 \begin_inset Quotes sld
20522 \end_inset
20523
20524 Hello World
20525 \begin_inset Quotes srd
20526 \end_inset
20527
20528  size
20529 \end_layout
20530
20531 \begin_layout Standard
20532 small / large
20533 \end_layout
20534
20535 \end_inset
20536 </cell>
20537 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20538 \begin_inset Text
20539
20540 \begin_layout Standard
20541 1.7k / 2.4k
20542 \end_layout
20543
20544 \end_inset
20545 </cell>
20546 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20547 \begin_inset Text
20548
20549 \begin_layout Standard
20550 4.3k / 5.6k
20551 \end_layout
20552
20553 \end_inset
20554 </cell>
20555 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20556 \begin_inset Text
20557
20558 \begin_layout Standard
20559 1.2k / 1.8k
20560 \end_layout
20561
20562 \end_inset
20563 </cell>
20564 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20565 \begin_inset Text
20566
20567 \begin_layout Standard
20568 1.3k / 1.3k
20569 \end_layout
20570
20571 \end_inset
20572 </cell>
20573 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20574 \begin_inset Text
20575
20576 \begin_layout Standard
20577 1.9k / 1.9k
20578 \end_layout
20579
20580 \end_inset
20581 </cell>
20582 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20583 \begin_inset Text
20584
20585 \begin_layout Standard
20586 0.44k / 0.44k
20587 \end_layout
20588
20589 \end_inset
20590 </cell>
20591 </row>
20592 <row topline="true" endhead="true">
20593 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20594 \begin_inset Text
20595
20596 \begin_layout Standard
20597 code size
20598 \end_layout
20599
20600 \begin_layout Standard
20601 small / large
20602 \end_layout
20603
20604 \end_inset
20605 </cell>
20606 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20607 \begin_inset Text
20608
20609 \begin_layout Standard
20610 1.4k / 2.0k
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 2.8k / 3.7k
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 0.45k / 0.47k (+ _ltoa)
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 1.2k / 1.2k
20638 \end_layout
20639
20640 \end_inset
20641 </cell>
20642 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20643 \begin_inset Text
20644
20645 \begin_layout Standard
20646 1.6k / 1.6k
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 0.26k / 0.26k
20656 \end_layout
20657
20658 \end_inset
20659 </cell>
20660 </row>
20661 <row topline="true">
20662 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20663 \begin_inset Text
20664
20665 \begin_layout Standard
20666 formats
20667 \end_layout
20668
20669 \end_inset
20670 </cell>
20671 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20672 \begin_inset Text
20673
20674 \begin_layout Standard
20675 cdi
20676 \emph on
20677 o
20678 \emph default
20679 psux
20680 \end_layout
20681
20682 \end_inset
20683 </cell>
20684 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20685 \begin_inset Text
20686
20687 \begin_layout Standard
20688
20689 \family roman
20690 \series medium
20691 \shape up
20692 \size normal
20693 \emph off
20694 \bar no
20695 \noun off
20696 \color none
20697 cd
20698 \family default
20699 \series default
20700 \shape default
20701 \size default
20702 \emph default
20703 \bar default
20704 \noun default
20705 f
20706 \family roman
20707 \series medium
20708 \shape up
20709 \size normal
20710 \emph off
20711 \bar no
20712 \noun off
20713 i
20714 \family default
20715 \series default
20716 \shape default
20717 \size default
20718 \emph on
20719 \bar default
20720 \noun default
20721 o
20722 \family roman
20723 \series medium
20724 \shape up
20725 \size normal
20726 \emph off
20727 \bar no
20728 \noun off
20729 psux
20730 \end_layout
20731
20732 \end_inset
20733 </cell>
20734 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20735 \begin_inset Text
20736
20737 \begin_layout Standard
20738 c
20739 \family roman
20740 \series medium
20741 \shape up
20742 \size normal
20743 \emph off
20744 \bar no
20745 \noun off
20746 \color none
20747 d
20748 \family default
20749 \series default
20750 \shape default
20751 \size default
20752 \emph on
20753 \bar default
20754 \noun default
20755 o
20756 \family roman
20757 \series medium
20758 \shape up
20759 \size normal
20760 \emph off
20761 \bar no
20762 \noun off
20763 s
20764 \family default
20765 \series default
20766 \shape default
20767 \size default
20768 \emph default
20769 \bar default
20770 \noun default
20771 x
20772 \end_layout
20773
20774 \end_inset
20775 </cell>
20776 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20777 \begin_inset Text
20778
20779 \begin_layout Standard
20780 cdsux
20781 \end_layout
20782
20783 \end_inset
20784 </cell>
20785 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20786 \begin_inset Text
20787
20788 \begin_layout Standard
20789 cdfsux
20790 \end_layout
20791
20792 \end_inset
20793 </cell>
20794 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20795 \begin_inset Text
20796
20797 \begin_layout Standard
20798 cdsux
20799 \end_layout
20800
20801 \end_inset
20802 </cell>
20803 </row>
20804 <row topline="true">
20805 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20806 \begin_inset Text
20807
20808 \begin_layout Standard
20809 long (32 bit) support
20810 \end_layout
20811
20812 \end_inset
20813 </cell>
20814 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20815 \begin_inset Text
20816
20817 \begin_layout Standard
20818 x
20819 \end_layout
20820
20821 \end_inset
20822 </cell>
20823 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20824 \begin_inset Text
20825
20826 \begin_layout Standard
20827 x
20828 \end_layout
20829
20830 \end_inset
20831 </cell>
20832 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20833 \begin_inset Text
20834
20835 \begin_layout Standard
20836 x
20837 \end_layout
20838
20839 \end_inset
20840 </cell>
20841 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20842 \begin_inset Text
20843
20844 \begin_layout Standard
20845 x
20846 \end_layout
20847
20848 \end_inset
20849 </cell>
20850 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20851 \begin_inset Text
20852
20853 \begin_layout Standard
20854
20855 \family roman
20856 \series medium
20857 \shape up
20858 \size normal
20859 \emph off
20860 \bar no
20861 \noun off
20862 \color none
20863 x
20864 \end_layout
20865
20866 \end_inset
20867 </cell>
20868 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20869 \begin_inset Text
20870
20871 \begin_layout Standard
20872 -
20873 \end_layout
20874
20875 \end_inset
20876 </cell>
20877 </row>
20878 <row topline="true">
20879 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20880 \begin_inset Text
20881
20882 \begin_layout Standard
20883 byte arguments on stack
20884 \end_layout
20885
20886 \end_inset
20887 </cell>
20888 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20889 \begin_inset Text
20890
20891 \begin_layout Standard
20892 b
20893 \end_layout
20894
20895 \end_inset
20896 </cell>
20897 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20898 \begin_inset Text
20899
20900 \begin_layout Standard
20901 b
20902 \end_layout
20903
20904 \end_inset
20905 </cell>
20906 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20907 \begin_inset Text
20908
20909 \begin_layout Standard
20910 -
20911 \end_layout
20912
20913 \end_inset
20914 </cell>
20915 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20916 \begin_inset Text
20917
20918 \begin_layout Standard
20919 -
20920 \end_layout
20921
20922 \end_inset
20923 </cell>
20924 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20925 \begin_inset Text
20926
20927 \begin_layout Standard
20928 -
20929 \end_layout
20930
20931 \end_inset
20932 </cell>
20933 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20934 \begin_inset Text
20935
20936 \begin_layout Standard
20937 -
20938 \end_layout
20939
20940 \end_inset
20941 </cell>
20942 </row>
20943 <row topline="true">
20944 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20945 \begin_inset Text
20946
20947 \begin_layout Standard
20948 float format
20949 \begin_inset LatexCommand \index{Floating point support}
20950
20951 \end_inset
20952
20953
20954 \end_layout
20955
20956 \end_inset
20957 </cell>
20958 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20959 \begin_inset Text
20960
20961 \begin_layout Standard
20962 -
20963 \end_layout
20964
20965 \end_inset
20966 </cell>
20967 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20968 \begin_inset Text
20969
20970 \begin_layout Standard
20971 %f
20972 \end_layout
20973
20974 \end_inset
20975 </cell>
20976 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20977 \begin_inset Text
20978
20979 \begin_layout Standard
20980 -
20981 \end_layout
20982
20983 \end_inset
20984 </cell>
20985 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20986 \begin_inset Text
20987
20988 \begin_layout Standard
20989 -
20990 \end_layout
20991
20992 \end_inset
20993 </cell>
20994 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20995 \begin_inset Text
20996
20997 \begin_layout Standard
20998 %f
20999 \begin_inset Foot
21000 status collapsed
21001
21002 \begin_layout Standard
21003 Range limited to +/- 4294967040, precision limited to 8 digits past decimal
21004 \end_layout
21005
21006 \end_inset
21007
21008
21009 \end_layout
21010
21011 \end_inset
21012 </cell>
21013 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
21014 \begin_inset Text
21015
21016 \begin_layout Standard
21017 -
21018 \end_layout
21019
21020 \end_inset
21021 </cell>
21022 </row>
21023 <row topline="true">
21024 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21025 \begin_inset Text
21026
21027 \begin_layout Standard
21028 float formats %e %g
21029 \end_layout
21030
21031 \end_inset
21032 </cell>
21033 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21034 \begin_inset Text
21035
21036 \begin_layout Standard
21037 -
21038 \end_layout
21039
21040 \end_inset
21041 </cell>
21042 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21043 \begin_inset Text
21044
21045 \begin_layout Standard
21046 -
21047 \end_layout
21048
21049 \end_inset
21050 </cell>
21051 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21052 \begin_inset Text
21053
21054 \begin_layout Standard
21055 -
21056 \end_layout
21057
21058 \end_inset
21059 </cell>
21060 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21061 \begin_inset Text
21062
21063 \begin_layout Standard
21064 -
21065 \end_layout
21066
21067 \end_inset
21068 </cell>
21069 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
21070 \begin_inset Text
21071
21072 \begin_layout Standard
21073 -
21074 \end_layout
21075
21076 \end_inset
21077 </cell>
21078 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
21079 \begin_inset Text
21080
21081 \begin_layout Standard
21082 -
21083 \end_layout
21084
21085 \end_inset
21086 </cell>
21087 </row>
21088 <row topline="true" bottomline="true">
21089 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21090 \begin_inset Text
21091
21092 \begin_layout Standard
21093 field width
21094 \end_layout
21095
21096 \end_inset
21097 </cell>
21098 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21099 \begin_inset Text
21100
21101 \begin_layout Standard
21102 x
21103 \end_layout
21104
21105 \end_inset
21106 </cell>
21107 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21108 \begin_inset Text
21109
21110 \begin_layout Standard
21111 x
21112 \end_layout
21113
21114 \end_inset
21115 </cell>
21116 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21117 \begin_inset Text
21118
21119 \begin_layout Standard
21120 -
21121 \end_layout
21122
21123 \end_inset
21124 </cell>
21125 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21126 \begin_inset Text
21127
21128 \begin_layout Standard
21129 x
21130 \end_layout
21131
21132 \end_inset
21133 </cell>
21134 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
21135 \begin_inset Text
21136
21137 \begin_layout Standard
21138 x
21139 \end_layout
21140
21141 \end_inset
21142 </cell>
21143 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
21144 \begin_inset Text
21145
21146 \begin_layout Standard
21147 -
21148 \end_layout
21149
21150 \end_inset
21151 </cell>
21152 </row>
21153 <row bottomline="true">
21154 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21155 \begin_inset Text
21156
21157 \begin_layout Standard
21158 string speed
21159 \begin_inset Foot
21160 status collapsed
21161
21162 \begin_layout Standard
21163 Execution time of printf("%s%c%s%c%c%c", "Hello", ' ', "World", '!', '
21164 \backslash
21165 r', '
21166 \backslash
21167 n'); standard 8051 @ 22.1184 MHz, empty putchar()
21168 \end_layout
21169
21170 \end_inset
21171
21172 ,
21173 \end_layout
21174
21175 \begin_layout Standard
21176 small / large
21177 \end_layout
21178
21179 \end_inset
21180 </cell>
21181 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21182 \begin_inset Text
21183
21184 \begin_layout Standard
21185 1.52 / 2.59 ms
21186 \end_layout
21187
21188 \end_inset
21189 </cell>
21190 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21191 \begin_inset Text
21192
21193 \begin_layout Standard
21194 1.53 / 2.62 ms
21195 \end_layout
21196
21197 \end_inset
21198 </cell>
21199 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21200 \begin_inset Text
21201
21202 \begin_layout Standard
21203 0.92 / 0.93 ms
21204 \end_layout
21205
21206 \end_inset
21207 </cell>
21208 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21209 \begin_inset Text
21210
21211 \begin_layout Standard
21212 0.45 / 0.45 ms
21213 \end_layout
21214
21215 \end_inset
21216 </cell>
21217 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21218 \begin_inset Text
21219
21220 \begin_layout Standard
21221 0.46 / 0.46 ms
21222 \end_layout
21223
21224 \end_inset
21225 </cell>
21226 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
21227 \begin_inset Text
21228
21229 \begin_layout Standard
21230 0.45 / 0.45 ms
21231 \end_layout
21232
21233 \end_inset
21234 </cell>
21235 </row>
21236 <row bottomline="true">
21237 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21238 \begin_inset Text
21239
21240 \begin_layout Standard
21241 int speed
21242 \begin_inset Foot
21243 status collapsed
21244
21245 \begin_layout Standard
21246 Execution time of printf("%d", -12345); standard 8051 @ 22.1184 MHz, empty
21247  putchar()
21248 \end_layout
21249
21250 \end_inset
21251
21252 ,
21253 \end_layout
21254
21255 \begin_layout Standard
21256 small / large
21257 \end_layout
21258
21259 \end_inset
21260 </cell>
21261 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21262 \begin_inset Text
21263
21264 \begin_layout Standard
21265 3.01 / 3.61 ms
21266 \end_layout
21267
21268 \end_inset
21269 </cell>
21270 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21271 \begin_inset Text
21272
21273 \begin_layout Standard
21274 3.01 / 3.61 ms
21275 \end_layout
21276
21277 \end_inset
21278 </cell>
21279 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21280 \begin_inset Text
21281
21282 \begin_layout Standard
21283 3.51 / 18.13 ms
21284 \end_layout
21285
21286 \end_inset
21287 </cell>
21288 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21289 \begin_inset Text
21290
21291 \begin_layout Standard
21292 0.22 / 0.22 ms
21293 \end_layout
21294
21295 \end_inset
21296 </cell>
21297 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21298 \begin_inset Text
21299
21300 \begin_layout Standard
21301 0.23 / 0.23 ms
21302 \end_layout
21303
21304 \end_inset
21305 </cell>
21306 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
21307 \begin_inset Text
21308
21309 \begin_layout Standard
21310 0.25 / 0.25 ms
21311 \begin_inset Foot
21312 status collapsed
21313
21314 \begin_layout Standard
21315 printf_tiny integer speed is data dependent, worst case is 0.33 ms
21316 \end_layout
21317
21318 \end_inset
21319
21320
21321 \end_layout
21322
21323 \end_inset
21324 </cell>
21325 </row>
21326 <row bottomline="true">
21327 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21328 \begin_inset Text
21329
21330 \begin_layout Standard
21331 long speed
21332 \begin_inset Foot
21333 status collapsed
21334
21335 \begin_layout Standard
21336 Execution time of printf("%ld", -123456789); standard 8051 @ 22.1184 MHz,
21337  empty putchar()
21338 \end_layout
21339
21340 \end_inset
21341
21342 ,
21343 \end_layout
21344
21345 \begin_layout Standard
21346 small / large
21347 \end_layout
21348
21349 \end_inset
21350 </cell>
21351 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21352 \begin_inset Text
21353
21354 \begin_layout Standard
21355 5.37 / 6.31 ms
21356 \end_layout
21357
21358 \end_inset
21359 </cell>
21360 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21361 \begin_inset Text
21362
21363 \begin_layout Standard
21364 5.37 / 6.31 ms
21365 \end_layout
21366
21367 \end_inset
21368 </cell>
21369 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21370 \begin_inset Text
21371
21372 \begin_layout Standard
21373 8.71 / 40.65 ms
21374 \end_layout
21375
21376 \end_inset
21377 </cell>
21378 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21379 \begin_inset Text
21380
21381 \begin_layout Standard
21382 0.40 / 0.40 ms
21383 \end_layout
21384
21385 \end_inset
21386 </cell>
21387 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21388 \begin_inset Text
21389
21390 \begin_layout Standard
21391 0.40 / 0.40 ms
21392 \end_layout
21393
21394 \end_inset
21395 </cell>
21396 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
21397 \begin_inset Text
21398
21399 \begin_layout Standard
21400 -
21401 \end_layout
21402
21403 \end_inset
21404 </cell>
21405 </row>
21406 <row bottomline="true">
21407 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21408 \begin_inset Text
21409
21410 \begin_layout Standard
21411 float speed
21412 \begin_inset Foot
21413 status collapsed
21414
21415 \begin_layout Standard
21416 Execution time of printf("%.3f", -12345.678); standard 8051 @ 22.1184 MHz,
21417  empty putchar()
21418 \end_layout
21419
21420 \end_inset
21421
21422 ,
21423 \end_layout
21424
21425 \begin_layout Standard
21426 small / large
21427 \end_layout
21428
21429 \end_inset
21430 </cell>
21431 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21432 \begin_inset Text
21433
21434 \begin_layout Standard
21435 -
21436 \end_layout
21437
21438 \end_inset
21439 </cell>
21440 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21441 \begin_inset Text
21442
21443 \begin_layout Standard
21444 7.49 / 22.47 ms
21445 \end_layout
21446
21447 \end_inset
21448 </cell>
21449 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21450 \begin_inset Text
21451
21452 \begin_layout Standard
21453 -
21454 \end_layout
21455
21456 \end_inset
21457 </cell>
21458 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21459 \begin_inset Text
21460
21461 \begin_layout Standard
21462 -
21463 \end_layout
21464
21465 \end_inset
21466 </cell>
21467 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21468 \begin_inset Text
21469
21470 \begin_layout Standard
21471 1.04 / 1.04 ms
21472 \end_layout
21473
21474 \end_inset
21475 </cell>
21476 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
21477 \begin_inset Text
21478
21479 \begin_layout Standard
21480 -
21481 \end_layout
21482
21483 \end_inset
21484 </cell>
21485 </row>
21486 </lyxtabular>
21487
21488 \end_inset
21489
21490
21491 \end_layout
21492
21493 \begin_layout Subsubsection
21494 <malloc.h>
21495 \begin_inset LatexCommand \index{malloc.h}
21496
21497 \end_inset
21498
21499
21500 \end_layout
21501
21502 \begin_layout Standard
21503 As of SDCC 2.6.2 you no longer need to call an initialization routine before
21504  using dynamic memory allocation
21505 \begin_inset LatexCommand \index{dynamic memory allocation (malloc)}
21506
21507 \end_inset
21508
21509  and a default heap
21510 \begin_inset LatexCommand \index{heap (malloc)}
21511
21512 \end_inset
21513
21514  space of 1024 bytes is provided for malloc to allocate memory from.
21515  If you need a different heap size you need to recompile _heap.c with the
21516  required size defined in HEAP_SIZE.
21517  It is recommended to make a copy of this file into your project directory
21518  and compile it there with:
21519 \end_layout
21520
21521 \begin_layout Verse
21522
21523 \family typewriter
21524 sdcc -c _heap.c -D HEAD_SIZE=2048
21525 \end_layout
21526
21527 \begin_layout Standard
21528 And then link it with:
21529 \end_layout
21530
21531 \begin_layout Verse
21532
21533 \family typewriter
21534 sdcc main.rel _heap.rel
21535 \end_layout
21536
21537 \begin_layout Subsection
21538 Math functions (sinf, powf, sqrtf etc.)
21539 \end_layout
21540
21541 \begin_layout Subsubsection
21542 <math.h>
21543 \end_layout
21544
21545 \begin_layout Standard
21546 See definitions in file <math.h>.
21547 \end_layout
21548
21549 \begin_layout Subsection
21550 Other libraries
21551 \end_layout
21552
21553 \begin_layout Standard
21554 Libraries
21555 \begin_inset LatexCommand \index{Libraries}
21556
21557 \end_inset
21558
21559  included in SDCC should have a license at least as liberal as the GNU Lesser
21560  General Public License
21561 \begin_inset LatexCommand \index{GNU Lesser General Public License, LGPL}
21562
21563 \end_inset
21564
21565  
21566 \emph on
21567 LGPL
21568 \emph default
21569 .
21570 \end_layout
21571
21572 \begin_layout Standard
21573 \begin_inset Note Note
21574 status collapsed
21575
21576 \begin_layout Standard
21577 license statements for the libraries are missing.
21578  sdcc/device/lib/ser_ir.c
21579 \end_layout
21580
21581 \begin_layout Standard
21582 or _decdptr f.e.
21583  come with a GPL (as opposed to LGPL) License - this will not be liberal
21584  enough for many embedded programmers.
21585 \end_layout
21586
21587 \end_inset
21588
21589
21590 \end_layout
21591
21592 \begin_layout Standard
21593 If you have ported some library or want to share experience about some code
21594  which f.e.
21595  falls into any of these categories Busses (I
21596 \begin_inset Formula $^{\textrm{2}}$
21597 \end_inset
21598
21599 C, CAN, Ethernet, Profibus, Modbus, USB, SPI, JTAG ...), Media (IDE, Memory
21600  cards, eeprom, flash...), En-/Decryption, Remote debugging, Realtime kernel,
21601  Keyboard, LCD, RTC, FPGA, PID then the sdcc-user mailing list 
21602 \begin_inset LatexCommand \url{http://sourceforge.net/mail/?group_id=599}
21603
21604 \end_inset
21605
21606 \InsetSpace ~
21607 would certainly like to hear about it.
21608 \end_layout
21609
21610 \begin_layout Standard
21611 Programmers coding for embedded systems are not especially famous for being
21612  enthusiastic, so don't expect a big hurray but as the mailing list is searchabl
21613 e these references are very valuable.
21614  Let's help to create a climate where information is shared.
21615 \begin_inset VSpace bigskip
21616 \end_inset
21617
21618
21619 \end_layout
21620
21621 \begin_layout Section
21622 Memory Models
21623 \end_layout
21624
21625 \begin_layout Subsection
21626 MCS51 Memory Models
21627 \begin_inset LatexCommand \index{Memory model}
21628
21629 \end_inset
21630
21631
21632 \begin_inset LatexCommand \index{MCS51 memory model}
21633
21634 \end_inset
21635
21636
21637 \end_layout
21638
21639 \begin_layout Subsubsection
21640 Small, Medium and Large
21641 \end_layout
21642
21643 \begin_layout Standard
21644 SDCC allows three memory models for MCS51 code, 
21645 \shape slanted
21646 small, medium
21647 \shape default
21648  and 
21649 \shape slanted
21650 large
21651 \shape default
21652 .
21653  Modules compiled with different memory models should 
21654 \emph on
21655 never
21656 \emph default
21657  be combined together or the results would be unpredictable.
21658  The library routines supplied with the compiler are compiled as small,
21659  medium and large.
21660  The compiled library modules are contained in separate directories as small,
21661  medium and large so that you can link to the appropriate set.
21662 \end_layout
21663
21664 \begin_layout Standard
21665 When the medium or large model is used all variables declared without a
21666  storage class will be allocated into the external ram, this includes all
21667  parameters and local variables (for non-reentrant
21668 \begin_inset LatexCommand \index{reentrant}
21669
21670 \end_inset
21671
21672  functions).
21673  When the small model is used variables without storage class are allocated
21674  in the internal ram.
21675 \end_layout
21676
21677 \begin_layout Standard
21678 Judicious usage of the processor specific storage classes
21679 \begin_inset LatexCommand \index{Storage class}
21680
21681 \end_inset
21682
21683  and the 'reentrant' function type will yield much more efficient code,
21684  than using the large model.
21685  Several optimizations are disabled when the program is compiled using the
21686  large model, it is therefore recommended that the small model be used unless
21687  absolutely required.
21688 \end_layout
21689
21690 \begin_layout Subsubsection
21691 External Stack
21692 \begin_inset LatexCommand \label{sub:External-Stack}
21693
21694 \end_inset
21695
21696
21697 \begin_inset LatexCommand \index{stack}
21698
21699 \end_inset
21700
21701
21702 \begin_inset LatexCommand \index{External stack (mcs51)}
21703
21704 \end_inset
21705
21706
21707 \end_layout
21708
21709 \begin_layout Standard
21710 The external stack (-
21711 \begin_inset ERT
21712 status collapsed
21713
21714 \begin_layout Standard
21715
21716
21717 \backslash
21718 /
21719 \end_layout
21720
21721 \end_inset
21722
21723 -xstack option
21724 \begin_inset LatexCommand \index{-\/-xstack}
21725
21726 \end_inset
21727
21728 ) is located in pdata
21729 \begin_inset LatexCommand \index{pdata (mcs51, ds390 storage class)}
21730
21731 \end_inset
21732
21733  memory (usually at the start of the external ram segment) and uses all
21734  unused space in pdata (max.
21735  256 bytes).
21736  When -
21737 \begin_inset ERT
21738 status collapsed
21739
21740 \begin_layout Standard
21741
21742
21743 \backslash
21744 /
21745 \end_layout
21746
21747 \end_inset
21748
21749 -xstack option is used to compile the program, the parameters and local
21750  variables
21751 \begin_inset LatexCommand \index{local variables}
21752
21753 \end_inset
21754
21755  of all reentrant functions are allocated in this area.
21756  This option is provided for programs with large stack space requirements.
21757  When used with the -
21758 \begin_inset ERT
21759 status collapsed
21760
21761 \begin_layout Standard
21762
21763
21764 \backslash
21765 /
21766 \end_layout
21767
21768 \end_inset
21769
21770 -stack-auto
21771 \begin_inset LatexCommand \index{-\/-stack-auto}
21772
21773 \end_inset
21774
21775  option, all parameters and local variables are allocated on the external
21776  stack (note: support libraries will need to be recompiled with the same
21777  options.
21778  There is a predefined target in the library makefile).
21779 \end_layout
21780
21781 \begin_layout Standard
21782 The compiler outputs the higher order address byte of the external ram segment
21783  into port P2
21784 \begin_inset LatexCommand \index{P2 (mcs51 sfr)}
21785
21786 \end_inset
21787
21788  (see also section 
21789 \begin_inset LatexCommand \ref{sub:MCS51-variants}
21790
21791 \end_inset
21792
21793 ), therefore when using the External Stack option, this port 
21794 \emph on
21795 may not
21796 \emph default
21797  be used by the application program.
21798 \end_layout
21799
21800 \begin_layout Subsection
21801 DS390 Memory Model
21802 \begin_inset LatexCommand \index{Memory model}
21803
21804 \end_inset
21805
21806
21807 \begin_inset LatexCommand \index{DS390 memory model}
21808
21809 \end_inset
21810
21811
21812 \end_layout
21813
21814 \begin_layout Standard
21815 The only model supported is Flat 24
21816 \begin_inset LatexCommand \index{Flat 24 (DS390 memory model)}
21817
21818 \end_inset
21819
21820 .
21821  This generates code for the 24 bit contiguous addressing mode of the Dallas
21822  DS80C390 part.
21823  In this mode, up to four meg of external RAM or code space can be directly
21824  addressed.
21825  See the data sheets at www.dalsemi.com for further information on this part.
21826 \newline
21827
21828 \newline
21829 Note
21830  that the compiler does not generate any code to place the processor into
21831  24 bitmode (although 
21832 \emph on
21833 tinibios
21834 \emph default
21835  in the ds390 libraries will do that for you).
21836  If you don't use 
21837 \emph on
21838 tinibios
21839 \emph default
21840
21841 \begin_inset LatexCommand \index{Tinibios (DS390)}
21842
21843 \end_inset
21844
21845 , the boot loader or similar code must ensure that the processor is in 24
21846  bit contiguous addressing mode before calling the SDCC startup code.
21847 \newline
21848
21849 \newline
21850 Like
21851  the 
21852 \emph on
21853 -
21854 \begin_inset ERT
21855 status collapsed
21856
21857 \begin_layout Standard
21858
21859
21860 \backslash
21861 /
21862 \end_layout
21863
21864 \end_inset
21865
21866 -model-large
21867 \emph default
21868  option, variables will by default be placed into the XDATA segment.
21869  
21870 \newline
21871
21872 \newline
21873 Segments may be placed anywhere in the 4 meg address space using the usual
21874  -
21875 \begin_inset ERT
21876 status collapsed
21877
21878 \begin_layout Standard
21879
21880
21881 \backslash
21882 /
21883 \end_layout
21884
21885 \end_inset
21886
21887 -*-loc options.
21888  Note that if any segments are located above 64K, the -r flag must be passed
21889  to the linker to generate the proper segment relocations, and the Intel
21890  HEX output format must be used.
21891  The -r flag can be passed to the linker by using the option 
21892 \emph on
21893 -Wl-r
21894 \emph default
21895  on the SDCC command line.
21896  However, currently the linker can not handle code segments > 64k.
21897 \end_layout
21898
21899 \begin_layout Section
21900 Pragmas
21901 \begin_inset LatexCommand \label{sec:Pragmas}
21902
21903 \end_inset
21904
21905
21906 \begin_inset LatexCommand \index{Pragmas}
21907
21908 \end_inset
21909
21910
21911 \end_layout
21912
21913 \begin_layout Standard
21914 Pragmas are used to turn on and/or off certain compiler options.
21915  Some of them are closely related to corresponding command-line options
21916  (see section 
21917 \begin_inset LatexCommand \vref{sec:Command-Line-Options}
21918
21919 \end_inset
21920
21921 ).
21922 \newline
21923 Pragmas should be placed before and/or after a function, placing pragmas
21924  inside a function body could have unpredictable results.
21925 \newline
21926
21927 \newline
21928 SDCC supports the
21929  following #pragma directives:
21930 \end_layout
21931
21932 \begin_layout Itemize
21933
21934 \series bold
21935 save
21936 \series default
21937
21938 \begin_inset LatexCommand \index{\#pragma save}
21939
21940 \end_inset
21941
21942  - this will save most current options to the save/restore stack.
21943  See #pragma\InsetSpace ~
21944 restore.
21945 \end_layout
21946
21947 \begin_layout Itemize
21948
21949 \series bold
21950 restore
21951 \series default
21952
21953 \begin_inset LatexCommand \index{\#pragma restore}
21954
21955 \end_inset
21956
21957  - will restore saved options from the last save.
21958  saves & restores can be nested.
21959  SDCC uses a save/restore stack: save pushes current options to the stack,
21960  restore pulls current options from the stack.
21961  See #pragma\InsetSpace ~
21962 save.
21963 \newline
21964
21965 \end_layout
21966
21967 \begin_layout Itemize
21968
21969 \series bold
21970 callee_saves
21971 \series default
21972
21973 \begin_inset LatexCommand \index{\#pragma callee\_saves}
21974
21975 \end_inset
21976
21977
21978 \begin_inset LatexCommand \index{function prologue}
21979
21980 \end_inset
21981
21982  function1[,function2[,function3...]] 
21983 \begin_inset LatexCommand \label{ite:callee_saves-function1[,function2[,function3...]]--}
21984
21985 \end_inset
21986
21987 - The compiler by default uses a caller saves convention for register saving
21988  across function calls, however this can cause unnecessary register pushing
21989  and popping
21990 \begin_inset LatexCommand \index{push/pop}
21991
21992 \end_inset
21993
21994  when calling small functions from larger functions.
21995  This option can be used to switch off the register saving convention for
21996  the function names specified.
21997  The compiler will not save registers when calling these functions, extra
21998  code need to be manually inserted at the entry and exit for these functions
21999  to save and restore the registers used by these functions, this can SUBSTANTIAL
22000 LY reduce code and improve run time performance of the generated code.
22001  In the future the compiler (with inter procedural analysis) may be able
22002  to determine the appropriate scheme to use for each function call.
22003  If -
22004 \begin_inset ERT
22005 status collapsed
22006
22007 \begin_layout Standard
22008
22009
22010 \backslash
22011 /
22012 \end_layout
22013
22014 \end_inset
22015
22016 -callee-saves command line option is used (see page 
22017 \begin_inset LatexCommand \vpageref{lyx:--callee-saves-function1[,function2][,function3]...}
22018
22019 \end_inset
22020
22021 ), the function names specified in #pragma\InsetSpace ~
22022 callee_saves
22023 \begin_inset LatexCommand \index{\#pragma callee\_saves}
22024
22025 \end_inset
22026
22027  is appended to the list of functions specified in the command line.
22028 \end_layout
22029
22030 \begin_layout Itemize
22031
22032 \series bold
22033 exclude
22034 \series default
22035
22036 \begin_inset LatexCommand \index{\#pragma exclude}
22037
22038 \end_inset
22039
22040  none | {acc[,b[,dpl[,dph]]] - The exclude pragma disables the generation
22041  of pairs of push/pop
22042 \begin_inset LatexCommand \index{push/pop}
22043
22044 \end_inset
22045
22046  instructions in 
22047 \emph on
22048 I
22049 \emph default
22050 nterrupt
22051 \begin_inset LatexCommand \index{interrupt}
22052
22053 \end_inset
22054
22055  
22056 \emph on
22057 S
22058 \emph default
22059 ervice 
22060 \emph on
22061 R
22062 \emph default
22063 outines.
22064  The directive should be placed immediately before the ISR function definition
22065  and it affects ALL ISR functions following it.
22066  To enable the normal register saving for ISR functions use #pragma\InsetSpace ~
22067 exclude\InsetSpace ~
22068 none
22069 \begin_inset LatexCommand \index{\#pragma exclude}
22070
22071 \end_inset
22072
22073 .
22074  See also the related keyword _naked
22075 \begin_inset LatexCommand \index{\_naked}
22076
22077 \end_inset
22078
22079
22080 \begin_inset LatexCommand \index{\_\_naked}
22081
22082 \end_inset
22083
22084 .
22085 \end_layout
22086
22087 \begin_layout Itemize
22088
22089 \series bold
22090 less_pedantic
22091 \series default
22092
22093 \begin_inset LatexCommand \index{pedantic}
22094
22095 \end_inset
22096
22097
22098 \begin_inset LatexCommand \index{\#pragma less\_pedantic}
22099
22100 \end_inset
22101
22102  
22103 \begin_inset LatexCommand \label{ite:less_pedantic}
22104
22105 \end_inset
22106
22107 - the compiler will not warn you anymore for obvious mistakes, you're on
22108  your own now ;-( .
22109  See also the command line option -
22110 \begin_inset ERT
22111 status collapsed
22112
22113 \begin_layout Standard
22114
22115
22116 \backslash
22117 /
22118 \end_layout
22119
22120 \end_inset
22121
22122 -less-pedantic 
22123 \begin_inset LatexCommand \vpageref{lyx:--less-pedantic}
22124
22125 \end_inset
22126
22127 .
22128  
22129 \newline
22130 More specifically, the following warnings will be disabled: 
22131 \shape italic
22132 comparison is always [true/false] due to limited range of data type
22133 \shape default
22134  (94); 
22135 \shape italic
22136 overflow in implicit constant conversion
22137 \shape default
22138  (158); [the (in)famous] 
22139 \shape italic
22140 conditional flow changed by optimizer: so said EVELYN the modified DOG
22141 \shape default
22142  (110); 
22143 \shape italic
22144 function '[function name]' must return value
22145 \shape default
22146  (59).
22147  
22148 \newline
22149 Furthermore, warnings of less importance (of PEDANTIC and INFO warning
22150  level) are disabled, too, namely: 
22151 \shape italic
22152 constant value '[
22153 \begin_inset Note Note
22154 status collapsed
22155
22156 \begin_layout Standard
22157 dunno what comes here - this warning appears to be unused altogether
22158 \end_layout
22159
22160 \end_inset
22161
22162 ]', out of range
22163 \shape default
22164  (81); 
22165 \shape italic
22166 [left/right] shifting more than size of object changed to zero
22167 \shape default
22168  (116); 
22169 \shape italic
22170 unreachable code
22171 \shape default
22172  (126); 
22173 \shape italic
22174 integer overflow in expression
22175 \shape default
22176  (165); 
22177 \shape italic
22178 unmatched #pragma save and #pragma restore
22179 \shape default
22180  (170); 
22181 \shape italic
22182 comparison of 'signed char' with 'unsigned char' requires promotion to int
22183 \shape default
22184  (185); 
22185 \shape italic
22186 ISO C90 does not support flexible array members
22187 \shape default
22188  (187); 
22189 \shape italic
22190 extended stack by [number] bytes for compiler temp(s) :in function '[function\InsetSpace ~
22191 nam
22192 e]':\InsetSpace ~
22193 [
22194 \begin_inset Note Note
22195 status collapsed
22196
22197 \begin_layout Standard
22198 appears to be always blank - what was supposed to be here?
22199 \end_layout
22200
22201 \end_inset
22202
22203 ]
22204 \shape default
22205  (114); 
22206 \shape italic
22207 function '[function name]', # edges [number] , # nodes [number] , cyclomatic
22208  complexity [number]
22209 \shape default
22210  (121).
22211 \end_layout
22212
22213 \begin_layout Itemize
22214
22215 \series bold
22216 disable_warning
22217 \series default
22218  <nnnn>
22219 \begin_inset LatexCommand \index{\#pragma disable\_warning}
22220
22221 \end_inset
22222
22223  - the compiler will not warn you anymore about warning number <nnnn>.
22224 \end_layout
22225
22226 \begin_layout Itemize
22227
22228 \series bold
22229 nogcse
22230 \series default
22231
22232 \begin_inset LatexCommand \index{\#pragma nogcse}
22233
22234 \end_inset
22235
22236  - will stop global common subexpression elimination.
22237 \end_layout
22238
22239 \begin_layout Itemize
22240
22241 \series bold
22242 noinduction
22243 \series default
22244
22245 \begin_inset LatexCommand \index{\#pragma noinduction}
22246
22247 \end_inset
22248
22249  - will stop loop induction optimizations.
22250 \end_layout
22251
22252 \begin_layout Itemize
22253
22254 \series bold
22255 noinvariant
22256 \series default
22257
22258 \begin_inset LatexCommand \index{\#pragma noinvariant}
22259
22260 \end_inset
22261
22262  - will not do loop invariant optimizations.
22263  For more details see Loop Invariants in section
22264 \begin_inset LatexCommand \ref{sub:Loop-Optimizations}
22265
22266 \end_inset
22267
22268 .
22269 \end_layout
22270
22271 \begin_layout Itemize
22272
22273 \series bold
22274 noiv
22275 \series default
22276
22277 \begin_inset LatexCommand \index{\#pragma noiv}
22278
22279 \end_inset
22280
22281  - Do not generate interrupt
22282 \begin_inset LatexCommand \index{interrupt}
22283
22284 \end_inset
22285
22286  vector table
22287 \begin_inset LatexCommand \index{interrupt vector table}
22288
22289 \end_inset
22290
22291  entries for all ISR functions defined after the pragma.
22292  This is useful in cases where the interrupt vector table must be defined
22293  manually, or when there is a secondary, manually defined interrupt vector
22294  table (e.g.
22295  for the autovector feature of the Cypress EZ-USB FX2).
22296  More elegantly this can be achieved by obmitting the optional interrupt
22297  number after the interrupt keyword, see section 
22298 \begin_inset LatexCommand \ref{sub:Interrupt-Service-Routines}
22299
22300 \end_inset
22301
22302 \InsetSpace ~
22303 about interrupts.
22304 \end_layout
22305
22306 \begin_layout Itemize
22307
22308 \series bold
22309 nojtbound
22310 \series default
22311
22312 \begin_inset LatexCommand \index{\#pragma nojtbound}
22313
22314 \end_inset
22315
22316  - will not generate code for boundary value checking, when switch statements
22317  are turned into jump-tables (dangerous).
22318  For more details see section 
22319 \begin_inset LatexCommand \ref{sub:'switch'-Statements}
22320
22321 \end_inset
22322
22323 .
22324 \end_layout
22325
22326 \begin_layout Itemize
22327
22328 \series bold
22329 noloopreverse
22330 \series default
22331
22332 \begin_inset LatexCommand \index{\#pragma noloopreverse}
22333
22334 \end_inset
22335
22336  - Will not do loop reversal optimization
22337 \end_layout
22338
22339 \begin_layout Itemize
22340
22341 \series bold
22342 nooverlay
22343 \series default
22344
22345 \begin_inset LatexCommand \index{\#pragma nooverlay}
22346
22347 \end_inset
22348
22349  - the compiler will not overlay the parameters and local variables of a
22350  function.
22351 \end_layout
22352
22353 \begin_layout Itemize
22354
22355 \series bold
22356 stackauto
22357 \series default
22358
22359 \begin_inset LatexCommand \index{\#pragma stackauto}
22360
22361 \end_inset
22362
22363 - See option -
22364 \begin_inset ERT
22365 status collapsed
22366
22367 \begin_layout Standard
22368
22369
22370 \backslash
22371 /
22372 \end_layout
22373
22374 \end_inset
22375
22376 -stack-auto
22377 \begin_inset LatexCommand \index{-\/-stack-auto}
22378
22379 \end_inset
22380
22381  and section 
22382 \begin_inset LatexCommand \ref{sec:Parameters-and-Local-Variables}
22383
22384 \end_inset
22385
22386  Parameters and Local Variables.
22387 \end_layout
22388
22389 \begin_layout Itemize
22390
22391 \series bold
22392 opt_code_speed
22393 \series default
22394  
22395 \begin_inset LatexCommand \index{\#pragma opt\_code\_speed}
22396
22397 \end_inset
22398
22399 - The compiler will optimize code generation towards fast code, possibly
22400  at the expense of code size.
22401  Currently this has little effect.
22402 \end_layout
22403
22404 \begin_layout Itemize
22405
22406 \series bold
22407 opt_code_size
22408 \series default
22409  
22410 \begin_inset LatexCommand \index{\#pragma opt\_code\_size}
22411
22412 \end_inset
22413
22414 - The compiler will optimize code generation towards compact code, possibly
22415  at the expense of code speed.
22416  Currently this has little effect.
22417 \end_layout
22418
22419 \begin_layout Itemize
22420
22421 \series bold
22422 opt_code_balanced
22423 \series default
22424  
22425 \begin_inset LatexCommand \index{\#pragma opt\_code\_balanced}
22426
22427 \end_inset
22428
22429 - The compiler will attempt to generate code that is both compact and fast,
22430  as long as meeting one goal is not a detriment to the other (this is the
22431  default).
22432  
22433 \end_layout
22434
22435 \begin_layout Itemize
22436
22437 \series bold
22438 std_sdcc89
22439 \series default
22440  
22441 \begin_inset LatexCommand \index{\#pragma std\_sdcc89}
22442
22443 \end_inset
22444
22445 - Generally follow the C89 standard, but allow SDCC features that conflict
22446  with the standard (default).
22447 \end_layout
22448
22449 \begin_layout Itemize
22450
22451 \series bold
22452 std_c89
22453 \series default
22454  
22455 \begin_inset LatexCommand \index{\#pragma std\_c89}
22456
22457 \end_inset
22458
22459 - Follow the C89 standard and disable SDCC features that conflict with the
22460  standard.
22461 \end_layout
22462
22463 \begin_layout Itemize
22464
22465 \series bold
22466 std_sdcc99
22467 \series default
22468  
22469 \begin_inset LatexCommand \index{\#pragma std\_sdcc99}
22470
22471 \end_inset
22472
22473 - Generally follow the C99 standard, but allow SDCC features that conflict
22474  with the standard (incomplete support).
22475 \end_layout
22476
22477 \begin_layout Itemize
22478
22479 \series bold
22480 std_c99
22481 \series default
22482  
22483 \begin_inset LatexCommand \index{\#pragma std\_c99}
22484
22485 \end_inset
22486
22487 - Follow the C99 standard and disable SDCC features that conflict with the
22488  standard (incomplete support).
22489 \end_layout
22490
22491 \begin_layout Itemize
22492
22493 \series bold
22494 codeseg
22495 \series default
22496  <name>
22497 \begin_inset LatexCommand \index{\#pragma codeseg}
22498
22499 \end_inset
22500
22501 - Use this name (max.
22502  8 characters) for the code segment.
22503  See option -
22504 \begin_inset ERT
22505 status collapsed
22506
22507 \begin_layout Standard
22508
22509
22510 \backslash
22511 /
22512 \end_layout
22513
22514 \end_inset
22515
22516 -codeseg.
22517 \end_layout
22518
22519 \begin_layout Itemize
22520
22521 \series bold
22522 constseg
22523 \series default
22524  <name>
22525 \begin_inset LatexCommand \index{\#pragma constseg}
22526
22527 \end_inset
22528
22529 - Use this name (max.
22530  8 characters) for the const segment.
22531  See option -
22532 \begin_inset ERT
22533 status collapsed
22534
22535 \begin_layout Standard
22536
22537
22538 \backslash
22539 /
22540 \end_layout
22541
22542 \end_inset
22543
22544 -constseg.
22545 \end_layout
22546
22547 \begin_layout Standard
22548 The preprocessor SDCPP
22549 \begin_inset LatexCommand \index{sdcpp (preprocessor)}
22550
22551 \end_inset
22552
22553  supports the following #pragma directives:
22554 \end_layout
22555
22556 \begin_layout Itemize
22557
22558 \series bold
22559 pedantic_parse_number
22560 \series default
22561
22562 \begin_inset LatexCommand \index{pedantic}
22563
22564 \end_inset
22565
22566
22567 \begin_inset LatexCommand \index{\#pragma pedantic\_parse\_number}
22568
22569 \end_inset
22570
22571  (+ | -) 
22572 \begin_inset LatexCommand \label{ite:pedantic_parse_number}
22573
22574 \end_inset
22575
22576 - Pedantic parse numbers so that situations like 0xfe-LO_B(3) are parsed
22577  properly and the macro LO_B(3) gets expanded.
22578  Default is off.
22579  See also the -
22580 \begin_inset ERT
22581 status collapsed
22582
22583 \begin_layout Standard
22584
22585
22586 \backslash
22587 /
22588 \end_layout
22589
22590 \end_inset
22591
22592 -pedantic-parse-number command line option 
22593 \begin_inset LatexCommand \vpageref{lyx:-pedantic-parse-number}
22594
22595 \end_inset
22596
22597 .
22598  
22599 \newline
22600 Below is an example on how to use this pragma.
22601
22602 \emph on
22603  Note: this functionality is not in conformance with standard!
22604 \end_layout
22605
22606 \begin_layout Verse
22607
22608 \family typewriter
22609 #pragma pedantic_parse_number +
22610 \begin_inset LatexCommand \index{\#pragma pedantic\_parse\_number}
22611
22612 \end_inset
22613
22614
22615 \newline
22616
22617 \newline
22618 #define LO_B(x) ((x) & 0xff)
22619 \newline
22620
22621 \newline
22622 unsigned char foo(void)
22623 \newline
22624 {
22625 \newline
22626 \InsetSpace ~
22627 \InsetSpace ~
22628 \InsetSpace ~
22629 unsigned char c=0xfe-LO_B(3)
22630 ;
22631 \newline
22632
22633 \newline
22634 \InsetSpace ~
22635 \InsetSpace ~
22636 \InsetSpace ~
22637 return c;
22638 \newline
22639 }
22640 \newline
22641
22642 \end_layout
22643
22644 \begin_layout Itemize
22645
22646 \series bold
22647 preproc_asm
22648 \series default
22649
22650 \begin_inset LatexCommand \index{\#pragma preproc\_asm}
22651
22652 \end_inset
22653
22654  (+ | -) - switch _asm _endasm block preprocessing on / off.
22655  Default is on.
22656  You use this prama to define multilines of assembly code.
22657  This will prevent the preprocessor from changing the formating required
22658  by assembly code.
22659  Below is an example on how to use this pragma.
22660 \end_layout
22661
22662 \begin_layout Verse
22663
22664 \family typewriter
22665 #pragma preproc_asm -
22666 \begin_inset LatexCommand \index{\#pragma preproc\_asm}
22667
22668 \end_inset
22669
22670
22671 \newline
22672 #define MYDELAY _asm
22673 \newline
22674 \InsetSpace ~
22675 \InsetSpace ~
22676 \InsetSpace ~
22677 nop ;my assembly comment...
22678 \newline
22679 \InsetSpace ~
22680 \InsetSpace ~
22681 \InsetSpace ~
22682 nop
22683 \newline
22684 \InsetSpace ~
22685 \InsetSpace ~
22686 \InsetSpace ~
22687 nop
22688 \newline
22689 _endasm
22690 \newline
22691 #pragma preproc_asm
22692  +
22693 \newline
22694
22695 \newline
22696 void foo (void) 
22697 \newline
22698
22699 \newline
22700 \InsetSpace ~
22701 \InsetSpace ~
22702 \InsetSpace ~
22703  ...
22704  
22705 \newline
22706 \InsetSpace ~
22707 \InsetSpace ~
22708 \InsetSpace ~
22709  MYDELAY;
22710 \newline
22711 \InsetSpace ~
22712 \InsetSpace ~
22713 \InsetSpace ~
22714  ...
22715  
22716 \newline
22717
22718 \newline
22719
22720 \end_layout
22721
22722 \begin_layout Itemize
22723
22724 \series bold
22725 sdcc_hash
22726 \series default
22727
22728 \begin_inset LatexCommand \index{\#pragma sdcc\_hash}
22729
22730 \end_inset
22731
22732  (+ | -) - Allow "naked" hash in macro definition, for example:
22733 \newline
22734
22735 \family typewriter
22736 #define DIR_LO(x) #(x & 0xff)
22737 \family default
22738
22739 \newline
22740 Default is off.
22741  Below is an example on how to use this pragma.
22742 \end_layout
22743
22744 \begin_layout Verse
22745
22746 \family typewriter
22747 #pragma preproc_asm +
22748 \newline
22749 #pragma sdcc_hash +
22750 \begin_inset LatexCommand \index{\#pragma sdcc\_hash}
22751
22752 \end_inset
22753
22754
22755 \newline
22756
22757 \newline
22758 #define ROMCALL(x) 
22759 \backslash
22760
22761 \newline
22762 \InsetSpace ~
22763 \InsetSpace ~
22764 \InsetSpace ~
22765 mov R6_B3, #(x & 0xff) 
22766 \backslash
22767
22768 \newline
22769 \InsetSpace ~
22770 \InsetSpace ~
22771 \InsetSpace ~
22772 mov R7_B3, #((x >> 8) & 0xff) 
22773 \backslash
22774
22775 \newline
22776 \InsetSpace ~
22777 \InsetSpace ~
22778 \InsetSpace ~
22779 lcall __romcall
22780 \newline
22781
22782 \newline
22783 ...
22784 \newline
22785 _asm
22786 \newline
22787 ROMCALL(72)
22788 \newline
22789 _endasm;
22790 \newline
22791 ...
22792 \newline
22793
22794 \end_layout
22795
22796 \begin_layout Standard
22797 Some of the pragmas are intended to be used to turn-on or off certain optimizati
22798 ons which might cause the compiler to generate extra stack and/or data space
22799  to store compiler generated temporary variables.
22800  This usually happens in large functions.
22801  Pragma directives should be used as shown in the following example, they
22802  are used to control options and optimizations for a given function.
22803  
22804 \end_layout
22805
22806 \begin_layout Verse
22807
22808 \family typewriter
22809 #pragma save
22810 \begin_inset LatexCommand \index{\#pragma save}
22811
22812 \end_inset
22813
22814  \InsetSpace ~
22815 \InsetSpace ~
22816 \InsetSpace ~
22817 \InsetSpace ~
22818 \InsetSpace ~
22819 \InsetSpace ~
22820 \InsetSpace ~
22821 /* save the current settings */ 
22822 \newline
22823 #pragma nogcse
22824 \begin_inset LatexCommand \index{\#pragma nogcse}
22825
22826 \end_inset
22827
22828  \InsetSpace ~
22829 \InsetSpace ~
22830 \InsetSpace ~
22831 \InsetSpace ~
22832 \InsetSpace ~
22833 /* turnoff global subexpression elimination */ 
22834 \newline
22835 #pragma noinduction
22836 \begin_inset LatexCommand \index{\#pragma noinduction}
22837
22838 \end_inset
22839
22840  /* turn off induction optimizations */ 
22841 \newline
22842 int foo () 
22843 \newline
22844
22845 \newline
22846 \InsetSpace ~
22847  \InsetSpace ~
22848  ...
22849  
22850 \newline
22851 \InsetSpace ~
22852  \InsetSpace ~
22853  /* large code */ 
22854 \newline
22855 \InsetSpace ~
22856  \InsetSpace ~
22857  ...
22858  
22859 \newline
22860
22861 \newline
22862 #pragma restore
22863 \begin_inset LatexCommand \index{\#pragma restore}
22864
22865 \end_inset
22866
22867  /* turn the optimizations back on */
22868 \end_layout
22869
22870 \begin_layout Standard
22871 The compiler will generate a warning message when extra space is allocated.
22872  It is strongly recommended that the save and restore pragmas be used when
22873  changing options for a function.
22874 \newline
22875
22876 \newline
22877
22878 \newline
22879
22880 \end_layout
22881
22882 \begin_layout Section
22883 Defines Created by the Compiler
22884 \end_layout
22885
22886 \begin_layout Standard
22887 The compiler creates the following #defines
22888 \begin_inset LatexCommand \index{\#defines}
22889
22890 \end_inset
22891
22892
22893 \begin_inset LatexCommand \index{Defines created by the compiler}
22894
22895 \end_inset
22896
22897 :
22898 \newline
22899
22900 \end_layout
22901
22902 \begin_layout Standard
22903 \begin_inset Tabular
22904 <lyxtabular version="3" rows="15" columns="2">
22905 <features>
22906 <column alignment="left" valignment="top" leftline="true" width="3in">
22907 <column alignment="left" valignment="top" leftline="true" rightline="true" width="3in">
22908 <row topline="true" bottomline="true">
22909 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
22910 \begin_inset Text
22911
22912 \begin_layout Standard
22913
22914 \series bold
22915 #define
22916 \end_layout
22917
22918 \end_inset
22919 </cell>
22920 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
22921 \begin_inset Text
22922
22923 \begin_layout Standard
22924
22925 \series bold
22926 Description
22927 \end_layout
22928
22929 \end_inset
22930 </cell>
22931 </row>
22932 <row topline="true">
22933 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
22934 \begin_inset Text
22935
22936 \begin_layout Standard
22937 SDCC
22938 \begin_inset LatexCommand \index{SDCC}
22939
22940 \end_inset
22941
22942  
22943 \end_layout
22944
22945 \end_inset
22946 </cell>
22947 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
22948 \begin_inset Text
22949
22950 \begin_layout Standard
22951 Always defined.
22952  Since version 2.5.6 the version number as an int (ex.
22953  256)
22954 \end_layout
22955
22956 \end_inset
22957 </cell>
22958 </row>
22959 <row topline="true">
22960 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
22961 \begin_inset Text
22962
22963 \begin_layout Standard
22964 SDCC_mcs51
22965 \begin_inset LatexCommand \index{SDCC\_mcs51}
22966
22967 \end_inset
22968
22969  or SDCC_ds390
22970 \begin_inset LatexCommand \index{SDCC\_ds390}
22971
22972 \end_inset
22973
22974  or SDCC_z80
22975 \begin_inset LatexCommand \index{SDCC\_z80}
22976
22977 \end_inset
22978
22979 , etc.
22980 \end_layout
22981
22982 \end_inset
22983 </cell>
22984 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
22985 \begin_inset Text
22986
22987 \begin_layout Standard
22988 depending on the model used (e.g.: -mds390)
22989 \end_layout
22990
22991 \end_inset
22992 </cell>
22993 </row>
22994 <row topline="true">
22995 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
22996 \begin_inset Text
22997
22998 \begin_layout Standard
22999 __mcs51
23000 \begin_inset LatexCommand \index{\_\_mcs51}
23001
23002 \end_inset
23003
23004 , __ds390
23005 \begin_inset LatexCommand \index{\_\_ds390}
23006
23007 \end_inset
23008
23009 , __hc08
23010 \begin_inset LatexCommand \index{\_\_hc08}
23011
23012 \end_inset
23013
23014 , __z80
23015 \begin_inset LatexCommand \index{\_\_z80}
23016
23017 \end_inset
23018
23019 , etc
23020 \end_layout
23021
23022 \end_inset
23023 </cell>
23024 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
23025 \begin_inset Text
23026
23027 \begin_layout Standard
23028 depending on the model used (e.g.
23029  -mz80)
23030 \end_layout
23031
23032 \end_inset
23033 </cell>
23034 </row>
23035 <row topline="true">
23036 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
23037 \begin_inset Text
23038
23039 \begin_layout Standard
23040 SDCC_STACK_AUTO
23041 \begin_inset LatexCommand \index{SDCC\_STACK\_AUTO}
23042
23043 \end_inset
23044
23045
23046 \end_layout
23047
23048 \end_inset
23049 </cell>
23050 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
23051 \begin_inset Text
23052
23053 \begin_layout Standard
23054 when 
23055 \emph on
23056 -
23057 \begin_inset ERT
23058 status collapsed
23059
23060 \begin_layout Standard
23061
23062
23063 \backslash
23064 /
23065 \end_layout
23066
23067 \end_inset
23068
23069 -stack-auto
23070 \emph default
23071  option is used
23072 \end_layout
23073
23074 \end_inset
23075 </cell>
23076 </row>
23077 <row topline="true">
23078 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
23079 \begin_inset Text
23080
23081 \begin_layout Standard
23082 SDCC_MODEL_SMALL
23083 \begin_inset LatexCommand \index{SDCC\_MODEL\_SMALL}
23084
23085 \end_inset
23086
23087
23088 \end_layout
23089
23090 \end_inset
23091 </cell>
23092 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
23093 \begin_inset Text
23094
23095 \begin_layout Standard
23096 when 
23097 \emph on
23098 -
23099 \begin_inset ERT
23100 status collapsed
23101
23102 \begin_layout Standard
23103
23104
23105 \backslash
23106 /
23107 \end_layout
23108
23109 \end_inset
23110
23111 -model-small
23112 \emph default
23113  is used
23114 \end_layout
23115
23116 \end_inset
23117 </cell>
23118 </row>
23119 <row topline="true">
23120 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
23121 \begin_inset Text
23122
23123 \begin_layout Standard
23124 SDCC_MODEL_MEDIUM
23125 \begin_inset LatexCommand \index{SDCC\_MODEL\_MEDIUM}
23126
23127 \end_inset
23128
23129
23130 \end_layout
23131
23132 \end_inset
23133 </cell>
23134 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
23135 \begin_inset Text
23136
23137 \begin_layout Standard
23138 when 
23139 \emph on
23140 -
23141 \begin_inset ERT
23142 status collapsed
23143
23144 \begin_layout Standard
23145
23146
23147 \backslash
23148 /
23149 \end_layout
23150
23151 \end_inset
23152
23153 -model-medium
23154 \emph default
23155  is used
23156 \end_layout
23157
23158 \end_inset
23159 </cell>
23160 </row>
23161 <row topline="true">
23162 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
23163 \begin_inset Text
23164
23165 \begin_layout Standard
23166 SDCC_MODEL_LARGE
23167 \begin_inset LatexCommand \index{SDCC\_MODEL\_LARGE}
23168
23169 \end_inset
23170
23171
23172 \end_layout
23173
23174 \end_inset
23175 </cell>
23176 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
23177 \begin_inset Text
23178
23179 \begin_layout Standard
23180 when 
23181 \emph on
23182 -
23183 \begin_inset ERT
23184 status collapsed
23185
23186 \begin_layout Standard
23187
23188
23189 \backslash
23190 /
23191 \end_layout
23192
23193 \end_inset
23194
23195 -model-large
23196 \emph default
23197  is used
23198 \end_layout
23199
23200 \end_inset
23201 </cell>
23202 </row>
23203 <row topline="true">
23204 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
23205 \begin_inset Text
23206
23207 \begin_layout Standard
23208 SDCC_USE_XSTACK
23209 \begin_inset LatexCommand \index{SDCC\_USE\_XSTACK}
23210
23211 \end_inset
23212
23213
23214 \end_layout
23215
23216 \end_inset
23217 </cell>
23218 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
23219 \begin_inset Text
23220
23221 \begin_layout Standard
23222 when 
23223 \emph on
23224 -
23225 \begin_inset ERT
23226 status collapsed
23227
23228 \begin_layout Standard
23229
23230
23231 \backslash
23232 /
23233 \end_layout
23234
23235 \end_inset
23236
23237 -xstack
23238 \emph default
23239  option is used
23240 \end_layout
23241
23242 \end_inset
23243 </cell>
23244 </row>
23245 <row topline="true">
23246 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
23247 \begin_inset Text
23248
23249 \begin_layout Standard
23250 SDCC_STACK_TENBIT
23251 \begin_inset LatexCommand \index{SDCC\_STACK\_TENBIT}
23252
23253 \end_inset
23254
23255  
23256 \end_layout
23257
23258 \end_inset
23259 </cell>
23260 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
23261 \begin_inset Text
23262
23263 \begin_layout Standard
23264 when 
23265 \emph on
23266 -mds390
23267 \emph default
23268  is used
23269 \end_layout
23270
23271 \end_inset
23272 </cell>
23273 </row>
23274 <row topline="true">
23275 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
23276 \begin_inset Text
23277
23278 \begin_layout Standard
23279 SDCC_MODEL_FLAT24
23280 \begin_inset LatexCommand \index{SDCC\_MODEL\_FLAT24}
23281
23282 \end_inset
23283
23284
23285 \end_layout
23286
23287 \end_inset
23288 </cell>
23289 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
23290 \begin_inset Text
23291
23292 \begin_layout Standard
23293 when 
23294 \emph on
23295 -mds390
23296 \emph default
23297  is used
23298 \end_layout
23299
23300 \end_inset
23301 </cell>
23302 </row>
23303 <row topline="true">
23304 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
23305 \begin_inset Text
23306
23307 \begin_layout Standard
23308 SDCC_REVISION
23309 \begin_inset LatexCommand \index{SDCC\_REVISION}
23310
23311 \end_inset
23312
23313
23314 \end_layout
23315
23316 \end_inset
23317 </cell>
23318 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
23319 \begin_inset Text
23320
23321 \begin_layout Standard
23322 Always defined.
23323  SDCC svn revision number
23324 \end_layout
23325
23326 \end_inset
23327 </cell>
23328 </row>
23329 <row topline="true">
23330 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
23331 \begin_inset Text
23332
23333 \begin_layout Standard
23334 SDCC_PARMS_IN_BANK1
23335 \begin_inset LatexCommand \index{SDCC\_PARMS\_IN\_BANK1}
23336
23337 \end_inset
23338
23339
23340 \end_layout
23341
23342 \end_inset
23343 </cell>
23344 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
23345 \begin_inset Text
23346
23347 \begin_layout Standard
23348 when 
23349 \emph on
23350 -
23351 \begin_inset ERT
23352 status collapsed
23353
23354 \begin_layout Standard
23355
23356
23357 \backslash
23358 /
23359 \end_layout
23360
23361 \end_inset
23362
23363 -parms-in-bank1
23364 \emph default
23365  is used
23366 \end_layout
23367
23368 \end_inset
23369 </cell>
23370 </row>
23371 <row topline="true">
23372 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
23373 \begin_inset Text
23374
23375 \begin_layout Standard
23376 SDCC_FLOAT_REENT
23377 \begin_inset LatexCommand \index{SDCC\_MODEL\_FLAT24}
23378
23379 \end_inset
23380
23381
23382 \end_layout
23383
23384 \end_inset
23385 </cell>
23386 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
23387 \begin_inset Text
23388
23389 \begin_layout Standard
23390 when 
23391 \emph on
23392 -
23393 \begin_inset ERT
23394 status collapsed
23395
23396 \begin_layout Standard
23397
23398
23399 \backslash
23400 /
23401 \end_layout
23402
23403 \end_inset
23404
23405 -float-reent
23406 \emph default
23407  is used
23408 \end_layout
23409
23410 \end_inset
23411 </cell>
23412 </row>
23413 <row topline="true" bottomline="true">
23414 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
23415 \begin_inset Text
23416
23417 \begin_layout Standard
23418 SDCC_INT_LONG_REENT
23419 \begin_inset LatexCommand \index{SDCC\_INT\_LONG\_REENT}
23420
23421 \end_inset
23422
23423
23424 \end_layout
23425
23426 \end_inset
23427 </cell>
23428 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
23429 \begin_inset Text
23430
23431 \begin_layout Standard
23432 when 
23433 \emph on
23434 -
23435 \begin_inset ERT
23436 status collapsed
23437
23438 \begin_layout Standard
23439
23440
23441 \backslash
23442 /
23443 \end_layout
23444
23445 \end_inset
23446
23447 -int-long-reent
23448 \emph default
23449  is used
23450 \end_layout
23451
23452 \end_inset
23453 </cell>
23454 </row>
23455 </lyxtabular>
23456
23457 \end_inset
23458
23459
23460 \end_layout
23461
23462 \begin_layout Chapter
23463 Notes on supported Processors
23464 \end_layout
23465
23466 \begin_layout Section
23467 MCS51 variants
23468 \begin_inset LatexCommand \label{sub:MCS51-variants}
23469
23470 \end_inset
23471
23472
23473 \begin_inset LatexCommand \index{MCS51 variants}
23474
23475 \end_inset
23476
23477
23478 \end_layout
23479
23480 \begin_layout Standard
23481 MCS51 processors are available from many vendors and come in many different
23482  flavours.
23483  While they might differ considerably in respect to Special Function Registers
23484  the core MCS51 is usually not modified or is kept compatible.
23485  
23486 \end_layout
23487
23488 \begin_layout Subsection
23489 pdata access by SFR 
23490 \end_layout
23491
23492 \begin_layout Standard
23493 With the upcome of devices with internal xdata and flash memory devices
23494  using port P2
23495 \begin_inset LatexCommand \index{P2 (mcs51 sfr)}
23496
23497 \end_inset
23498
23499  as dedicated I/O port is becoming more popular.
23500  Switching the high byte for pdata
23501 \begin_inset LatexCommand \index{pdata (mcs51, ds390 storage class)}
23502
23503 \end_inset
23504
23505  access which was formerly done by port P2 is then achieved by a Special
23506  Function Register
23507 \begin_inset LatexCommand \index{sfr}
23508
23509 \end_inset
23510
23511 .
23512  In well-established MCS51 tradition the address of this 
23513 \emph on
23514 sfr
23515 \emph default
23516  is where the chip designers decided to put it.
23517  Needless to say that they didn't agree on a common name either.
23518  So that the startup code can correctly initialize xdata variables, you
23519  should define an sfr with the name _XPAGE
23520 \family typewriter
23521
23522 \begin_inset LatexCommand \index{\_XPAGE (mcs51)}
23523
23524 \end_inset
23525
23526
23527 \family default
23528  at the appropriate location if the default, port P2, is not used for this.
23529  Some examples are:
23530 \end_layout
23531
23532 \begin_layout Verse
23533
23534 \family typewriter
23535 __sfr __at (0x85) _XPAGE; /* Ramtron VRS51 family a.k.a.
23536  MPAGE */
23537 \end_layout
23538
23539 \begin_layout Verse
23540
23541 \family typewriter
23542 __sfr __at (0x92) _XPAGE; /* Cypress EZ-USB family, Texas Instruments (Chipcon)
23543  a.k.a.
23544  MPAGE */
23545 \end_layout
23546
23547 \begin_layout Verse
23548
23549 \family typewriter
23550 __sfr __at (0x91) _XPAGE; /* Infineon (Siemens) C500 family a.k.a.
23551  XPAGE */
23552 \end_layout
23553
23554 \begin_layout Verse
23555
23556 \family typewriter
23557 __sfr __at (0xaf) _XPAGE; /* some Silicon Labs (Cygnal) chips a.k.a.
23558  EMI0CN */
23559 \end_layout
23560
23561 \begin_layout Verse
23562
23563 \family typewriter
23564 __sfr __at (0xaa) _XPAGE; /* some Silicon Labs (Cygnal) chips a.k.a.
23565  EMI0CN */
23566 \end_layout
23567
23568 \begin_layout Standard
23569 For more exotic implementations further customizations may be needed.
23570  See section 
23571 \begin_inset LatexCommand \ref{sub:Startup-Code}
23572
23573 \end_inset
23574
23575  for other possibilities.
23576 \end_layout
23577
23578 \begin_layout Subsection
23579 Other Features available by SFR
23580 \end_layout
23581
23582 \begin_layout Standard
23583 Some MCS51 variants offer features like Double DPTR
23584 \begin_inset LatexCommand \index{DPTR}
23585
23586 \end_inset
23587
23588 , multiple DPTR, decrementing DPTR, 16x16 Multiply.
23589  These are currently not used for the MCS51 port.
23590  If you absolutely need them you can fall back to inline assembly or submit
23591  a patch to SDCC.
23592 \end_layout
23593
23594 \begin_layout Subsection
23595 Bankswitching
23596 \end_layout
23597
23598 \begin_layout Standard
23599 Bankswitching
23600 \begin_inset LatexCommand \index{Bankswitching}
23601
23602 \end_inset
23603
23604  (a.k.a.
23605  code banking
23606 \begin_inset LatexCommand \index{code banking}
23607
23608 \end_inset
23609
23610 ) is a technique to increase the code space above the 64k limit of the 8051.
23611 \end_layout
23612
23613 \begin_layout Subsubsection
23614 Hardware
23615 \end_layout
23616
23617 \begin_layout Standard
23618 \begin_inset Tabular
23619 <lyxtabular version="3" rows="3" columns="4">
23620 <features>
23621 <column alignment="center" valignment="top" width="0">
23622 <column alignment="center" valignment="top" leftline="true" width="0">
23623 <column alignment="center" valignment="top" leftline="true" width="0">
23624 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
23625 <row topline="true" bottomline="true">
23626 <cell multicolumn="1" alignment="center" valignment="top" usebox="none">
23627 \begin_inset Text
23628
23629 \begin_layout Standard
23630 8000-FFFF
23631 \end_layout
23632
23633 \end_inset
23634 </cell>
23635 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
23636 \begin_inset Text
23637
23638 \begin_layout Standard
23639 bank1
23640 \end_layout
23641
23642 \end_inset
23643 </cell>
23644 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
23645 \begin_inset Text
23646
23647 \begin_layout Standard
23648 bank2
23649 \end_layout
23650
23651 \end_inset
23652 </cell>
23653 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
23654 \begin_inset Text
23655
23656 \begin_layout Standard
23657 bank3
23658 \end_layout
23659
23660 \end_inset
23661 </cell>
23662 </row>
23663 <row topline="true" bottomline="true">
23664 <cell multicolumn="1" alignment="center" valignment="top" usebox="none">
23665 \begin_inset Text
23666
23667 \begin_layout Standard
23668 0000-7FFF
23669 \end_layout
23670
23671 \end_inset
23672 </cell>
23673 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
23674 \begin_inset Text
23675
23676 \begin_layout Standard
23677 common
23678 \end_layout
23679
23680 \end_inset
23681 </cell>
23682 <cell multicolumn="1" alignment="center" valignment="top" usebox="none">
23683 \begin_inset Text
23684
23685 \begin_layout Standard
23686
23687 \end_layout
23688
23689 \end_inset
23690 </cell>
23691 <cell multicolumn="2" alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
23692 \begin_inset Text
23693
23694 \begin_layout Standard
23695
23696 \end_layout
23697
23698 \end_inset
23699 </cell>
23700 </row>
23701 <row>
23702 <cell multicolumn="1" alignment="center" valignment="top" usebox="none">
23703 \begin_inset Text
23704
23705 \begin_layout Standard
23706 SiLabs C8051F120 example
23707 \end_layout
23708
23709 \end_inset
23710 </cell>
23711 <cell multicolumn="2" alignment="center" valignment="top" usebox="none">
23712 \begin_inset Text
23713
23714 \begin_layout Standard
23715
23716 \end_layout
23717
23718 \end_inset
23719 </cell>
23720 <cell multicolumn="2" alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
23721 \begin_inset Text
23722
23723 \begin_layout Standard
23724
23725 \end_layout
23726
23727 \end_inset
23728 </cell>
23729 <cell multicolumn="2" alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
23730 \begin_inset Text
23731
23732 \begin_layout Standard
23733
23734 \end_layout
23735
23736 \end_inset
23737 </cell>
23738 </row>
23739 </lyxtabular>
23740
23741 \end_inset
23742
23743
23744 \newline
23745
23746 \newline
23747 Usually the hardware uses some sfr (an output port or an internal sfr) to
23748  select a bank and put it in the banked area of the memory map.
23749  The selected bank usually becomes active immediately upon assignment to
23750  this sfr and when running inside a bank it will switch out this code it
23751  is currently running.
23752  Therefor you cannot jump or call directly from one bank to another and
23753  need to use a so-called trampoline in the common area.
23754  For SDCC an example trampoline is in crtbank.asm and you may need to change
23755  it to your 8051 derivative or schematic.
23756  The presented code is written for the C8051F120.
23757 \newline
23758
23759 \newline
23760 When calling a banked function
23761  SDCC will put the LSB of the functions address in register R0, the MSB
23762  in R1 and the bank in R2 and then call this trampoline 
23763 \emph on
23764 __sdcc_banked_call
23765 \emph default
23766 .
23767  The current selected bank is saved on the stack, the new bank is selected
23768  and an indirect jump is made.
23769  When the banked function returns it jumps to 
23770 \emph on
23771 __sdcc_banked_ret
23772 \emph default
23773  which restores the previous bank and returns to the caller.
23774 \end_layout
23775
23776 \begin_layout Subsubsection
23777 Software
23778 \end_layout
23779
23780 \begin_layout Standard
23781 When writing banked software using SDCC you need to use some special keywords
23782  and options.
23783  You also need to take over a bit of work from the linker.
23784 \newline
23785
23786 \newline
23787 To create a function
23788  that can be called from another bank it requires the keyword 
23789 \emph on
23790 banked
23791 \emph default
23792
23793 \begin_inset LatexCommand \index{banked}
23794
23795 \end_inset
23796
23797 .
23798  The caller must see this in the prototype of the callee and the callee
23799  needs it for a proper return.
23800  Called functions within the same bank as the caller do not need the 
23801 \emph on
23802 banked
23803 \emph default
23804  keyword nor do functions in the common area.
23805  Beware: SDCC does not know or check if functions are in the same bank.
23806  This is your responsibility!
23807 \newline
23808
23809 \newline
23810 Normally all functions you write end up in
23811  the segment CSEG.
23812  If you want a function explicitly to reside in the common area put it in
23813  segment HOME.
23814  This applies for instance to interrupt service routines as they should
23815  not be banked.
23816 \end_layout
23817
23818 \begin_layout Standard
23819 Functions that need to be in a switched bank must be put in a named segment.
23820  The name can be mostly anything upto eight characters (e.g.
23821  BANK1).
23822  To do this you either use -
23823 \begin_inset ERT
23824 status collapsed
23825
23826 \begin_layout Standard
23827
23828
23829 \backslash
23830 /
23831 \end_layout
23832
23833 \end_inset
23834
23835 -codeseg BANK1 (See 
23836 \begin_inset LatexCommand \ref{lyx:-codeseg}
23837
23838 \end_inset
23839
23840 ) on the command line when compiling or #pragma codeseg BANK1 (See 
23841 \begin_inset LatexCommand \ref{sec:Pragmas}
23842
23843 \end_inset
23844
23845 ) at the top of the C source file.
23846  The segment name always applies to the whole source file and generated
23847  object so functions for different banks need to be defined in different
23848  source files.
23849 \newline
23850
23851 \newline
23852 When linking your objects you need to tell the linker where
23853  to put your segments.
23854  To do this you use the following command line option to SDCC: -Wl-b BANK1=0x180
23855 00 (See 
23856 \begin_inset LatexCommand \ref{lyx:-Wl option}
23857
23858 \end_inset
23859
23860 ).
23861  This sets the virtual start address of this segment.
23862  It sets the banknumber to 0x01 and maps the bank to 0x8000 and up.
23863  The linker will not check for overflows, again this is your responsibility.
23864 \end_layout
23865
23866 \begin_layout Standard
23867 \begin_inset VSpace bigskip
23868 \end_inset
23869
23870
23871 \end_layout
23872
23873 \begin_layout Section
23874 DS400 port
23875 \end_layout
23876
23877 \begin_layout Standard
23878 The DS80C400
23879 \begin_inset LatexCommand \index{DS80C400}
23880
23881 \end_inset
23882
23883
23884 \begin_inset LatexCommand \index{DS400}
23885
23886 \end_inset
23887
23888  microcontroller has a rich set of peripherals.
23889  In its built-in ROM library it includes functions to access some of the
23890  features, among them is a TCP stack with IP4 and IP6 support.
23891  Library headers (currently in beta status) and other files are provided
23892  at 
23893 \size footnotesize
23894
23895 \begin_inset LatexCommand \url{ftp://ftp.dalsemi.com/pub/tini/ds80c400/c_libraries/sdcc/index.html}
23896
23897 \end_inset
23898
23899 .
23900  
23901 \begin_inset VSpace bigskip
23902 \end_inset
23903
23904
23905 \end_layout
23906
23907 \begin_layout Section
23908 The Z80 and gbz80 port
23909 \end_layout
23910
23911 \begin_layout Standard
23912 SDCC can target both the Zilog Z80
23913 \begin_inset LatexCommand \index{Z80}
23914
23915 \end_inset
23916
23917  and the Nintendo Gameboy's Z80-like gbz80
23918 \begin_inset LatexCommand \index{gbz80 (GameBoy Z80)}
23919
23920 \end_inset
23921
23922 .
23923  The Z80 port is passed through the same 
23924 \emph on
23925 regressions tests
23926 \begin_inset LatexCommand \index{Regression test}
23927
23928 \end_inset
23929
23930
23931 \emph default
23932  (see section 
23933 \begin_inset LatexCommand \ref{sec:Quality-control}
23934
23935 \end_inset
23936
23937 ) as the MCS51 and DS390 ports, so floating point support, support for long
23938  variables and bitfield support is fine.
23939  See mailing lists and forums about interrupt routines.
23940 \end_layout
23941
23942 \begin_layout Standard
23943 As always, the code is the authoritative reference - see z80/ralloc.c and
23944  z80/gen.c.
23945  The stack
23946 \begin_inset LatexCommand \index{Z80!stack}
23947
23948 \end_inset
23949
23950  frame is similar to that generated by the IAR Z80 compiler.
23951  IX is used as the base pointer, HL and IY are used as a temporary registers,
23952  and BC and DE are available for holding variables.
23953  Return values
23954 \begin_inset LatexCommand \index{Z80!return value}
23955
23956 \end_inset
23957
23958  for the Z80 port are stored in L (one byte), HL (two bytes), or DEHL (four
23959  bytes).
23960  The gbz80 port use the same set of registers for the return values, but
23961  in a different order of significance: E (one byte), DE (two bytes), or
23962  HLDE (four bytes).
23963 \begin_inset VSpace bigskip
23964 \end_inset
23965
23966
23967 \end_layout
23968
23969 \begin_layout Section
23970 The HC08 port
23971 \end_layout
23972
23973 \begin_layout Standard
23974 The port to the Freescale/Motorola HC08
23975 \begin_inset LatexCommand \index{HC08}
23976
23977 \end_inset
23978
23979  family has been added in October 2003, and is still undergoing some basic
23980  development.
23981  The code generator is complete, but the register allocation is still quite
23982  unoptimized.
23983  Some of the SDCC's standard C library functions have embedded non-HC08
23984  inline assembly and so are not yet usable.
23985 \end_layout
23986
23987 \begin_layout Standard
23988 The HC08 port passes the regression test suite (see section 
23989 \begin_inset LatexCommand \ref{sec:Quality-control}
23990
23991 \end_inset
23992
23993 ).
23994 \begin_inset VSpace bigskip
23995 \end_inset
23996
23997
23998 \end_layout
23999
24000 \begin_layout Section
24001 The PIC14
24002 \begin_inset LatexCommand \index{PIC14}
24003
24004 \end_inset
24005
24006  port
24007 \end_layout
24008
24009 \begin_layout Standard
24010 The PIC14 port adds support for Microchip
24011 \begin_inset LatexCommand \index{Microchip}
24012
24013 \end_inset
24014
24015
24016 \begin_inset Formula $^{\text{TM}}$
24017 \end_inset
24018
24019  PIC
24020 \begin_inset LatexCommand \index{PIC14}
24021
24022 \end_inset
24023
24024
24025 \begin_inset Formula $^{\text{TM}}$
24026 \end_inset
24027
24028  MCUs with 14 bit wide instructions.
24029  This port is not yet mature and still lacks many features.
24030  However, it can work for simple code.
24031 \end_layout
24032
24033 \begin_layout Standard
24034 \noindent
24035 Currently supported devices include:
24036 \end_layout
24037
24038 \begin_layout Standard
24039 12F: 629, 635, 675, 683
24040 \end_layout
24041
24042 \begin_layout Standard
24043 16C: 432, 433
24044 \end_layout
24045
24046 \begin_layout Standard
24047 16C: 554, 557, 558
24048 \end_layout
24049
24050 \begin_layout Standard
24051 16C: 62, 620, 620a, 621, 621a, 622, 622a, 63a, 65b
24052 \end_layout
24053
24054 \begin_layout Standard
24055 16C: 71, 710, 711, 715, 717, 72, 73b, 745, 74b, 765, 770, 771, 773, 774,
24056  781, 782
24057 \end_layout
24058
24059 \begin_layout Standard
24060 16C: 925, 926
24061 \end_layout
24062
24063 \begin_layout Standard
24064 16CR: 620a, 73, 74, 76, 77
24065 \end_layout
24066
24067 \begin_layout Standard
24068 16F: 616, 627, 627a, 628, 628a, 630, 636, 639, 648, 648a, 676, 684, 685,
24069  687, 688, 689, 690
24070 \end_layout
24071
24072 \begin_layout Standard
24073 16F: 716, 72, 73, 737, 74, 747, 76, 767, 77, 777, 785
24074 \end_layout
24075
24076 \begin_layout Standard
24077 16F: 818, 819, 84, 84a, 87, 870, 871, 872, 873, 873a, 874, 874a, 876, 876a,
24078  877, 877a, 88, 886, 887
24079 \end_layout
24080
24081 \begin_layout Standard
24082 16F: 913, 914, 916, 917, 946
24083 \end_layout
24084
24085 \begin_layout Standard
24086 26HV: 626, 785
24087 \end_layout
24088
24089 \begin_layout Standard
24090 \noindent
24091 An up-to-date list of currently supported devices can be obtained via 
24092 \family typewriter
24093 sdcc -mpic14 -phelp foo.c
24094 \family default
24095  (foo.c must exist...).
24096 \end_layout
24097
24098 \begin_layout Subsection
24099 PIC Code Pages
24100 \begin_inset LatexCommand \index{code page (pic14)}
24101
24102 \end_inset
24103
24104  and Memory Banks
24105 \begin_inset LatexCommand \index{Memory bank (pic14)}
24106
24107 \end_inset
24108
24109
24110 \end_layout
24111
24112 \begin_layout Standard
24113 The linker organizes allocation for the code page and RAM banks.
24114  It does not have intimate knowledge of the code flow.
24115  It will put all the code section of a single .asm file into a single code
24116  page.
24117  In order to make use of multiple code pages, separate asm files must be
24118  used.
24119  The compiler assigns all 
24120 \emph on
24121 static
24122 \emph default
24123  functions of a single .c file into the same code page.
24124 \newline
24125
24126 \newline
24127 To get the best results,
24128  follow these guidelines:
24129 \end_layout
24130
24131 \begin_layout Enumerate
24132 Make local functions static, as non static functions require code page selection
24133  overhead.
24134 \newline
24135 Due to the way sdcc handles functions, place called functions prior
24136  to calling functions in the file wherever possible: Otherwise sdcc will
24137  insert unneccessary pagesel directives around the call, believing that
24138  the called function is externally defined.
24139 \end_layout
24140
24141 \begin_layout Enumerate
24142 For devices that have multiple code pages it is more efficient to use the
24143  same number of files as pages: Use up to 4 separate .c files for the 16F877,
24144  but only 2 files for the 16F874.
24145  This way the linker can put the code for each file into different code
24146  pages and there will be less page selection overhead.
24147 \end_layout
24148
24149 \begin_layout Enumerate
24150 And as for any 8 bit micro (especially for PIC14 as they have a very simple
24151  instruction set), use `unsigned char' wherever possible instead of `int'.
24152 \end_layout
24153
24154 \begin_layout Subsection
24155 Adding New Devices to the Port 
24156 \end_layout
24157
24158 \begin_layout Standard
24159 Adding support for a new 14
24160 \begin_inset ERT
24161 status open
24162
24163 \begin_layout Standard
24164
24165
24166 \backslash
24167 ,
24168 \end_layout
24169
24170 \end_inset
24171
24172 bit PIC MCU requires the following steps:
24173 \end_layout
24174
24175 \begin_layout Enumerate
24176 Create a new device description.
24177 \newline
24178 Each device is described in two files: pic16f*.h
24179  and pic16f*.c.
24180  These files primarily define SFRs, structs to access their bits, and symbolic
24181  configuration options.
24182  Both files can be generated from gputils' .inc files using the perl script
24183  
24184 \family typewriter
24185 support/scripts/inc2h.pl
24186 \family default
24187 .
24188  This file also contains further instructions on how to proceed.
24189 \end_layout
24190
24191 \begin_layout Enumerate
24192 Copy the .h file into SDCC's include path and either add the .c file to your
24193  project or copy it to 
24194 \family typewriter
24195 device/lib/pic/libdev
24196 \family default
24197 .
24198  Afterwards, rebuild and install the libraries.
24199 \end_layout
24200
24201 \begin_layout Enumerate
24202 Edit pic14devices.txt in SDCC's include path (
24203 \family typewriter
24204 device/include/pic/
24205 \family default
24206  in the source tree or 
24207 \family typewriter
24208 /usr/local/share/sdcc/include/pic
24209 \family default
24210  after installation).
24211 \newline
24212 You need to add a device specification here to make
24213  the memory layout (code banks, RAM, aliased memory regions, ...) known to
24214  the compiler.
24215  Probably you can copy and modify an existing entry.
24216  The file format is documented at the top of the file.
24217 \end_layout
24218
24219 \begin_layout Subsection
24220 Interrupt Code
24221 \end_layout
24222
24223 \begin_layout Standard
24224 For the interrupt function, use the keyword `__interrupt'
24225 \begin_inset LatexCommand \index{PIC14!interrupt}
24226
24227 \end_inset
24228
24229  with level number of 0 (PIC14 only has 1 interrupt so this number is only
24230  there to avoid a syntax error - it ought to be fixed).
24231  E.g.:
24232 \end_layout
24233
24234 \begin_layout Verse
24235
24236 \family typewriter
24237 void Intr(void) __interrupt 0
24238 \newline
24239 {
24240 \newline
24241 \InsetSpace ~
24242 \InsetSpace ~
24243 T0IF = 0; /* Clear timer interrupt */
24244 \newline
24245 }
24246 \end_layout
24247
24248 \begin_layout Subsection
24249 Linking and Assembling
24250 \end_layout
24251
24252 \begin_layout Standard
24253 For assembling you can use either GPUTILS'
24254 \begin_inset LatexCommand \index{gputils (pic tools)}
24255
24256 \end_inset
24257
24258  gpasm.exe or MPLAB's mpasmwin.exe.
24259  GPUTILS are available from 
24260 \begin_inset LatexCommand \url{http://sourceforge.net/projects/gputils}
24261
24262 \end_inset
24263
24264 .
24265  For linking you can use either GPUTILS' gplink or MPLAB's mplink.exe.
24266  If you use MPLAB and an interrupt function then the linker script file
24267  vectors section will need to be enlarged to link with mplink.
24268 \newline
24269
24270 \newline
24271 Here is a 
24272 \family typewriter
24273 Makefile
24274 \family default
24275  using GPUTILS:
24276 \end_layout
24277
24278 \begin_layout Verse
24279
24280 \family typewriter
24281 .c.o:
24282 \newline
24283 \InsetSpace ~
24284 \InsetSpace ~
24285 \InsetSpace ~
24286 \InsetSpace ~
24287 \InsetSpace ~
24288 \InsetSpace ~
24289 \InsetSpace ~
24290 \InsetSpace ~
24291 sdcc -V -mpic14 -p16f877 -c $< 
24292 \newline
24293
24294 \newline
24295 $(PRJ).hex: $(OBJS) 
24296 \newline
24297 \InsetSpace ~
24298 \InsetSpace ~
24299 \InsetSpace ~
24300 \InsetSpace ~
24301 \InsetSpace ~
24302 \InsetSpace ~
24303 \InsetSpace ~
24304 \InsetSpace ~
24305 gplink -m -s $(PRJ).lkr
24306  -o $(PRJ).hex $(OBJS) libsdcc.lib
24307 \end_layout
24308
24309 \begin_layout Standard
24310 Here is a 
24311 \family typewriter
24312 Makefile
24313 \family default
24314  using MPLAB:
24315 \end_layout
24316
24317 \begin_layout Verse
24318
24319 \family typewriter
24320 .c.o: 
24321 \newline
24322 \InsetSpace ~
24323 \InsetSpace ~
24324 \InsetSpace ~
24325 \InsetSpace ~
24326 \InsetSpace ~
24327 \InsetSpace ~
24328 \InsetSpace ~
24329 \InsetSpace ~
24330 sdcc -S -V -mpic14 -p16f877 $< 
24331 \newline
24332 \InsetSpace ~
24333 \InsetSpace ~
24334 \InsetSpace ~
24335 \InsetSpace ~
24336 \InsetSpace ~
24337 \InsetSpace ~
24338 \InsetSpace ~
24339 \InsetSpace ~
24340 mpasmwin /q /o $*.asm
24341 \newline
24342
24343 \newline
24344 $(PRJ).hex: $(OBJS)
24345  
24346 \newline
24347 \InsetSpace ~
24348 \InsetSpace ~
24349 \InsetSpace ~
24350 \InsetSpace ~
24351 \InsetSpace ~
24352 \InsetSpace ~
24353 \InsetSpace ~
24354 \InsetSpace ~
24355 mplink /v $(PRJ).lkr /m $(PRJ).map /o $(PRJ).hex $(OBJS) libsdcc.lib
24356 \end_layout
24357
24358 \begin_layout Standard
24359 Please note that indentations within a
24360 \family typewriter
24361  Makefile
24362 \family default
24363  have to be done with a tabulator character.
24364 \end_layout
24365
24366 \begin_layout Subsection
24367 Command-Line Options
24368 \end_layout
24369
24370 \begin_layout Standard
24371 Besides the switches common to all SDCC backends, the PIC14 port accepts
24372  the following options (for an updated list see sdcc -
24373 \begin_inset ERT
24374 status collapsed
24375
24376 \begin_layout Standard
24377
24378
24379 \backslash
24380 /
24381 \end_layout
24382
24383 \end_inset
24384
24385 -help):
24386 \end_layout
24387
24388 \begin_layout Description
24389 -
24390 \begin_inset ERT
24391 status collapsed
24392
24393 \begin_layout Standard
24394
24395
24396 \backslash
24397 /
24398 \end_layout
24399
24400 \end_inset
24401
24402 -debug-xtra
24403 \begin_inset LatexCommand \index{PIC14!Options!-\/-debug-extra}
24404
24405 \end_inset
24406
24407  emit debug info in assembly output
24408 \end_layout
24409
24410 \begin_layout Description
24411 -
24412 \begin_inset ERT
24413 status collapsed
24414
24415 \begin_layout Standard
24416
24417
24418 \backslash
24419 /
24420 \end_layout
24421
24422 \end_inset
24423
24424 -no-pcode-opt
24425 \begin_inset LatexCommand \index{PIC14!Options!-\/-no-pcode-opt}
24426
24427 \end_inset
24428
24429  disable (slightly faulty) optimization on pCode
24430 \end_layout
24431
24432 \begin_layout Description
24433 -
24434 \begin_inset ERT
24435 status collapsed
24436
24437 \begin_layout Standard
24438
24439
24440 \backslash
24441 /
24442 \end_layout
24443
24444 \end_inset
24445
24446 -stack-loc
24447 \begin_inset LatexCommand \index{PIC14!Options!-\/-stack-loc}
24448
24449 \end_inset
24450
24451  sets the lowest address of the argument passing stack (defaults to a suitably
24452  large shared databank to reduce BANKSEL overhead)
24453 \end_layout
24454
24455 \begin_layout Description
24456 -
24457 \begin_inset ERT
24458 status collapsed
24459
24460 \begin_layout Standard
24461
24462
24463 \backslash
24464 /
24465 \end_layout
24466
24467 \end_inset
24468
24469 -stack-size
24470 \begin_inset LatexCommand \index{PIC14!Options!-\/-stack-size}
24471
24472 \end_inset
24473
24474  sets the size if the argument passing stack (default: 16, minimum: 4)
24475 \end_layout
24476
24477 \begin_layout Subsection
24478 Environment Variables
24479 \end_layout
24480
24481 \begin_layout Standard
24482 The PIC14 port recognizes the following environment variables:
24483 \end_layout
24484
24485 \begin_layout Description
24486 SDCC_PIC14_SPLIT_LOCALS If set and not empty, sdcc will allocate each temporary
24487  register (the ones called r0xNNNN) in a section of its own.
24488  By default (if this variable is unset), sdcc tries to cluster registers
24489  in sections in order to reduce the BANKSEL overhead when accessing them.
24490 \end_layout
24491
24492 \begin_layout Subsection
24493 The Library
24494 \end_layout
24495
24496 \begin_layout Standard
24497 The PIC14 library currently only contains support routines required by the
24498  compiler to implement multiplication, division, and floating point support.
24499  No libc-like replacement is available at the moment, though many of the
24500  common sdcc library sources (in 
24501 \family typewriter
24502 device/lib
24503 \family default
24504 ) should also compile with the PIC14 port.
24505 \end_layout
24506
24507 \begin_layout Subsubsection
24508 error: missing definition for symbol ``__gptrget1''
24509 \end_layout
24510
24511 \begin_layout Standard
24512 The PIC14 port uses library routines to provide more complex operations
24513  like multiplication, division/modulus and (generic) pointer dereferencing.
24514  In order to add these routines to your project, you must link with PIC14's
24515  
24516 \family typewriter
24517 libsdcc.lib
24518 \family default
24519 .
24520  For single source file projects this is done automatically, more complex
24521  projects must add 
24522 \family typewriter
24523 libsdcc.lib
24524 \family default
24525  to the linker's arguments.
24526  Make sure you also add an include path for the library (using the -I switch
24527  to the linker)!
24528 \end_layout
24529
24530 \begin_layout Subsubsection
24531 Processor mismatch in file ``XXX''.
24532 \end_layout
24533
24534 \begin_layout Standard
24535 This warning can usually be ignored due to the very good compatibility amongst
24536  14
24537 \begin_inset ERT
24538 status open
24539
24540 \begin_layout Standard
24541
24542
24543 \backslash
24544 ,
24545 \end_layout
24546
24547 \end_inset
24548
24549 bit PIC
24550 \begin_inset LatexCommand \index{PIC14}
24551
24552 \end_inset
24553
24554  devices.
24555 \end_layout
24556
24557 \begin_layout Standard
24558 You might also consider recompiling the library for your specific device
24559  by changing the ARCH=p16f877 (default target) entry in 
24560 \family typewriter
24561 device/lib/pic/Makefile.in
24562 \family default
24563  and 
24564 \family typewriter
24565 device/lib/pic/Makefile
24566 \family default
24567  to reflect your device.
24568  This might even improve performance for smaller devices as unneccesary
24569  BANKSELs might be removed.
24570 \end_layout
24571
24572 \begin_layout Subsection
24573 Known Bugs
24574 \end_layout
24575
24576 \begin_layout Subsubsection
24577 Function arguments
24578 \end_layout
24579
24580 \begin_layout Standard
24581 Functions with variable argument lists (like printf) are not yet supported.
24582  Similarly, taking the address of the first argument passed into a function
24583  does not work: It is currently passed in WREG and has no address...
24584 \end_layout
24585
24586 \begin_layout Subsubsection
24587 Regression tests fail
24588 \end_layout
24589
24590 \begin_layout Standard
24591 Though the small subset of regression tests in src/regression passes, SDCC
24592  regression test suite does not, indicating that there are still major bugs
24593  in the port.
24594  However, many smaller projects have successfully used SDCC in the past...
24595 \end_layout
24596
24597 \begin_layout Standard
24598
24599 \size footnotesize
24600
24601 \newpage
24602
24603 \end_layout
24604
24605 \begin_layout Section
24606 The PIC16
24607 \begin_inset LatexCommand \index{PIC16}
24608
24609 \end_inset
24610
24611  port
24612 \end_layout
24613
24614 \begin_layout Standard
24615 The PIC16 port adds support for Microchip
24616 \begin_inset LatexCommand \index{Microchip}
24617
24618 \end_inset
24619
24620
24621 \begin_inset Formula $^{\text{TM}}$
24622 \end_inset
24623
24624  PIC
24625 \begin_inset LatexCommand \index{PIC}
24626
24627 \end_inset
24628
24629
24630 \begin_inset Formula $^{\text{TM}}$
24631 \end_inset
24632
24633  MCUs with 16 bit wide instructions.
24634  Currently this family of microcontrollers contains the PIC18Fxxx and PIC18Fxxxx
24635 ; devices supported by the port include:
24636 \end_layout
24637
24638 \begin_layout Standard
24639 18F: 242, 248, 252, 258, 442, 448, 452, 458
24640 \end_layout
24641
24642 \begin_layout Standard
24643 18F: 1220, 1320
24644 \end_layout
24645
24646 \begin_layout Standard
24647 18F: 2220, 2221, 2320, 2321, 2331, 2410, 2420, 2423, 2431, 2450, 2455, 2480,
24648  24j10
24649 \end_layout
24650
24651 \begin_layout Standard
24652 18F: (2510,) 2515, 2520, 2523, 2525, 2550, 2580, 2585, 25j10, 2610, 2620,
24653  2680, 2682, 2685
24654 \end_layout
24655
24656 \begin_layout Standard
24657 18F: 4220, 4221, 4320, 4321, 4331, 4410, 4420, 4423, 4431, 4450, 4455, 4480,
24658  44j10
24659 \end_layout
24660
24661 \begin_layout Standard
24662 18F: 4510, 4515, 4520, 4523, 4525, 4550, 4580, 4585, 45j10, 4610, 4620,
24663  4680, 4682, 4685
24664 \end_layout
24665
24666 \begin_layout Standard
24667 18F: 6520, 6585, 6620, 6680, 66j60, 66j65, 6720, 67j60
24668 \end_layout
24669
24670 \begin_layout Standard
24671 18F: 8520, 8585, 8620, 8680, 86j60, 86j65, 8720, 87j60
24672 \end_layout
24673
24674 \begin_layout Standard
24675 18F: 96j60, 96j65, 97j60
24676 \end_layout
24677
24678 \begin_layout Standard
24679 \noindent
24680 An up-to-date list of supported devices is also available via '
24681 \family typewriter
24682 sdcc -mpic16 -plist
24683 \family default
24684 '.
24685 \end_layout
24686
24687 \begin_layout Subsection
24688 Global Options
24689 \end_layout
24690
24691 \begin_layout Standard
24692 PIC16 port supports the standard command line arguments as supposed, with
24693  the exception of certain cases that will be mentioned in the following
24694  list:
24695 \end_layout
24696
24697 \begin_layout Description
24698 -
24699 \begin_inset ERT
24700 status collapsed
24701
24702 \begin_layout Standard
24703
24704
24705 \backslash
24706 /
24707 \end_layout
24708
24709 \end_inset
24710
24711 -callee-saves
24712 \begin_inset LatexCommand \index{PIC16!Options!-\/-callee-saves}
24713
24714 \end_inset
24715
24716  See -
24717 \begin_inset ERT
24718 status collapsed
24719
24720 \begin_layout Standard
24721
24722
24723 \backslash
24724 /
24725 \end_layout
24726
24727 \end_inset
24728
24729 -all-callee-saves
24730 \end_layout
24731
24732 \begin_layout Description
24733 -
24734 \begin_inset ERT
24735 status collapsed
24736
24737 \begin_layout Standard
24738
24739
24740 \backslash
24741 /
24742 \end_layout
24743
24744 \end_inset
24745
24746 -fommit-frame-pointer
24747 \begin_inset LatexCommand \index{PIC16!Options!-\/-fommit-frame-pointer}
24748
24749 \end_inset
24750
24751  Frame pointer will be omitted when the function uses no local variables.
24752 \end_layout
24753
24754 \begin_layout Subsection
24755 Port Specific Options
24756 \begin_inset LatexCommand \index{Options PIC16}
24757
24758 \end_inset
24759
24760
24761 \end_layout
24762
24763 \begin_layout Standard
24764 The port specific options appear after the global options in the sdcc -
24765 \begin_inset ERT
24766 status collapsed
24767
24768 \begin_layout Standard
24769
24770
24771 \backslash
24772 /
24773 \end_layout
24774
24775 \end_inset
24776
24777 -help output.
24778 \end_layout
24779
24780 \begin_layout Subsubsection
24781 Code Generation Options
24782 \end_layout
24783
24784 \begin_layout Standard
24785 These options influence the generated assembler code.
24786 \end_layout
24787
24788 \begin_layout Description
24789 -
24790 \begin_inset ERT
24791 status collapsed
24792
24793 \begin_layout Standard
24794
24795
24796 \backslash
24797 /
24798 \end_layout
24799
24800 \end_inset
24801
24802 -pstack-model=[model] Used in conjuction with the command above.
24803  Defines the stack model to be used, valid stack models are:
24804 \end_layout
24805
24806 \begin_deeper
24807 \begin_layout List
24808 \labelwidthstring 00.00.0000
24809
24810 \emph on
24811 small
24812 \emph default
24813  Selects small stack model.
24814  8 bit stack and frame pointers.
24815  Supports 256 bytes stack size.
24816 \end_layout
24817
24818 \begin_layout List
24819 \labelwidthstring 00.00.0000
24820
24821 \emph on
24822 large
24823 \emph default
24824  Selects large stack model.
24825  16 bit stack and frame pointers.
24826  Supports 65536 bytes stack size.
24827 \end_layout
24828
24829 \end_deeper
24830 \begin_layout Description
24831 -
24832 \begin_inset ERT
24833 status collapsed
24834
24835 \begin_layout Standard
24836
24837
24838 \backslash
24839 /
24840 \end_layout
24841
24842 \end_inset
24843
24844 -pno-banksel Do not generate BANKSEL assembler directives.
24845 \end_layout
24846
24847 \begin_layout Description
24848 -
24849 \begin_inset ERT
24850 status collapsed
24851
24852 \begin_layout Standard
24853
24854
24855 \backslash
24856 /
24857 \end_layout
24858
24859 \end_inset
24860
24861 -extended Enable extended instruction set/literal offset addressing mode.
24862  Use with care!
24863 \end_layout
24864
24865 \begin_layout Subsubsection
24866 Optimization Options
24867 \end_layout
24868
24869 \begin_layout Description
24870 -
24871 \begin_inset ERT
24872 status collapsed
24873
24874 \begin_layout Standard
24875
24876
24877 \backslash
24878 /
24879 \end_layout
24880
24881 \end_inset
24882
24883 -obanksel=n Set optimization level for inserting BANKSELs.
24884 \newline
24885
24886 \end_layout
24887
24888 \begin_deeper
24889 \begin_layout List
24890 \labelwidthstring 00.00.0000
24891 0 no optimization
24892 \end_layout
24893
24894 \begin_layout List
24895 \labelwidthstring 00.00.0000
24896 1 checks previous used register and if it is the same then does not emit
24897  BANKSEL, accounts only for labels.
24898 \end_layout
24899
24900 \begin_layout List
24901 \labelwidthstring 00.00.0000
24902 2 tries to check the location of (even different) symbols and removes BANKSELs
24903  if they are in the same bank.
24904  
24905 \newline
24906
24907 \emph on
24908 Important: There might be problems if the linker script has data sections
24909  across bank borders!
24910 \end_layout
24911
24912 \end_deeper
24913 \begin_layout Description
24914 -
24915 \begin_inset ERT
24916 status collapsed
24917
24918 \begin_layout Standard
24919
24920
24921 \backslash
24922 /
24923 \end_layout
24924
24925 \end_inset
24926
24927 -denable-peeps Force the usage of peepholes.
24928  Use with care.
24929 \end_layout
24930
24931 \begin_layout Description
24932 -
24933 \begin_inset ERT
24934 status collapsed
24935
24936 \begin_layout Standard
24937
24938
24939 \backslash
24940 /
24941 \end_layout
24942
24943 \end_inset
24944
24945 -no-optimize-goto Do not use (conditional) BRA instead of GOTO.
24946 \end_layout
24947
24948 \begin_layout Description
24949 -
24950 \begin_inset ERT
24951 status collapsed
24952
24953 \begin_layout Standard
24954
24955
24956 \backslash
24957 /
24958 \end_layout
24959
24960 \end_inset
24961
24962 -optimize-cmp Try to optimize some compares.
24963 \end_layout
24964
24965 \begin_layout Description
24966 -
24967 \begin_inset ERT
24968 status collapsed
24969
24970 \begin_layout Standard
24971
24972
24973 \backslash
24974 /
24975 \end_layout
24976
24977 \end_inset
24978
24979 -optimize-df Analyze the dataflow of the generated code and improve it.
24980 \end_layout
24981
24982 \begin_layout Subsubsection
24983 Assembling Options
24984 \end_layout
24985
24986 \begin_layout Description
24987 -
24988 \begin_inset ERT
24989 status collapsed
24990
24991 \begin_layout Standard
24992
24993
24994 \backslash
24995 /
24996 \end_layout
24997
24998 \end_inset
24999
25000 -asm= Sets the full path and name of an external assembler to call.
25001 \end_layout
25002
25003 \begin_layout Description
25004 -
25005 \begin_inset ERT
25006 status collapsed
25007
25008 \begin_layout Standard
25009
25010
25011 \backslash
25012 /
25013 \end_layout
25014
25015 \end_inset
25016
25017 -mplab-comp MPLAB
25018 \begin_inset LatexCommand \index{PIC16!MPLAB}
25019
25020 \end_inset
25021
25022  compatibility option.
25023  Currently only suppresses special gpasm directives.
25024 \end_layout
25025
25026 \begin_layout Subsubsection
25027 Linking Options
25028 \end_layout
25029
25030 \begin_layout Description
25031 -
25032 \begin_inset ERT
25033 status collapsed
25034
25035 \begin_layout Standard
25036
25037
25038 \backslash
25039 /
25040 \end_layout
25041
25042 \end_inset
25043
25044 -link= Sets the full path and name of an external linker to call.
25045 \end_layout
25046
25047 \begin_layout Description
25048 -
25049 \begin_inset ERT
25050 status collapsed
25051
25052 \begin_layout Standard
25053
25054
25055 \backslash
25056 /
25057 \end_layout
25058
25059 \end_inset
25060
25061 -preplace-udata-with=[kword] Replaces the default udata keyword for allocating
25062  unitialized data variables with [kword].
25063  Valid keywords are: "udata_acs", "udata_shr", "udata_ovr".
25064 \end_layout
25065
25066 \begin_layout Description
25067 -
25068 \begin_inset ERT
25069 status collapsed
25070
25071 \begin_layout Standard
25072
25073
25074 \backslash
25075 /
25076 \end_layout
25077
25078 \end_inset
25079
25080 -ivt-loc=n Place the interrupt vector table at address 
25081 \emph on
25082 n
25083 \emph default
25084 .
25085  Useful for bootloaders.
25086 \end_layout
25087
25088 \begin_layout Description
25089 -
25090 \begin_inset ERT
25091 status collapsed
25092
25093 \begin_layout Standard
25094
25095
25096 \backslash
25097 /
25098 \end_layout
25099
25100 \end_inset
25101
25102 -nodefaultlibs Do not link default libraries when linking.
25103 \end_layout
25104
25105 \begin_layout Description
25106 -
25107 \begin_inset ERT
25108 status collapsed
25109
25110 \begin_layout Standard
25111
25112
25113 \backslash
25114 /
25115 \end_layout
25116
25117 \end_inset
25118
25119 -use-crt= Use a custom run-time module instead of the defaults.
25120 \end_layout
25121
25122 \begin_layout Description
25123 -
25124 \begin_inset ERT
25125 status collapsed
25126
25127 \begin_layout Standard
25128
25129
25130 \backslash
25131 /
25132 \end_layout
25133
25134 \end_inset
25135
25136 -no-crt Don't link the default run-time modules
25137 \end_layout
25138
25139 \begin_layout Subsubsection
25140 Debugging Options
25141 \end_layout
25142
25143 \begin_layout Standard
25144 Debugging options enable extra debugging information in the output files.
25145 \end_layout
25146
25147 \begin_layout Description
25148 -
25149 \begin_inset ERT
25150 status collapsed
25151
25152 \begin_layout Standard
25153
25154
25155 \backslash
25156 /
25157 \end_layout
25158
25159 \end_inset
25160
25161 -debug-xtra Similar to -
25162 \begin_inset ERT
25163 status collapsed
25164
25165 \begin_layout Standard
25166
25167
25168 \backslash
25169 /
25170 \end_layout
25171
25172 \end_inset
25173
25174 -debug
25175 \begin_inset LatexCommand \index{-\/-debug}
25176
25177 \end_inset
25178
25179 , but dumps more information.
25180 \end_layout
25181
25182 \begin_layout Description
25183 -
25184 \begin_inset ERT
25185 status collapsed
25186
25187 \begin_layout Standard
25188
25189
25190 \backslash
25191 /
25192 \end_layout
25193
25194 \end_inset
25195
25196 -debug-ralloc Force register allocator to dump <source>.d file with debugging
25197  information.
25198  <source> is the name of the file being compiled.
25199 \end_layout
25200
25201 \begin_layout Description
25202 -
25203 \begin_inset ERT
25204 status collapsed
25205
25206 \begin_layout Standard
25207
25208
25209 \backslash
25210 /
25211 \end_layout
25212
25213 \end_inset
25214
25215 -pcode-verbose Enable pcode debugging information in translation.
25216 \end_layout
25217
25218 \begin_layout Description
25219 -
25220 \begin_inset ERT
25221 status collapsed
25222
25223 \begin_layout Standard
25224
25225
25226 \backslash
25227 /
25228 \end_layout
25229
25230 \end_inset
25231
25232 -calltree Dump call tree in .calltree file.
25233 \end_layout
25234
25235 \begin_layout Description
25236 -
25237 \begin_inset ERT
25238 status collapsed
25239
25240 \begin_layout Standard
25241
25242
25243 \backslash
25244 /
25245 \end_layout
25246
25247 \end_inset
25248
25249 -gstack Trace push/pops for stack pointer overflow.
25250 \end_layout
25251
25252 \begin_layout Subsection
25253 Enviroment Variables
25254 \end_layout
25255
25256 \begin_layout Standard
25257 There is a number of enviromental variables that can be used when running
25258  SDCC to enable certain optimizations or force a specific program behaviour.
25259  these variables are primarily for debugging purposes so they can be enabled/dis
25260 abled at will.
25261 \end_layout
25262
25263 \begin_layout Standard
25264 Currently there is only two such variables available:
25265 \end_layout
25266
25267 \begin_layout Description
25268 OPTIMIZE_BITFIELD_POINTER_GET When this variable exists, reading of structure
25269  bitfields is optimized by directly loading FSR0 with the address of the
25270  bitfield structure.
25271  Normally SDCC will cast the bitfield structure to a bitfield pointer and
25272  then load FSR0.
25273  This step saves data ram and code space for functions that make heavy use
25274  of bitfields.
25275  (i.e., 80 bytes of code space are saved when compiling malloc.c with this
25276  option).
25277  
25278 \end_layout
25279
25280 \begin_layout Description
25281 NO_REG_OPT Do not perform pCode registers optimization.
25282  This should be used for debugging purposes.
25283  If bugs in the pcode optimizer are found, users can benefit from temporarily
25284  disabling the optimizer until the bug is fixed.
25285 \end_layout
25286
25287 \begin_layout Subsection
25288 Preprocessor Macros
25289 \end_layout
25290
25291 \begin_layout Standard
25292 PIC16
25293 \begin_inset LatexCommand \index{PIC16}
25294
25295 \end_inset
25296
25297  port defines the following preprocessor macros while translating a source.
25298 \end_layout
25299
25300 \begin_layout Standard
25301 \align center
25302 \begin_inset Tabular
25303 <lyxtabular version="3" rows="6" columns="2">
25304 <features>
25305 <column alignment="center" valignment="top" leftline="true" width="0">
25306 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
25307 <row topline="true" bottomline="true">
25308 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25309 \begin_inset Text
25310
25311 \begin_layout Standard
25312 Macro
25313 \end_layout
25314
25315 \end_inset
25316 </cell>
25317 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
25318 \begin_inset Text
25319
25320 \begin_layout Standard
25321 Description
25322 \end_layout
25323
25324 \end_inset
25325 </cell>
25326 </row>
25327 <row topline="true">
25328 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25329 \begin_inset Text
25330
25331 \begin_layout Standard
25332 SDCC_pic16
25333 \end_layout
25334
25335 \end_inset
25336 </cell>
25337 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
25338 \begin_inset Text
25339
25340 \begin_layout Standard
25341 Port identification
25342 \end_layout
25343
25344 \end_inset
25345 </cell>
25346 </row>
25347 <row topline="true">
25348 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25349 \begin_inset Text
25350
25351 \begin_layout Standard
25352 _
25353 \begin_inset ERT
25354 status collapsed
25355
25356 \begin_layout Standard
25357
25358
25359 \backslash
25360 /
25361 \end_layout
25362
25363 \end_inset
25364
25365 _pic16
25366 \end_layout
25367
25368 \end_inset
25369 </cell>
25370 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
25371 \begin_inset Text
25372
25373 \begin_layout Standard
25374 Port identification (same as above)
25375 \end_layout
25376
25377 \end_inset
25378 </cell>
25379 </row>
25380 <row topline="true">
25381 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25382 \begin_inset Text
25383
25384 \begin_layout Standard
25385 pic18fxxxx
25386 \end_layout
25387
25388 \end_inset
25389 </cell>
25390 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
25391 \begin_inset Text
25392
25393 \begin_layout Standard
25394 MCU Identification.
25395  
25396 \emph on
25397 xxxx
25398 \emph default
25399  is the microcontrol identification number, i.e.
25400  452, 6620, etc
25401 \end_layout
25402
25403 \end_inset
25404 </cell>
25405 </row>
25406 <row topline="true">
25407 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25408 \begin_inset Text
25409
25410 \begin_layout Standard
25411 _
25412 \begin_inset ERT
25413 status collapsed
25414
25415 \begin_layout Standard
25416
25417
25418 \backslash
25419 /
25420 \end_layout
25421
25422 \end_inset
25423
25424 _18Fxxxx
25425 \end_layout
25426
25427 \end_inset
25428 </cell>
25429 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
25430 \begin_inset Text
25431
25432 \begin_layout Standard
25433 MCU Identification (same as above)
25434 \end_layout
25435
25436 \end_inset
25437 </cell>
25438 </row>
25439 <row topline="true" bottomline="true">
25440 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25441 \begin_inset Text
25442
25443 \begin_layout Standard
25444 STACK_MODEL_nnn
25445 \end_layout
25446
25447 \end_inset
25448 </cell>
25449 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
25450 \begin_inset Text
25451
25452 \begin_layout Standard
25453 nnn = SMALL or LARGE respectively according to the stack model used
25454 \end_layout
25455
25456 \end_inset
25457 </cell>
25458 </row>
25459 </lyxtabular>
25460
25461 \end_inset
25462
25463
25464 \end_layout
25465
25466 \begin_layout Standard
25467 \noindent
25468 In addition the following macros are defined when calling assembler:
25469 \end_layout
25470
25471 \begin_layout Standard
25472 \align center
25473 \begin_inset Tabular
25474 <lyxtabular version="3" rows="4" columns="2">
25475 <features>
25476 <column alignment="center" valignment="top" leftline="true" width="0">
25477 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
25478 <row topline="true" bottomline="true">
25479 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25480 \begin_inset Text
25481
25482 \begin_layout Standard
25483 Macro
25484 \end_layout
25485
25486 \end_inset
25487 </cell>
25488 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
25489 \begin_inset Text
25490
25491 \begin_layout Standard
25492 Description
25493 \end_layout
25494
25495 \end_inset
25496 </cell>
25497 </row>
25498 <row topline="true">
25499 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25500 \begin_inset Text
25501
25502 \begin_layout Standard
25503 __18Fxxxx
25504 \end_layout
25505
25506 \end_inset
25507 </cell>
25508 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
25509 \begin_inset Text
25510
25511 \begin_layout Standard
25512 MCU Identification.
25513  
25514 \emph on
25515 xxxx
25516 \emph default
25517  is the microcontrol identification number, i.e.
25518  452, 6620, etc
25519 \end_layout
25520
25521 \end_inset
25522 </cell>
25523 </row>
25524 <row topline="true">
25525 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25526 \begin_inset Text
25527
25528 \begin_layout Standard
25529 SDCC_MODEL_nnn
25530 \end_layout
25531
25532 \end_inset
25533 </cell>
25534 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
25535 \begin_inset Text
25536
25537 \begin_layout Standard
25538 nnn = SMALL or LARGE respectively according to the memory model used for
25539  SDCC
25540 \end_layout
25541
25542 \end_inset
25543 </cell>
25544 </row>
25545 <row topline="true" bottomline="true">
25546 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25547 \begin_inset Text
25548
25549 \begin_layout Standard
25550 STACK_MODEL_nnn
25551 \end_layout
25552
25553 \end_inset
25554 </cell>
25555 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
25556 \begin_inset Text
25557
25558 \begin_layout Standard
25559 nnn = SMALL or LARGE respectively according to the stack model used
25560 \end_layout
25561
25562 \end_inset
25563 </cell>
25564 </row>
25565 </lyxtabular>
25566
25567 \end_inset
25568
25569
25570 \end_layout
25571
25572 \begin_layout Subsection
25573 Directories
25574 \end_layout
25575
25576 \begin_layout Standard
25577 PIC16
25578 \begin_inset LatexCommand \index{PIC16}
25579
25580 \end_inset
25581
25582  port uses the following directories for searching header files and libraries.
25583 \end_layout
25584
25585 \begin_layout Standard
25586 \align center
25587 \begin_inset Tabular
25588 <lyxtabular version="3" rows="3" columns="4">
25589 <features>
25590 <column alignment="center" valignment="top" leftline="true" width="0">
25591 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
25592 <column alignment="center" valignment="top" width="0">
25593 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
25594 <row topline="true" bottomline="true">
25595 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25596 \begin_inset Text
25597
25598 \begin_layout Standard
25599 Directory
25600 \end_layout
25601
25602 \end_inset
25603 </cell>
25604 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
25605 \begin_inset Text
25606
25607 \begin_layout Standard
25608 Description
25609 \end_layout
25610
25611 \end_inset
25612 </cell>
25613 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
25614 \begin_inset Text
25615
25616 \begin_layout Standard
25617 Target
25618 \end_layout
25619
25620 \end_inset
25621 </cell>
25622 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
25623 \begin_inset Text
25624
25625 \begin_layout Standard
25626 Command prefix
25627 \end_layout
25628
25629 \end_inset
25630 </cell>
25631 </row>
25632 <row topline="true">
25633 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25634 \begin_inset Text
25635
25636 \begin_layout Standard
25637 PREFIX/sdcc/include/pic16
25638 \end_layout
25639
25640 \end_inset
25641 </cell>
25642 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
25643 \begin_inset Text
25644
25645 \begin_layout Standard
25646 PIC16 specific headers
25647 \end_layout
25648
25649 \end_inset
25650 </cell>
25651 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
25652 \begin_inset Text
25653
25654 \begin_layout Standard
25655 Compiler
25656 \end_layout
25657
25658 \end_inset
25659 </cell>
25660 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
25661 \begin_inset Text
25662
25663 \begin_layout Standard
25664 -I
25665 \end_layout
25666
25667 \end_inset
25668 </cell>
25669 </row>
25670 <row topline="true" bottomline="true">
25671 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25672 \begin_inset Text
25673
25674 \begin_layout Standard
25675 PREFIX/sdcc/lib/pic16
25676 \end_layout
25677
25678 \end_inset
25679 </cell>
25680 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
25681 \begin_inset Text
25682
25683 \begin_layout Standard
25684 PIC16 specific libraries
25685 \end_layout
25686
25687 \end_inset
25688 </cell>
25689 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
25690 \begin_inset Text
25691
25692 \begin_layout Standard
25693 Linker
25694 \end_layout
25695
25696 \end_inset
25697 </cell>
25698 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
25699 \begin_inset Text
25700
25701 \begin_layout Standard
25702 -L
25703 \end_layout
25704
25705 \end_inset
25706 </cell>
25707 </row>
25708 </lyxtabular>
25709
25710 \end_inset
25711
25712
25713 \end_layout
25714
25715 \begin_layout Subsection
25716 Pragmas
25717 \begin_inset LatexCommand \label{sub:PIC16_Pragmas}
25718
25719 \end_inset
25720
25721
25722 \end_layout
25723
25724 \begin_layout Standard
25725 The PIC16
25726 \begin_inset LatexCommand \index{PIC16}
25727
25728 \end_inset
25729
25730  port currently supports the following pragmas:
25731 \end_layout
25732
25733 \begin_layout Description
25734 stack
25735 \begin_inset LatexCommand \index{PIC16!Pragmas!\#pragma stack}
25736
25737 \end_inset
25738
25739  This forces the code generator to initialize the stack & frame pointers
25740  at a specific address.
25741  This is an ad hoc solution for cases where no STACK directive is available
25742  in the linker script or gplink is not instructed to create a stack section.
25743 \newline
25744 The
25745  stack pragma should be used only once in a project.
25746  Multiple pragmas may result in indeterminate behaviour of the program.
25747 \begin_inset Foot
25748 status open
25749
25750 \begin_layout Standard
25751 The old format (ie.
25752  #pragma stack 0x5ff) is deprecated and will cause the stack pointer to
25753  cross page boundaries (or even exceed the available data RAM) and crash
25754  the program.
25755  Make sure that stack does not cross page boundaries when using the SMALL
25756  stack model.
25757 \end_layout
25758
25759 \end_inset
25760
25761
25762 \newline
25763 The format is as follows:
25764 \newline
25765
25766 \end_layout
25767
25768 \begin_layout LyX-Code
25769 #pragma stack bottom_address [stack_size]
25770 \newline
25771
25772 \end_layout
25773
25774 \begin_layout Standard
25775
25776 \emph on
25777 bottom_address
25778 \emph default
25779  is the lower bound of the stack section.
25780  The stack pointer initially will point at address (bottom_address+stack_size-1).
25781 \end_layout
25782
25783 \begin_layout LyX-Code
25784 Example:
25785 \end_layout
25786
25787 \begin_layout LyX-Code
25788
25789 \end_layout
25790
25791 \begin_layout LyX-Code
25792 /* initializes stack of 100 bytes at RAM address 0x200 */
25793 \end_layout
25794
25795 \begin_layout LyX-Code
25796 #pragma stack 0x200 100
25797 \end_layout
25798
25799 \begin_layout Standard
25800 If the stack_size field is omitted then a stack is created with the default
25801  size of 64.
25802  This size might be enough for most programs, but its not enough for operations
25803  with deep function nesting or excessive stack usage.
25804 \end_layout
25805
25806 \begin_layout Description
25807 code
25808 \begin_inset LatexCommand \index{PIC16!Pragmas!\#pragma code}
25809
25810 \end_inset
25811
25812  Force a function to a static FLASH address.
25813 \end_layout
25814
25815 \begin_layout LyX-Code
25816 Example:
25817 \end_layout
25818
25819 \begin_layout LyX-Code
25820
25821 \end_layout
25822
25823 \begin_layout LyX-Code
25824 /* place function test_func at 0x4000 */
25825 \end_layout
25826
25827 \begin_layout LyX-Code
25828 #pragma code test_func 0x4000
25829 \end_layout
25830
25831 \begin_layout LyX-Code
25832
25833 \end_layout
25834
25835 \begin_layout Description
25836 library instructs the linker to use a library module.
25837 \newline
25838 Usage:
25839 \end_layout
25840
25841 \begin_layout LyX-Code
25842 #pragma library module_name
25843 \end_layout
25844
25845 \begin_layout Standard
25846
25847 \emph on
25848 module_name
25849 \emph default
25850  can be any library or object file (including its path).
25851  Note that there are four reserved keywords which have special meaning.
25852  These are:
25853 \end_layout
25854
25855 \begin_layout Standard
25856 \align center
25857 \begin_inset Tabular
25858 <lyxtabular version="3" rows="6" columns="3">
25859 <features>
25860 <column alignment="center" valignment="top" leftline="true" width="0">
25861 <column alignment="block" valignment="top" leftline="true" width="20page%">
25862 <column alignment="left" valignment="top" leftline="true" rightline="true" width="0">
25863 <row topline="true" bottomline="true">
25864 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25865 \begin_inset Text
25866
25867 \begin_layout Standard
25868 Keyword
25869 \end_layout
25870
25871 \end_inset
25872 </cell>
25873 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25874 \begin_inset Text
25875
25876 \begin_layout Standard
25877 Description
25878 \end_layout
25879
25880 \end_inset
25881 </cell>
25882 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
25883 \begin_inset Text
25884
25885 \begin_layout Standard
25886 Module to link
25887 \end_layout
25888
25889 \end_inset
25890 </cell>
25891 </row>
25892 <row topline="true">
25893 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25894 \begin_inset Text
25895
25896 \begin_layout Standard
25897
25898 \series bold
25899 ignore
25900 \end_layout
25901
25902 \end_inset
25903 </cell>
25904 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25905 \begin_inset Text
25906
25907 \begin_layout Standard
25908 ignore all library pragmas
25909 \end_layout
25910
25911 \end_inset
25912 </cell>
25913 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
25914 \begin_inset Text
25915
25916 \begin_layout Standard
25917
25918 \emph on
25919 (none)
25920 \end_layout
25921
25922 \end_inset
25923 </cell>
25924 </row>
25925 <row topline="true">
25926 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25927 \begin_inset Text
25928
25929 \begin_layout Standard
25930
25931 \series bold
25932 c
25933 \end_layout
25934
25935 \end_inset
25936 </cell>
25937 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25938 \begin_inset Text
25939
25940 \begin_layout Standard
25941 link the C library
25942 \end_layout
25943
25944 \end_inset
25945 </cell>
25946 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
25947 \begin_inset Text
25948
25949 \begin_layout Standard
25950
25951 \emph on
25952 libc18f
25953 \emph default
25954 .lib
25955 \end_layout
25956
25957 \end_inset
25958 </cell>
25959 </row>
25960 <row topline="true">
25961 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25962 \begin_inset Text
25963
25964 \begin_layout Standard
25965
25966 \series bold
25967 math
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 link the Math libarary
25977 \end_layout
25978
25979 \end_inset
25980 </cell>
25981 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
25982 \begin_inset Text
25983
25984 \begin_layout Standard
25985
25986 \emph on
25987 libm18f
25988 \emph default
25989 .lib
25990 \end_layout
25991
25992 \end_inset
25993 </cell>
25994 </row>
25995 <row topline="true">
25996 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25997 \begin_inset Text
25998
25999 \begin_layout Standard
26000
26001 \series bold
26002 io
26003 \end_layout
26004
26005 \end_inset
26006 </cell>
26007 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26008 \begin_inset Text
26009
26010 \begin_layout Standard
26011 link the I/O library
26012 \end_layout
26013
26014 \end_inset
26015 </cell>
26016 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26017 \begin_inset Text
26018
26019 \begin_layout Standard
26020
26021 \emph on
26022 libio18f*
26023 \emph default
26024 .lib
26025 \end_layout
26026
26027 \end_inset
26028 </cell>
26029 </row>
26030 <row topline="true" bottomline="true">
26031 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26032 \begin_inset Text
26033
26034 \begin_layout Standard
26035
26036 \series bold
26037 debug
26038 \end_layout
26039
26040 \end_inset
26041 </cell>
26042 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26043 \begin_inset Text
26044
26045 \begin_layout Standard
26046 link the debug library
26047 \end_layout
26048
26049 \end_inset
26050 </cell>
26051 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26052 \begin_inset Text
26053
26054 \begin_layout Standard
26055
26056 \emph on
26057 libdebug
26058 \emph default
26059 .lib
26060 \end_layout
26061
26062 \end_inset
26063 </cell>
26064 </row>
26065 </lyxtabular>
26066
26067 \end_inset
26068
26069
26070 \newline
26071 * is the device number, i.e.
26072  452 for PIC18F452 MCU.
26073 \end_layout
26074
26075 \begin_layout Standard
26076 \noindent
26077 This feature allows for linking with specific libraries withoug having to
26078  explicit name them in the command line.
26079  Note that the 
26080 \noun on
26081 ignore
26082 \noun default
26083  keyword will reject all modules specified by the library pragma.
26084 \end_layout
26085
26086 \begin_layout Description
26087 udata The pragma udata instructs the compiler to emit code so that linker
26088  will place a variable at a specific memory bank.
26089 \end_layout
26090
26091 \begin_layout LyX-Code
26092 Example:
26093 \end_layout
26094
26095 \begin_layout LyX-Code
26096
26097 \end_layout
26098
26099 \begin_layout LyX-Code
26100 /* places variable foo at bank2 */
26101 \end_layout
26102
26103 \begin_layout LyX-Code
26104 #pragma udata bank2 foo
26105 \end_layout
26106
26107 \begin_layout LyX-Code
26108 char foo;
26109 \end_layout
26110
26111 \begin_layout Standard
26112 In order for this pragma to work extra SECTION directives should be added
26113  in the .lkr script.
26114  In the following example a sample .lkr file is shown:
26115 \end_layout
26116
26117 \begin_layout LyX-Code
26118
26119 \end_layout
26120
26121 \begin_layout LyX-Code
26122 // Sample linker script for the PIC18F452 processor
26123 \end_layout
26124
26125 \begin_layout LyX-Code
26126 LIBPATH .
26127 \end_layout
26128
26129 \begin_layout LyX-Code
26130 CODEPAGE   NAME=vectors    START=0x0            END=0x29           PROTECTED
26131 \end_layout
26132
26133 \begin_layout LyX-Code
26134 CODEPAGE   NAME=page       START=0x2A           END=0x7FFF
26135 \end_layout
26136
26137 \begin_layout LyX-Code
26138 CODEPAGE   NAME=idlocs     START=0x200000       END=0x200007       PROTECTED
26139 \end_layout
26140
26141 \begin_layout LyX-Code
26142 CODEPAGE   NAME=config     START=0x300000       END=0x30000D       PROTECTED
26143 \end_layout
26144
26145 \begin_layout LyX-Code
26146 CODEPAGE   NAME=devid      START=0x3FFFFE       END=0x3FFFFF       PROTECTED
26147 \end_layout
26148
26149 \begin_layout LyX-Code
26150 CODEPAGE   NAME=eedata     START=0xF00000       END=0xF000FF       PROTECTED
26151 \end_layout
26152
26153 \begin_layout LyX-Code
26154 ACCESSBANK NAME=accessram  START=0x0            END=0x7F
26155 \end_layout
26156
26157 \begin_layout LyX-Code
26158
26159 \end_layout
26160
26161 \begin_layout LyX-Code
26162 DATABANK   NAME=gpr0       START=0x80           END=0xFF
26163 \end_layout
26164
26165 \begin_layout LyX-Code
26166 DATABANK   NAME=gpr1       START=0x100          END=0x1FF
26167 \end_layout
26168
26169 \begin_layout LyX-Code
26170 DATABANK   NAME=gpr2       START=0x200          END=0x2FF
26171 \end_layout
26172
26173 \begin_layout LyX-Code
26174 DATABANK   NAME=gpr3       START=0x300          END=0x3FF
26175 \end_layout
26176
26177 \begin_layout LyX-Code
26178 DATABANK   NAME=gpr4       START=0x400          END=0x4FF
26179 \end_layout
26180
26181 \begin_layout LyX-Code
26182 DATABANK   NAME=gpr5       START=0x500          END=0x5FF
26183 \end_layout
26184
26185 \begin_layout LyX-Code
26186 ACCESSBANK NAME=accesssfr  START=0xF80          END=0xFFF          PROTECTED
26187 \end_layout
26188
26189 \begin_layout LyX-Code
26190
26191 \end_layout
26192
26193 \begin_layout LyX-Code
26194 SECTION    NAME=CONFIG     ROM=config
26195 \end_layout
26196
26197 \begin_layout LyX-Code
26198
26199 \end_layout
26200
26201 \begin_layout LyX-Code
26202 SECTION    NAME=bank0      RAM=gpr0       # these SECTION directives
26203 \end_layout
26204
26205 \begin_layout LyX-Code
26206 SECTION    NAME=bank1      RAM=gpr1       # should be added to link
26207 \end_layout
26208
26209 \begin_layout LyX-Code
26210 SECTION    NAME=bank2      RAM=gpr2       # section name 'bank?' with
26211 \end_layout
26212
26213 \begin_layout LyX-Code
26214 SECTION    NAME=bank3      RAM=gpr3       # a specific DATABANK name
26215 \end_layout
26216
26217 \begin_layout LyX-Code
26218 SECTION    NAME=bank4      RAM=gpr4
26219 \end_layout
26220
26221 \begin_layout LyX-Code
26222 SECTION    NAME=bank5      RAM=gpr5
26223 \end_layout
26224
26225 \begin_layout Standard
26226 The linker will recognise the section name set in the pragma statement and
26227  will position the variable at the memory bank set with the RAM field at
26228  the SECTION line in the linker script file.
26229 \end_layout
26230
26231 \begin_layout Subsection
26232 Header Files
26233 \begin_inset LatexCommand \label{sub:PIC16_Header-Files}
26234
26235 \end_inset
26236
26237
26238 \end_layout
26239
26240 \begin_layout Standard
26241 There is one main header file
26242 \begin_inset LatexCommand \index{PIC16!Header files}
26243
26244 \end_inset
26245
26246  that can be included to the source files using the pic16
26247 \begin_inset LatexCommand \index{PIC16}
26248
26249 \end_inset
26250
26251  port.
26252  That file is the 
26253 \series bold
26254 pic18fregs.h
26255 \series default
26256 .
26257  This header file contains the definitions for the processor special registers,
26258  so it is necessary if the source accesses them.
26259  It can be included by adding the following line in the beginning of the
26260  file:
26261 \end_layout
26262
26263 \begin_layout LyX-Code
26264 #include <pic18fregs.h>
26265 \end_layout
26266
26267 \begin_layout Standard
26268 The specific microcontroller is selected within the pic18fregs.h automatically,
26269  so the same source can be used with a variety of devices.
26270 \end_layout
26271
26272 \begin_layout Subsection
26273 Libraries
26274 \begin_inset LatexCommand \label{sub:pic16Libraries}
26275
26276 \end_inset
26277
26278
26279 \end_layout
26280
26281 \begin_layout Standard
26282 The libraries
26283 \begin_inset LatexCommand \index{PIC16!Libraries}
26284
26285 \end_inset
26286
26287  that PIC16
26288 \begin_inset LatexCommand \index{PIC16}
26289
26290 \end_inset
26291
26292  port depends on are the microcontroller device libraries which contain
26293  the symbol definitions for the microcontroller special function registers.
26294  These libraries have the format pic18fxxxx.lib, where 
26295 \emph on
26296 xxxx
26297 \emph default
26298  is the microcontroller identification number.
26299  The specific library is selected automatically by the compiler at link
26300  stage according to the selected device.
26301 \end_layout
26302
26303 \begin_layout Standard
26304 \noindent
26305 Libraries are created with gplib which is part of the gputils package 
26306 \begin_inset LatexCommand \url{http://sourceforge.net/projects/gputils}
26307
26308 \end_inset
26309
26310 .
26311 \end_layout
26312
26313 \begin_layout Subsubsection*
26314 Building the libraries
26315 \end_layout
26316
26317 \begin_layout Standard
26318 Before using SDCC/pic16 there are some libraries that need to be compiled.
26319  This process is done automatically if gputils are found at SDCC's compile
26320  time.
26321  Should you require to rebuild the pic16 libraries manually, these are the
26322  steps required to do so under Linux or Mac OS X (cygwin might work as well,
26323  but is untested):
26324 \end_layout
26325
26326 \begin_layout LyX-Code
26327 cd device/lib/pic16
26328 \end_layout
26329
26330 \begin_layout LyX-Code
26331 ./configure.gnu
26332 \end_layout
26333
26334 \begin_layout LyX-Code
26335 cd ..
26336 \end_layout
26337
26338 \begin_layout LyX-Code
26339 make model-pic16
26340 \end_layout
26341
26342 \begin_layout LyX-Code
26343 su -c 'make install'     # install the libraries, you need the root password
26344 \end_layout
26345
26346 \begin_layout LyX-Code
26347 cd ../..
26348 \end_layout
26349
26350 \begin_layout Standard
26351 If you need to install the headers too, do:
26352 \end_layout
26353
26354 \begin_layout LyX-Code
26355 cd device/include
26356 \end_layout
26357
26358 \begin_layout LyX-Code
26359 su -c 'make install'     # install the headers, you need the root password
26360 \end_layout
26361
26362 \begin_layout Subsection
26363 Adding New Devices to the Port
26364 \end_layout
26365
26366 \begin_layout Standard
26367 Adding support for a new 16
26368 \begin_inset ERT
26369 status collapsed
26370
26371 \begin_layout Standard
26372
26373
26374 \backslash
26375 ,
26376 \end_layout
26377
26378 \end_inset
26379
26380 bit PIC MCU requires the following steps:
26381 \end_layout
26382
26383 \begin_layout Enumerate
26384 Create picDEVICE.c and picDEVICE.h from pDEVICE.inc using
26385 \newline
26386
26387 \family typewriter
26388 perl /path/to/sdcc/support/scripts/inc2h-pic16.pl /path/to/gputils/header/pDEVICE.
26389 inc
26390 \end_layout
26391
26392 \begin_layout Enumerate
26393
26394 \family typewriter
26395 mv picDEVICE.h /path/to/sdcc/device/include/pic16
26396 \end_layout
26397
26398 \begin_layout Enumerate
26399
26400 \family typewriter
26401 mv picDEVICE.c /path/to/sdcc/device/lib/pic16/libdev
26402 \end_layout
26403
26404 \begin_layout Enumerate
26405 Add DEVICE to 
26406 \family typewriter
26407 /path/to/sdcc/device/lib/pic16/pics.all
26408 \family default
26409
26410 \newline
26411 Note: No 18f prefix here!
26412 \end_layout
26413
26414 \begin_layout Enumerate
26415 Edit 
26416 \family typewriter
26417 /path/to/sdcc/device/include/pic16/adc.h
26418 \newline
26419
26420 \family default
26421 Add the new devices to the correct ADC style class (depending on the number
26422  of ADC channels).
26423 \newline
26424 Do not touch 
26425 \family typewriter
26426 adc.h
26427 \family default
26428  if the device does not offer any ADC at all.
26429 \end_layout
26430
26431 \begin_layout Enumerate
26432 Edit 
26433 \family typewriter
26434 /path/to/sdcc/device/include/pic16/pic18fregs.h
26435 \family default
26436
26437 \newline
26438 The file format is self-explanatory, just add
26439 \newline
26440
26441 \family typewriter
26442 #elif defined(picDEVICE)
26443 \newline
26444 #
26445 \begin_inset ERT
26446 status collapsed
26447
26448 \begin_layout Standard
26449
26450
26451 \backslash
26452  
26453 \backslash
26454  
26455 \end_layout
26456
26457 \end_inset
26458
26459 include <picDEVICE.h>
26460 \family default
26461
26462 \newline
26463 at the right place (keep the file sorted, please).
26464 \end_layout
26465
26466 \begin_layout Enumerate
26467 Edit 
26468 \family typewriter
26469 /path/to/sdcc/device/include/pic16devices.txt
26470 \newline
26471
26472 \family default
26473 Copy and modify an existing entry or create a new one and insert it at the
26474  correct place (keep the file sorted, please).
26475 \end_layout
26476
26477 \begin_layout Enumerate
26478 Add the device to 
26479 \family typewriter
26480 /path/to/sdcc/device/lib/pic16/libdev/Makefile.am
26481 \family default
26482
26483 \newline
26484 Copy an existing entry and adjust the device name.
26485 \end_layout
26486
26487 \begin_layout Enumerate
26488 Add the device to 
26489 \family typewriter
26490 /path/to/sdcc/device/lib/pic16/libio/Makefile.am
26491 \family default
26492
26493 \newline
26494 Copy the record from the 18f2220 and adjust the device name.
26495 \newline
26496 If the new device
26497  does not offer ADC, I
26498 \begin_inset Formula $^{\text{2}}$
26499 \end_inset
26500
26501 C, and/or (E)USART functionality as assumed by the library, remove the lines
26502  with references to 
26503 \family typewriter
26504 adc/*.c
26505 \family default
26506
26507 \family typewriter
26508 usart/*.c
26509 \family default
26510 , or 
26511 \family typewriter
26512 usart/*.c
26513 \family default
26514 , respectively.
26515 \end_layout
26516
26517 \begin_layout Enumerate
26518 Update 
26519 \family typewriter
26520 libdev/Makefile.in
26521 \family default
26522  and 
26523 \family typewriter
26524 libio/Makefile.in
26525 \family default
26526  using
26527 \newline
26528
26529 \family typewriter
26530 ./bootstrap.sh
26531 \family default
26532
26533 \newline
26534 in 
26535 \family typewriter
26536 /path/to/sdcc/device/lib/pic16
26537 \family default
26538 .
26539 \end_layout
26540
26541 \begin_layout Enumerate
26542 Recompile the pic16 libraries as described in 
26543 \begin_inset LatexCommand \ref{sub:pic16Libraries}
26544
26545 \end_inset
26546
26547 .
26548 \end_layout
26549
26550 \begin_layout Subsection
26551 Memory Models
26552 \end_layout
26553
26554 \begin_layout Standard
26555 The following memory models are supported by the PIC16 port:
26556 \end_layout
26557
26558 \begin_layout Itemize
26559 small model
26560 \end_layout
26561
26562 \begin_layout Itemize
26563 large model
26564 \end_layout
26565
26566 \begin_layout Standard
26567 Memory model affects the default size of pointers within the source.
26568  The sizes are shown in the next table:
26569 \end_layout
26570
26571 \begin_layout Standard
26572 \align center
26573 \begin_inset Tabular
26574 <lyxtabular version="3" rows="3" columns="3">
26575 <features>
26576 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
26577 <column alignment="center" valignment="top" leftline="true" width="0">
26578 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
26579 <row topline="true" bottomline="true">
26580 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26581 \begin_inset Text
26582
26583 \begin_layout Standard
26584 Pointer sizes according to memory model
26585 \end_layout
26586
26587 \end_inset
26588 </cell>
26589 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26590 \begin_inset Text
26591
26592 \begin_layout Standard
26593 small model
26594 \end_layout
26595
26596 \end_inset
26597 </cell>
26598 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26599 \begin_inset Text
26600
26601 \begin_layout Standard
26602 large model
26603 \end_layout
26604
26605 \end_inset
26606 </cell>
26607 </row>
26608 <row topline="true" bottomline="true">
26609 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26610 \begin_inset Text
26611
26612 \begin_layout Standard
26613 code pointers
26614 \end_layout
26615
26616 \end_inset
26617 </cell>
26618 <cell multicolumn="1" alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26619 \begin_inset Text
26620
26621 \begin_layout Standard
26622 16-bits
26623 \end_layout
26624
26625 \end_inset
26626 </cell>
26627 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26628 \begin_inset Text
26629
26630 \begin_layout Standard
26631 24-bits
26632 \end_layout
26633
26634 \end_inset
26635 </cell>
26636 </row>
26637 <row topline="true" bottomline="true">
26638 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26639 \begin_inset Text
26640
26641 \begin_layout Standard
26642 data pointers
26643 \end_layout
26644
26645 \end_inset
26646 </cell>
26647 <cell multicolumn="1" alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
26648 \begin_inset Text
26649
26650 \begin_layout Standard
26651 16-bits
26652 \end_layout
26653
26654 \end_inset
26655 </cell>
26656 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26657 \begin_inset Text
26658
26659 \begin_layout Standard
26660 16-bits
26661 \end_layout
26662
26663 \end_inset
26664 </cell>
26665 </row>
26666 </lyxtabular>
26667
26668 \end_inset
26669
26670
26671 \end_layout
26672
26673 \begin_layout Standard
26674 It is advisable that all sources within a project are compiled with the
26675  same memory model.
26676  If one wants to override the default memory model, this can be done by
26677  declaring a pointer as 
26678 \series bold
26679 far
26680 \series default
26681  or 
26682 \series bold
26683 near
26684 \series default
26685 .
26686  Far selects large memory model's pointers, while near selects small memory
26687  model's pointers.
26688 \end_layout
26689
26690 \begin_layout Standard
26691 The standard device libraries (see 
26692 \begin_inset LatexCommand \ref{sub:PIC16_Header-Files}
26693
26694 \end_inset
26695
26696 ) contain no reference to pointers, so they can be used with both memory
26697  models.
26698 \end_layout
26699
26700 \begin_layout Subsection
26701 Stack
26702 \end_layout
26703
26704 \begin_layout Standard
26705 The stack
26706 \begin_inset LatexCommand \index{PIC16!stack}
26707
26708 \end_inset
26709
26710  implementation for the PIC16 port uses two indirect registers, FSR1 and
26711  FSR2.
26712 \end_layout
26713
26714 \begin_layout Description
26715 FSR1 is assigned as stack pointer
26716 \end_layout
26717
26718 \begin_layout Description
26719 FSR2 is assigned as frame pointer
26720 \end_layout
26721
26722 \begin_layout Standard
26723 The following stack models are supported by the PIC16 port
26724 \end_layout
26725
26726 \begin_layout Itemize
26727
26728 \noun on
26729 small
26730 \noun default
26731  model
26732 \end_layout
26733
26734 \begin_layout Itemize
26735
26736 \noun on
26737 large
26738 \noun default
26739  model
26740 \end_layout
26741
26742 \begin_layout Standard
26743
26744 \noun on
26745 Small
26746 \noun default
26747  model means that only the FSRxL byte is used to access stack and frame,
26748  while 
26749 \emph on
26750 \noun on
26751 large
26752 \emph default
26753 \noun default
26754  uses both FSRxL and FSRxH registers.
26755  The following table shows the stack/frame pointers sizes according to stack
26756  model and the maximum space they can address:
26757 \end_layout
26758
26759 \begin_layout Standard
26760 \align center
26761 \begin_inset Tabular
26762 <lyxtabular version="3" rows="3" columns="3">
26763 <features>
26764 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
26765 <column alignment="center" valignment="top" leftline="true" width="0">
26766 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
26767 <row topline="true" bottomline="true">
26768 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26769 \begin_inset Text
26770
26771 \begin_layout Standard
26772 Stack & Frame pointer sizes according to stack model
26773 \end_layout
26774
26775 \end_inset
26776 </cell>
26777 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26778 \begin_inset Text
26779
26780 \begin_layout Standard
26781 small
26782 \end_layout
26783
26784 \end_inset
26785 </cell>
26786 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26787 \begin_inset Text
26788
26789 \begin_layout Standard
26790 large
26791 \end_layout
26792
26793 \end_inset
26794 </cell>
26795 </row>
26796 <row topline="true">
26797 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26798 \begin_inset Text
26799
26800 \begin_layout Standard
26801 Stack pointer FSR1
26802 \end_layout
26803
26804 \end_inset
26805 </cell>
26806 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26807 \begin_inset Text
26808
26809 \begin_layout Standard
26810 8-bits
26811 \end_layout
26812
26813 \end_inset
26814 </cell>
26815 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26816 \begin_inset Text
26817
26818 \begin_layout Standard
26819 16-bits
26820 \end_layout
26821
26822 \end_inset
26823 </cell>
26824 </row>
26825 <row topline="true" bottomline="true">
26826 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26827 \begin_inset Text
26828
26829 \begin_layout Standard
26830 Frame pointer FSR2
26831 \end_layout
26832
26833 \end_inset
26834 </cell>
26835 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26836 \begin_inset Text
26837
26838 \begin_layout Standard
26839 8-bits
26840 \end_layout
26841
26842 \end_inset
26843 </cell>
26844 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26845 \begin_inset Text
26846
26847 \begin_layout Standard
26848 16-bits
26849 \end_layout
26850
26851 \end_inset
26852 </cell>
26853 </row>
26854 </lyxtabular>
26855
26856 \end_inset
26857
26858
26859 \end_layout
26860
26861 \begin_layout Standard
26862 \noindent
26863
26864 \noun on
26865 Large 
26866 \noun default
26867 stack model is currently not working properly throughout the code generator.
26868  So its use is not advised.
26869  Also there are some other points that need special care:
26870 \newline
26871
26872 \end_layout
26873
26874 \begin_layout Enumerate
26875 Do not create stack sections with size more than one physical bank (that
26876  is 256 bytes)
26877 \end_layout
26878
26879 \begin_layout Enumerate
26880 Stack sections should no cross physical bank limits (i.e.
26881  #pragma stack 0x50 0x100)
26882 \end_layout
26883
26884 \begin_layout Standard
26885 These limitations are caused by the fact that only FSRxL is modified when
26886  using SMALL stack model, so no more than 256 bytes of stack can be used.
26887  This problem will disappear after LARGE model is fully implemented.
26888 \end_layout
26889
26890 \begin_layout Subsection
26891 Functions
26892 \end_layout
26893
26894 \begin_layout Standard
26895 In addition to the standard SDCC function keywords, PIC16
26896 \begin_inset LatexCommand \index{PIC16}
26897
26898 \end_inset
26899
26900  port makes available two more:
26901 \end_layout
26902
26903 \begin_layout Description
26904 wparam
26905 \begin_inset LatexCommand \index{PIC16!wparam}
26906
26907 \end_inset
26908
26909  Use the WREG to pass one byte of the first function argument.
26910  This improves speed but you may not use this for functions with arguments
26911  that are called via function pointers, otherwise the first byte of the
26912  first parameter will get lost.
26913  Usage:
26914 \end_layout
26915
26916 \begin_layout LyX-Code
26917 void func_wparam(int a) wparam
26918 \end_layout
26919
26920 \begin_layout LyX-Code
26921 {
26922 \end_layout
26923
26924 \begin_layout LyX-Code
26925     /* WREG hold the lower part of a */
26926 \end_layout
26927
26928 \begin_layout LyX-Code
26929     /* the high part of a is stored in FSR2+2 (or +3 for large stack model)
26930  */
26931 \end_layout
26932
26933 \begin_layout LyX-Code
26934 ...
26935 \end_layout
26936
26937 \begin_layout LyX-Code
26938 }
26939 \end_layout
26940
26941 \begin_layout Description
26942 shadowregs
26943 \begin_inset LatexCommand \index{PIC16!shadowregs}
26944
26945 \end_inset
26946
26947  When entering/exiting an ISR, it is possible to take advantage of the PIC18F
26948  hardware shadow registers which hold the values of WREG, STATUS and BSR
26949  registers.
26950  This can be done by adding the keyword 
26951 \emph on
26952 shadowregs
26953 \emph default
26954  before the 
26955 \emph on
26956 interrupt
26957 \emph default
26958  keyword in the function's header.
26959 \end_layout
26960
26961 \begin_layout LyX-Code
26962 void isr_shadow(void) shadowregs interrupt 1
26963 \end_layout
26964
26965 \begin_layout LyX-Code
26966 {
26967 \end_layout
26968
26969 \begin_layout LyX-Code
26970 ...
26971 \end_layout
26972
26973 \begin_layout LyX-Code
26974 }
26975 \end_layout
26976
26977 \begin_layout Standard
26978
26979 \emph on
26980 shadowregs
26981 \emph default
26982  instructs the code generator not to store/restore WREG, STATUS, BSR when
26983  entering/exiting the ISR.
26984 \end_layout
26985
26986 \begin_layout Subsection
26987 Function return values
26988 \end_layout
26989
26990 \begin_layout Standard
26991 Return values from functions are placed to the appropriate registers following
26992  a modified Microchip policy optimized for SDCC.
26993  The following table shows these registers:
26994 \end_layout
26995
26996 \begin_layout Standard
26997 \align center
26998 \begin_inset Tabular
26999 <lyxtabular version="3" rows="6" columns="2">
27000 <features>
27001 <column alignment="center" valignment="top" leftline="true" width="0">
27002 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
27003 <row topline="true" bottomline="true">
27004 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27005 \begin_inset Text
27006
27007 \begin_layout Standard
27008 size
27009 \end_layout
27010
27011 \end_inset
27012 </cell>
27013 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27014 \begin_inset Text
27015
27016 \begin_layout Standard
27017 destination register
27018 \end_layout
27019
27020 \end_inset
27021 </cell>
27022 </row>
27023 <row topline="true">
27024 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27025 \begin_inset Text
27026
27027 \begin_layout Standard
27028 8 bits
27029 \end_layout
27030
27031 \end_inset
27032 </cell>
27033 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27034 \begin_inset Text
27035
27036 \begin_layout Standard
27037 WREG
27038 \end_layout
27039
27040 \end_inset
27041 </cell>
27042 </row>
27043 <row topline="true">
27044 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27045 \begin_inset Text
27046
27047 \begin_layout Standard
27048 16 bits
27049 \end_layout
27050
27051 \end_inset
27052 </cell>
27053 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27054 \begin_inset Text
27055
27056 \begin_layout Standard
27057 PRODL:WREG
27058 \end_layout
27059
27060 \end_inset
27061 </cell>
27062 </row>
27063 <row topline="true">
27064 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27065 \begin_inset Text
27066
27067 \begin_layout Standard
27068 24 bits
27069 \end_layout
27070
27071 \end_inset
27072 </cell>
27073 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27074 \begin_inset Text
27075
27076 \begin_layout Standard
27077 PRODH:PRODL:WREG
27078 \end_layout
27079
27080 \end_inset
27081 </cell>
27082 </row>
27083 <row topline="true">
27084 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27085 \begin_inset Text
27086
27087 \begin_layout Standard
27088 32 bits
27089 \end_layout
27090
27091 \end_inset
27092 </cell>
27093 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27094 \begin_inset Text
27095
27096 \begin_layout Standard
27097 FSR0L:PRODH:PRODL:WREG
27098 \end_layout
27099
27100 \end_inset
27101 </cell>
27102 </row>
27103 <row topline="true" bottomline="true">
27104 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27105 \begin_inset Text
27106
27107 \begin_layout Standard
27108 >32 bits
27109 \end_layout
27110
27111 \end_inset
27112 </cell>
27113 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27114 \begin_inset Text
27115
27116 \begin_layout Standard
27117 on stack, FSR0 points to the beginning
27118 \end_layout
27119
27120 \end_inset
27121 </cell>
27122 </row>
27123 </lyxtabular>
27124
27125 \end_inset
27126
27127
27128 \end_layout
27129
27130 \begin_layout Subsection
27131 Interrupts
27132 \end_layout
27133
27134 \begin_layout Standard
27135 An interrupt
27136 \begin_inset LatexCommand \index{PIC16!interrupt}
27137
27138 \end_inset
27139
27140  service routine (ISR) is declared using the 
27141 \emph on
27142 interrupt
27143 \emph default
27144  keyword.
27145 \end_layout
27146
27147 \begin_layout LyX-Code
27148 void isr(void) interrupt 
27149 \emph on
27150 n
27151 \end_layout
27152
27153 \begin_layout LyX-Code
27154 {
27155 \end_layout
27156
27157 \begin_layout LyX-Code
27158 ...
27159 \end_layout
27160
27161 \begin_layout LyX-Code
27162 }
27163 \end_layout
27164
27165 \begin_layout Standard
27166
27167 \emph on
27168 n
27169 \emph default
27170  is the interrupt number, which for PIC18F devices can be:
27171 \end_layout
27172
27173 \begin_layout Standard
27174 \align center
27175 \begin_inset Tabular
27176 <lyxtabular version="3" rows="4" columns="3">
27177 <features>
27178 <column alignment="center" valignment="top" leftline="true" width="0">
27179 <column alignment="center" valignment="top" leftline="true" width="0">
27180 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
27181 <row topline="true" bottomline="true">
27182 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27183 \begin_inset Text
27184
27185 \begin_layout Standard
27186
27187 \emph on
27188 n
27189 \end_layout
27190
27191 \end_inset
27192 </cell>
27193 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27194 \begin_inset Text
27195
27196 \begin_layout Standard
27197 Interrupt Vector
27198 \end_layout
27199
27200 \end_inset
27201 </cell>
27202 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27203 \begin_inset Text
27204
27205 \begin_layout Standard
27206 Interrupt Vector Address
27207 \end_layout
27208
27209 \end_inset
27210 </cell>
27211 </row>
27212 <row topline="true">
27213 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27214 \begin_inset Text
27215
27216 \begin_layout Standard
27217 0
27218 \end_layout
27219
27220 \end_inset
27221 </cell>
27222 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27223 \begin_inset Text
27224
27225 \begin_layout Standard
27226 RESET vector
27227 \end_layout
27228
27229 \end_inset
27230 </cell>
27231 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27232 \begin_inset Text
27233
27234 \begin_layout Standard
27235 0x000000
27236 \end_layout
27237
27238 \end_inset
27239 </cell>
27240 </row>
27241 <row topline="true">
27242 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27243 \begin_inset Text
27244
27245 \begin_layout Standard
27246
27247 \family roman
27248 \series medium
27249 \shape up
27250 \size normal
27251 \emph off
27252 \bar no
27253 \noun off
27254 \color none
27255 1
27256 \end_layout
27257
27258 \end_inset
27259 </cell>
27260 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27261 \begin_inset Text
27262
27263 \begin_layout Standard
27264
27265 \family roman
27266 \series medium
27267 \shape up
27268 \size normal
27269 \emph off
27270 \bar no
27271 \noun off
27272 \color none
27273 HIGH priority interrupts
27274 \end_layout
27275
27276 \end_inset
27277 </cell>
27278 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27279 \begin_inset Text
27280
27281 \begin_layout Standard
27282 0x000008
27283 \end_layout
27284
27285 \end_inset
27286 </cell>
27287 </row>
27288 <row topline="true" bottomline="true">
27289 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27290 \begin_inset Text
27291
27292 \begin_layout Standard
27293 2
27294 \end_layout
27295
27296 \end_inset
27297 </cell>
27298 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27299 \begin_inset Text
27300
27301 \begin_layout Standard
27302 LOW priority interrupts
27303 \end_layout
27304
27305 \end_inset
27306 </cell>
27307 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27308 \begin_inset Text
27309
27310 \begin_layout Standard
27311 0x000018
27312 \end_layout
27313
27314 \end_inset
27315 </cell>
27316 </row>
27317 </lyxtabular>
27318
27319 \end_inset
27320
27321
27322 \end_layout
27323
27324 \begin_layout Standard
27325 When generating assembly code for ISR the code generator places a 
27326 \noun on
27327 goto 
27328 \noun default
27329 instruction at the 
27330 \emph on
27331 Interrupt Vector Address
27332 \emph default
27333  which points at the genetated ISR.
27334  This single GOTO instruction is part of an automatically generated 
27335 \emph on
27336 interrupt entry point
27337 \emph default
27338  function.
27339  The actuall ISR code is placed as normally would in the code space.
27340  Upon interrupt request, the GOTO instruction is executed which jumps to
27341  the ISR code.
27342  When declaring interrupt functions as _naked this GOTO instruction is 
27343 \series bold
27344 not
27345 \series default
27346  generated.
27347  The whole interrupt functions is therefore placed at the Interrupt Vector
27348  Address of the specific interrupt.
27349  This is not a problem for the LOW priority interrupts, but it is a problem
27350  for the RESET and the HIGH priority interrupts because code may be written
27351  at the next interrupt's vector address and cause undeterminate program
27352  behaviour if that interrupt is raised.
27353 \begin_inset Foot
27354 status open
27355
27356 \begin_layout Standard
27357 This is not a problem when
27358 \end_layout
27359
27360 \begin_layout Enumerate
27361 this is a HIGH interrupt ISR and LOW interrupts are 
27362 \emph on
27363 disabled
27364 \emph default
27365  or not used.
27366 \end_layout
27367
27368 \begin_layout Enumerate
27369 when the ISR is small enough not to reach the next interrupt's vector address.
27370 \end_layout
27371
27372 \end_inset
27373
27374
27375 \end_layout
27376
27377 \begin_layout Standard
27378
27379 \emph on
27380 n
27381 \emph default
27382  may be omitted.
27383  This way a function is generated similar to an ISR, but it is not assigned
27384  to any interrupt.
27385 \end_layout
27386
27387 \begin_layout Standard
27388 When entering an interrupt, currently the PIC16
27389 \begin_inset LatexCommand \index{PIC16}
27390
27391 \end_inset
27392
27393  port automatically saves the following registers:
27394 \end_layout
27395
27396 \begin_layout Itemize
27397 WREG
27398 \end_layout
27399
27400 \begin_layout Itemize
27401 STATUS
27402 \end_layout
27403
27404 \begin_layout Itemize
27405 BSR
27406 \end_layout
27407
27408 \begin_layout Itemize
27409 PROD (PRODL and PRODH)
27410 \end_layout
27411
27412 \begin_layout Itemize
27413 FSR0 (FSR0L and FSR0H)
27414 \end_layout
27415
27416 \begin_layout Standard
27417 These registers are restored upon return from the interrupt routine.
27418 \begin_inset Foot
27419 status open
27420
27421 \begin_layout Standard
27422 NOTE that when the _naked attribute is specified for an interrupt routine,
27423  then NO registers are stored or restored.
27424 \end_layout
27425
27426 \end_inset
27427
27428
27429 \end_layout
27430
27431 \begin_layout Subsection
27432 Generic Pointers
27433 \end_layout
27434
27435 \begin_layout Standard
27436 Generic pointers are implemented in PIC16 port as 3-byte (24-bit) types.
27437  There are 3 types of generic pointers currently implemented data, code
27438  and eeprom pointers.
27439  They are differentiated by the value of the 7th and 6th bits of the upper
27440  byte:
27441 \end_layout
27442
27443 \begin_layout Standard
27444 \align center
27445 \begin_inset Tabular
27446 <lyxtabular version="3" rows="5" columns="5">
27447 <features>
27448 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
27449 <column alignment="center" valignment="top" width="0">
27450 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
27451 <column alignment="center" valignment="top" width="0">
27452 <column alignment="left" valignment="top" rightline="true" width="0">
27453 <row topline="true" bottomline="true">
27454 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27455 \begin_inset Text
27456
27457 \begin_layout Standard
27458 pointer type
27459 \end_layout
27460
27461 \end_inset
27462 </cell>
27463 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27464 \begin_inset Text
27465
27466 \begin_layout Standard
27467 7th bit
27468 \end_layout
27469
27470 \end_inset
27471 </cell>
27472 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27473 \begin_inset Text
27474
27475 \begin_layout Standard
27476 6th bit
27477 \end_layout
27478
27479 \end_inset
27480 </cell>
27481 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27482 \begin_inset Text
27483
27484 \begin_layout Standard
27485 rest of the pointer
27486 \end_layout
27487
27488 \end_inset
27489 </cell>
27490 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27491 \begin_inset Text
27492
27493 \begin_layout Standard
27494 description
27495 \end_layout
27496
27497 \end_inset
27498 </cell>
27499 </row>
27500 <row topline="true" bottomline="true">
27501 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27502 \begin_inset Text
27503
27504 \begin_layout Standard
27505 data 
27506 \end_layout
27507
27508 \end_inset
27509 </cell>
27510 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27511 \begin_inset Text
27512
27513 \begin_layout Standard
27514 1
27515 \end_layout
27516
27517 \end_inset
27518 </cell>
27519 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27520 \begin_inset Text
27521
27522 \begin_layout Standard
27523 0
27524 \end_layout
27525
27526 \end_inset
27527 </cell>
27528 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27529 \begin_inset Text
27530
27531 \begin_layout Standard
27532
27533 \family typewriter
27534 \shape slanted
27535 \emph on
27536 uuuuuu uuuuxxxx xxxxxxxx
27537 \end_layout
27538
27539 \end_inset
27540 </cell>
27541 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27542 \begin_inset Text
27543
27544 \begin_layout Standard
27545 a 12-bit data pointer in data RAM memory
27546 \end_layout
27547
27548 \end_inset
27549 </cell>
27550 </row>
27551 <row bottomline="true">
27552 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27553 \begin_inset Text
27554
27555 \begin_layout Standard
27556 code
27557 \end_layout
27558
27559 \end_inset
27560 </cell>
27561 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27562 \begin_inset Text
27563
27564 \begin_layout Standard
27565 0
27566 \end_layout
27567
27568 \end_inset
27569 </cell>
27570 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27571 \begin_inset Text
27572
27573 \begin_layout Standard
27574 0
27575 \end_layout
27576
27577 \end_inset
27578 </cell>
27579 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27580 \begin_inset Text
27581
27582 \begin_layout Standard
27583
27584 \family typewriter
27585 \shape slanted
27586 \emph on
27587 uxxxxx xxxxxxxx xxxxxxxx
27588 \end_layout
27589
27590 \end_inset
27591 </cell>
27592 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27593 \begin_inset Text
27594
27595 \begin_layout Standard
27596 a 21-bit code pointer in FLASH memory
27597 \end_layout
27598
27599 \end_inset
27600 </cell>
27601 </row>
27602 <row bottomline="true">
27603 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27604 \begin_inset Text
27605
27606 \begin_layout Standard
27607 eeprom
27608 \end_layout
27609
27610 \end_inset
27611 </cell>
27612 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27613 \begin_inset Text
27614
27615 \begin_layout Standard
27616 0
27617 \end_layout
27618
27619 \end_inset
27620 </cell>
27621 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27622 \begin_inset Text
27623
27624 \begin_layout Standard
27625 1
27626 \end_layout
27627
27628 \end_inset
27629 </cell>
27630 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27631 \begin_inset Text
27632
27633 \begin_layout Standard
27634
27635 \family typewriter
27636 \shape slanted
27637 \emph on
27638 uuuuuu uuuuuuxx xxxxxxxx
27639 \end_layout
27640
27641 \end_inset
27642 </cell>
27643 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27644 \begin_inset Text
27645
27646 \begin_layout Standard
27647 a 10-bit eeprom pointer in EEPROM memory
27648 \end_layout
27649
27650 \end_inset
27651 </cell>
27652 </row>
27653 <row bottomline="true">
27654 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27655 \begin_inset Text
27656
27657 \begin_layout Standard
27658 (unimplemented)
27659 \end_layout
27660
27661 \end_inset
27662 </cell>
27663 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27664 \begin_inset Text
27665
27666 \begin_layout Standard
27667 1
27668 \end_layout
27669
27670 \end_inset
27671 </cell>
27672 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27673 \begin_inset Text
27674
27675 \begin_layout Standard
27676 1
27677 \end_layout
27678
27679 \end_inset
27680 </cell>
27681 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27682 \begin_inset Text
27683
27684 \begin_layout Standard
27685
27686 \family typewriter
27687 \shape slanted
27688 \emph on
27689 xxxxxx xxxxxxxx xxxxxxxx
27690 \end_layout
27691
27692 \end_inset
27693 </cell>
27694 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27695 \begin_inset Text
27696
27697 \begin_layout Standard
27698 unimplemented pointer type
27699 \end_layout
27700
27701 \end_inset
27702 </cell>
27703 </row>
27704 </lyxtabular>
27705
27706 \end_inset
27707
27708
27709 \end_layout
27710
27711 \begin_layout Standard
27712 \noindent
27713 Generic pointer are read and written with a set of library functions which
27714  read/write 1, 2, 3, 4 bytes.
27715 \end_layout
27716
27717 \begin_layout Subsection
27718 PIC16 C Libraries
27719 \end_layout
27720
27721 \begin_layout Subsubsection
27722 Standard I/O Streams
27723 \end_layout
27724
27725 \begin_layout Standard
27726 In the 
27727 \emph on
27728 stdio.h
27729 \emph default
27730  the type FILE is defined as:
27731 \end_layout
27732
27733 \begin_layout LyX-Code
27734 typedef char * FILE;
27735 \end_layout
27736
27737 \begin_layout Standard
27738 This type is the stream type implemented I/O in the PIC18F devices.
27739  Also the standard input and output streams are declared in stdio.h:
27740 \end_layout
27741
27742 \begin_layout LyX-Code
27743 extern FILE * stdin;
27744 \end_layout
27745
27746 \begin_layout LyX-Code
27747 extern FILE * stdout;
27748 \end_layout
27749
27750 \begin_layout Standard
27751 The FILE type is actually a generic pointer which defines one more type
27752  of generic pointers, the 
27753 \emph on
27754 stream 
27755 \emph default
27756 pointer.
27757  This new type has the format:
27758 \end_layout
27759
27760 \begin_layout Standard
27761 \noindent
27762 \align center
27763 \begin_inset Tabular
27764 <lyxtabular version="3" rows="2" columns="7">
27765 <features>
27766 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
27767 <column alignment="center" valignment="top" width="0">
27768 <column alignment="center" valignment="top" leftline="true" width="0">
27769 <column alignment="center" valignment="top" leftline="true" width="0">
27770 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
27771 <column alignment="center" valignment="top" width="0">
27772 <column alignment="left" valignment="top" rightline="true" width="0">
27773 <row topline="true" bottomline="true">
27774 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27775 \begin_inset Text
27776
27777 \begin_layout Standard
27778 pointer type
27779 \end_layout
27780
27781 \end_inset
27782 </cell>
27783 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27784 \begin_inset Text
27785
27786 \begin_layout Standard
27787 <7:6>
27788 \end_layout
27789
27790 \end_inset
27791 </cell>
27792 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27793 \begin_inset Text
27794
27795 \begin_layout Standard
27796 <5>
27797 \end_layout
27798
27799 \end_inset
27800 </cell>
27801 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27802 \begin_inset Text
27803
27804 \begin_layout Standard
27805 <4>
27806 \end_layout
27807
27808 \end_inset
27809 </cell>
27810 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27811 \begin_inset Text
27812
27813 \begin_layout Standard
27814 <3:0>
27815 \end_layout
27816
27817 \end_inset
27818 </cell>
27819 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27820 \begin_inset Text
27821
27822 \begin_layout Standard
27823 rest of the pointer
27824 \end_layout
27825
27826 \end_inset
27827 </cell>
27828 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27829 \begin_inset Text
27830
27831 \begin_layout Standard
27832 descrption
27833 \end_layout
27834
27835 \end_inset
27836 </cell>
27837 </row>
27838 <row topline="true" bottomline="true">
27839 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27840 \begin_inset Text
27841
27842 \begin_layout Standard
27843 stream
27844 \end_layout
27845
27846 \end_inset
27847 </cell>
27848 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27849 \begin_inset Text
27850
27851 \begin_layout Standard
27852 00
27853 \end_layout
27854
27855 \end_inset
27856 </cell>
27857 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27858 \begin_inset Text
27859
27860 \begin_layout Standard
27861 1
27862 \end_layout
27863
27864 \end_inset
27865 </cell>
27866 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27867 \begin_inset Text
27868
27869 \begin_layout Standard
27870 0
27871 \end_layout
27872
27873 \end_inset
27874 </cell>
27875 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27876 \begin_inset Text
27877
27878 \begin_layout Standard
27879 nnnn
27880 \end_layout
27881
27882 \end_inset
27883 </cell>
27884 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27885 \begin_inset Text
27886
27887 \begin_layout Standard
27888
27889 \family typewriter
27890 \shape slanted
27891 \emph on
27892 uuuuuuuu uuuuuuuu
27893 \end_layout
27894
27895 \end_inset
27896 </cell>
27897 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27898 \begin_inset Text
27899
27900 \begin_layout Standard
27901 upper byte high nubble is 0x2n, the rest are zeroes
27902 \end_layout
27903
27904 \end_inset
27905 </cell>
27906 </row>
27907 </lyxtabular>
27908
27909 \end_inset
27910
27911
27912 \end_layout
27913
27914 \begin_layout Standard
27915 \noindent
27916 Currently implemented there are 3 types of streams defined:
27917 \end_layout
27918
27919 \begin_layout Standard
27920 \noindent
27921 \align center
27922 \begin_inset Tabular
27923 <lyxtabular version="3" rows="4" columns="4">
27924 <features>
27925 <column alignment="center" valignment="top" leftline="true" width="0">
27926 <column alignment="center" valignment="top" leftline="true" width="0">
27927 <column alignment="center" valignment="top" leftline="true" width="0">
27928 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
27929 <row topline="true" bottomline="true">
27930 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27931 \begin_inset Text
27932
27933 \begin_layout Standard
27934 stream type
27935 \end_layout
27936
27937 \end_inset
27938 </cell>
27939 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27940 \begin_inset Text
27941
27942 \begin_layout Standard
27943 value
27944 \end_layout
27945
27946 \end_inset
27947 </cell>
27948 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27949 \begin_inset Text
27950
27951 \begin_layout Standard
27952 module
27953 \end_layout
27954
27955 \end_inset
27956 </cell>
27957 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27958 \begin_inset Text
27959
27960 \begin_layout Standard
27961 description
27962 \end_layout
27963
27964 \end_inset
27965 </cell>
27966 </row>
27967 <row topline="true">
27968 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27969 \begin_inset Text
27970
27971 \begin_layout Standard
27972 STREAM_USART
27973 \end_layout
27974
27975 \end_inset
27976 </cell>
27977 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27978 \begin_inset Text
27979
27980 \begin_layout Standard
27981
27982 \family typewriter
27983 0x200000UL
27984 \end_layout
27985
27986 \end_inset
27987 </cell>
27988 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27989 \begin_inset Text
27990
27991 \begin_layout Standard
27992 USART
27993 \end_layout
27994
27995 \end_inset
27996 </cell>
27997 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27998 \begin_inset Text
27999
28000 \begin_layout Standard
28001 Writes/Reads characters via the USART peripheral
28002 \end_layout
28003
28004 \end_inset
28005 </cell>
28006 </row>
28007 <row topline="true">
28008 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28009 \begin_inset Text
28010
28011 \begin_layout Standard
28012 STREAM_MSSP
28013 \end_layout
28014
28015 \end_inset
28016 </cell>
28017 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28018 \begin_inset Text
28019
28020 \begin_layout Standard
28021
28022 \family typewriter
28023 0x210000UL
28024 \end_layout
28025
28026 \end_inset
28027 </cell>
28028 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28029 \begin_inset Text
28030
28031 \begin_layout Standard
28032 MSSP
28033 \end_layout
28034
28035 \end_inset
28036 </cell>
28037 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28038 \begin_inset Text
28039
28040 \begin_layout Standard
28041 Writes/Reads characters via the MSSP peripheral
28042 \end_layout
28043
28044 \end_inset
28045 </cell>
28046 </row>
28047 <row topline="true" bottomline="true">
28048 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28049 \begin_inset Text
28050
28051 \begin_layout Standard
28052 STREAM_USER
28053 \end_layout
28054
28055 \end_inset
28056 </cell>
28057 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28058 \begin_inset Text
28059
28060 \begin_layout Standard
28061
28062 \family typewriter
28063 0x2f0000UL
28064 \end_layout
28065
28066 \end_inset
28067 </cell>
28068 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28069 \begin_inset Text
28070
28071 \begin_layout Standard
28072 (none)
28073 \end_layout
28074
28075 \end_inset
28076 </cell>
28077 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28078 \begin_inset Text
28079
28080 \begin_layout Standard
28081 Writes/Reads characters via used defined functions
28082 \end_layout
28083
28084 \end_inset
28085 </cell>
28086 </row>
28087 </lyxtabular>
28088
28089 \end_inset
28090
28091
28092 \end_layout
28093
28094 \begin_layout Standard
28095 \noindent
28096 The stream identifiers are declared as macros in the stdio.h header.
28097 \end_layout
28098
28099 \begin_layout Standard
28100 \noindent
28101 In the libc library there exist the functions that are used to write to
28102  each of the above streams.
28103  These are
28104 \end_layout
28105
28106 \begin_layout Description
28107 _
28108 \begin_inset ERT
28109 status collapsed
28110
28111 \begin_layout Standard
28112
28113
28114 \backslash
28115 /
28116 \end_layout
28117
28118 \end_inset
28119
28120 _stream_usart_putchar writes a character at the USART stream
28121 \end_layout
28122
28123 \begin_layout Description
28124 _
28125 \begin_inset ERT
28126 status collapsed
28127
28128 \begin_layout Standard
28129
28130
28131 \backslash
28132 /
28133 \end_layout
28134
28135 \end_inset
28136
28137 _stream_mssp_putchar writes a character at the MSSP stream
28138 \end_layout
28139
28140 \begin_layout Description
28141 putchar dummy function.
28142  This writes a character to a user specified manner.
28143 \end_layout
28144
28145 \begin_layout Standard
28146 In order to increase performance 
28147 \emph on
28148 putchar 
28149 \emph default
28150 is declared in stdio.h as having its parameter in WREG (it has the wparam
28151  keyword).
28152  In stdio.h exists the macro PUTCHAR(arg) that defines the putchar function
28153  in a user-friendly way.
28154  
28155 \emph on
28156 arg
28157 \emph default
28158  is the name of the variable that holds the character to print.
28159  An example follows:
28160 \end_layout
28161
28162 \begin_layout LyX-Code
28163 #include <pic18fregs.h>
28164 \newline
28165 #include <stdio.h>
28166 \newline
28167
28168 \newline
28169 PUTCHAR( c )
28170 \end_layout
28171
28172 \begin_layout LyX-Code
28173 {
28174 \end_layout
28175
28176 \begin_layout LyX-Code
28177     PORTA = c;    /* dump character c to PORTA */
28178 \end_layout
28179
28180 \begin_layout LyX-Code
28181
28182 \newline
28183
28184 \newline
28185 void main(void)
28186 \end_layout
28187
28188 \begin_layout LyX-Code
28189 {
28190 \end_layout
28191
28192 \begin_layout LyX-Code
28193     stdout = STREAM_USER;    /* this is not necessary, since stdout points
28194 \end_layout
28195
28196 \begin_layout LyX-Code
28197                               * by default to STREAM_USER */
28198 \end_layout
28199
28200 \begin_layout LyX-Code
28201     printf (
28202 \begin_inset Quotes sld
28203 \end_inset
28204
28205 This is a printf test
28206 \backslash
28207 n
28208 \begin_inset Quotes srd
28209 \end_inset
28210
28211 );
28212 \end_layout
28213
28214 \begin_layout LyX-Code
28215 }
28216 \end_layout
28217
28218 \begin_layout LyX-Code
28219
28220 \end_layout
28221
28222 \begin_layout Subsubsection
28223 Printing functions
28224 \end_layout
28225
28226 \begin_layout Standard
28227 PIC16 contains an implementation of the printf-family of functions.
28228  There exist the following functions:
28229 \end_layout
28230
28231 \begin_layout LyX-Code
28232 extern unsigned int sprintf(char *buf, char *fmt, ...);
28233 \end_layout
28234
28235 \begin_layout LyX-Code
28236 extern unsigned int vsprintf(char *buf, char *fmt, va_list ap);
28237 \end_layout
28238
28239 \begin_layout LyX-Code
28240
28241 \end_layout
28242
28243 \begin_layout LyX-Code
28244 extern unsigned int printf(char *fmt, ...);
28245 \end_layout
28246
28247 \begin_layout LyX-Code
28248 extern unsigned int vprintf(char *fmt, va_lista ap);
28249 \end_layout
28250
28251 \begin_layout LyX-Code
28252
28253 \end_layout
28254
28255 \begin_layout LyX-Code
28256 extern unsigned int fprintf(FILE *fp, char *fmt, ...);
28257 \end_layout
28258
28259 \begin_layout LyX-Code
28260 extern unsigned int vfprintf(FILE *fp, char *fmt, va_list ap);
28261 \end_layout
28262
28263 \begin_layout Standard
28264 For sprintf and vsprintf 
28265 \emph on
28266 buf 
28267 \emph default
28268 should normally be a data pointer where the resulting string will be placed.
28269  No range checking is done so the user should allocate the necessery buffer.
28270  For fprintf and vfprintf 
28271 \emph on
28272 fp
28273 \emph default
28274  should be a stream pointer (i.e.
28275  stdout, STREAM_MSSP, etc...).
28276 \end_layout
28277
28278 \begin_layout Subsubsection
28279 Signals
28280 \end_layout
28281
28282 \begin_layout Standard
28283 The PIC18F family of microcontrollers supports a number of interrupt sources.
28284  A list of these interrupts is shown in the following table:
28285 \end_layout
28286
28287 \begin_layout Standard
28288 \align center
28289 \begin_inset Tabular
28290 <lyxtabular version="3" rows="11" columns="4">
28291 <features>
28292 <column alignment="left" valignment="top" leftline="true" width="0">
28293 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
28294 <column alignment="left" valignment="top" leftline="true" width="0">
28295 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
28296 <row topline="true" bottomline="true">
28297 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28298 \begin_inset Text
28299
28300 \begin_layout Standard
28301 signal name
28302 \end_layout
28303
28304 \end_inset
28305 </cell>
28306 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28307 \begin_inset Text
28308
28309 \begin_layout Standard
28310 description
28311 \end_layout
28312
28313 \end_inset
28314 </cell>
28315 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28316 \begin_inset Text
28317
28318 \begin_layout Standard
28319 signal name
28320 \end_layout
28321
28322 \end_inset
28323 </cell>
28324 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28325 \begin_inset Text
28326
28327 \begin_layout Standard
28328 descritpion
28329 \end_layout
28330
28331 \end_inset
28332 </cell>
28333 </row>
28334 <row topline="true">
28335 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28336 \begin_inset Text
28337
28338 \begin_layout Standard
28339 SIG_RB
28340 \end_layout
28341
28342 \end_inset
28343 </cell>
28344 <cell multicolumn="1" alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28345 \begin_inset Text
28346
28347 \begin_layout Standard
28348 PORTB change interrupt
28349 \end_layout
28350
28351 \end_inset
28352 </cell>
28353 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28354 \begin_inset Text
28355
28356 \begin_layout Standard
28357 SIG_EE
28358 \end_layout
28359
28360 \end_inset
28361 </cell>
28362 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28363 \begin_inset Text
28364
28365 \begin_layout Standard
28366 EEPROM/FLASH write complete interrupt
28367 \end_layout
28368
28369 \end_inset
28370 </cell>
28371 </row>
28372 <row topline="true">
28373 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28374 \begin_inset Text
28375
28376 \begin_layout Standard
28377 SIG_INT0
28378 \end_layout
28379
28380 \end_inset
28381 </cell>
28382 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28383 \begin_inset Text
28384
28385 \begin_layout Standard
28386 INT0 external interrupt
28387 \end_layout
28388
28389 \end_inset
28390 </cell>
28391 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28392 \begin_inset Text
28393
28394 \begin_layout Standard
28395 SIG_BCOL
28396 \end_layout
28397
28398 \end_inset
28399 </cell>
28400 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28401 \begin_inset Text
28402
28403 \begin_layout Standard
28404 Bus collision interrupt
28405 \end_layout
28406
28407 \end_inset
28408 </cell>
28409 </row>
28410 <row topline="true">
28411 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28412 \begin_inset Text
28413
28414 \begin_layout Standard
28415 SIG_INT1
28416 \end_layout
28417
28418 \end_inset
28419 </cell>
28420 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28421 \begin_inset Text
28422
28423 \begin_layout Standard
28424 INT1 external interrupt
28425 \end_layout
28426
28427 \end_inset
28428 </cell>
28429 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28430 \begin_inset Text
28431
28432 \begin_layout Standard
28433 SIG_LVD
28434 \end_layout
28435
28436 \end_inset
28437 </cell>
28438 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28439 \begin_inset Text
28440
28441 \begin_layout Standard
28442 Low voltage detect interrupt
28443 \end_layout
28444
28445 \end_inset
28446 </cell>
28447 </row>
28448 <row topline="true">
28449 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28450 \begin_inset Text
28451
28452 \begin_layout Standard
28453 SIG_INT2
28454 \end_layout
28455
28456 \end_inset
28457 </cell>
28458 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28459 \begin_inset Text
28460
28461 \begin_layout Standard
28462 INT2 external interrupt
28463 \end_layout
28464
28465 \end_inset
28466 </cell>
28467 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28468 \begin_inset Text
28469
28470 \begin_layout Standard
28471 SIG_PSP
28472 \end_layout
28473
28474 \end_inset
28475 </cell>
28476 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28477 \begin_inset Text
28478
28479 \begin_layout Standard
28480 Parallel slave port interrupt
28481 \end_layout
28482
28483 \end_inset
28484 </cell>
28485 </row>
28486 <row topline="true">
28487 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28488 \begin_inset Text
28489
28490 \begin_layout Standard
28491 SIG_CCP1
28492 \end_layout
28493
28494 \end_inset
28495 </cell>
28496 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28497 \begin_inset Text
28498
28499 \begin_layout Standard
28500 CCP1 module interrupt
28501 \end_layout
28502
28503 \end_inset
28504 </cell>
28505 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28506 \begin_inset Text
28507
28508 \begin_layout Standard
28509 SIG_AD
28510 \end_layout
28511
28512 \end_inset
28513 </cell>
28514 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28515 \begin_inset Text
28516
28517 \begin_layout Standard
28518 AD convertion complete interrupt
28519 \end_layout
28520
28521 \end_inset
28522 </cell>
28523 </row>
28524 <row topline="true">
28525 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28526 \begin_inset Text
28527
28528 \begin_layout Standard
28529 SIG_CCP2
28530 \end_layout
28531
28532 \end_inset
28533 </cell>
28534 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28535 \begin_inset Text
28536
28537 \begin_layout Standard
28538 CCP2 module interrupt
28539 \end_layout
28540
28541 \end_inset
28542 </cell>
28543 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28544 \begin_inset Text
28545
28546 \begin_layout Standard
28547 SIG_RC
28548 \end_layout
28549
28550 \end_inset
28551 </cell>
28552 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28553 \begin_inset Text
28554
28555 \begin_layout Standard
28556 USART receive interrupt
28557 \end_layout
28558
28559 \end_inset
28560 </cell>
28561 </row>
28562 <row topline="true">
28563 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28564 \begin_inset Text
28565
28566 \begin_layout Standard
28567 SIG_TMR0
28568 \end_layout
28569
28570 \end_inset
28571 </cell>
28572 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28573 \begin_inset Text
28574
28575 \begin_layout Standard
28576 TMR0 overflow interrupt
28577 \end_layout
28578
28579 \end_inset
28580 </cell>
28581 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28582 \begin_inset Text
28583
28584 \begin_layout Standard
28585 SIG_TX
28586 \end_layout
28587
28588 \end_inset
28589 </cell>
28590 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28591 \begin_inset Text
28592
28593 \begin_layout Standard
28594 USART transmit interrupt
28595 \end_layout
28596
28597 \end_inset
28598 </cell>
28599 </row>
28600 <row topline="true">
28601 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28602 \begin_inset Text
28603
28604 \begin_layout Standard
28605 SIG_TMR1
28606 \end_layout
28607
28608 \end_inset
28609 </cell>
28610 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28611 \begin_inset Text
28612
28613 \begin_layout Standard
28614 TMR1 overflow interrupt
28615 \end_layout
28616
28617 \end_inset
28618 </cell>
28619 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28620 \begin_inset Text
28621
28622 \begin_layout Standard
28623 SIG_MSSP
28624 \end_layout
28625
28626 \end_inset
28627 </cell>
28628 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28629 \begin_inset Text
28630
28631 \begin_layout Standard
28632 SSP receive/transmit interrupt
28633 \end_layout
28634
28635 \end_inset
28636 </cell>
28637 </row>
28638 <row topline="true">
28639 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28640 \begin_inset Text
28641
28642 \begin_layout Standard
28643 SIG_TMR2
28644 \end_layout
28645
28646 \end_inset
28647 </cell>
28648 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28649 \begin_inset Text
28650
28651 \begin_layout Standard
28652 TMR2 matches PR2 interrupt
28653 \end_layout
28654
28655 \end_inset
28656 </cell>
28657 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28658 \begin_inset Text
28659
28660 \begin_layout Standard
28661
28662 \end_layout
28663
28664 \end_inset
28665 </cell>
28666 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28667 \begin_inset Text
28668
28669 \begin_layout Standard
28670
28671 \end_layout
28672
28673 \end_inset
28674 </cell>
28675 </row>
28676 <row topline="true" bottomline="true">
28677 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28678 \begin_inset Text
28679
28680 \begin_layout Standard
28681 SIG_TMR3
28682 \end_layout
28683
28684 \end_inset
28685 </cell>
28686 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28687 \begin_inset Text
28688
28689 \begin_layout Standard
28690 TMR3 overflow interrupt
28691 \end_layout
28692
28693 \end_inset
28694 </cell>
28695 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28696 \begin_inset Text
28697
28698 \begin_layout Standard
28699
28700 \end_layout
28701
28702 \end_inset
28703 </cell>
28704 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28705 \begin_inset Text
28706
28707 \begin_layout Standard
28708
28709 \end_layout
28710
28711 \end_inset
28712 </cell>
28713 </row>
28714 </lyxtabular>
28715
28716 \end_inset
28717
28718
28719 \end_layout
28720
28721 \begin_layout Standard
28722 \noindent
28723 The prototypes for these names are defined in the header file 
28724 \emph on
28725 signal.h
28726 \emph default
28727  .
28728 \end_layout
28729
28730 \begin_layout Standard
28731 \noindent
28732 In order to simplify signal handling, a number of macros is provided:
28733 \end_layout
28734
28735 \begin_layout List
28736 \labelwidthstring 00.00.0000
28737 DEF_INTHIGH(name) begin the definition of the interrupt dispatch table for
28738  high priority interrupts.
28739  
28740 \emph on
28741 name
28742 \emph default
28743  is the function name to use.
28744 \end_layout
28745
28746 \begin_layout List
28747 \labelwidthstring 00.00.0000
28748 DEF_INTLOW(name) begin the definition of the interrupt dispatch table fo
28749  low priority interrupt.
28750  
28751 \emph on
28752 name
28753 \emph default
28754  is the function name to use.
28755 \end_layout
28756
28757 \begin_layout List
28758 \labelwidthstring 00.00.0000
28759 DEF_HANDLER(sig,handler) define a handler for signal 
28760 \emph on
28761 sig.
28762 \end_layout
28763
28764 \begin_layout List
28765 \labelwidthstring 00.00.0000
28766 END_DEF end the declaration of the dispatch table.
28767 \end_layout
28768
28769 \begin_layout Standard
28770 Additionally there are two more macros to simplify the declaration of the
28771  signal handler:
28772 \end_layout
28773
28774 \begin_layout List
28775 \labelwidthstring 00.00.0000
28776
28777 \series medium
28778 SIGHANDLER(handler) 
28779 \series default
28780 this declares the function prototype for the 
28781 \emph on
28782 handler
28783 \emph default
28784  function.
28785 \end_layout
28786
28787 \begin_layout List
28788 \labelwidthstring 00.00.0000
28789 SIGHANDLERNAKED(handler) same as SIGHANDLER() but declares a naked function.
28790 \end_layout
28791
28792 \begin_layout Standard
28793 An example of using the macros above is shown below:
28794 \end_layout
28795
28796 \begin_layout LyX-Code
28797 #include <pic18fregs.h>
28798 \end_layout
28799
28800 \begin_layout LyX-Code
28801 #include <signal.h>
28802 \newline
28803
28804 \newline
28805 DEF_INTHIGH(high_int)
28806 \end_layout
28807
28808 \begin_layout LyX-Code
28809 DEF_HANDLER(SIG_TMR0, _tmr0_handler)
28810 \end_layout
28811
28812 \begin_layout LyX-Code
28813 DEF_HANDLER(SIG_BCOL, _bcol_handler)
28814 \end_layout
28815
28816 \begin_layout LyX-Code
28817 END_DEF
28818 \newline
28819
28820 \newline
28821 SIGHANDLER(_tmr0_handler)
28822 \end_layout
28823
28824 \begin_layout LyX-Code
28825 {
28826 \end_layout
28827
28828 \begin_layout LyX-Code
28829   /* action to be taken when timer 0 overflows */
28830 \end_layout
28831
28832 \begin_layout LyX-Code
28833 }
28834 \newline
28835
28836 \newline
28837 SIGHANDLERNAKED(_bcol_handler)
28838 \end_layout
28839
28840 \begin_layout LyX-Code
28841 {
28842 \end_layout
28843
28844 \begin_layout LyX-Code
28845   _asm
28846 \end_layout
28847
28848 \begin_layout LyX-Code
28849     /* action to be taken when bus collision occurs */
28850 \end_layout
28851
28852 \begin_layout LyX-Code
28853     retfie
28854 \end_layout
28855
28856 \begin_layout LyX-Code
28857  _endasm;
28858 \end_layout
28859
28860 \begin_layout LyX-Code
28861 }
28862 \end_layout
28863
28864 \begin_layout Standard
28865
28866 \series bold
28867 NOTES:
28868 \series default
28869  Special care should be taken when using the above scheme:
28870 \end_layout
28871
28872 \begin_layout Itemize
28873 do not place a colon (;) at the end of the DEF_* and END_DEF macros.
28874 \end_layout
28875
28876 \begin_layout Itemize
28877 when declaring SIGHANDLERNAKED handler never forget to use 
28878 \emph on
28879 retfie
28880 \emph default
28881  for proper returning.
28882 \end_layout
28883
28884 \begin_layout Subsection
28885 PIC16 Port -- Tips
28886 \end_layout
28887
28888 \begin_layout Standard
28889 Here you can find some general tips for compiling programs with SDCC/pic16.
28890 \end_layout
28891
28892 \begin_layout Subsubsection
28893 Stack size
28894 \end_layout
28895
28896 \begin_layout Standard
28897 The default stack
28898 \begin_inset LatexCommand \index{PIC16!stack}
28899
28900 \end_inset
28901
28902  size (that is 64 bytes) probably is enough for many programs.
28903  One must take care that when there are many levels of function nesting,
28904  or there is excessive usage of stack, its size should be extended.
28905  An example of such a case is the printf/sprintf family of functions.
28906  If you encounter problems like not being able to print integers, then you
28907  need to set the stack size around the maximum (256 for small stack model).
28908  The following diagram shows what happens when calling printf to print an
28909  integer:
28910 \end_layout
28911
28912 \begin_layout LyX-Code
28913 printf () --> ltoa () --> ultoa () --> divschar ()
28914 \end_layout
28915
28916 \begin_layout Standard
28917 It is should be understood that stack is easily consumed when calling complicate
28918 d functions.
28919  Using command line arguments like -
28920 \begin_inset ERT
28921 status collapsed
28922
28923 \begin_layout Standard
28924
28925
28926 \backslash
28927 /
28928 \end_layout
28929
28930 \end_inset
28931
28932 -fommit-frame-pointer might reduce stack usage by not creating unnecessery
28933  stack frames.
28934  Other ways to reduce stack usage may exist.
28935 \end_layout
28936
28937 \begin_layout Subsection
28938 Known Bugs
28939 \end_layout
28940
28941 \begin_layout Subsubsection
28942 Extended Instruction Set
28943 \end_layout
28944
28945 \begin_layout Standard
28946 The PIC16 port emits code which is incompatible with the extended instruction
28947  set available with many newer devices.
28948  Make sure to always explicitly disable it, usually using
28949 \end_layout
28950
28951 \begin_layout Standard
28952
28953 \family typewriter
28954 static __code char __at(__CONFIG4L) conf4l = /* more flags & */ _XINST_OFF_4L;
28955 \end_layout
28956
28957 \begin_layout Standard
28958 \noindent
28959 Some devices (namely 18f2455, 18f2550, 18f4455, and 18f4550) use _ENHCPU_OFF_4L
28960  instead of _XINST_OFF_4L.
28961 \end_layout
28962
28963 \begin_layout Subsubsection
28964 Regression Tests
28965 \end_layout
28966
28967 \begin_layout Standard
28968 The PIC16 port currently passes most but not all of the tests in SDCC's
28969  regression test
28970 \begin_inset LatexCommand \index{Regression test (PIC16)}
28971
28972 \end_inset
28973
28974  suite (see section 
28975 \begin_inset LatexCommand \ref{sec:Quality-control}
28976
28977 \end_inset
28978
28979 ), thus no automatic regression tests are currently performed for the PIC16
28980  target.
28981 \end_layout
28982
28983 \begin_layout Chapter
28984 Debugging
28985 \end_layout
28986
28987 \begin_layout Standard
28988 There are several approaches to debugging your code.
28989  This chapter is meant to show your options and to give detail on some of
28990  them:
28991 \newline
28992
28993 \newline
28994 When writing your code:
28995 \end_layout
28996
28997 \begin_layout Itemize
28998 write your code with debugging in mind (avoid duplicating code, put conceptually
28999  similar variables into structs, use structured code, have strategic points
29000  within your code where all variables are consistent, ...)
29001 \end_layout
29002
29003 \begin_layout Itemize
29004 run a syntax-checking tool like splint
29005 \begin_inset LatexCommand \index{splint (syntax checking tool)}
29006
29007 \end_inset
29008
29009
29010 \begin_inset LatexCommand \index{lint (syntax checking tool)}
29011
29012 \end_inset
29013
29014  (see -
29015 \begin_inset ERT
29016 status collapsed
29017
29018 \begin_layout Standard
29019
29020
29021 \backslash
29022 /
29023 \end_layout
29024
29025 \end_inset
29026
29027 -more-pedantic 
29028 \begin_inset LatexCommand \ref{lyx:more-pedantic-SPLINT}
29029
29030 \end_inset
29031
29032 ) over the code.
29033 \end_layout
29034
29035 \begin_layout Itemize
29036 for the high level code use a C-compiler (like f.e.
29037  GCC) to compile run and debug the code on your host.
29038  See (see -
29039 \begin_inset ERT
29040 status collapsed
29041
29042 \begin_layout Standard
29043
29044
29045 \backslash
29046 /
29047 \end_layout
29048
29049 \end_inset
29050
29051 -more-pedantic 
29052 \begin_inset LatexCommand \ref{lyx:more-pedantic-SPLINT}
29053
29054 \end_inset
29055
29056 ) on how to handle syntax extensions like __xdata, __at(), ...
29057  
29058 \end_layout
29059
29060 \begin_layout Itemize
29061 use another C-compiler to compile code for your target.
29062  Always an option but not recommended:) And not very likely to help you.
29063  If you seriously consider walking this path you should at least occasionally
29064  check portability of your code.
29065  Most commercial compiler vendors will offer an evaluation version so you
29066  can test compile your code or snippets of your code.
29067 \end_layout
29068
29069 \begin_layout Standard
29070 Debugging on a simulator:
29071 \end_layout
29072
29073 \begin_layout Itemize
29074 there is a separate section about SDCDB (section 
29075 \begin_inset LatexCommand \ref{cha:Debugging-with-SDCDB}
29076
29077 \end_inset
29078
29079 ) below.
29080 \end_layout
29081
29082 \begin_layout Itemize
29083 or (8051 specific) use a freeware/commercial simulator which interfaces
29084  to the AOMF
29085 \begin_inset LatexCommand \index{AOMF, AOMF51}
29086
29087 \end_inset
29088
29089  file (see 
29090 \begin_inset LatexCommand \ref{OMF file}
29091
29092 \end_inset
29093
29094 ) optionally generated by SDCC.
29095 \end_layout
29096
29097 \begin_layout Standard
29098 Debugging On-target: 
29099 \end_layout
29100
29101 \begin_layout Itemize
29102 use a MCU port pin to serially output debug data to the RS232 port of your
29103  host.
29104  You'll probably want some level shifting device typically involving a MAX232
29105  or similar IC.
29106  If the hardware serial port of the MCU is not available search for 'Software
29107  UART' in your favourite search machine.
29108 \end_layout
29109
29110 \begin_layout Itemize
29111 use an on-target monitor.
29112  In this context a monitor is a small program which usually accepts commands
29113  via a serial line and allows to set program counter, to single step through
29114  a program and read/write memory locations.
29115  For the 8051 good examples of monitors are paulmon and cmon51 (see section
29116  
29117 \begin_inset LatexCommand \ref{sec:Related-open-source-tools}
29118
29119 \end_inset
29120
29121 ).
29122 \end_layout
29123
29124 \begin_layout Itemize
29125 toggle MCU port pins at strategic points within your code and use an oscilloscop
29126 e.
29127  A 
29128 \emph on
29129 digital oscilloscope
29130 \emph default
29131
29132 \begin_inset LatexCommand \index{Oscilloscope}
29133
29134 \end_inset
29135
29136  with deep trace memory is really helpful especially if you have to debug
29137  a realtime application.
29138  If you need to monitor more pins than your oscilloscope provides you can
29139  sometimes get away with a small R-2R network.
29140  On a single channel oscilloscope you could f.e.
29141  monitor 2 push-pull driven pins by connecting one via a 10\InsetSpace ~
29142 k
29143 \begin_inset Formula $\Omega$
29144 \end_inset
29145
29146  resistor and the other one by a 5\InsetSpace ~
29147 k
29148 \begin_inset Formula $\Omega$
29149 \end_inset
29150
29151  resistor to the oscilloscope probe (check output drive capability of the
29152  pins you want to monitor).
29153  If you need to monitor many more pins a 
29154 \emph on
29155 logic analyzer
29156 \emph default
29157  will be handy.
29158 \end_layout
29159
29160 \begin_layout Itemize
29161 use an ICE (
29162 \emph on
29163 i
29164 \emph default
29165
29166 \emph on
29167 c
29168 \emph default
29169 ircuit 
29170 \emph on
29171 e
29172 \emph default
29173 mulator
29174 \begin_inset LatexCommand \index{ICE (in circuit emulator)}
29175
29176 \end_inset
29177
29178 ).
29179  Usually very expensive.
29180  And very nice to have too.
29181  And usually locks you (for years...) to the devices the ICE can emulate.
29182  
29183 \end_layout
29184
29185 \begin_layout Itemize
29186 use a remote debugger.
29187  In most 8-bit systems the symbol information is not available on the target,
29188  and a complete debugger is too bulky for the target system.
29189  Therefore usually a debugger on the host system connects to an on-target
29190  debugging stub which accepts only primitive commands.
29191  
29192 \newline
29193 Terms to enter into your favourite search engine could be 'remote debugging',
29194  'gdb stub' or 'inferior debugger'.
29195  (is there one?)
29196 \end_layout
29197
29198 \begin_layout Itemize
29199 use an on target hardware debugger.
29200  Some of the more modern MCUs include hardware support for setting break
29201  points and monitoring/changing variables by using dedicated hardware pins.
29202  This facility doesn't require additional code to run on the target and
29203  
29204 \emph on
29205 usually
29206 \emph default
29207  doesn't affect runtime behaviour until a breakpoint is hit.
29208  For the mcs51 most hardware debuggers use the AOMF
29209 \begin_inset LatexCommand \index{AOMF, AOMF51}
29210
29211 \end_inset
29212
29213  file (see 
29214 \begin_inset LatexCommand \ref{OMF file}
29215
29216 \end_inset
29217
29218 ) as input file.
29219  
29220 \end_layout
29221
29222 \begin_layout Standard
29223 Last not least:
29224 \end_layout
29225
29226 \begin_layout Itemize
29227 if you are not familiar with any of the following terms you're likely to
29228  run into problems rather sooner than later: 
29229 \emph on
29230 volatile
29231 \emph default
29232
29233 \emph on
29234 atomic
29235 \emph default
29236
29237 \emph on
29238 memory map
29239 \emph default
29240
29241 \emph on
29242 overlay
29243 \emph default
29244 .
29245  As an embedded programmer you 
29246 \emph on
29247 have
29248 \emph default
29249  to know them so why not look them up 
29250 \emph on
29251 before
29252 \emph default
29253  you have problems?)
29254 \end_layout
29255
29256 \begin_layout Itemize
29257 tell someone else about your problem (actually this is a surprisingly effective
29258  means to hunt down the bug even if the listener is not familiar with your
29259  environment).
29260  As 'failure to communicate' is probably one of the job-induced deformations
29261  of an embedded programmer this is highly encouraged.
29262 \end_layout
29263
29264 \begin_layout Section
29265 Debugging with SDCDB
29266 \begin_inset LatexCommand \label{cha:Debugging-with-SDCDB}
29267
29268 \end_inset
29269
29270
29271 \begin_inset LatexCommand \index{SDCDB (debugger)}
29272
29273 \end_inset
29274
29275  
29276 \end_layout
29277
29278 \begin_layout Standard
29279 SDCC is distributed with a source level debugger
29280 \begin_inset LatexCommand \index{Debugger}
29281
29282 \end_inset
29283
29284 .
29285  The debugger uses a command line interface, the command repertoire of the
29286  debugger has been kept as close to gdb
29287 \begin_inset LatexCommand \index{gdb}
29288
29289 \end_inset
29290
29291  (the GNU debugger) as possible.
29292  The configuration and build process is part of the standard compiler installati
29293 on, which also builds and installs the debugger in the target directory
29294  specified during configuration.
29295  The debugger allows you debug BOTH at the C source and at the ASM source
29296  level.
29297 \end_layout
29298
29299 \begin_layout Subsection
29300 Compiling for Debugging
29301 \end_layout
29302
29303 \begin_layout Standard
29304 The -
29305 \begin_inset ERT
29306 status collapsed
29307
29308 \begin_layout Standard
29309
29310
29311 \backslash
29312 /
29313 \end_layout
29314
29315 \end_inset
29316
29317 -debug
29318 \begin_inset LatexCommand \index{-\/-debug}
29319
29320 \end_inset
29321
29322  option must be specified for all files for which debug information is to
29323  be generated.
29324  The compiler generates a .adb file for each of these files.
29325  The linker creates the .cdb
29326 \begin_inset LatexCommand \index{<file>.cdb}
29327
29328 \end_inset
29329
29330  file from the .adb
29331 \begin_inset LatexCommand \index{<file>.adb}
29332
29333 \end_inset
29334
29335  files and the address information.
29336  This .cdb is used by the debugger.
29337 \end_layout
29338
29339 \begin_layout Subsection
29340 How the Debugger Works
29341 \end_layout
29342
29343 \begin_layout Standard
29344 When the -
29345 \begin_inset ERT
29346 status collapsed
29347
29348 \begin_layout Standard
29349
29350
29351 \backslash
29352 /
29353 \end_layout
29354
29355 \end_inset
29356
29357 -debug option is specified the compiler generates extra symbol information
29358  some of which are put into the assembler source and some are put into the
29359  .adb file.
29360  Then the linker creates the .cdb file from the individual .adb files with
29361  the address information for the symbols.
29362  The debugger reads the symbolic information generated by the compiler &
29363  the address information generated by the linker.
29364  It uses the SIMULATOR (Daniel's S51) to execute the program, the program
29365  execution is controlled by the debugger.
29366  When a command is issued for the debugger, it translates it into appropriate
29367  commands for the simulator.
29368  (Currently SDCDM only connects to the simulator but 
29369 \emph on
29370 newcdb
29371 \emph default
29372  at 
29373 \begin_inset LatexCommand \url{http://ec2drv.sf.net/}
29374
29375 \end_inset
29376
29377  is an effort to connect directly to the hardware.) 
29378 \end_layout
29379
29380 \begin_layout Subsection
29381 Starting the Debugger SDCDB
29382 \end_layout
29383
29384 \begin_layout Standard
29385 The debugger can be started using the following command line.
29386  (Assume the file you are debugging has the file name foo).
29387 \newline
29388
29389 \newline
29390
29391 \family sans
29392 \series bold
29393 sdcdb foo
29394 \newline
29395
29396 \family default
29397 \series default
29398
29399 \newline
29400 The debugger will look for the following files.
29401 \end_layout
29402
29403 \begin_layout Itemize
29404 foo.c - the source file.
29405 \end_layout
29406
29407 \begin_layout Itemize
29408 foo.cdb - the debugger symbol information file.
29409 \end_layout
29410
29411 \begin_layout Itemize
29412 foo.ihx - the Intel hex format
29413 \begin_inset LatexCommand \index{Intel hex format}
29414
29415 \end_inset
29416
29417  object file.
29418 \end_layout
29419
29420 \begin_layout Subsection
29421 SDCDB Command Line Options
29422 \end_layout
29423
29424 \begin_layout Itemize
29425 -
29426 \begin_inset ERT
29427 status collapsed
29428
29429 \begin_layout Standard
29430
29431
29432 \backslash
29433 /
29434 \end_layout
29435
29436 \end_inset
29437
29438 -directory=<source file directory> this option can used to specify the directory
29439  search list.
29440  The debugger will look into the directory list specified for source, cdb
29441  & ihx files.
29442  The items in the directory list must be separated by ':', e.g.
29443  if the source files can be in the directories /home/src1 and /home/src2,
29444  the -
29445 \begin_inset ERT
29446 status collapsed
29447
29448 \begin_layout Standard
29449
29450
29451 \backslash
29452 /
29453 \end_layout
29454
29455 \end_inset
29456
29457 -directory option should be -
29458 \begin_inset ERT
29459 status collapsed
29460
29461 \begin_layout Standard
29462
29463
29464 \backslash
29465 /
29466 \end_layout
29467
29468 \end_inset
29469
29470 -directory=/home/src1:/home/src2.
29471  Note there can be no spaces in the option.
29472  
29473 \end_layout
29474
29475 \begin_layout Itemize
29476 -cd <directory> - change to the <directory>.
29477 \end_layout
29478
29479 \begin_layout Itemize
29480 -fullname - used by GUI front ends.
29481 \end_layout
29482
29483 \begin_layout Itemize
29484 -cpu <cpu-type> - this argument is passed to the simulator please see the
29485  simulator docs for details.
29486 \end_layout
29487
29488 \begin_layout Itemize
29489 -X <Clock frequency > this options is passed to the simulator please see
29490  the simulator docs for details.
29491 \end_layout
29492
29493 \begin_layout Itemize
29494 -s <serial port file> passed to simulator see the simulator docs for details.
29495 \end_layout
29496
29497 \begin_layout Itemize
29498 -S <serial in,out> passed to simulator see the simulator docs for details.
29499 \end_layout
29500
29501 \begin_layout Itemize
29502 -k <port number> passed to simulator see the simulator docs for details.
29503 \end_layout
29504
29505 \begin_layout Subsection
29506 SDCDB Debugger Commands
29507 \end_layout
29508
29509 \begin_layout Standard
29510 As mentioned earlier the command interface for the debugger has been deliberatel
29511 y kept as close the GNU debugger gdb, as possible.
29512  This will help the integration with existing graphical user interfaces
29513  (like ddd, xxgdb or xemacs) existing for the GNU debugger.
29514  If you use a graphical user interface for the debugger you can skip this
29515  section.
29516 \end_layout
29517
29518 \begin_layout Subsubsection*
29519 break [line | file:line | function | file:function]
29520 \end_layout
29521
29522 \begin_layout Standard
29523 Set breakpoint at specified line or function:
29524 \newline
29525
29526 \newline
29527
29528 \family sans
29529 \series bold
29530 sdcdb>break 100 
29531 \newline
29532 sdcdb>break foo.c:100
29533 \newline
29534 sdcdb>break funcfoo
29535 \newline
29536 sdcdb>break foo.c:funcfoo
29537 \end_layout
29538
29539 \begin_layout Subsubsection*
29540 clear [line | file:line | function | file:function ]
29541 \end_layout
29542
29543 \begin_layout Standard
29544 Clear breakpoint at specified line or function:
29545 \newline
29546
29547 \newline
29548
29549 \family sans
29550 \series bold
29551 sdcdb>clear 100
29552 \newline
29553 sdcdb>clear foo.c:100
29554 \newline
29555 sdcdb>clear funcfoo
29556 \newline
29557 sdcdb>clear foo.c:funcfoo
29558 \end_layout
29559
29560 \begin_layout Subsubsection*
29561 continue
29562 \end_layout
29563
29564 \begin_layout Standard
29565 Continue program being debugged, after breakpoint.
29566 \end_layout
29567
29568 \begin_layout Subsubsection*
29569 finish
29570 \end_layout
29571
29572 \begin_layout Standard
29573 Execute till the end of the current function.
29574 \end_layout
29575
29576 \begin_layout Subsubsection*
29577 delete [n]
29578 \end_layout
29579
29580 \begin_layout Standard
29581 Delete breakpoint number 'n'.
29582  If used without any option clear ALL user defined break points.
29583 \end_layout
29584
29585 \begin_layout Subsubsection*
29586 info [break | stack | frame | registers ]
29587 \end_layout
29588
29589 \begin_layout Itemize
29590 info break - list all breakpoints
29591 \end_layout
29592
29593 \begin_layout Itemize
29594 info stack - show the function call stack.
29595 \end_layout
29596
29597 \begin_layout Itemize
29598 info frame - show information about the current execution frame.
29599 \end_layout
29600
29601 \begin_layout Itemize
29602 info registers - show content of all registers.
29603 \end_layout
29604
29605 \begin_layout Subsubsection*
29606 step
29607 \end_layout
29608
29609 \begin_layout Standard
29610 Step program until it reaches a different source line.
29611  Note: pressing <return> repeats the last command.
29612 \end_layout
29613
29614 \begin_layout Subsubsection*
29615 next
29616 \end_layout
29617
29618 \begin_layout Standard
29619 Step program, proceeding through subroutine calls.
29620 \end_layout
29621
29622 \begin_layout Subsubsection*
29623 run
29624 \end_layout
29625
29626 \begin_layout Standard
29627 Start debugged program.
29628 \end_layout
29629
29630 \begin_layout Subsubsection*
29631 ptype variable 
29632 \end_layout
29633
29634 \begin_layout Standard
29635 Print type information of the variable.
29636 \end_layout
29637
29638 \begin_layout Subsubsection*
29639 print variable
29640 \end_layout
29641
29642 \begin_layout Standard
29643 print value of variable.
29644 \end_layout
29645
29646 \begin_layout Subsubsection*
29647 file filename
29648 \end_layout
29649
29650 \begin_layout Standard
29651 load the given file name.
29652  Note this is an alternate method of loading file for debugging.
29653 \end_layout
29654
29655 \begin_layout Subsubsection*
29656 frame
29657 \end_layout
29658
29659 \begin_layout Standard
29660 print information about current frame.
29661 \end_layout
29662
29663 \begin_layout Subsubsection*
29664 set srcmode
29665 \end_layout
29666
29667 \begin_layout Standard
29668 Toggle between C source & assembly source.
29669 \end_layout
29670
29671 \begin_layout Subsubsection*
29672 ! simulator command
29673 \end_layout
29674
29675 \begin_layout Standard
29676 Send the string following '!' to the simulator, the simulator response is
29677  displayed.
29678  Note the debugger does not interpret the command being sent to the simulator,
29679  so if a command like 'go' is sent the debugger can loose its execution
29680  context and may display incorrect values.
29681 \end_layout
29682
29683 \begin_layout Subsubsection*
29684 quit
29685 \end_layout
29686
29687 \begin_layout Standard
29688 "Watch me now.
29689  Iam going Down.
29690  My name is Bobby Brown"
29691 \end_layout
29692
29693 \begin_layout Subsection
29694 Interfacing SDCDB with DDD
29695 \end_layout
29696
29697 \begin_layout Standard
29698 \begin_inset Note Note
29699 status collapsed
29700
29701 \begin_layout Standard
29702 The screenshot was converted from png to eps with: 
29703 \begin_inset Quotes sld
29704 \end_inset
29705
29706 bmeps -c -e8f -p3 ddd_example.png >ddd_example.eps
29707 \begin_inset Quotes srd
29708 \end_inset
29709
29710  which produces a pretty compact eps file which is free from compression
29711  artifacts.
29712 \end_layout
29713
29714 \begin_layout Standard
29715 The screenshot was included in sdccman.lyx cvs version 1.120 but later removed
29716  as this broke the build system on Sourceforge (pdf-file was broken.
29717  pdflatex does not accept eps files).
29718 \end_layout
29719
29720 \end_inset
29721
29722
29723 \end_layout
29724
29725 \begin_layout Standard
29726 The 
29727 \emph on
29728 p
29729 \emph default
29730 ortable 
29731 \emph on
29732 n
29733 \emph default
29734 etwork 
29735 \emph on
29736 g
29737 \emph default
29738 raphics File 
29739 \size footnotesize
29740
29741 \begin_inset LatexCommand \url{http://sdcc.svn.sourceforge.net/viewvc/*checkout*/sdcc/trunk/sdcc/doc/figures/ddd_example.png}
29742
29743 \end_inset
29744
29745
29746 \size default
29747  shows a screenshot of a debugging session with DDD
29748 \begin_inset LatexCommand \index{DDD (debugger)}
29749
29750 \end_inset
29751
29752  (Unix only) on a simulated 8032.
29753  The debugging session might not run as smoothly as the screenshot suggests.
29754  The debugger allows setting of breakpoints, displaying and changing variables,
29755  single stepping through C and assembler code.
29756  
29757 \newline
29758 The source was compiled with 
29759 \family sans
29760 \series bold
29761
29762 \newline
29763
29764 \newline
29765 sdcc -
29766 \family default
29767 \series default
29768
29769 \begin_inset ERT
29770 status collapsed
29771
29772 \begin_layout Standard
29773
29774
29775 \backslash
29776 /
29777 \end_layout
29778
29779 \end_inset
29780
29781
29782 \family sans
29783 \series bold
29784 -debug ddd_example.c
29785 \family default
29786 \series default
29787  
29788 \family sans
29789 \series bold
29790
29791 \newline
29792
29793 \family default
29794 \series default
29795
29796 \newline
29797 and DDD was invoked with 
29798 \family sans
29799 \series bold
29800
29801 \newline
29802
29803 \newline
29804 ddd -debugger "sdcdb -cpu 8032 ddd_example"
29805 \end_layout
29806
29807 \begin_layout Standard
29808 \begin_inset Note Note
29809 status open
29810
29811 \begin_layout Standard
29812 Check that the double quotes or an apostroph within the command line survive
29813  the LyX tool chain.
29814  Previously the apostrophs got slanted in the PDF output so a cut and paste
29815  did not work.
29816 \end_layout
29817
29818 \end_inset
29819
29820
29821 \end_layout
29822
29823 \begin_layout Subsection
29824 Interfacing SDCDB with XEmacs
29825 \begin_inset LatexCommand \index{XEmacs}
29826
29827 \end_inset
29828
29829
29830 \begin_inset LatexCommand \index{Emacs}
29831
29832 \end_inset
29833
29834
29835 \end_layout
29836
29837 \begin_layout Standard
29838 Two files (in emacs lisp) are provided for the interfacing with XEmacs,
29839  sdcdb.el and sdcdbsrc.el.
29840  These two files can be found in the $(prefix)/bin directory after the installat
29841 ion is complete.
29842  These files need to be loaded into XEmacs for the interface to work.
29843  This can be done at XEmacs startup time by inserting the following into
29844  your '.xemacs' file (which can be found in your HOME directory): 
29845 \newline
29846
29847 \newline
29848
29849 \family typewriter
29850 (load-file sdcdbsrc.el) 
29851 \family default
29852
29853 \newline
29854
29855 \newline
29856 .xemacs is a lisp file so the () around the command is REQUIRED.
29857  The files can also be loaded dynamically while XEmacs is running, set the
29858  environment variable 'EMACSLOADPATH' to the installation bin directory
29859  (<installdir>/bin), then enter the following command ESC-x load-file sdcdbsrc.
29860  To start the interface enter the following command: 
29861 \newline
29862
29863 \newline
29864
29865 \family sans
29866 \series bold
29867 ESC-x sdcdbsrc
29868 \family default
29869 \series default
29870
29871 \newline
29872
29873 \newline
29874 You will prompted to enter the file name to be debugged.
29875  
29876 \newline
29877
29878 \newline
29879 The command line options that are passed to the simulator directly are
29880  bound to default values in the file sdcdbsrc.el.
29881  The variables are listed below, these values maybe changed as required.
29882 \end_layout
29883
29884 \begin_layout Itemize
29885 sdcdbsrc-cpu-type '51
29886 \end_layout
29887
29888 \begin_layout Itemize
29889 sdcdbsrc-frequency '11059200
29890 \end_layout
29891
29892 \begin_layout Itemize
29893 sdcdbsrc-serial nil
29894 \end_layout
29895
29896 \begin_layout Standard
29897 The following is a list of key mapping for the debugger interface.
29898 \end_layout
29899
29900 \begin_layout Standard
29901 \InsetSpace ~
29902
29903 \family typewriter
29904
29905 \newline
29906 ;;\InsetSpace ~
29907 Current Listing :: 
29908 \newline
29909 ;;key\InsetSpace ~
29910 \InsetSpace ~
29911 \InsetSpace ~
29912 \InsetSpace ~
29913 \InsetSpace ~
29914 \InsetSpace ~
29915 \InsetSpace ~
29916 \InsetSpace ~
29917 \InsetSpace ~
29918 \InsetSpace ~
29919 \InsetSpace ~
29920 \InsetSpace ~
29921 \InsetSpace ~
29922 \InsetSpace ~
29923 binding\InsetSpace ~
29924 \InsetSpace ~
29925 \InsetSpace ~
29926 \InsetSpace ~
29927 \InsetSpace ~
29928 \InsetSpace ~
29929 \InsetSpace ~
29930 \InsetSpace ~
29931 \InsetSpace ~
29932 \InsetSpace ~
29933 \InsetSpace ~
29934 \InsetSpace ~
29935 \InsetSpace ~
29936 \InsetSpace ~
29937 \InsetSpace ~
29938 \InsetSpace ~
29939 \InsetSpace ~
29940 \InsetSpace ~
29941 \InsetSpace ~
29942 \InsetSpace ~
29943 \InsetSpace ~
29944 \InsetSpace ~
29945 Comment 
29946 \newline
29947 ;;---\InsetSpace ~
29948 \InsetSpace ~
29949 \InsetSpace ~
29950 \InsetSpace ~
29951 \InsetSpace ~
29952 \InsetSpace ~
29953 \InsetSpace ~
29954 \InsetSpace ~
29955 \InsetSpace ~
29956 \InsetSpace ~
29957 \InsetSpace ~
29958 \InsetSpace ~
29959 \InsetSpace ~
29960 \InsetSpace ~
29961 -------\InsetSpace ~
29962 \InsetSpace ~
29963 \InsetSpace ~
29964 \InsetSpace ~
29965 \InsetSpace ~
29966 \InsetSpace ~
29967 \InsetSpace ~
29968 \InsetSpace ~
29969 \InsetSpace ~
29970 \InsetSpace ~
29971 \InsetSpace ~
29972 \InsetSpace ~
29973 \InsetSpace ~
29974 \InsetSpace ~
29975 \InsetSpace ~
29976 \InsetSpace ~
29977 \InsetSpace ~
29978 \InsetSpace ~
29979 \InsetSpace ~
29980 \InsetSpace ~
29981 \InsetSpace ~
29982 \InsetSpace ~
29983 -------
29984 \newline
29985 ;; 
29986 \newline
29987 ;;\InsetSpace ~
29988 n\InsetSpace ~
29989 \InsetSpace ~
29990 \InsetSpace ~
29991 \InsetSpace ~
29992 \InsetSpace ~
29993 \InsetSpace ~
29994 \InsetSpace ~
29995 \InsetSpace ~
29996 \InsetSpace ~
29997 \InsetSpace ~
29998 \InsetSpace ~
29999 \InsetSpace ~
30000 \InsetSpace ~
30001 \InsetSpace ~
30002 \InsetSpace ~
30003 sdcdb-next-fro
30004 m-src\InsetSpace ~
30005 \InsetSpace ~
30006 \InsetSpace ~
30007 \InsetSpace ~
30008 \InsetSpace ~
30009 \InsetSpace ~
30010 \InsetSpace ~
30011 \InsetSpace ~
30012 \InsetSpace ~
30013 \InsetSpace ~
30014 SDCDB next command 
30015 \newline
30016 ;;\InsetSpace ~
30017 b\InsetSpace ~
30018 \InsetSpace ~
30019 \InsetSpace ~
30020 \InsetSpace ~
30021 \InsetSpace ~
30022 \InsetSpace ~
30023 \InsetSpace ~
30024 \InsetSpace ~
30025 \InsetSpace ~
30026 \InsetSpace ~
30027 \InsetSpace ~
30028 \InsetSpace ~
30029 \InsetSpace ~
30030 \InsetSpace ~
30031 \InsetSpace ~
30032 sdcdb-back-from-src\InsetSpace ~
30033 \InsetSpace ~
30034 \InsetSpace ~
30035 \InsetSpace ~
30036 \InsetSpace ~
30037 \InsetSpace ~
30038 \InsetSpace ~
30039 \InsetSpace ~
30040 \InsetSpace ~
30041 \InsetSpace ~
30042 SDCDB back command 
30043 \newline
30044 ;;\InsetSpace ~
30045 c\InsetSpace ~
30046 \InsetSpace ~
30047 \InsetSpace ~
30048 \InsetSpace ~
30049 \InsetSpace ~
30050 \InsetSpace ~
30051 \InsetSpace ~
30052 \InsetSpace ~
30053 \InsetSpace ~
30054 \InsetSpace ~
30055 \InsetSpace ~
30056 \InsetSpace ~
30057 \InsetSpace ~
30058 \InsetSpace ~
30059 \InsetSpace ~
30060 sdcdb-cont-f
30061 rom-src\InsetSpace ~
30062 \InsetSpace ~
30063 \InsetSpace ~
30064 \InsetSpace ~
30065 \InsetSpace ~
30066 \InsetSpace ~
30067 \InsetSpace ~
30068 \InsetSpace ~
30069 \InsetSpace ~
30070 \InsetSpace ~
30071 SDCDB continue command
30072 \newline
30073 ;;\InsetSpace ~
30074 s\InsetSpace ~
30075 \InsetSpace ~
30076 \InsetSpace ~
30077 \InsetSpace ~
30078 \InsetSpace ~
30079 \InsetSpace ~
30080 \InsetSpace ~
30081 \InsetSpace ~
30082 \InsetSpace ~
30083 \InsetSpace ~
30084 \InsetSpace ~
30085 \InsetSpace ~
30086 \InsetSpace ~
30087 \InsetSpace ~
30088 \InsetSpace ~
30089 sdcdb-step-from-src\InsetSpace ~
30090 \InsetSpace ~
30091 \InsetSpace ~
30092 \InsetSpace ~
30093 \InsetSpace ~
30094 \InsetSpace ~
30095 \InsetSpace ~
30096 \InsetSpace ~
30097 \InsetSpace ~
30098 \InsetSpace ~
30099 SDCDB step command 
30100 \newline
30101 ;;\InsetSpace ~
30102 ?\InsetSpace ~
30103 \InsetSpace ~
30104 \InsetSpace ~
30105 \InsetSpace ~
30106 \InsetSpace ~
30107 \InsetSpace ~
30108 \InsetSpace ~
30109 \InsetSpace ~
30110 \InsetSpace ~
30111 \InsetSpace ~
30112 \InsetSpace ~
30113 \InsetSpace ~
30114 \InsetSpace ~
30115 \InsetSpace ~
30116 \InsetSpace ~
30117 sdcdb-w
30118 hatis-c-sexp\InsetSpace ~
30119 \InsetSpace ~
30120 \InsetSpace ~
30121 \InsetSpace ~
30122 \InsetSpace ~
30123 \InsetSpace ~
30124 \InsetSpace ~
30125 \InsetSpace ~
30126 \InsetSpace ~
30127 \InsetSpace ~
30128 SDCDB ptypecommand for data at 
30129 \newline
30130 ;;\InsetSpace ~
30131 \InsetSpace ~
30132 \InsetSpace ~
30133 \InsetSpace ~
30134 \InsetSpace ~
30135 \InsetSpace ~
30136 \InsetSpace ~
30137 \InsetSpace ~
30138 \InsetSpace ~
30139 \InsetSpace ~
30140 \InsetSpace ~
30141 \InsetSpace ~
30142 \InsetSpace ~
30143 \InsetSpace ~
30144 \InsetSpace ~
30145 \InsetSpace ~
30146 \InsetSpace ~
30147 \InsetSpace ~
30148 \InsetSpace ~
30149 \InsetSpace ~
30150 \InsetSpace ~
30151 \InsetSpace ~
30152 \InsetSpace ~
30153 \InsetSpace ~
30154 \InsetSpace ~
30155 \InsetSpace ~
30156 \InsetSpace ~
30157 \InsetSpace ~
30158 \InsetSpace ~
30159 \InsetSpace ~
30160 \InsetSpace ~
30161 \InsetSpace ~
30162 \InsetSpace ~
30163 \InsetSpace ~
30164 \InsetSpace ~
30165 \InsetSpace ~
30166 \InsetSpace ~
30167 \InsetSpace ~
30168 \InsetSpace ~
30169 \InsetSpace ~
30170 \InsetSpace ~
30171 \InsetSpace ~
30172 \InsetSpace ~
30173 \InsetSpace ~
30174 \InsetSpace ~
30175 \InsetSpace ~
30176 \InsetSpace ~
30177 buffer point 
30178 \newline
30179 ;;\InsetSpace ~
30180 x\InsetSpace ~
30181 \InsetSpace ~
30182 \InsetSpace ~
30183 \InsetSpace ~
30184 \InsetSpace ~
30185 \InsetSpace ~
30186 \InsetSpace ~
30187 \InsetSpace ~
30188 \InsetSpace ~
30189 \InsetSpace ~
30190 \InsetSpace ~
30191 \InsetSpace ~
30192 \InsetSpace ~
30193 \InsetSpace ~
30194 \InsetSpace ~
30195 sdcdbsrc-delete\InsetSpace ~
30196 \InsetSpace ~
30197 \InsetSpace ~
30198 \InsetSpace ~
30199 \InsetSpace ~
30200 \InsetSpace ~
30201 \InsetSpace ~
30202 \InsetSpace ~
30203 \InsetSpace ~
30204 \InsetSpace ~
30205 \InsetSpace ~
30206 \InsetSpace ~
30207 \InsetSpace ~
30208 \InsetSpace ~
30209 SDCD
30210 B Delete all breakpoints if no arg 
30211 \newline
30212 ;;\InsetSpace ~
30213 \InsetSpace ~
30214 \InsetSpace ~
30215 \InsetSpace ~
30216 \InsetSpace ~
30217 \InsetSpace ~
30218 \InsetSpace ~
30219 \InsetSpace ~
30220 \InsetSpace ~
30221 \InsetSpace ~
30222 \InsetSpace ~
30223 \InsetSpace ~
30224 \InsetSpace ~
30225 \InsetSpace ~
30226 \InsetSpace ~
30227 \InsetSpace ~
30228 \InsetSpace ~
30229 \InsetSpace ~
30230 \InsetSpace ~
30231 \InsetSpace ~
30232 \InsetSpace ~
30233 \InsetSpace ~
30234 \InsetSpace ~
30235 \InsetSpace ~
30236 \InsetSpace ~
30237 \InsetSpace ~
30238 \InsetSpace ~
30239 \InsetSpace ~
30240 \InsetSpace ~
30241 \InsetSpace ~
30242 \InsetSpace ~
30243 \InsetSpace ~
30244 \InsetSpace ~
30245 \InsetSpace ~
30246 \InsetSpace ~
30247 \InsetSpace ~
30248 \InsetSpace ~
30249 \InsetSpace ~
30250 \InsetSpace ~
30251 \InsetSpace ~
30252 \InsetSpace ~
30253 \InsetSpace ~
30254 \InsetSpace ~
30255 \InsetSpace ~
30256 \InsetSpace ~
30257 \InsetSpace ~
30258 \InsetSpace ~
30259 given or delete arg (C-u arg x) 
30260 \newline
30261 ;;\InsetSpace ~
30262 m\InsetSpace ~
30263 \InsetSpace ~
30264 \InsetSpace ~
30265 \InsetSpace ~
30266 \InsetSpace ~
30267 \InsetSpace ~
30268 \InsetSpace ~
30269 \InsetSpace ~
30270 \InsetSpace ~
30271 \InsetSpace ~
30272 \InsetSpace ~
30273 \InsetSpace ~
30274 \InsetSpace ~
30275 \InsetSpace ~
30276 \InsetSpace ~
30277 sdcdbsrc
30278 -frame\InsetSpace ~
30279 \InsetSpace ~
30280 \InsetSpace ~
30281 \InsetSpace ~
30282 \InsetSpace ~
30283 \InsetSpace ~
30284 \InsetSpace ~
30285 \InsetSpace ~
30286 \InsetSpace ~
30287 \InsetSpace ~
30288 \InsetSpace ~
30289 \InsetSpace ~
30290 \InsetSpace ~
30291 \InsetSpace ~
30292 \InsetSpace ~
30293 SDCDB Display current frame if no arg, 
30294 \newline
30295 ;;\InsetSpace ~
30296 \InsetSpace ~
30297 \InsetSpace ~
30298 \InsetSpace ~
30299 \InsetSpace ~
30300 \InsetSpace ~
30301 \InsetSpace ~
30302 \InsetSpace ~
30303 \InsetSpace ~
30304 \InsetSpace ~
30305 \InsetSpace ~
30306 \InsetSpace ~
30307 \InsetSpace ~
30308 \InsetSpace ~
30309 \InsetSpace ~
30310 \InsetSpace ~
30311 \InsetSpace ~
30312 \InsetSpace ~
30313 \InsetSpace ~
30314 \InsetSpace ~
30315 \InsetSpace ~
30316 \InsetSpace ~
30317 \InsetSpace ~
30318 \InsetSpace ~
30319 \InsetSpace ~
30320 \InsetSpace ~
30321 \InsetSpace ~
30322 \InsetSpace ~
30323 \InsetSpace ~
30324 \InsetSpace ~
30325 \InsetSpace ~
30326 \InsetSpace ~
30327 \InsetSpace ~
30328 \InsetSpace ~
30329 \InsetSpace ~
30330 \InsetSpace ~
30331 \InsetSpace ~
30332 \InsetSpace ~
30333 \InsetSpace ~
30334 \InsetSpace ~
30335 \InsetSpace ~
30336 \InsetSpace ~
30337 \InsetSpace ~
30338 \InsetSpace ~
30339 \InsetSpace ~
30340 \InsetSpace ~
30341 \InsetSpace ~
30342 given or display frame arg
30343  
30344 \newline
30345 ;;\InsetSpace ~
30346 \InsetSpace ~
30347 \InsetSpace ~
30348 \InsetSpace ~
30349 \InsetSpace ~
30350 \InsetSpace ~
30351 \InsetSpace ~
30352 \InsetSpace ~
30353 \InsetSpace ~
30354 \InsetSpace ~
30355 \InsetSpace ~
30356 \InsetSpace ~
30357 \InsetSpace ~
30358 \InsetSpace ~
30359 \InsetSpace ~
30360 \InsetSpace ~
30361 \InsetSpace ~
30362 \InsetSpace ~
30363 \InsetSpace ~
30364 \InsetSpace ~
30365 \InsetSpace ~
30366 \InsetSpace ~
30367 \InsetSpace ~
30368 \InsetSpace ~
30369 \InsetSpace ~
30370 \InsetSpace ~
30371 \InsetSpace ~
30372 \InsetSpace ~
30373 \InsetSpace ~
30374 \InsetSpace ~
30375 \InsetSpace ~
30376 \InsetSpace ~
30377 \InsetSpace ~
30378 \InsetSpace ~
30379 \InsetSpace ~
30380 \InsetSpace ~
30381 \InsetSpace ~
30382 \InsetSpace ~
30383 \InsetSpace ~
30384 \InsetSpace ~
30385 \InsetSpace ~
30386 \InsetSpace ~
30387 \InsetSpace ~
30388 \InsetSpace ~
30389 \InsetSpace ~
30390 \InsetSpace ~
30391 \InsetSpace ~
30392 buffer point 
30393 \newline
30394 ;;\InsetSpace ~
30395 !\InsetSpace ~
30396 \InsetSpace ~
30397 \InsetSpace ~
30398 \InsetSpace ~
30399 \InsetSpace ~
30400 \InsetSpace ~
30401 \InsetSpace ~
30402 \InsetSpace ~
30403 \InsetSpace ~
30404 \InsetSpace ~
30405 \InsetSpace ~
30406 \InsetSpace ~
30407 \InsetSpace ~
30408 \InsetSpace ~
30409 \InsetSpace ~
30410 sdcdbsrc-goto-sdcdb\InsetSpace ~
30411 \InsetSpace ~
30412 \InsetSpace ~
30413 \InsetSpace ~
30414 \InsetSpace ~
30415 \InsetSpace ~
30416 \InsetSpace ~
30417 \InsetSpace ~
30418 \InsetSpace ~
30419 \InsetSpace ~
30420 Goto the SDCDB output buffer 
30421 \newline
30422 ;;\InsetSpace ~
30423 p\InsetSpace ~
30424 \InsetSpace ~
30425 \InsetSpace ~
30426 \InsetSpace ~
30427 \InsetSpace ~
30428 \InsetSpace ~
30429 \InsetSpace ~
30430 \InsetSpace ~
30431 \InsetSpace ~
30432 \InsetSpace ~
30433 \InsetSpace ~
30434 \InsetSpace ~
30435 \InsetSpace ~
30436 \InsetSpace ~
30437 \InsetSpace ~
30438 sdcdb-prin
30439 t-c-sexp\InsetSpace ~
30440 \InsetSpace ~
30441 \InsetSpace ~
30442 \InsetSpace ~
30443 \InsetSpace ~
30444 \InsetSpace ~
30445 \InsetSpace ~
30446 \InsetSpace ~
30447 \InsetSpace ~
30448 \InsetSpace ~
30449 \InsetSpace ~
30450 SDCDB print command for data at 
30451 \newline
30452 ;;\InsetSpace ~
30453 \InsetSpace ~
30454 \InsetSpace ~
30455 \InsetSpace ~
30456 \InsetSpace ~
30457 \InsetSpace ~
30458 \InsetSpace ~
30459 \InsetSpace ~
30460 \InsetSpace ~
30461 \InsetSpace ~
30462 \InsetSpace ~
30463 \InsetSpace ~
30464 \InsetSpace ~
30465 \InsetSpace ~
30466 \InsetSpace ~
30467 \InsetSpace ~
30468 \InsetSpace ~
30469 \InsetSpace ~
30470 \InsetSpace ~
30471 \InsetSpace ~
30472 \InsetSpace ~
30473 \InsetSpace ~
30474 \InsetSpace ~
30475 \InsetSpace ~
30476 \InsetSpace ~
30477 \InsetSpace ~
30478 \InsetSpace ~
30479 \InsetSpace ~
30480 \InsetSpace ~
30481 \InsetSpace ~
30482 \InsetSpace ~
30483 \InsetSpace ~
30484 \InsetSpace ~
30485 \InsetSpace ~
30486 \InsetSpace ~
30487 \InsetSpace ~
30488 \InsetSpace ~
30489 \InsetSpace ~
30490 \InsetSpace ~
30491 \InsetSpace ~
30492 \InsetSpace ~
30493 \InsetSpace ~
30494 \InsetSpace ~
30495 \InsetSpace ~
30496 \InsetSpace ~
30497 \InsetSpace ~
30498 \InsetSpace ~
30499 buffer point 
30500 \newline
30501 ;;\InsetSpace ~
30502 g\InsetSpace ~
30503 \InsetSpace ~
30504 \InsetSpace ~
30505 \InsetSpace ~
30506 \InsetSpace ~
30507 \InsetSpace ~
30508 \InsetSpace ~
30509 \InsetSpace ~
30510 \InsetSpace ~
30511 \InsetSpace ~
30512 \InsetSpace ~
30513 \InsetSpace ~
30514 \InsetSpace ~
30515 \InsetSpace ~
30516 \InsetSpace ~
30517 sdcdbsrc-goto-sdcdb\InsetSpace ~
30518 \InsetSpace ~
30519 \InsetSpace ~
30520 \InsetSpace ~
30521 \InsetSpace ~
30522 \InsetSpace ~
30523 \InsetSpace ~
30524 \InsetSpace ~
30525 \InsetSpace ~
30526 \InsetSpace ~
30527 Got
30528 o the SDCDB output buffer 
30529 \newline
30530 ;;\InsetSpace ~
30531 t\InsetSpace ~
30532 \InsetSpace ~
30533 \InsetSpace ~
30534 \InsetSpace ~
30535 \InsetSpace ~
30536 \InsetSpace ~
30537 \InsetSpace ~
30538 \InsetSpace ~
30539 \InsetSpace ~
30540 \InsetSpace ~
30541 \InsetSpace ~
30542 \InsetSpace ~
30543 \InsetSpace ~
30544 \InsetSpace ~
30545 \InsetSpace ~
30546 sdcdbsrc-mode\InsetSpace ~
30547 \InsetSpace ~
30548 \InsetSpace ~
30549 \InsetSpace ~
30550 \InsetSpace ~
30551 \InsetSpace ~
30552 \InsetSpace ~
30553 \InsetSpace ~
30554 \InsetSpace ~
30555 \InsetSpace ~
30556 \InsetSpace ~
30557 \InsetSpace ~
30558 \InsetSpace ~
30559 \InsetSpace ~
30560 \InsetSpace ~
30561 \InsetSpace ~
30562 Toggles Sdcdbsrc mode (turns it
30563  off) 
30564 \newline
30565 ;; 
30566 \newline
30567 ;;\InsetSpace ~
30568 C-c\InsetSpace ~
30569 C-f\InsetSpace ~
30570 \InsetSpace ~
30571 \InsetSpace ~
30572 \InsetSpace ~
30573 \InsetSpace ~
30574 \InsetSpace ~
30575 \InsetSpace ~
30576 \InsetSpace ~
30577 \InsetSpace ~
30578 sdcdb-finish-from-src\InsetSpace ~
30579 \InsetSpace ~
30580 \InsetSpace ~
30581 \InsetSpace ~
30582 \InsetSpace ~
30583 \InsetSpace ~
30584 \InsetSpace ~
30585 \InsetSpace ~
30586 SDCDB finish command 
30587 \newline
30588 ;; 
30589 \newline
30590 ;;\InsetSpace ~
30591 C-x\InsetSpace ~
30592 SPC\InsetSpace ~
30593 \InsetSpace ~
30594 \InsetSpace ~
30595 \InsetSpace ~
30596 \InsetSpace ~
30597 \InsetSpace ~
30598 \InsetSpace ~
30599 \InsetSpace ~
30600 \InsetSpace ~
30601 sdcdb-brea
30602 k\InsetSpace ~
30603 \InsetSpace ~
30604 \InsetSpace ~
30605 \InsetSpace ~
30606 \InsetSpace ~
30607 \InsetSpace ~
30608 \InsetSpace ~
30609 \InsetSpace ~
30610 \InsetSpace ~
30611 \InsetSpace ~
30612 \InsetSpace ~
30613 \InsetSpace ~
30614 \InsetSpace ~
30615 \InsetSpace ~
30616 \InsetSpace ~
30617 \InsetSpace ~
30618 \InsetSpace ~
30619 \InsetSpace ~
30620 Set break for line with point 
30621 \newline
30622 ;;\InsetSpace ~
30623 ESC\InsetSpace ~
30624 t\InsetSpace ~
30625 \InsetSpace ~
30626 \InsetSpace ~
30627 \InsetSpace ~
30628 \InsetSpace ~
30629 \InsetSpace ~
30630 \InsetSpace ~
30631 \InsetSpace ~
30632 \InsetSpace ~
30633 \InsetSpace ~
30634 \InsetSpace ~
30635 sdcdbsrc-mode\InsetSpace ~
30636 \InsetSpace ~
30637 \InsetSpace ~
30638 \InsetSpace ~
30639 \InsetSpace ~
30640 \InsetSpace ~
30641 \InsetSpace ~
30642 \InsetSpace ~
30643 \InsetSpace ~
30644 \InsetSpace ~
30645 \InsetSpace ~
30646 \InsetSpace ~
30647 \InsetSpace ~
30648 \InsetSpace ~
30649 \InsetSpace ~
30650 \InsetSpace ~
30651 Toggle Sdcdbsrc mode 
30652 \newline
30653 ;;\InsetSpace ~
30654 ESC\InsetSpace ~
30655 m\InsetSpace ~
30656 \InsetSpace ~
30657 \InsetSpace ~
30658 \InsetSpace ~
30659 \InsetSpace ~
30660 \InsetSpace ~
30661 \InsetSpace ~
30662 \InsetSpace ~
30663 \InsetSpace ~
30664 \InsetSpace ~
30665 \InsetSpace ~
30666 sdc
30667 dbsrc-srcmode\InsetSpace ~
30668 \InsetSpace ~
30669 \InsetSpace ~
30670 \InsetSpace ~
30671 \InsetSpace ~
30672 \InsetSpace ~
30673 \InsetSpace ~
30674 \InsetSpace ~
30675 \InsetSpace ~
30676 \InsetSpace ~
30677 \InsetSpace ~
30678 \InsetSpace ~
30679 \InsetSpace ~
30680 Toggle list mode 
30681 \newline
30682 ;; 
30683 \newline
30684
30685 \family default
30686
30687 \newpage
30688
30689 \end_layout
30690
30691 \begin_layout Chapter
30692 TIPS
30693 \end_layout
30694
30695 \begin_layout Standard
30696 Here are a few guidelines that will help the compiler generate more efficient
30697  code, some of the tips are specific to this compiler others are generally
30698  good programming practice.
30699 \end_layout
30700
30701 \begin_layout Itemize
30702 Use the smallest data type to represent your data-value.
30703  If it is known in advance that the value is going to be less than 256 then
30704  use an 'unsigned char' instead of a 'short' or 'int'.
30705  Please note, that ANSI C requires both signed and unsigned chars to be
30706  promoted to 'signed int'
30707 \begin_inset LatexCommand \index{promotion to signed int}
30708
30709 \end_inset
30710
30711
30712 \begin_inset Marginal
30713 status collapsed
30714
30715 \begin_layout Standard
30716
30717 \series bold
30718 \InsetSpace ~
30719 !
30720 \end_layout
30721
30722 \end_inset
30723
30724  before doing any operation.
30725  This promotion
30726 \begin_inset LatexCommand \index{type promotion}
30727
30728 \end_inset
30729
30730
30731 \begin_inset LatexCommand \label{type promotion}
30732
30733 \end_inset
30734
30735  can be omitted, if the result is the same.
30736  The effect of the promotion rules together with the sign-extension is often
30737  surprising:
30738 \end_layout
30739
30740 \begin_deeper
30741 \begin_layout Verse
30742
30743 \family typewriter
30744 unsigned char uc = 0xfe;
30745 \newline
30746 if (uc * uc < 0) /* this is true! */
30747 \newline
30748 {
30749 \newline
30750 \InsetSpace ~
30751 \InsetSpace ~
30752 \InsetSpace ~
30753 \InsetSpace ~
30754 ....
30755 \newline
30756 }
30757 \end_layout
30758
30759 \begin_layout Standard
30760
30761 \family typewriter
30762 uc * uc
30763 \family default
30764  is evaluated as 
30765 \family typewriter
30766 (int) uc * (int) uc = (int) 0xfe * (int) 0xfe = (int) 0xfc04 = -1024
30767 \family default
30768 .
30769  
30770 \newline
30771 Another one:
30772 \end_layout
30773
30774 \begin_layout Verse
30775
30776 \family typewriter
30777 (unsigned char) -12 / (signed char) -3 = ...
30778 \end_layout
30779
30780 \begin_layout Standard
30781 No, the result is not 4:
30782 \end_layout
30783
30784 \begin_layout Verse
30785
30786 \family typewriter
30787 (int) (unsigned char) -12 / (int) (signed char) -3 =
30788 \newline
30789 (int) (unsigned char)
30790  0xf4 / (int) (signed char) 0xfd =
30791 \newline
30792 (int) 0x00f4 / (int) 0xfffd =
30793 \newline
30794 (int) 0x00f4
30795  / (int) 0xfffd =
30796 \newline
30797 (int) 244 / (int) -3 =
30798 \newline
30799 (int) -81 = (int) 0xffaf;
30800 \end_layout
30801
30802 \begin_layout Standard
30803 Don't complain, that gcc gives you a different result.
30804  gcc uses 32 bit ints, while SDCC uses 16 bit ints.
30805  Therefore the results are different.
30806 \newline
30807 From 
30808 \begin_inset Quotes sld
30809 \end_inset
30810
30811 comp.lang.c FAQ
30812 \begin_inset Quotes srd
30813 \end_inset
30814
30815 :
30816 \end_layout
30817
30818 \begin_layout Quote
30819
30820 \emph on
30821 If well-defined overflow characteristics are important and negative values
30822  are not, or if you want to steer clear of sign-extension problems when
30823  manipulating bits or bytes, use one of the corresponding unsigned types.
30824  (Beware when mixing signed and unsigned values in expressions, though.)
30825 \newline
30826 Although
30827  character types (especially unsigned char) can be used as "tiny" integers,
30828  doing so is sometimes more trouble than it's worth, due to unpredictable
30829  sign extension and increased code size.
30830 \end_layout
30831
30832 \end_deeper
30833 \begin_layout Itemize
30834 Use unsigned when it is known in advance that the value is not going to
30835  be negative.
30836  This helps especially if you are doing division or multiplication, bit-shifting
30837  or are using an array index.
30838 \end_layout
30839
30840 \begin_layout Itemize
30841 NEVER jump into a LOOP.
30842 \end_layout
30843
30844 \begin_layout Itemize
30845 Declare the variables to be local
30846 \begin_inset LatexCommand \index{local variables}
30847
30848 \end_inset
30849
30850  whenever possible, especially loop control variables (induction).
30851 \end_layout
30852
30853 \begin_layout Itemize
30854 Have a look at the assembly listing to get a 
30855 \begin_inset Quotes sld
30856 \end_inset
30857
30858 feeling
30859 \begin_inset Quotes srd
30860 \end_inset
30861
30862  for the code generation.
30863 \end_layout
30864
30865 \begin_layout Section
30866 Porting code from or to other compilers
30867 \begin_inset LatexCommand \label{sec:Porting-code-to-other-compilers}
30868
30869 \end_inset
30870
30871
30872 \end_layout
30873
30874 \begin_layout Itemize
30875 check whether endianness of the compilers differs and adapt where needed.
30876 \end_layout
30877
30878 \begin_layout Itemize
30879 check the device specific header files
30880 \begin_inset LatexCommand \index{Header files}
30881
30882 \end_inset
30883
30884
30885 \begin_inset LatexCommand \index{Include files}
30886
30887 \end_inset
30888
30889  for compiler specific syntax.
30890  Eventually include the file <compiler.h
30891 \begin_inset LatexCommand \index{compiler.h (include file)}
30892
30893 \end_inset
30894
30895
30896 \begin_inset LatexCommand \url{http://sdcc.svn.sourceforge.net/viewvc/sdcc/trunk/sdcc/device/include/mcs51/compiler.h?view=markup}
30897
30898 \end_inset
30899
30900  to allow using common header files.
30901  (see f.e.
30902  cc2510fx.h 
30903 \begin_inset LatexCommand \url{http://sdcc.svn.sourceforge.net/viewvc/sdcc/trunk/sdcc/device/include/mcs51/cc2510fx.h?view=markup}
30904
30905 \end_inset
30906
30907 ).
30908 \end_layout
30909
30910 \begin_layout Itemize
30911 check whether the startup code contains the correct initialization (watchdog,
30912  peripherals).
30913 \end_layout
30914
30915 \begin_layout Itemize
30916 check whether the sizes of short, int, long match.
30917 \end_layout
30918
30919 \begin_layout Itemize
30920 check if some 16 or 32 bit hardware registers require a specific addressing
30921  order (least significant or most significant byte first) and adapt if needed
30922  (
30923 \emph on
30924 first
30925 \emph default
30926  and 
30927 \emph on
30928 last
30929 \emph default
30930  relate to time and not to lower/upper memory location here, so this is
30931  
30932 \emph on
30933 not
30934 \emph default
30935  the same as endianness).
30936 \end_layout
30937
30938 \begin_layout Itemize
30939 check whether the keyword 
30940 \emph on
30941 volatile
30942 \emph default
30943  is used where needed.
30944  The compilers might differ in their optimization characteristics (as different
30945  versions of the same compiler might also use more clever optimizations
30946  this is good idea anyway).
30947  See section 
30948 \begin_inset LatexCommand \ref{sub:Common-interrupt-pitfall-volatile}
30949
30950 \end_inset
30951
30952 .
30953 \end_layout
30954
30955 \begin_layout Itemize
30956 check that the compilers are not told to supress warnings.
30957 \end_layout
30958
30959 \begin_layout Itemize
30960 check and convert compiler specific extensions (interrupts, memory areas,
30961  pragmas etc.).
30962 \end_layout
30963
30964 \begin_layout Itemize
30965 check for differences in type promotion.
30966  Especially check for math operations on 
30967 \family typewriter
30968 char
30969 \family default
30970  or 
30971 \family typewriter
30972 unsigned char
30973 \family default
30974  variables.
30975  For the sake of C99 compatibility SDCC will probably promote these to 
30976 \family typewriter
30977 int
30978 \family default
30979  more often than other compilers.
30980  Eventually insert explicit casts to 
30981 \family typewriter
30982 (char) 
30983 \family default
30984 or
30985 \family typewriter
30986  (unsigned char)
30987 \family default
30988 .
30989  Also check that the ~\InsetSpace ~
30990 operator
30991 \begin_inset LatexCommand \index{\~\/ Operator}
30992
30993 \end_inset
30994
30995  is not used on 
30996 \family typewriter
30997 bit
30998 \begin_inset LatexCommand \index{bit}
30999
31000 \end_inset
31001
31002
31003 \family default
31004  variables, use the !\InsetSpace ~
31005 operator instead.
31006  See sections 
31007 \begin_inset LatexCommand \ref{type promotion}
31008
31009 \end_inset
31010
31011  and 
31012 \begin_inset LatexCommand \ref{sec:Compatibility-with-previous}
31013
31014 \end_inset
31015
31016 .
31017 \end_layout
31018
31019 \begin_layout Itemize
31020 check the assembly code generated for interrupt routines (f.e.
31021  for calls to possibly non-reentrant library functions).
31022 \end_layout
31023
31024 \begin_layout Itemize
31025 check whether timing loops result in proper timing (or preferably consider
31026  a rewrite of the code with timer based delays instead).
31027 \end_layout
31028
31029 \begin_layout Itemize
31030 check for differences in printf parameters (some compilers push (va_arg
31031 \begin_inset LatexCommand \index{vararg, va\_arg}
31032
31033 \end_inset
31034
31035 ) char variables as 
31036 \family typewriter
31037 int
31038 \family default
31039  others push them as 
31040 \family typewriter
31041 char
31042 \family default
31043 .
31044  See section 
31045 \begin_inset LatexCommand \ref{sec:Compatibility-with-previous}
31046
31047 \end_inset
31048
31049 ).
31050 \end_layout
31051
31052 \begin_layout Itemize
31053 check the resulting memory map
31054 \begin_inset LatexCommand \index{Memory map}
31055
31056 \end_inset
31057
31058 .
31059  Usage of different memory spaces: code, stack, data (for mcs51/ds390 additional
31060 ly idata, pdata, xdata).
31061  Eventually check if unexpected library functions are included.
31062 \end_layout
31063
31064 \begin_layout Section
31065 Tools
31066 \begin_inset LatexCommand \index{Tools}
31067
31068 \end_inset
31069
31070  included in the distribution
31071 \end_layout
31072
31073 \begin_layout Standard
31074 \align left
31075 \begin_inset Tabular
31076 <lyxtabular version="3" rows="12" columns="3">
31077 <features>
31078 <column alignment="left" valignment="top" leftline="true" width="0pt">
31079 <column alignment="left" valignment="top" leftline="true" width="0pt">
31080 <column alignment="left" valignment="top" leftline="true" rightline="true" width="0pt">
31081 <row topline="true" bottomline="true">
31082 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31083 \begin_inset Text
31084
31085 \begin_layout Standard
31086
31087 \series bold
31088 Name
31089 \end_layout
31090
31091 \end_inset
31092 </cell>
31093 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31094 \begin_inset Text
31095
31096 \begin_layout Standard
31097
31098 \series bold
31099 Purpose
31100 \end_layout
31101
31102 \end_inset
31103 </cell>
31104 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31105 \begin_inset Text
31106
31107 \begin_layout Standard
31108
31109 \series bold
31110 Directory
31111 \end_layout
31112
31113 \end_inset
31114 </cell>
31115 </row>
31116 <row topline="true">
31117 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31118 \begin_inset Text
31119
31120 \begin_layout Standard
31121 uCsim
31122 \begin_inset LatexCommand \index{uCsim}
31123
31124 \end_inset
31125
31126
31127 \end_layout
31128
31129 \end_inset
31130 </cell>
31131 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31132 \begin_inset Text
31133
31134 \begin_layout Standard
31135 Simulator for various architectures
31136 \end_layout
31137
31138 \end_inset
31139 </cell>
31140 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31141 \begin_inset Text
31142
31143 \begin_layout Standard
31144 sdcc/sim/ucsim
31145 \end_layout
31146
31147 \end_inset
31148 </cell>
31149 </row>
31150 <row topline="true">
31151 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31152 \begin_inset Text
31153
31154 \begin_layout Standard
31155 keil2sdcc.pl
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 header file
31165 \begin_inset LatexCommand \index{Header files}
31166
31167 \end_inset
31168
31169
31170 \begin_inset LatexCommand \index{Include files}
31171
31172 \end_inset
31173
31174  conversion
31175 \end_layout
31176
31177 \end_inset
31178 </cell>
31179 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31180 \begin_inset Text
31181
31182 \begin_layout Standard
31183 sdcc/support/scripts
31184 \end_layout
31185
31186 \end_inset
31187 </cell>
31188 </row>
31189 <row topline="true">
31190 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31191 \begin_inset Text
31192
31193 \begin_layout Standard
31194 mh2h.c
31195 \end_layout
31196
31197 \end_inset
31198 </cell>
31199 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31200 \begin_inset Text
31201
31202 \begin_layout Standard
31203 header file conversion
31204 \end_layout
31205
31206 \end_inset
31207 </cell>
31208 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31209 \begin_inset Text
31210
31211 \begin_layout Standard
31212 sdcc/support/scripts
31213 \end_layout
31214
31215 \end_inset
31216 </cell>
31217 </row>
31218 <row topline="true">
31219 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31220 \begin_inset Text
31221
31222 \begin_layout Standard
31223 as-gbz80
31224 \end_layout
31225
31226 \end_inset
31227 </cell>
31228 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31229 \begin_inset Text
31230
31231 \begin_layout Standard
31232 Assembler
31233 \end_layout
31234
31235 \end_inset
31236 </cell>
31237 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31238 \begin_inset Text
31239
31240 \begin_layout Standard
31241
31242 \family roman
31243 \series medium
31244 \shape up
31245 \size normal
31246 \emph off
31247 \bar no
31248 \noun off
31249 \color none
31250 sdcc/bin
31251 \end_layout
31252
31253 \end_inset
31254 </cell>
31255 </row>
31256 <row topline="true">
31257 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31258 \begin_inset Text
31259
31260 \begin_layout Standard
31261 as-z80
31262 \end_layout
31263
31264 \end_inset
31265 </cell>
31266 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31267 \begin_inset Text
31268
31269 \begin_layout Standard
31270 Assembler
31271 \end_layout
31272
31273 \end_inset
31274 </cell>
31275 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31276 \begin_inset Text
31277
31278 \begin_layout Standard
31279
31280 \family roman
31281 \series medium
31282 \shape up
31283 \size normal
31284 \emph off
31285 \bar no
31286 \noun off
31287 \color none
31288 sdcc/bin
31289 \end_layout
31290
31291 \end_inset
31292 </cell>
31293 </row>
31294 <row topline="true">
31295 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31296 \begin_inset Text
31297
31298 \begin_layout Standard
31299 asx8051
31300 \end_layout
31301
31302 \end_inset
31303 </cell>
31304 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31305 \begin_inset Text
31306
31307 \begin_layout Standard
31308 Assembler
31309 \end_layout
31310
31311 \end_inset
31312 </cell>
31313 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31314 \begin_inset Text
31315
31316 \begin_layout Standard
31317
31318 \family roman
31319 \series medium
31320 \shape up
31321 \size normal
31322 \emph off
31323 \bar no
31324 \noun off
31325 \color none
31326 sdcc/bin
31327 \end_layout
31328
31329 \end_inset
31330 </cell>
31331 </row>
31332 <row topline="true">
31333 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31334 \begin_inset Text
31335
31336 \begin_layout Standard
31337 SDCDB
31338 \end_layout
31339
31340 \end_inset
31341 </cell>
31342 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31343 \begin_inset Text
31344
31345 \begin_layout Standard
31346 Simulator
31347 \end_layout
31348
31349 \end_inset
31350 </cell>
31351 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31352 \begin_inset Text
31353
31354 \begin_layout Standard
31355
31356 \family roman
31357 \series medium
31358 \shape up
31359 \size normal
31360 \emph off
31361 \bar no
31362 \noun off
31363 \color none
31364 sdcc/bin
31365 \end_layout
31366
31367 \end_inset
31368 </cell>
31369 </row>
31370 <row topline="true">
31371 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31372 \begin_inset Text
31373
31374 \begin_layout Standard
31375 aslink
31376 \end_layout
31377
31378 \end_inset
31379 </cell>
31380 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31381 \begin_inset Text
31382
31383 \begin_layout Standard
31384 Linker
31385 \end_layout
31386
31387 \end_inset
31388 </cell>
31389 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31390 \begin_inset Text
31391
31392 \begin_layout Standard
31393
31394 \family roman
31395 \series medium
31396 \shape up
31397 \size normal
31398 \emph off
31399 \bar no
31400 \noun off
31401 \color none
31402 sdcc/bin
31403 \end_layout
31404
31405 \end_inset
31406 </cell>
31407 </row>
31408 <row topline="true">
31409 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31410 \begin_inset Text
31411
31412 \begin_layout Standard
31413 link-z80
31414 \end_layout
31415
31416 \end_inset
31417 </cell>
31418 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31419 \begin_inset Text
31420
31421 \begin_layout Standard
31422 Linker
31423 \end_layout
31424
31425 \end_inset
31426 </cell>
31427 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31428 \begin_inset Text
31429
31430 \begin_layout Standard
31431
31432 \family roman
31433 \series medium
31434 \shape up
31435 \size normal
31436 \emph off
31437 \bar no
31438 \noun off
31439 \color none
31440 sdcc/bin
31441 \end_layout
31442
31443 \end_inset
31444 </cell>
31445 </row>
31446 <row topline="true">
31447 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31448 \begin_inset Text
31449
31450 \begin_layout Standard
31451 link-gbz80
31452 \end_layout
31453
31454 \end_inset
31455 </cell>
31456 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31457 \begin_inset Text
31458
31459 \begin_layout Standard
31460 Linker
31461 \end_layout
31462
31463 \end_inset
31464 </cell>
31465 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31466 \begin_inset Text
31467
31468 \begin_layout Standard
31469
31470 \family roman
31471 \series medium
31472 \shape up
31473 \size normal
31474 \emph off
31475 \bar no
31476 \noun off
31477 \color none
31478 sdcc/bin
31479 \end_layout
31480
31481 \end_inset
31482 </cell>
31483 </row>
31484 <row topline="true" bottomline="true">
31485 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31486 \begin_inset Text
31487
31488 \begin_layout Standard
31489 packihx
31490 \end_layout
31491
31492 \end_inset
31493 </cell>
31494 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31495 \begin_inset Text
31496
31497 \begin_layout Standard
31498 Intel Hex packer 
31499 \begin_inset LatexCommand \index{packihx (tool)}
31500
31501 \end_inset
31502
31503
31504 \end_layout
31505
31506 \end_inset
31507 </cell>
31508 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31509 \begin_inset Text
31510
31511 \begin_layout Standard
31512
31513 \family roman
31514 \series medium
31515 \shape up
31516 \size normal
31517 \emph off
31518 \bar no
31519 \noun off
31520 \color none
31521 sdcc/bin
31522 \end_layout
31523
31524 \end_inset
31525 </cell>
31526 </row>
31527 </lyxtabular>
31528
31529 \end_inset
31530
31531
31532 \newline
31533
31534 \end_layout
31535
31536 \begin_layout Section
31537 Documentation
31538 \begin_inset LatexCommand \index{Documentation}
31539
31540 \end_inset
31541
31542  included in the distribution
31543 \end_layout
31544
31545 \begin_layout Standard
31546 \align left
31547 \begin_inset Tabular
31548 <lyxtabular version="3" rows="10" columns="2">
31549 <features>
31550 <column alignment="block" valignment="top" leftline="true" width="40col%">
31551 <column alignment="block" valignment="top" leftline="true" rightline="true" width="60col%">
31552 <row topline="true" bottomline="true" endhead="true">
31553 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31554 \begin_inset Text
31555
31556 \begin_layout Standard
31557
31558 \series bold
31559 Subject / Title
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
31569 \series bold
31570 Filename / Where to get
31571 \end_layout
31572
31573 \end_inset
31574 </cell>
31575 </row>
31576 <row topline="true">
31577 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31578 \begin_inset Text
31579
31580 \begin_layout Standard
31581 SDCC Compiler User Guide
31582 \end_layout
31583
31584 \end_inset
31585 </cell>
31586 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31587 \begin_inset Text
31588
31589 \begin_layout Standard
31590 You're reading it right now
31591 \emph on
31592  \InsetSpace ~
31593 \InsetSpace ~
31594 \InsetSpace ~
31595
31596 \hfill
31597 online at:
31598 \emph default
31599
31600 \newline
31601
31602 \begin_inset LatexCommand \url{http://sdcc.sourceforge.net/doc/sdccman.pdf}
31603
31604 \end_inset
31605
31606
31607 \end_layout
31608
31609 \end_inset
31610 </cell>
31611 </row>
31612 <row topline="true">
31613 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31614 \begin_inset Text
31615
31616 \begin_layout Standard
31617 Changelog of SDCC
31618 \end_layout
31619
31620 \end_inset
31621 </cell>
31622 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31623 \begin_inset Text
31624
31625 \begin_layout Standard
31626 sdcc/Changelog
31627 \emph on
31628  \InsetSpace ~
31629 \InsetSpace ~
31630 \InsetSpace ~
31631
31632 \hfill
31633 online at:
31634 \emph default
31635
31636 \newline
31637
31638 \begin_inset LatexCommand \url{http://sdcc.svn.sourceforge.net/viewvc/*checkout*/sdcc/trunk/sdcc/ChangeLog}
31639
31640 \end_inset
31641
31642
31643 \end_layout
31644
31645 \end_inset
31646 </cell>
31647 </row>
31648 <row topline="true">
31649 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31650 \begin_inset Text
31651
31652 \begin_layout Standard
31653 ASXXXX
31654 \begin_inset LatexCommand \index{asXXXX (as-gbz80, as-hc08, asx8051, as-z80)}
31655
31656 \end_inset
31657
31658
31659 \begin_inset LatexCommand \index{Assembler documentation}
31660
31661 \end_inset
31662
31663  Assemblers and
31664 \newline
31665 ASLINK
31666 \begin_inset LatexCommand \index{aslink}
31667
31668 \end_inset
31669
31670
31671 \begin_inset LatexCommand \index{Linker documentation}
31672
31673 \end_inset
31674
31675  Relocating Linker
31676 \end_layout
31677
31678 \end_inset
31679 </cell>
31680 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31681 \begin_inset Text
31682
31683 \begin_layout Standard
31684 sdcc/as/doc/asxhtm.html 
31685 \emph on
31686 \InsetSpace ~
31687 \InsetSpace ~
31688 \InsetSpace ~
31689
31690 \hfill
31691 online at:
31692 \emph default
31693
31694 \newline
31695
31696 \begin_inset LatexCommand \url{http://sdcc.svn.sourceforge.net/viewvc/*checkout*/sdcc/trunk/sdcc/as/doc/asxhtm.html}
31697
31698 \end_inset
31699
31700
31701 \end_layout
31702
31703 \end_inset
31704 </cell>
31705 </row>
31706 <row topline="true">
31707 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31708 \begin_inset Text
31709
31710 \begin_layout Standard
31711 SDCC regression test
31712 \begin_inset LatexCommand \index{Regression test}
31713
31714 \end_inset
31715
31716
31717 \end_layout
31718
31719 \end_inset
31720 </cell>
31721 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31722 \begin_inset Text
31723
31724 \begin_layout Standard
31725 sdcc/doc/test_suite_spec.pdf 
31726 \emph on
31727 \InsetSpace ~
31728 \InsetSpace ~
31729 \InsetSpace ~
31730
31731 \hfill
31732 online at:
31733 \emph default
31734
31735 \newline
31736
31737 \begin_inset LatexCommand \url{http://sdcc.sourceforge.net/doc/test_suite_spec.pdf}
31738
31739 \end_inset
31740
31741
31742 \end_layout
31743
31744 \end_inset
31745 </cell>
31746 </row>
31747 <row topline="true">
31748 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31749 \begin_inset Text
31750
31751 \begin_layout Standard
31752 Various notes
31753 \end_layout
31754
31755 \end_inset
31756 </cell>
31757 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31758 \begin_inset Text
31759
31760 \begin_layout Standard
31761 sdcc/doc/* 
31762 \emph on
31763 \InsetSpace ~
31764 \InsetSpace ~
31765 \InsetSpace ~
31766
31767 \hfill
31768 online at:
31769 \emph default
31770
31771 \newline
31772
31773 \begin_inset LatexCommand \url{http://sdcc.svn.sourceforge.net/viewvc/sdcc/trunk/sdcc/doc/}
31774
31775 \end_inset
31776
31777
31778 \end_layout
31779
31780 \end_inset
31781 </cell>
31782 </row>
31783 <row topline="true">
31784 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31785 \begin_inset Text
31786
31787 \begin_layout Standard
31788 Notes on debugging with SDCDB
31789 \begin_inset LatexCommand \index{SDCDB (debugger)}
31790
31791 \end_inset
31792
31793
31794 \end_layout
31795
31796 \end_inset
31797 </cell>
31798 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31799 \begin_inset Text
31800
31801 \begin_layout Standard
31802 sdcc/debugger/README 
31803 \emph on
31804 \InsetSpace ~
31805 \InsetSpace ~
31806 \InsetSpace ~
31807
31808 \hfill
31809 online at
31810 \emph default
31811 :
31812 \newline
31813
31814 \begin_inset LatexCommand \url{http://sdcc.svn.sourceforge.net/viewvc/*checkout*/sdcc/trunk/sdcc/debugger/README}
31815
31816 \end_inset
31817
31818
31819 \end_layout
31820
31821 \end_inset
31822 </cell>
31823 </row>
31824 <row topline="true">
31825 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31826 \begin_inset Text
31827
31828 \begin_layout Standard
31829 uCsim
31830 \begin_inset LatexCommand \index{uCsim}
31831
31832 \end_inset
31833
31834  Software simulator for microcontrollers
31835 \end_layout
31836
31837 \end_inset
31838 </cell>
31839 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31840 \begin_inset Text
31841
31842 \begin_layout Standard
31843
31844 \family roman
31845 \series medium
31846 \shape up
31847 \size normal
31848 \emph off
31849 \bar no
31850 \noun off
31851 \color none
31852 sdcc/sim/ucsim/doc
31853 \family default
31854 \series default
31855 \shape default
31856 \size default
31857 \emph default
31858 \bar default
31859 \noun default
31860 /index.html 
31861 \emph on
31862 \InsetSpace ~
31863 \InsetSpace ~
31864 \InsetSpace ~
31865
31866 \hfill
31867 online at:
31868 \emph default
31869
31870 \newline
31871
31872 \begin_inset LatexCommand \url{http://sdcc.svn.sourceforge.net/viewvc/*checkout*/sdcc/trunk/sdcc/sim/ucsim/doc/index.html}
31873
31874 \end_inset
31875
31876
31877 \end_layout
31878
31879 \end_inset
31880 </cell>
31881 </row>
31882 <row topline="true">
31883 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31884 \begin_inset Text
31885
31886 \begin_layout Standard
31887 Temporary notes on the pic16
31888 \begin_inset LatexCommand \index{PIC16}
31889
31890 \end_inset
31891
31892  port
31893 \end_layout
31894
31895 \end_inset
31896 </cell>
31897 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31898 \begin_inset Text
31899
31900 \begin_layout Standard
31901 sdcc/src/pic16/NOTES 
31902 \emph on
31903 \InsetSpace ~
31904 \InsetSpace ~
31905 \InsetSpace ~
31906
31907 \hfill
31908 online at:
31909 \newline
31910
31911 \emph default
31912
31913 \begin_inset LatexCommand \url{http://sdcc.svn.sourceforge.net/viewvc/*checkout*/sdcc/trunk/sdcc/src/pic16/NOTES}
31914
31915 \end_inset
31916
31917
31918 \end_layout
31919
31920 \end_inset
31921 </cell>
31922 </row>
31923 <row topline="true" bottomline="true">
31924 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31925 \begin_inset Text
31926
31927 \begin_layout Standard
31928 SDCC internal documentation (debugging file format)
31929 \end_layout
31930
31931 \end_inset
31932 </cell>
31933 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31934 \begin_inset Text
31935
31936 \begin_layout Standard
31937 sdcc/doc/
31938 \family roman
31939 \series medium
31940 \shape up
31941 \size normal
31942 \emph off
31943 \bar no
31944 \noun off
31945 \color none
31946 cdbfileformat.pd
31947 \family default
31948 \series default
31949 \shape default
31950 \size default
31951 \emph default
31952 \bar default
31953 \noun default
31954 f
31955 \emph on
31956  \InsetSpace ~
31957 \InsetSpace ~
31958 \InsetSpace ~
31959
31960 \hfill
31961 online at:
31962 \emph default
31963
31964 \newline
31965
31966 \begin_inset LatexCommand \url{http://sdcc.sourceforge.net/doc/cdbfileformat.pdf}
31967
31968 \end_inset
31969
31970
31971 \end_layout
31972
31973 \end_inset
31974 </cell>
31975 </row>
31976 </lyxtabular>
31977
31978 \end_inset
31979
31980
31981 \newline
31982
31983 \end_layout
31984
31985 \begin_layout Section
31986 Related open source tools
31987 \begin_inset LatexCommand \label{sec:Related-open-source-tools}
31988
31989 \end_inset
31990
31991
31992 \begin_inset LatexCommand \index{Related tools}
31993
31994 \end_inset
31995
31996
31997 \end_layout
31998
31999 \begin_layout Standard
32000 \align left
32001 \begin_inset Tabular
32002 <lyxtabular version="3" rows="16" columns="3">
32003 <features>
32004 <column alignment="left" valignment="top" leftline="true" width="0pt">
32005 <column alignment="block" valignment="top" leftline="true" width="30line%">
32006 <column alignment="left" valignment="top" leftline="true" rightline="true" width="40col%">
32007 <row topline="true" bottomline="true">
32008 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32009 \begin_inset Text
32010
32011 \begin_layout Standard
32012
32013 \series bold
32014 Name
32015 \end_layout
32016
32017 \end_inset
32018 </cell>
32019 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32020 \begin_inset Text
32021
32022 \begin_layout Standard
32023
32024 \series bold
32025 Purpose
32026 \end_layout
32027
32028 \end_inset
32029 </cell>
32030 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32031 \begin_inset Text
32032
32033 \begin_layout Standard
32034
32035 \series bold
32036 Where to get
32037 \end_layout
32038
32039 \end_inset
32040 </cell>
32041 </row>
32042 <row topline="true">
32043 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32044 \begin_inset Text
32045
32046 \begin_layout Standard
32047 gpsim
32048 \begin_inset LatexCommand \index{gpsim (pic simulator)}
32049
32050 \end_inset
32051
32052
32053 \end_layout
32054
32055 \end_inset
32056 </cell>
32057 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32058 \begin_inset Text
32059
32060 \begin_layout Standard
32061 PIC simulator
32062 \end_layout
32063
32064 \end_inset
32065 </cell>
32066 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32067 \begin_inset Text
32068
32069 \begin_layout Standard
32070 \begin_inset LatexCommand \url{http://www.dattalo.com/gnupic/gpsim.html}
32071
32072 \end_inset
32073
32074
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 gputils
32086 \begin_inset LatexCommand \index{gputils (pic tools)}
32087
32088 \end_inset
32089
32090
32091 \end_layout
32092
32093 \end_inset
32094 </cell>
32095 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32096 \begin_inset Text
32097
32098 \begin_layout Standard
32099 GNU PIC utilities
32100 \end_layout
32101
32102 \end_inset
32103 </cell>
32104 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32105 \begin_inset Text
32106
32107 \begin_layout Standard
32108 \begin_inset LatexCommand \url{http://sourceforge.net/projects/gputils}
32109
32110 \end_inset
32111
32112
32113 \end_layout
32114
32115 \end_inset
32116 </cell>
32117 </row>
32118 <row topline="true">
32119 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32120 \begin_inset Text
32121
32122 \begin_layout Standard
32123 flP5
32124 \end_layout
32125
32126 \end_inset
32127 </cell>
32128 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32129 \begin_inset Text
32130
32131 \begin_layout Standard
32132 PIC programmer
32133 \end_layout
32134
32135 \end_inset
32136 </cell>
32137 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32138 \begin_inset Text
32139
32140 \begin_layout Standard
32141 \begin_inset LatexCommand \url{http://freshmeat.net/projects/flp5/}
32142
32143 \end_inset
32144
32145
32146 \end_layout
32147
32148 \end_inset
32149 </cell>
32150 </row>
32151 <row topline="true">
32152 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32153 \begin_inset Text
32154
32155 \begin_layout Standard
32156 ec2drv/newcdb
32157 \end_layout
32158
32159 \end_inset
32160 </cell>
32161 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32162 \begin_inset Text
32163
32164 \begin_layout Standard
32165 Tools for Silicon Laboratories JTAG debug adapter, partly based on SDCDB
32166  (Unix only)
32167 \end_layout
32168
32169 \end_inset
32170 </cell>
32171 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32172 \begin_inset Text
32173
32174 \begin_layout Standard
32175 \begin_inset LatexCommand \url{http://sourceforge.net/projects/ec2drv}
32176
32177 \end_inset
32178
32179
32180 \end_layout
32181
32182 \end_inset
32183 </cell>
32184 </row>
32185 <row topline="true">
32186 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32187 \begin_inset Text
32188
32189 \begin_layout Standard
32190 indent
32191 \begin_inset LatexCommand \index{indent (source formatting tool)}
32192
32193 \end_inset
32194
32195
32196 \end_layout
32197
32198 \end_inset
32199 </cell>
32200 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32201 \begin_inset Text
32202
32203 \begin_layout Standard
32204 Formats C source - Master of the white spaces
32205 \end_layout
32206
32207 \end_inset
32208 </cell>
32209 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32210 \begin_inset Text
32211
32212 \begin_layout Standard
32213 \begin_inset LatexCommand \url{http://directory.fsf.org/GNU/indent.html}
32214
32215 \end_inset
32216
32217
32218 \end_layout
32219
32220 \end_inset
32221 </cell>
32222 </row>
32223 <row topline="true">
32224 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32225 \begin_inset Text
32226
32227 \begin_layout Standard
32228 srecord
32229 \begin_inset LatexCommand \index{srecord (bin, hex, ... tool)}
32230
32231 \end_inset
32232
32233
32234 \end_layout
32235
32236 \end_inset
32237 </cell>
32238 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32239 \begin_inset Text
32240
32241 \begin_layout Standard
32242 Object file conversion, checksumming, ...
32243 \end_layout
32244
32245 \end_inset
32246 </cell>
32247 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32248 \begin_inset Text
32249
32250 \begin_layout Standard
32251 \begin_inset LatexCommand \url{http://sourceforge.net/projects/srecord}
32252
32253 \end_inset
32254
32255
32256 \end_layout
32257
32258 \end_inset
32259 </cell>
32260 </row>
32261 <row topline="true">
32262 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32263 \begin_inset Text
32264
32265 \begin_layout Standard
32266 objdump
32267 \begin_inset LatexCommand \index{objdump (tool)}
32268
32269 \end_inset
32270
32271
32272 \end_layout
32273
32274 \end_inset
32275 </cell>
32276 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32277 \begin_inset Text
32278
32279 \begin_layout Standard
32280 Object file conversion, ...
32281 \end_layout
32282
32283 \end_inset
32284 </cell>
32285 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32286 \begin_inset Text
32287
32288 \begin_layout Standard
32289 Part of binutils (should be there anyway)
32290 \end_layout
32291
32292 \end_inset
32293 </cell>
32294 </row>
32295 <row topline="true">
32296 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32297 \begin_inset Text
32298
32299 \begin_layout Standard
32300 cmon51
32301 \end_layout
32302
32303 \end_inset
32304 </cell>
32305 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32306 \begin_inset Text
32307
32308 \begin_layout Standard
32309 8051 monitor (hex up-/download, single step, disassemble)
32310 \end_layout
32311
32312 \end_inset
32313 </cell>
32314 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32315 \begin_inset Text
32316
32317 \begin_layout Standard
32318 \begin_inset LatexCommand \url{http://sourceforge.net/projects/cmon51}
32319
32320 \end_inset
32321
32322
32323 \end_layout
32324
32325 \end_inset
32326 </cell>
32327 </row>
32328 <row topline="true">
32329 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32330 \begin_inset Text
32331
32332 \begin_layout Standard
32333 doxygen
32334 \begin_inset LatexCommand \index{doxygen (source documentation tool)}
32335
32336 \end_inset
32337
32338
32339 \end_layout
32340
32341 \end_inset
32342 </cell>
32343 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32344 \begin_inset Text
32345
32346 \begin_layout Standard
32347 Source code documentation system
32348 \end_layout
32349
32350 \end_inset
32351 </cell>
32352 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32353 \begin_inset Text
32354
32355 \begin_layout Standard
32356 \begin_inset LatexCommand \url{http://www.doxygen.org}
32357
32358 \end_inset
32359
32360
32361 \end_layout
32362
32363 \end_inset
32364 </cell>
32365 </row>
32366 <row topline="true">
32367 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32368 \begin_inset Text
32369
32370 \begin_layout Standard
32371 kdevelop
32372 \end_layout
32373
32374 \end_inset
32375 </cell>
32376 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32377 \begin_inset Text
32378
32379 \begin_layout Standard
32380 IDE (has anyone tried integrating SDCC & SDCDB? Unix only)
32381 \end_layout
32382
32383 \end_inset
32384 </cell>
32385 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32386 \begin_inset Text
32387
32388 \begin_layout Standard
32389 \begin_inset LatexCommand \url{http://www.kdevelop.org}
32390
32391 \end_inset
32392
32393
32394 \end_layout
32395
32396 \end_inset
32397 </cell>
32398 </row>
32399 <row topline="true">
32400 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32401 \begin_inset Text
32402
32403 \begin_layout Standard
32404 paulmon
32405 \end_layout
32406
32407 \end_inset
32408 </cell>
32409 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32410 \begin_inset Text
32411
32412 \begin_layout Standard
32413 8051 monitor (hex up-/download, single step, disassemble)
32414 \end_layout
32415
32416 \end_inset
32417 </cell>
32418 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32419 \begin_inset Text
32420
32421 \begin_layout Standard
32422 \begin_inset LatexCommand \url{http://www.pjrc.com/tech/8051/paulmon2.html}
32423
32424 \end_inset
32425
32426
32427 \end_layout
32428
32429 \end_inset
32430 </cell>
32431 </row>
32432 <row topline="true">
32433 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32434 \begin_inset Text
32435
32436 \begin_layout Standard
32437 splint
32438 \begin_inset LatexCommand \index{splint (syntax checking tool)}
32439
32440 \end_inset
32441
32442
32443 \end_layout
32444
32445 \end_inset
32446 </cell>
32447 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32448 \begin_inset Text
32449
32450 \begin_layout Standard
32451 Statically checks c sources (see 
32452 \begin_inset LatexCommand \ref{lyx:more-pedantic-SPLINT}
32453
32454 \end_inset
32455
32456 )
32457 \end_layout
32458
32459 \end_inset
32460 </cell>
32461 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32462 \begin_inset Text
32463
32464 \begin_layout Standard
32465 \begin_inset LatexCommand \url{http://www.splint.org}
32466
32467 \end_inset
32468
32469
32470 \end_layout
32471
32472 \end_inset
32473 </cell>
32474 </row>
32475 <row topline="true" bottomline="true">
32476 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32477 \begin_inset Text
32478
32479 \begin_layout Standard
32480 ddd
32481 \begin_inset LatexCommand \index{DDD (debugger)}
32482
32483 \end_inset
32484
32485
32486 \end_layout
32487
32488 \end_inset
32489 </cell>
32490 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32491 \begin_inset Text
32492
32493 \begin_layout Standard
32494 Debugger, serves nicely as GUI to SDCDB
32495 \begin_inset LatexCommand \index{SDCDB (debugger)}
32496
32497 \end_inset
32498
32499  (Unix only)
32500 \end_layout
32501
32502 \end_inset
32503 </cell>
32504 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32505 \begin_inset Text
32506
32507 \begin_layout Standard
32508 \begin_inset LatexCommand \url{http://www.gnu.org/software/ddd/}
32509
32510 \end_inset
32511
32512
32513 \end_layout
32514
32515 \end_inset
32516 </cell>
32517 </row>
32518 <row bottomline="true">
32519 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32520 \begin_inset Text
32521
32522 \begin_layout Standard
32523 d52
32524 \begin_inset LatexCommand \index{d52}
32525
32526 \end_inset
32527
32528
32529 \begin_inset LatexCommand \index{d52 (disassembler)}
32530
32531 \end_inset
32532
32533
32534 \end_layout
32535
32536 \end_inset
32537 </cell>
32538 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32539 \begin_inset Text
32540
32541 \begin_layout Standard
32542 Disassembler, can count instruction cycles
32543 \begin_inset LatexCommand \index{instruction cycles (count)}
32544
32545 \end_inset
32546
32547 , use with options -pnd
32548 \end_layout
32549
32550 \end_inset
32551 </cell>
32552 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32553 \begin_inset Text
32554
32555 \begin_layout Standard
32556 \begin_inset LatexCommand \url{http://www.8052.com/users/disasm/}
32557
32558 \end_inset
32559
32560
32561 \end_layout
32562
32563 \end_inset
32564 </cell>
32565 </row>
32566 <row bottomline="true">
32567 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32568 \begin_inset Text
32569
32570 \begin_layout Standard
32571 cmake
32572 \begin_inset LatexCommand \index{cmake}
32573
32574 \end_inset
32575
32576
32577 \end_layout
32578
32579 \end_inset
32580 </cell>
32581 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32582 \begin_inset Text
32583
32584 \begin_layout Standard
32585 Cross platform build system, generates Makefiles
32586 \begin_inset LatexCommand \index{Makefile}
32587
32588 \end_inset
32589
32590  and project workspaces
32591 \begin_inset LatexCommand \index{project workspace}
32592
32593 \end_inset
32594
32595
32596 \end_layout
32597
32598 \end_inset
32599 </cell>
32600 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32601 \begin_inset Text
32602
32603 \begin_layout Standard
32604 \begin_inset LatexCommand \url{http://www.cmake.org}
32605
32606 \end_inset
32607
32608  \InsetSpace ~
32609 \InsetSpace ~
32610 \InsetSpace ~
32611 \InsetSpace ~
32612 and a dedicated wiki entry: 
32613 \begin_inset LatexCommand \url{http://www.cmake.org/Wiki/CmakeSdcc}
32614
32615 \end_inset
32616
32617
32618 \end_layout
32619
32620 \end_inset
32621 </cell>
32622 </row>
32623 </lyxtabular>
32624
32625 \end_inset
32626
32627
32628 \newline
32629
32630 \end_layout
32631
32632 \begin_layout Section
32633 Related documentation / recommended reading
32634 \end_layout
32635
32636 \begin_layout Standard
32637 \align left
32638 \begin_inset Tabular
32639 <lyxtabular version="3" rows="7" columns="3">
32640 <features>
32641 <column alignment="left" valignment="top" leftline="true" width="0pt">
32642 <column alignment="left" valignment="top" leftline="true" width="0">
32643 <column alignment="left" valignment="top" leftline="true" rightline="true" width="0pt">
32644 <row topline="true" bottomline="true">
32645 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32646 \begin_inset Text
32647
32648 \begin_layout Standard
32649
32650 \series bold
32651 Name
32652 \end_layout
32653
32654 \end_inset
32655 </cell>
32656 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32657 \begin_inset Text
32658
32659 \begin_layout Standard
32660
32661 \series bold
32662 Subject / Title
32663 \end_layout
32664
32665 \end_inset
32666 </cell>
32667 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32668 \begin_inset Text
32669
32670 \begin_layout Standard
32671
32672 \series bold
32673 Where to get
32674 \end_layout
32675
32676 \end_inset
32677 </cell>
32678 </row>
32679 <row topline="true">
32680 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32681 \begin_inset Text
32682
32683 \begin_layout Standard
32684
32685 \family roman
32686 \series medium
32687 \shape up
32688 \size normal
32689 \emph off
32690 \bar no
32691 \noun off
32692 \color none
32693 c-refcard.pdf
32694 \end_layout
32695
32696 \end_inset
32697 </cell>
32698 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32699 \begin_inset Text
32700
32701 \begin_layout Standard
32702 C Reference Card
32703 \begin_inset LatexCommand \index{C Reference card}
32704
32705 \end_inset
32706
32707 , 2 pages
32708 \end_layout
32709
32710 \end_inset
32711 </cell>
32712 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32713 \begin_inset Text
32714
32715 \begin_layout Standard
32716 \begin_inset LatexCommand \url{http://refcards.com/refcards/c/index.html}
32717
32718 \end_inset
32719
32720
32721 \end_layout
32722
32723 \end_inset
32724 </cell>
32725 </row>
32726 <row topline="true">
32727 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32728 \begin_inset Text
32729
32730 \begin_layout Standard
32731 c-faq
32732 \end_layout
32733
32734 \end_inset
32735 </cell>
32736 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32737 \begin_inset Text
32738
32739 \begin_layout Standard
32740 C-FAQ
32741 \begin_inset LatexCommand \index{C FAQ}
32742
32743 \end_inset
32744
32745
32746 \end_layout
32747
32748 \end_inset
32749 </cell>
32750 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32751 \begin_inset Text
32752
32753 \begin_layout Standard
32754 \begin_inset LatexCommand \url{http://www.c-faq.com}
32755
32756 \end_inset
32757
32758
32759 \end_layout
32760
32761 \end_inset
32762 </cell>
32763 </row>
32764 <row topline="true">
32765 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32766 \begin_inset Text
32767
32768 \begin_layout Standard
32769 ISO/IEC 9899:TC2
32770 \end_layout
32771
32772 \end_inset
32773 </cell>
32774 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32775 \begin_inset Text
32776
32777 \begin_layout Standard
32778 \begin_inset Quotes sld
32779 \end_inset
32780
32781 C-Standard
32782 \begin_inset Quotes srd
32783 \end_inset
32784
32785
32786 \end_layout
32787
32788 \end_inset
32789 </cell>
32790 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32791 \begin_inset Text
32792
32793 \begin_layout Standard
32794
32795 \size footnotesize
32796 \begin_inset LatexCommand \url{http://www.open-std.org/jtc1/sc22/wg14/www/standards.html#9899}
32797
32798 \end_inset
32799
32800
32801 \end_layout
32802
32803 \end_inset
32804 </cell>
32805 </row>
32806 <row topline="true">
32807 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32808 \begin_inset Text
32809
32810 \begin_layout Standard
32811 ISO/IEC DTR 18037
32812 \end_layout
32813
32814 \end_inset
32815 </cell>
32816 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32817 \begin_inset Text
32818
32819 \begin_layout Standard
32820 \begin_inset Quotes sld
32821 \end_inset
32822
32823 Extensions for Embedded C
32824 \begin_inset Quotes srd
32825 \end_inset
32826
32827
32828 \end_layout
32829
32830 \end_inset
32831 </cell>
32832 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32833 \begin_inset Text
32834
32835 \begin_layout Standard
32836
32837 \size footnotesize
32838 \begin_inset LatexCommand \url{http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1021.pdf}
32839
32840 \end_inset
32841
32842
32843 \end_layout
32844
32845 \end_inset
32846 </cell>
32847 </row>
32848 <row topline="true">
32849 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32850 \begin_inset Text
32851
32852 \begin_layout Standard
32853
32854 \end_layout
32855
32856 \end_inset
32857 </cell>
32858 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32859 \begin_inset Text
32860
32861 \begin_layout Standard
32862 Latest datasheet of target CPU
32863 \end_layout
32864
32865 \end_inset
32866 </cell>
32867 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32868 \begin_inset Text
32869
32870 \begin_layout Standard
32871 vendor
32872 \end_layout
32873
32874 \end_inset
32875 </cell>
32876 </row>
32877 <row topline="true" bottomline="true">
32878 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32879 \begin_inset Text
32880
32881 \begin_layout Standard
32882
32883 \end_layout
32884
32885 \end_inset
32886 </cell>
32887 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32888 \begin_inset Text
32889
32890 \begin_layout Standard
32891 Revision history of datasheet
32892 \end_layout
32893
32894 \end_inset
32895 </cell>
32896 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32897 \begin_inset Text
32898
32899 \begin_layout Standard
32900 vendor
32901 \end_layout
32902
32903 \end_inset
32904 </cell>
32905 </row>
32906 </lyxtabular>
32907
32908 \end_inset
32909
32910
32911 \newline
32912
32913 \end_layout
32914
32915 \begin_layout Section
32916 Application notes specifically for SDCC
32917 \end_layout
32918
32919 \begin_layout Standard
32920 SDCC makes no claims about the completeness of this list and about up-to-datenes
32921 s or correctness of the application notes
32922 \begin_inset LatexCommand \index{Application notes}
32923
32924 \end_inset
32925
32926 .
32927 \end_layout
32928
32929 \begin_layout Standard
32930 \align left
32931
32932 \size footnotesize
32933 \begin_inset Tabular
32934 <lyxtabular version="3" rows="7" columns="3">
32935 <features>
32936 <column alignment="block" valignment="top" leftline="true" width="17col%">
32937 <column alignment="block" valignment="top" leftline="true" width="27col%">
32938 <column alignment="block" valignment="top" leftline="true" rightline="true" width="57col%">
32939 <row topline="true" bottomline="true">
32940 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32941 \begin_inset Text
32942
32943 \begin_layout Standard
32944
32945 \series bold
32946 \size footnotesize
32947 Vendor
32948 \end_layout
32949
32950 \end_inset
32951 </cell>
32952 <cell alignment="left" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
32953 \begin_inset Text
32954
32955 \begin_layout Standard
32956
32957 \series bold
32958 \size footnotesize
32959 Subject / Title
32960 \end_layout
32961
32962 \end_inset
32963 </cell>
32964 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32965 \begin_inset Text
32966
32967 \begin_layout Standard
32968
32969 \series bold
32970 \size footnotesize
32971 Where to get
32972 \end_layout
32973
32974 \end_inset
32975 </cell>
32976 </row>
32977 <row topline="true">
32978 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32979 \begin_inset Text
32980
32981 \begin_layout Standard
32982
32983 \size footnotesize
32984 Maxim / Dallas
32985 \end_layout
32986
32987 \end_inset
32988 </cell>
32989 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32990 \begin_inset Text
32991
32992 \begin_layout Standard
32993
32994 \size footnotesize
32995 Using the SDCC Compiler for the DS80C400
32996 \begin_inset LatexCommand \index{DS80C400}
32997
32998 \end_inset
32999
33000
33001 \end_layout
33002
33003 \end_inset
33004 </cell>
33005 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
33006 \begin_inset Text
33007
33008 \begin_layout Standard
33009
33010 \size footnotesize
33011 \begin_inset LatexCommand \url{http://pdfserv.maxim-ic.com/en/an/AN3346.pdf}
33012
33013 \end_inset
33014
33015
33016 \end_layout
33017
33018 \end_inset
33019 </cell>
33020 </row>
33021 <row topline="true">
33022 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33023 \begin_inset Text
33024
33025 \begin_layout Standard
33026
33027 \size footnotesize
33028 Maxim / Dallas
33029 \end_layout
33030
33031 \end_inset
33032 </cell>
33033 <cell multicolumn="1" alignment="left" valignment="top" topline="true" leftline="true" usebox="none" width="30line%">
33034 \begin_inset Text
33035
33036 \begin_layout Standard
33037
33038 \size footnotesize
33039 Using the Free SDCC C Compiler to Develop Firmware for the DS89C420/430/440/450
33040 \begin_inset LatexCommand \index{DS89C4x0}
33041
33042 \end_inset
33043
33044  Family of Microcontrollers
33045 \end_layout
33046
33047 \end_inset
33048 </cell>
33049 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
33050 \begin_inset Text
33051
33052 \begin_layout Standard
33053
33054 \size footnotesize
33055 \begin_inset LatexCommand \url{http://pdfserv.maxim-ic.com/en/an/AN3477.pdf}
33056
33057 \end_inset
33058
33059
33060 \end_layout
33061
33062 \end_inset
33063 </cell>
33064 </row>
33065 <row topline="true">
33066 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33067 \begin_inset Text
33068
33069 \begin_layout Standard
33070
33071 \size footnotesize
33072 Silicon Laboratories / Cygnal
33073 \end_layout
33074
33075 \end_inset
33076 </cell>
33077 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33078 \begin_inset Text
33079
33080 \begin_layout Standard
33081
33082 \size footnotesize
33083 Integrating SDCC 8051 Tools Into The Silicon Labs IDE
33084 \begin_inset LatexCommand \index{IDE}
33085
33086 \end_inset
33087
33088
33089 \end_layout
33090
33091 \end_inset
33092 </cell>
33093 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
33094 \begin_inset Text
33095
33096 \begin_layout Standard
33097
33098 \size footnotesize
33099 \begin_inset LatexCommand \url{http://www.silabs.com/public/documents/tpub_doc/anote/Microcontrollers/en/an198.pdf}
33100
33101 \end_inset
33102
33103
33104 \end_layout
33105
33106 \end_inset
33107 </cell>
33108 </row>
33109 <row topline="true">
33110 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33111 \begin_inset Text
33112
33113 \begin_layout Standard
33114
33115 \size footnotesize
33116 Ramtron / Goal Semiconductor
33117 \end_layout
33118
33119 \end_inset
33120 </cell>
33121 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33122 \begin_inset Text
33123
33124 \begin_layout Standard
33125
33126 \size footnotesize
33127 Interfacing SDCC to Syn and Textpad
33128 \end_layout
33129
33130 \end_inset
33131 </cell>
33132 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
33133 \begin_inset Text
33134
33135 \begin_layout Standard
33136
33137 \size footnotesize
33138 \begin_inset LatexCommand \url{http://www.ramtron.com/doc/Products/Microcontroller/Support_Tools.asp}
33139
33140 \end_inset
33141
33142
33143 \end_layout
33144
33145 \end_inset
33146 </cell>
33147 </row>
33148 <row topline="true">
33149 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33150 \begin_inset Text
33151
33152 \begin_layout Standard
33153
33154 \size footnotesize
33155 Ramtron / Goal Semiconductor
33156 \end_layout
33157
33158 \end_inset
33159 </cell>
33160 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33161 \begin_inset Text
33162
33163 \begin_layout Standard
33164
33165 \size footnotesize
33166 Installing and Configuring SDCC and Crimson Editor 
33167 \end_layout
33168
33169 \end_inset
33170 </cell>
33171 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
33172 \begin_inset Text
33173
33174 \begin_layout Standard
33175
33176 \size footnotesize
33177 \begin_inset LatexCommand \url{http://www.ramtron.com/doc/Products/Microcontroller/Support_Tools.asp}
33178
33179 \end_inset
33180
33181
33182 \end_layout
33183
33184 \end_inset
33185 </cell>
33186 </row>
33187 <row topline="true" bottomline="true">
33188 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33189 \begin_inset Text
33190
33191 \begin_layout Standard
33192
33193 \size footnotesize
33194 Texas Instruments
33195 \end_layout
33196
33197 \end_inset
33198 </cell>
33199 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33200 \begin_inset Text
33201
33202 \begin_layout Standard
33203
33204 \size footnotesize
33205 MSC12xx Programming with SDCC
33206 \end_layout
33207
33208 \end_inset
33209 </cell>
33210 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
33211 \begin_inset Text
33212
33213 \begin_layout Standard
33214
33215 \size footnotesize
33216 \begin_inset LatexCommand \url{http://focus.ti.com/general/docs/lit/getliterature.tsp?literatureNumber=sbaa109&fileType=pdf}
33217
33218 \end_inset
33219
33220
33221 \end_layout
33222
33223 \end_inset
33224 </cell>
33225 </row>
33226 </lyxtabular>
33227
33228 \end_inset
33229
33230
33231 \end_layout
33232
33233 \begin_layout Section
33234 Some Questions
33235 \end_layout
33236
33237 \begin_layout Standard
33238 Some questions answered, some pointers given - it might be time to in turn
33239  ask 
33240 \emph on
33241 you
33242 \emph default
33243  some questions: 
33244 \end_layout
33245
33246 \begin_layout Itemize
33247 can you solve your project with the selected microcontroller? Would you
33248  find out early or rather late that your target is too small/slow/whatever?
33249  Can you switch to a slightly better device if it doesn't fit?
33250 \end_layout
33251
33252 \begin_layout Itemize
33253 should you solve the problem with an 8 bit CPU? Or would a 16/32 bit CPU
33254  and/or another programming language be more adequate? Would an operating
33255  system on the target device help?
33256 \end_layout
33257
33258 \begin_layout Itemize
33259 if you solved the problem, will the marketing department be happy?
33260 \end_layout
33261
33262 \begin_layout Itemize
33263 if the marketing department is happy, will customers be happy?
33264 \end_layout
33265
33266 \begin_layout Itemize
33267 if you're the project manager, marketing department and maybe even the customer
33268  in one person, have you tried to see the project from the outside?
33269 \end_layout
33270
33271 \begin_layout Itemize
33272 is the project done if you think it is done? Or is just that other interface/pro
33273 tocol/feature/configuration/option missing? How about website, manual(s),
33274  internationali(z|s)ation, packaging, labels, 2nd source for components,
33275  electromagnetic compatability/interference, documentation for production,
33276  production test software, update mechanism, patent issues?
33277 \end_layout
33278
33279 \begin_layout Itemize
33280 is your project adequately positioned in that magic triangle: fame, fortune,
33281  fun?
33282 \end_layout
33283
33284 \begin_layout Standard
33285 Maybe not all answers to these questions are known and some answers may
33286  even be 
33287 \emph on
33288 no
33289 \emph default
33290 , nevertheless knowing these questions may help you to avoid burnout
33291 \begin_inset Foot
33292 status open
33293
33294 \begin_layout Standard
33295 burnout is bad for electronic devices, programmers and motorcycle tyres
33296 \end_layout
33297
33298 \end_inset
33299
33300 .
33301  Chances are you didn't want to hear some of them...
33302 \end_layout
33303
33304 \begin_layout Chapter
33305 Support
33306 \begin_inset LatexCommand \index{Support}
33307
33308 \end_inset
33309
33310
33311 \end_layout
33312
33313 \begin_layout Standard
33314 SDCC has grown to be a large project.
33315  The compiler alone (without the preprocessor, assembler and linker) is
33316  well over 150,000 lines of code (blank stripped).
33317  The open source nature of this project is a key to its continued growth
33318  and support.
33319  You gain the benefit and support of many active software developers and
33320  end users.
33321  Is SDCC perfect? No, that's why we need your help.
33322  The developers take pride in fixing reported bugs.
33323  You can help by reporting the bugs and helping other SDCC users.
33324  There are lots of ways to contribute, and we encourage you to take part
33325  in making SDCC a great software package.
33326  
33327 \end_layout
33328
33329 \begin_layout Standard
33330 The SDCC project is hosted on the SDCC sourceforge site at 
33331 \begin_inset LatexCommand \htmlurl{http://sourceforge.net/projects/sdcc}
33332
33333 \end_inset
33334
33335 .
33336  You'll find the complete set of mailing lists
33337 \begin_inset LatexCommand \index{Mailing list(s)}
33338
33339 \end_inset
33340
33341 , forums, bug reporting system, patch submission
33342 \begin_inset LatexCommand \index{Patch submission}
33343
33344 \end_inset
33345
33346  system, download
33347 \begin_inset LatexCommand \index{download}
33348
33349 \end_inset
33350
33351  area and Subversion code repository
33352 \begin_inset LatexCommand \index{Subversion code repository}
33353
33354 \end_inset
33355
33356  there.
33357 \end_layout
33358
33359 \begin_layout Section
33360 Reporting Bugs
33361 \begin_inset LatexCommand \index{Bug reporting}
33362
33363 \end_inset
33364
33365
33366 \begin_inset LatexCommand \index{Reporting bugs}
33367
33368 \end_inset
33369
33370
33371 \end_layout
33372
33373 \begin_layout Standard
33374 The recommended way of reporting bugs is using the infrastructure of the
33375  sourceforge site.
33376  You can follow the status of bug reports there and have an overview about
33377  the known bugs.
33378 \end_layout
33379
33380 \begin_layout Standard
33381 Bug reports are automatically forwarded to the developer mailing list and
33382  will be fixed ASAP.
33383  When reporting a bug, it is very useful to include a small test program
33384  (the smaller the better) which reproduces the problem.
33385  If you can isolate the problem by looking at the generated assembly code,
33386  this can be very helpful.
33387  Compiling your program with the -
33388 \begin_inset ERT
33389 status collapsed
33390
33391 \begin_layout Standard
33392
33393
33394 \backslash
33395 /
33396 \end_layout
33397
33398 \end_inset
33399
33400 -dumpall
33401 \begin_inset LatexCommand \index{-\/-dumpall}
33402
33403 \end_inset
33404
33405  option can sometimes be useful in locating optimization problems.
33406  When reporting a bug please make sure you:
33407 \end_layout
33408
33409 \begin_layout Enumerate
33410 Attach the code you are compiling with SDCC.
33411  
33412 \end_layout
33413
33414 \begin_layout Enumerate
33415 Specify the exact command you use to run SDCC, or attach your Makefile.
33416  
33417 \end_layout
33418
33419 \begin_layout Enumerate
33420 Specify the SDCC version (type "
33421 \family sans
33422 \series bold
33423 sdcc -v
33424 \family default
33425 \series default
33426 "), your platform, and operating system.
33427  
33428 \end_layout
33429
33430 \begin_layout Enumerate
33431 Provide an exact copy of any error message or incorrect output.
33432  
33433 \end_layout
33434
33435 \begin_layout Enumerate
33436 Put something meaningful in the subject of your message.
33437 \end_layout
33438
33439 \begin_layout Standard
33440 Please attempt to include these 5 important parts, as applicable, in all
33441  requests for support or when reporting any problems or bugs with SDCC.
33442  Though this will make your message lengthy, it will greatly improve your
33443  chance that SDCC users and developers will be able to help you.
33444  Some SDCC developers are frustrated by bug reports without code provided
33445  that they can use to reproduce and ultimately fix the problem, so please
33446  be sure to provide sample code if you are reporting a bug! 
33447 \end_layout
33448
33449 \begin_layout Standard
33450 Please have a short check that you are using a recent version of SDCC and
33451  the bug is not yet known.
33452  This is the link for reporting bugs: 
33453 \begin_inset LatexCommand \htmlurl{http://sourceforge.net/tracker/?group_id=599&atid=100599}
33454
33455 \end_inset
33456
33457 .
33458  With SDCC on average having more than 200 downloads
33459 \begin_inset LatexCommand \index{download}
33460
33461 \end_inset
33462
33463  on sourceforge per day
33464 \begin_inset Foot
33465 status open
33466
33467 \begin_layout Standard
33468 220 daily downloads on average Jan-Sept 2006 and about 150 daily downloads
33469  between 2002 and 2005.
33470  This does not include other methods of distribution.
33471 \end_layout
33472
33473 \end_inset
33474
33475  there must be some users.
33476  So it's not exactly easy to find a new bug.
33477  If you find one we need it: 
33478 \emph on
33479 reporting bugs is good
33480 \emph default
33481 .
33482 \end_layout
33483
33484 \begin_layout Section
33485 Requesting Features
33486 \begin_inset LatexCommand \label{sub:Requesting-Features}
33487
33488 \end_inset
33489
33490
33491 \begin_inset LatexCommand \index{Feature request}
33492
33493 \end_inset
33494
33495
33496 \begin_inset LatexCommand \index{Requesting features}
33497
33498 \end_inset
33499
33500
33501 \end_layout
33502
33503 \begin_layout Standard
33504 Like bug reports feature requests are forwarded to the developer mailing
33505  list.
33506  This is the link for requesting features: 
33507 \begin_inset LatexCommand \htmlurl{http://sourceforge.net/tracker/?group_id=599&atid=350599}
33508
33509 \end_inset
33510
33511 .
33512 \end_layout
33513
33514 \begin_layout Section
33515 Submitting patches
33516 \end_layout
33517
33518 \begin_layout Standard
33519 Like bug reports contributed patches are forwarded to the developer mailing
33520  list.
33521  This is the link for submitting patches
33522 \begin_inset LatexCommand \index{Patch submission}
33523
33524 \end_inset
33525
33526
33527 \begin_inset LatexCommand \url{http://sourceforge.net/tracker/?group_id=599&atid=300599}
33528
33529 \end_inset
33530
33531 .
33532 \end_layout
33533
33534 \begin_layout Standard
33535 You need to specify some parameters to the 
33536 \family typewriter
33537 diff
33538 \family default
33539  command for the patches to be useful.
33540  If you modified more than one file a patch created f.e.
33541  with 
33542 \family sans
33543 \series bold
33544
33545 \begin_inset Quotes sld
33546 \end_inset
33547
33548 diff -Naur unmodified_directory modified_directory >my_changes.patch
33549 \begin_inset Quotes srd
33550 \end_inset
33551
33552
33553 \family default
33554 \series default
33555  will be fine, otherwise 
33556 \family sans
33557 \series bold
33558
33559 \begin_inset Quotes sld
33560 \end_inset
33561
33562 diff -u sourcefile.c.orig sourcefile.c >my_changes.patch
33563 \begin_inset Quotes srd
33564 \end_inset
33565
33566
33567 \series default
33568  
33569 \family default
33570 will do.
33571 \end_layout
33572
33573 \begin_layout Section
33574 Getting Help
33575 \end_layout
33576
33577 \begin_layout Standard
33578 These links should take you directly to the 
33579 \begin_inset LatexCommand \url[Mailing lists]{http://sourceforge.net/mail/?group_id=599}
33580
33581 \end_inset
33582
33583
33584 \begin_inset Foot
33585 status open
33586
33587 \begin_layout Standard
33588 Traffic on sdcc-devel and sdcc-user is about 100 mails/month each not counting
33589  automated messages (mid 2003)
33590 \end_layout
33591
33592 \end_inset
33593
33594  and the 
33595 \begin_inset LatexCommand \url[Forums]{http://sourceforge.net/forum/?group_id=599}
33596
33597 \end_inset
33598
33599 , lists
33600 \begin_inset LatexCommand \index{Mailing list(s)}
33601
33602 \end_inset
33603
33604  and forums are archived and searchable so if you are lucky someone already
33605  had a similar problem.
33606  While mails to the lists themselves are delivered promptly their web front
33607  end on sourceforge sometimes shows a severe time lag (up to several weeks),
33608  if you're seriously using SDCC please consider subscribing to the lists.
33609 \end_layout
33610
33611 \begin_layout Section
33612 ChangeLog
33613 \end_layout
33614
33615 \begin_layout Standard
33616 You can follow the status of the Subversion version
33617 \begin_inset LatexCommand \index{version}
33618
33619 \end_inset
33620
33621  of SDCC by watching the Changelog
33622 \begin_inset LatexCommand \index{Changelog}
33623
33624 \end_inset
33625
33626  in the Subversion repository
33627 \size footnotesize
33628  
33629 \begin_inset LatexCommand \htmlurl{http://sdcc.svn.sourceforge.net/viewcvs.cgi/*checkout*/sdcc/trunk/sdcc/ChangeLog}
33630
33631 \end_inset
33632
33633 .
33634 \end_layout
33635
33636 \begin_layout Section
33637 Subversion Source Code Repository
33638 \end_layout
33639
33640 \begin_layout Standard
33641 The output of 
33642 \family sans
33643 \series bold
33644 sdcc -
33645 \family default
33646
33647 \begin_inset ERT
33648 status open
33649
33650 \begin_layout Standard
33651
33652
33653 \backslash
33654 /
33655 \end_layout
33656
33657 \end_inset
33658
33659
33660 \family sans
33661 -version
33662 \family default
33663 \series default
33664  or the filenames of the snapshot versions of SDCC include date and its
33665  Subversion
33666 \begin_inset LatexCommand \index{Subversion code repository}
33667
33668 \end_inset
33669
33670  number.
33671  Subversion allows to download the source of recent or previous versions
33672  
33673 \begin_inset LatexCommand \url{http://sourceforge.net/svn/?group_id=599}
33674
33675 \end_inset
33676
33677  (by number or by date).
33678  An on-line source code browser and detailled instructions are also available
33679  there.
33680  SDCC versions starting from 1999 up to now are available (currently the
33681  versions prior to the conversion from cvs
33682 \begin_inset LatexCommand \index{cvs|see{Subversion}}
33683
33684 \end_inset
33685
33686  to Subversion (April 2006) are either by accessible by Subversion or by
33687  cvs).
33688 \end_layout
33689
33690 \begin_layout Section
33691 Release policy
33692 \begin_inset LatexCommand \index{Release policy}
33693
33694 \end_inset
33695
33696
33697 \end_layout
33698
33699 \begin_layout Standard
33700 Historically there often were long delays between official releases and
33701  the sourceforge download area tends to get not updated at all.
33702  Excuses in the past might have referred to problems with live range analysis,
33703  but as this was fixed a while ago, the current problem is that another
33704  excuse has to be found.
33705  Kidding aside, we have to get better there! On the other hand there are
33706  daily snapshots available at 
33707 \begin_inset LatexCommand \htmlurl[snap]{http://sdcc.sourceforge.net/snap.php}
33708
33709 \end_inset
33710
33711 , and you can always build the very last version (hopefully with many bugs
33712  fixed, and features added) from the source code available at 
33713 \begin_inset LatexCommand \htmlurl[Source]{http://sdcc.sourceforge.net/snap.php#Source}
33714
33715 \end_inset
33716
33717 .
33718  The SDCC Wiki
33719 \begin_inset LatexCommand \index{wiki}
33720
33721 \end_inset
33722
33723
33724 \begin_inset LatexCommand \index{SDCC Wiki}
33725
33726 \end_inset
33727
33728  at 
33729 \begin_inset LatexCommand \url{http://sdcc.wiki.sourceforge.net/}
33730
33731 \end_inset
33732
33733  also holds some information about past and future releases.
33734 \end_layout
33735
33736 \begin_layout Section
33737 Examples
33738 \begin_inset LatexCommand \index{Examples}
33739
33740 \end_inset
33741
33742
33743 \end_layout
33744
33745 \begin_layout Standard
33746 You'll find some small examples in the directory 
33747 \emph on
33748 sdcc/device/examples/.
33749  
33750 \emph default
33751 More examples and libraries are available at
33752 \emph on
33753  The SDCC Open Knowledge Resource 
33754 \begin_inset LatexCommand \url{http://sdccokr.dl9sec.de/}
33755
33756 \end_inset
33757
33758  
33759 \emph default
33760 web site or at 
33761 \begin_inset LatexCommand \url{http://www.pjrc.com/tech/8051/}
33762
33763 \end_inset
33764
33765 .
33766 \end_layout
33767
33768 \begin_layout Standard
33769 \begin_inset Note Note
33770 status collapsed
33771
33772 \begin_layout Standard
33773 I did insert a reference to Paul's web site here although it seems rather
33774  dedicated to a specific 8032 board (I think it's okay because it f.e.
33775  shows LCD/Harddisc interface and has a free 8051 monitor.
33776  Independent 8032 board vendors face hard competition of heavily subsidized
33777  development boards anyway).
33778 \end_layout
33779
33780 \begin_layout Standard
33781 Maybe we should include some links to real world applications.
33782  Preferably pointer to pointers (one for each architecture) so this stays
33783  manageable here?
33784 \end_layout
33785
33786 \end_inset
33787
33788
33789 \end_layout
33790
33791 \begin_layout Section
33792 Quality control
33793 \begin_inset LatexCommand \label{sec:Quality-control}
33794
33795 \end_inset
33796
33797
33798 \begin_inset LatexCommand \index{Quality control}
33799
33800 \end_inset
33801
33802
33803 \end_layout
33804
33805 \begin_layout Standard
33806 The compiler is passed through snaphot build compile and build checks.
33807  The so called 
33808 \shape italic
33809 regression tests
33810 \shape default
33811
33812 \begin_inset LatexCommand \index{Regression test}
33813
33814 \end_inset
33815
33816  check that SDCC itself compiles flawlessly on several host platforms (i386,
33817  Opteron, 64 bit Alpha, ppc64, Mac OS X on ppc and i386, Solaris on Sparc)
33818  and checks the quality of the code generated by SDCC by running the code
33819  for several target platforms through simulators.
33820  The regression test suite comprises more than 100 files which expand to
33821  more than 500 test cases which include more than 4500 tests.
33822  The results of these tests are published daily on SDCC's snapshot page
33823  (click on the red or green symbols on the right side of 
33824 \begin_inset LatexCommand \url{http://sdcc.sourceforge.net/snap.php}
33825
33826 \end_inset
33827
33828 ).
33829 \end_layout
33830
33831 \begin_layout Standard
33832 There is a separate document 
33833 \shape italic
33834 test_suite.pdf 
33835 \begin_inset LatexCommand \index{Test suite}
33836
33837 \end_inset
33838
33839
33840 \shape default
33841  
33842 \begin_inset LatexCommand \url{http://sdcc.sourceforge.net/doc/test_suite_spec.pdf}
33843
33844 \end_inset
33845
33846  about the regression test suite.
33847 \end_layout
33848
33849 \begin_layout Standard
33850 You'll find the test code in the directory 
33851 \shape italic
33852 sdcc/support/regression
33853 \shape default
33854 .
33855  You can run these tests manually by running 
33856 \family sans
33857 make
33858 \family default
33859  in this directory (or f.e.
33860  
33861 \family sans
33862 \series bold
33863
33864 \begin_inset Quotes sld
33865 \end_inset
33866
33867 make test-mcs51
33868 \begin_inset Quotes srd
33869 \end_inset
33870
33871
33872 \family default
33873 \series default
33874  if you don't want to run the complete tests).
33875  The test code might also be interesting if you want to look for examples
33876 \begin_inset LatexCommand \index{Examples}
33877
33878 \end_inset
33879
33880  checking corner cases of SDCC or if you plan to submit patches
33881 \begin_inset LatexCommand \index{Patch submission}
33882
33883 \end_inset
33884
33885 .
33886 \end_layout
33887
33888 \begin_layout Standard
33889 The PIC14 port uses a different set of regression tests 
33890 \begin_inset LatexCommand \index{Regression test (PIC14)}
33891
33892 \end_inset
33893
33894 , you'll find them in the directory 
33895 \shape italic
33896 sdcc/src/regression
33897 \shape default
33898 .
33899 \end_layout
33900
33901 \begin_layout Section
33902 Use of SDCC in Education
33903 \end_layout
33904
33905 \begin_layout Standard
33906 In short: 
33907 \emph on
33908 highly
33909 \emph default
33910  encouraged
33911 \begin_inset Foot
33912 status open
33913
33914 \begin_layout Standard
33915 the phrase "use in education" might evoke the association "
33916 \emph on
33917 only
33918 \emph default
33919  fit for use in education".
33920  This connotation is not intended but nevertheless risked as the licensing
33921  of SDCC makes it difficult to offer educational discounts
33922 \end_layout
33923
33924 \end_inset
33925
33926 .
33927  If your rationales are to:
33928 \end_layout
33929
33930 \begin_layout Enumerate
33931 give students a chance to understand the 
33932 \emph on
33933 complete
33934 \emph default
33935  steps of code generation
33936 \end_layout
33937
33938 \begin_layout Enumerate
33939 have a curriculum that can be extended for years.
33940  Then you could use an fpga board as target and your curriculum will seamlessly
33941  extend from logic synthesis (
33942 \begin_inset LatexCommand \url[http://www.opencores.org]{opencores.org}
33943
33944 \end_inset
33945
33946
33947 \begin_inset LatexCommand \url[Oregano]{http://www.oregano.at/ip/ip01.htm}
33948
33949 \end_inset
33950
33951 ), over assembly programming, to C to FPGA compilers (
33952 \begin_inset LatexCommand \url[FPGAC]{http://sf.net/projects/fpgac}
33953
33954 \end_inset
33955
33956 ) and to C.
33957 \end_layout
33958
33959 \begin_layout Enumerate
33960 be able to insert excursions about skills like using a revision control
33961  system, submitting/applying patches, using a type-setting (as opposed to
33962  word-processing) engine LyX/LaTeX, using 
33963 \begin_inset LatexCommand \url[SourceForge]{http://www.sf.net}
33964
33965 \end_inset
33966
33967 , following some 
33968 \begin_inset LatexCommand \url[netiquette]{http://en.wikipedia.org/wiki/Netiquette}
33969
33970 \end_inset
33971
33972 , understanding BSD/LGPL/GPL/Proprietary licensing, growth models of Open
33973  Source Software, CPU simulation, compiler regression tests
33974 \begin_inset LatexCommand \index{Regression test}
33975
33976 \end_inset
33977
33978 .
33979  
33980 \newline
33981 And if there should be a shortage of ideas then you can always point students
33982  to the ever-growing feature request list 
33983 \begin_inset LatexCommand \htmlurl{http://sourceforge.net/tracker/?group_id=599&atid=350599}
33984
33985 \end_inset
33986
33987 .
33988 \end_layout
33989
33990 \begin_layout Enumerate
33991 not tie students to a specific host platform and instead allow them to use
33992  a host platform of 
33993 \emph on
33994 their
33995 \emph default
33996  choice (among them Alpha, i386, i386_64, Mac OS X, Mips, Sparc, Windows
33997  and eventually 
33998 \begin_inset LatexCommand \url[OLPC]{http://www.laptop.org}
33999
34000 \end_inset
34001
34002 )
34003 \end_layout
34004
34005 \begin_layout Enumerate
34006 not encourage students to use illegal copies of educational software
34007 \end_layout
34008
34009 \begin_layout Enumerate
34010 be immune to licensing/availability/price changes of the chosen tool chain
34011 \end_layout
34012
34013 \begin_layout Enumerate
34014 be able to change to a new target platform without having to adopt a new
34015  tool chain
34016 \end_layout
34017
34018 \begin_layout Enumerate
34019 have complete control over and insight into the tool chain
34020 \end_layout
34021
34022 \begin_layout Enumerate
34023 make your students aware about the pros and cons of open source software
34024  development
34025 \end_layout
34026
34027 \begin_layout Enumerate
34028 give back to the public as you are probably at least partially publically
34029  funded
34030 \end_layout
34031
34032 \begin_layout Enumerate
34033 give students a chance to publically prove their skills and to possibly
34034  see a world wide impact
34035 \end_layout
34036
34037 \begin_layout Standard
34038 then SDCC is probably among the first choices.
34039  Well, probably SDCC might be the only choice.
34040 \newpage
34041
34042 \end_layout
34043
34044 \begin_layout Chapter
34045 SDCC Technical Data
34046 \end_layout
34047
34048 \begin_layout Section
34049 Optimizations
34050 \begin_inset LatexCommand \index{Optimizations}
34051
34052 \end_inset
34053
34054
34055 \end_layout
34056
34057 \begin_layout Standard
34058 SDCC performs a host of standard optimizations in addition to some MCU specific
34059  optimizations.
34060  
34061 \end_layout
34062
34063 \begin_layout Subsection
34064 Sub-expression Elimination
34065 \begin_inset LatexCommand \index{Subexpression elimination}
34066
34067 \end_inset
34068
34069
34070 \end_layout
34071
34072 \begin_layout Standard
34073 The compiler does local and 
34074 \emph on
34075 g
34076 \emph default
34077 lobal 
34078 \emph on
34079 c
34080 \emph default
34081 ommon 
34082 \emph on
34083 s
34084 \emph default
34085 ubexpression 
34086 \emph on
34087 e
34088 \emph default
34089 limination, e.g.: 
34090 \end_layout
34091
34092 \begin_layout Verse
34093
34094 \family typewriter
34095 i = x + y + 1; 
34096 \newline
34097 j = x + y;
34098 \end_layout
34099
34100 \begin_layout Standard
34101 will be translated to
34102 \end_layout
34103
34104 \begin_layout Verse
34105
34106 \family typewriter
34107 iTemp = x + y; 
34108 \newline
34109 i = iTemp + 1; 
34110 \newline
34111 j = iTemp;
34112 \end_layout
34113
34114 \begin_layout Standard
34115 Some subexpressions are not as obvious as the above example, e.g.:
34116 \end_layout
34117
34118 \begin_layout Verse
34119
34120 \family typewriter
34121 a->b[i].c = 10; 
34122 \newline
34123 a->b[i].d = 11;
34124 \end_layout
34125
34126 \begin_layout Standard
34127 In this case the address arithmetic a->b[i] will be computed only once;
34128  the equivalent code in C would be.
34129 \end_layout
34130
34131 \begin_layout Verse
34132
34133 \family typewriter
34134 iTemp = a->b[i]; 
34135 \newline
34136 iTemp.c = 10; 
34137 \newline
34138 iTemp.d = 11;
34139 \end_layout
34140
34141 \begin_layout Standard
34142 The compiler will try to keep these temporary variables in registers.
34143 \end_layout
34144
34145 \begin_layout Subsection
34146 Dead-Code Elimination
34147 \begin_inset LatexCommand \index{Dead-code elimination}
34148
34149 \end_inset
34150
34151
34152 \end_layout
34153
34154 \begin_layout Verse
34155
34156 \family typewriter
34157 int global;
34158 \newline
34159
34160 \newline
34161 void f () { 
34162 \newline
34163 \InsetSpace ~
34164 \InsetSpace ~
34165 int i; 
34166 \newline
34167 \InsetSpace ~
34168 \InsetSpace ~
34169 i = 1; \InsetSpace ~
34170 \InsetSpace ~
34171 \InsetSpace ~
34172 \InsetSpace ~
34173 \InsetSpace ~
34174 /* dead store */ 
34175 \newline
34176 \InsetSpace ~
34177 \InsetSpace ~
34178 global = 1;\InsetSpace ~
34179 /* dead
34180  store */ 
34181 \newline
34182 \InsetSpace ~
34183 \InsetSpace ~
34184 global = 2; 
34185 \newline
34186 \InsetSpace ~
34187 \InsetSpace ~
34188 return; 
34189 \newline
34190 \InsetSpace ~
34191 \InsetSpace ~
34192 global = 3;\InsetSpace ~
34193 /* unreachable */ 
34194 \newline
34195 }
34196 \end_layout
34197
34198 \begin_layout Standard
34199 will be changed to
34200 \end_layout
34201
34202 \begin_layout Verse
34203
34204 \family typewriter
34205 int global;
34206 \newline
34207
34208 \newline
34209 void f () {
34210 \newline
34211 \InsetSpace ~
34212 \InsetSpace ~
34213 global = 2; 
34214 \newline
34215 }
34216 \end_layout
34217
34218 \begin_layout Subsection
34219 Copy-Propagation
34220 \begin_inset LatexCommand \index{Copy propagation}
34221
34222 \end_inset
34223
34224
34225 \end_layout
34226
34227 \begin_layout Verse
34228
34229 \family typewriter
34230 int f() { 
34231 \newline
34232 \InsetSpace ~
34233 \InsetSpace ~
34234 int i, j; 
34235 \newline
34236 \InsetSpace ~
34237 \InsetSpace ~
34238 i = 10; 
34239 \newline
34240 \InsetSpace ~
34241 \InsetSpace ~
34242 j = i; 
34243 \newline
34244 \InsetSpace ~
34245 \InsetSpace ~
34246 return j; 
34247 \newline
34248 }
34249 \end_layout
34250
34251 \begin_layout Standard
34252 will be changed to 
34253 \end_layout
34254
34255 \begin_layout Verse
34256
34257 \family typewriter
34258 int f() { 
34259 \newline
34260 \InsetSpace ~
34261 \InsetSpace ~
34262 int i, j; 
34263 \newline
34264 \InsetSpace ~
34265 \InsetSpace ~
34266 i = 10; 
34267 \newline
34268 \InsetSpace ~
34269 \InsetSpace ~
34270 j = 10; 
34271 \newline
34272 \InsetSpace ~
34273 \InsetSpace ~
34274 return 10; 
34275 \newline
34276 }
34277 \end_layout
34278
34279 \begin_layout Standard
34280 Note: the dead stores created by this copy propagation will be eliminated
34281  by dead-code elimination.
34282 \end_layout
34283
34284 \begin_layout Subsection
34285 Loop Optimizations
34286 \begin_inset LatexCommand \index{Loop optimization}
34287
34288 \end_inset
34289
34290
34291 \begin_inset LatexCommand \label{sub:Loop-Optimizations}
34292
34293 \end_inset
34294
34295
34296 \end_layout
34297
34298 \begin_layout Standard
34299 Two types of loop optimizations are done by SDCC 
34300 \emph on
34301 loop invariant
34302 \emph default
34303  lifting and
34304 \emph on
34305  strength reduction
34306 \emph default
34307  of loop induction variables.
34308  In addition to the strength reduction the optimizer marks the induction
34309  variables and the register allocator tries to keep the induction variables
34310  in registers for the duration of the loop.
34311  Because of this preference of the register allocator
34312 \begin_inset LatexCommand \index{Register allocation}
34313
34314 \end_inset
34315
34316 , loop induction optimization causes an increase in register pressure, which
34317  may cause unwanted spilling of other temporary variables into the stack
34318 \begin_inset LatexCommand \index{stack}
34319
34320 \end_inset
34321
34322  / data space.
34323  The compiler will generate a warning message when it is forced to allocate
34324  extra space either on the stack or data space.
34325  If this extra space allocation is undesirable then induction optimization
34326  can be eliminated either for the entire source file (with -
34327 \begin_inset ERT
34328 status collapsed
34329
34330 \begin_layout Standard
34331
34332
34333 \backslash
34334 /
34335 \end_layout
34336
34337 \end_inset
34338
34339 -noinduction option) or for a given function only using #pragma\InsetSpace ~
34340 noinduction
34341 \begin_inset LatexCommand \index{\#pragma noinduction}
34342
34343 \end_inset
34344
34345 .
34346 \newline
34347
34348 \newline
34349 Loop Invariant:
34350 \end_layout
34351
34352 \begin_layout Verse
34353
34354 \family typewriter
34355 for (i = 0 ; i < 100 ; i ++) 
34356 \newline
34357 \InsetSpace ~
34358 \InsetSpace ~
34359 \InsetSpace ~
34360 \InsetSpace ~
34361 f += k + l;
34362 \end_layout
34363
34364 \begin_layout Standard
34365 changed to
34366 \end_layout
34367
34368 \begin_layout Verse
34369
34370 \family typewriter
34371 itemp = k + l; 
34372 \newline
34373 for (i = 0; i < 100; i++) 
34374 \newline
34375 \InsetSpace ~
34376 \InsetSpace ~
34377 \InsetSpace ~
34378 \InsetSpace ~
34379 f += itemp;
34380 \end_layout
34381
34382 \begin_layout Standard
34383 As mentioned previously some loop invariants are not as apparent, all static
34384  address computations are also moved out of the loop.
34385 \newline
34386
34387 \newline
34388 Strength Reduction
34389 \begin_inset LatexCommand \index{Strength reduction}
34390
34391 \end_inset
34392
34393 , this optimization substitutes an expression by a cheaper expression:
34394 \end_layout
34395
34396 \begin_layout Verse
34397
34398 \family typewriter
34399 for (i=0;i < 100; i++)
34400 \newline
34401 \InsetSpace ~
34402 \InsetSpace ~
34403 \InsetSpace ~
34404 \InsetSpace ~
34405 ar[i*5] = i*3;
34406 \end_layout
34407
34408 \begin_layout Standard
34409 changed to
34410 \end_layout
34411
34412 \begin_layout Verse
34413
34414 \family typewriter
34415 itemp1 = 0; 
34416 \newline
34417 itemp2 = 0; 
34418 \newline
34419 for (i=0;i< 100;i++) { 
34420 \newline
34421 \InsetSpace ~
34422 \InsetSpace ~
34423 \InsetSpace ~
34424 \InsetSpace ~
34425 ar[itemp1] = itemp2; 
34426 \newline
34427 \InsetSpace ~
34428 \InsetSpace ~
34429 \InsetSpace ~
34430 \InsetSpace ~
34431 itemp1
34432  += 5; 
34433 \newline
34434 \InsetSpace ~
34435 \InsetSpace ~
34436 \InsetSpace ~
34437 \InsetSpace ~
34438 itemp2 += 3; 
34439 \newline
34440 }
34441 \end_layout
34442
34443 \begin_layout Standard
34444 The more expensive multiplication
34445 \begin_inset LatexCommand \index{Multiplication}
34446
34447 \end_inset
34448
34449  is changed to a less expensive addition.
34450 \end_layout
34451
34452 \begin_layout Subsection
34453 Loop Reversing
34454 \begin_inset LatexCommand \index{Loop reversing}
34455
34456 \end_inset
34457
34458
34459 \end_layout
34460
34461 \begin_layout Standard
34462 This optimization is done to reduce the overhead of checking loop boundaries
34463  for every iteration.
34464  Some simple loops can be reversed and implemented using a 
34465 \begin_inset Quotes eld
34466 \end_inset
34467
34468 decrement and jump if not zero
34469 \begin_inset Quotes erd
34470 \end_inset
34471
34472  instruction.
34473  SDCC checks for the following criterion to determine if a loop is reversible
34474  (note: more sophisticated compilers use data-dependency analysis to make
34475  this determination, SDCC uses a more simple minded analysis).
34476 \end_layout
34477
34478 \begin_layout Itemize
34479 The 'for' loop is of the form 
34480 \newline
34481
34482 \newline
34483
34484 \family typewriter
34485 for(<symbol> = <expression>; <sym> [< | <=] <expression>; [<sym>++ | <sym>
34486  += 1])
34487 \newline
34488 \InsetSpace ~
34489 \InsetSpace ~
34490 \InsetSpace ~
34491 \InsetSpace ~
34492 <for body>
34493 \end_layout
34494
34495 \begin_layout Itemize
34496 The <for body> does not contain 
34497 \begin_inset Quotes eld
34498 \end_inset
34499
34500 continue
34501 \begin_inset Quotes erd
34502 \end_inset
34503
34504  or 'break
34505 \begin_inset Quotes erd
34506 \end_inset
34507
34508 .
34509 \end_layout
34510
34511 \begin_layout Itemize
34512 All goto's are contained within the loop.
34513 \end_layout
34514
34515 \begin_layout Itemize
34516 No function calls within the loop.
34517 \end_layout
34518
34519 \begin_layout Itemize
34520 The loop control variable <sym> is not assigned any value within the loop
34521 \end_layout
34522
34523 \begin_layout Itemize
34524 The loop control variable does NOT participate in any arithmetic operation
34525  within the loop.
34526 \end_layout
34527
34528 \begin_layout Itemize
34529 There are NO switch statements in the loop.
34530 \end_layout
34531
34532 \begin_layout Subsection
34533 Algebraic Simplifications
34534 \end_layout
34535
34536 \begin_layout Standard
34537 SDCC does numerous algebraic simplifications, the following is a small sub-set
34538  of these optimizations.
34539 \end_layout
34540
34541 \begin_layout Verse
34542
34543 \family typewriter
34544 i = j + 0;\InsetSpace ~
34545 \InsetSpace ~
34546 \InsetSpace ~
34547 \InsetSpace ~
34548  /* changed to: */\InsetSpace ~
34549 \InsetSpace ~
34550 \InsetSpace ~
34551 \InsetSpace ~
34552  i = j; 
34553 \newline
34554 i /= 2;\InsetSpace ~
34555 \InsetSpace ~
34556 \InsetSpace ~
34557 \InsetSpace ~
34558 \InsetSpace ~
34559 \InsetSpace ~
34560 \InsetSpace ~
34561  /* changed to: */\InsetSpace ~
34562 \InsetSpace ~
34563 \InsetSpace ~
34564 \InsetSpace ~
34565  i >>= 1; 
34566 \newline
34567 i
34568  = j - j;\InsetSpace ~
34569 \InsetSpace ~
34570 \InsetSpace ~
34571 \InsetSpace ~
34572  /* changed to: */\InsetSpace ~
34573 \InsetSpace ~
34574 \InsetSpace ~
34575 \InsetSpace ~
34576  i = 0; 
34577 \newline
34578 i = j / 1;\InsetSpace ~
34579 \InsetSpace ~
34580 \InsetSpace ~
34581 \InsetSpace ~
34582  /* changed to: */\InsetSpace ~
34583 \InsetSpace ~
34584 \InsetSpace ~
34585 \InsetSpace ~
34586  i = j;
34587 \end_layout
34588
34589 \begin_layout Standard
34590 Note the subexpressions
34591 \begin_inset LatexCommand \index{Subexpression}
34592
34593 \end_inset
34594
34595  given above are generally introduced by macro expansions or as a result
34596  of copy/constant propagation.
34597 \end_layout
34598
34599 \begin_layout Subsection
34600 'switch' Statements
34601 \begin_inset LatexCommand \label{sub:'switch'-Statements}
34602
34603 \end_inset
34604
34605
34606 \begin_inset LatexCommand \index{switch statement}
34607
34608 \end_inset
34609
34610
34611 \end_layout
34612
34613 \begin_layout Standard
34614 SDCC can optimize switch statements to jump tables
34615 \begin_inset LatexCommand \index{jump tables}
34616
34617 \end_inset
34618
34619 .
34620  It makes the decision based on an estimate of the generated code size.
34621  SDCC is quite liberal in the requirements for jump table generation: 
34622 \end_layout
34623
34624 \begin_layout Itemize
34625 The labels need not be in order, and the starting number need not be one
34626  or zero, the case labels are in numerical sequence or not too many case
34627  labels are missing.
34628 \end_layout
34629
34630 \begin_deeper
34631 \begin_layout Verse
34632
34633 \family typewriter
34634 switch(i) {\InsetSpace ~
34635 \InsetSpace ~
34636 \InsetSpace ~
34637 \InsetSpace ~
34638 \InsetSpace ~
34639 \InsetSpace ~
34640 \InsetSpace ~
34641 \InsetSpace ~
34642 \InsetSpace ~
34643 \InsetSpace ~
34644 \InsetSpace ~
34645 \InsetSpace ~
34646 \InsetSpace ~
34647 \InsetSpace ~
34648 \InsetSpace ~
34649 \InsetSpace ~
34650 \InsetSpace ~
34651 \InsetSpace ~
34652 \InsetSpace ~
34653 \InsetSpace ~
34654 \InsetSpace ~
34655 \InsetSpace ~
34656 \InsetSpace ~
34657 \InsetSpace ~
34658 \InsetSpace ~
34659 \InsetSpace ~
34660 switch (i) { 
34661 \newline
34662 \InsetSpace ~
34663 \InsetSpace ~
34664 \InsetSpace ~
34665 case 4: ...\InsetSpace ~
34666 \InsetSpace ~
34667 \InsetSpace ~
34668 \InsetSpace ~
34669 \InsetSpace ~
34670 \InsetSpace ~
34671 \InsetSpace ~
34672 \InsetSpace ~
34673 \InsetSpace ~
34674 \InsetSpace ~
34675 \InsetSpace ~
34676 \InsetSpace ~
34677 \InsetSpace ~
34678 \InsetSpace ~
34679 \InsetSpace ~
34680 \InsetSpace ~
34681 \InsetSpace ~
34682 \InsetSpace ~
34683 \InsetSpace ~
34684 \InsetSpace ~
34685 \InsetSpace ~
34686 \InsetSpace ~
34687 \InsetSpace ~
34688 \InsetSpace ~
34689 \InsetSpace ~
34690 \InsetSpace ~
34691 case 0: ...
34692  
34693 \newline
34694 \InsetSpace ~
34695 \InsetSpace ~
34696 \InsetSpace ~
34697 case 5: ...\InsetSpace ~
34698 \InsetSpace ~
34699 \InsetSpace ~
34700 \InsetSpace ~
34701 \InsetSpace ~
34702 \InsetSpace ~
34703 \InsetSpace ~
34704 \InsetSpace ~
34705 \InsetSpace ~
34706 \InsetSpace ~
34707 \InsetSpace ~
34708 \InsetSpace ~
34709 \InsetSpace ~
34710 \InsetSpace ~
34711 \InsetSpace ~
34712 \InsetSpace ~
34713 \InsetSpace ~
34714 \InsetSpace ~
34715 \InsetSpace ~
34716 \InsetSpace ~
34717 \InsetSpace ~
34718 \InsetSpace ~
34719 \InsetSpace ~
34720 \InsetSpace ~
34721 \InsetSpace ~
34722 \InsetSpace ~
34723 case 1: ...
34724  
34725 \newline
34726 \InsetSpace ~
34727 \InsetSpace ~
34728 \InsetSpace ~
34729 case 3: ...\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 \InsetSpace ~
34747 \InsetSpace ~
34748 \InsetSpace ~
34749 \InsetSpace ~
34750 \InsetSpace ~
34751 \InsetSpace ~
34752 \InsetSpace ~
34753 \InsetSpace ~
34754 \InsetSpace ~
34755
34756 \newline
34757 \InsetSpace ~
34758 \InsetSpace ~
34759 \InsetSpace ~
34760 case 6: ...\InsetSpace ~
34761 \InsetSpace ~
34762 \InsetSpace ~
34763 \InsetSpace ~
34764 \InsetSpace ~
34765 \InsetSpace ~
34766 \InsetSpace ~
34767 \InsetSpace ~
34768 \InsetSpace ~
34769 \InsetSpace ~
34770 \InsetSpace ~
34771 \InsetSpace ~
34772 \InsetSpace ~
34773 \InsetSpace ~
34774 \InsetSpace ~
34775 \InsetSpace ~
34776 \InsetSpace ~
34777 \InsetSpace ~
34778 \InsetSpace ~
34779 \InsetSpace ~
34780 \InsetSpace ~
34781 \InsetSpace ~
34782 \InsetSpace ~
34783 \InsetSpace ~
34784 \InsetSpace ~
34785 \InsetSpace ~
34786 case 3: ...
34787  
34788 \newline
34789 \InsetSpace ~
34790 \InsetSpace ~
34791 \InsetSpace ~
34792 case 7: ...\InsetSpace ~
34793 \InsetSpace ~
34794 \InsetSpace ~
34795 \InsetSpace ~
34796 \InsetSpace ~
34797 \InsetSpace ~
34798 \InsetSpace ~
34799 \InsetSpace ~
34800 \InsetSpace ~
34801 \InsetSpace ~
34802 \InsetSpace ~
34803 \InsetSpace ~
34804 \InsetSpace ~
34805 \InsetSpace ~
34806 \InsetSpace ~
34807 \InsetSpace ~
34808 \InsetSpace ~
34809 \InsetSpace ~
34810 \InsetSpace ~
34811 \InsetSpace ~
34812 \InsetSpace ~
34813 \InsetSpace ~
34814 \InsetSpace ~
34815 \InsetSpace ~
34816 \InsetSpace ~
34817 \InsetSpace ~
34818 case 4: ...
34819  
34820 \newline
34821 \InsetSpace ~
34822 \InsetSpace ~
34823 \InsetSpace ~
34824 case 8: ...\InsetSpace ~
34825 \InsetSpace ~
34826 \InsetSpace ~
34827 \InsetSpace ~
34828 \InsetSpace ~
34829 \InsetSpace ~
34830 \InsetSpace ~
34831 \InsetSpace ~
34832 \InsetSpace ~
34833 \InsetSpace ~
34834 \InsetSpace ~
34835 \InsetSpace ~
34836 \InsetSpace ~
34837 \InsetSpace ~
34838 \InsetSpace ~
34839 \InsetSpace ~
34840 \InsetSpace ~
34841 \InsetSpace ~
34842 \InsetSpace ~
34843 \InsetSpace ~
34844 \InsetSpace ~
34845 \InsetSpace ~
34846 \InsetSpace ~
34847 \InsetSpace ~
34848 \InsetSpace ~
34849 \InsetSpace ~
34850 case 5: ...
34851  
34852 \newline
34853 \InsetSpace ~
34854 \InsetSpace ~
34855 \InsetSpace ~
34856 case 9: ...\InsetSpace ~
34857 \InsetSpace ~
34858 \InsetSpace ~
34859 \InsetSpace ~
34860 \InsetSpace ~
34861 \InsetSpace ~
34862 \InsetSpace ~
34863 \InsetSpace ~
34864 \InsetSpace ~
34865 \InsetSpace ~
34866 \InsetSpace ~
34867 \InsetSpace ~
34868 \InsetSpace ~
34869 \InsetSpace ~
34870 \InsetSpace ~
34871 \InsetSpace ~
34872 \InsetSpace ~
34873 \InsetSpace ~
34874 \InsetSpace ~
34875 \InsetSpace ~
34876 \InsetSpace ~
34877 \InsetSpace ~
34878 \InsetSpace ~
34879 \InsetSpace ~
34880 \InsetSpace ~
34881 \InsetSpace ~
34882 case 6: ...
34883  
34884 \newline
34885 \InsetSpace ~
34886 \InsetSpace ~
34887 \InsetSpace ~
34888 case 10: ...\InsetSpace ~
34889 \InsetSpace ~
34890 \InsetSpace ~
34891 \InsetSpace ~
34892 \InsetSpace ~
34893 \InsetSpace ~
34894 \InsetSpace ~
34895 \InsetSpace ~
34896 \InsetSpace ~
34897 \InsetSpace ~
34898 \InsetSpace ~
34899 \InsetSpace ~
34900 \InsetSpace ~
34901 \InsetSpace ~
34902 \InsetSpace ~
34903 \InsetSpace ~
34904 \InsetSpace ~
34905 \InsetSpace ~
34906 \InsetSpace ~
34907 \InsetSpace ~
34908 \InsetSpace ~
34909 \InsetSpace ~
34910 \InsetSpace ~
34911 \InsetSpace ~
34912 \InsetSpace ~
34913 case 7: ...
34914  
34915 \newline
34916 \InsetSpace ~
34917 \InsetSpace ~
34918 \InsetSpace ~
34919 case 11: ...\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 \InsetSpace ~
34937 \InsetSpace ~
34938 \InsetSpace ~
34939 \InsetSpace ~
34940 \InsetSpace ~
34941 \InsetSpace ~
34942 \InsetSpace ~
34943 \InsetSpace ~
34944 case 8: ...
34945  
34946 \newline
34947 }\InsetSpace ~
34948 \InsetSpace ~
34949 \InsetSpace ~
34950 \InsetSpace ~
34951 \InsetSpace ~
34952 \InsetSpace ~
34953 \InsetSpace ~
34954 \InsetSpace ~
34955 \InsetSpace ~
34956 \InsetSpace ~
34957 \InsetSpace ~
34958 \InsetSpace ~
34959 \InsetSpace ~
34960 \InsetSpace ~
34961 \InsetSpace ~
34962 \InsetSpace ~
34963 \InsetSpace ~
34964 \InsetSpace ~
34965 \InsetSpace ~
34966 \InsetSpace ~
34967 \InsetSpace ~
34968 \InsetSpace ~
34969 \InsetSpace ~
34970 \InsetSpace ~
34971 \InsetSpace ~
34972 \InsetSpace ~
34973 \InsetSpace ~
34974 \InsetSpace ~
34975 \InsetSpace ~
34976 \InsetSpace ~
34977 \InsetSpace ~
34978 \InsetSpace ~
34979 \InsetSpace ~
34980 \InsetSpace ~
34981 \InsetSpace ~
34982 \InsetSpace ~
34983 }
34984 \end_layout
34985
34986 \begin_layout Standard
34987 Both the above switch statements will be implemented using a jump-table.
34988  The example to the right side is slightly more efficient as the check for
34989  the lower boundary of the jump-table is not needed.
34990 \end_layout
34991
34992 \end_deeper
34993 \begin_layout Itemize
34994 The number of case labels is not larger than supported by the target architectur
34995 e.
34996 \end_layout
34997
34998 \begin_layout Itemize
34999 If the case labels are not in numerical sequence ('gaps' between cases)
35000  SDCC checks whether a jump table with additionally inserted dummy cases
35001  is still attractive.
35002  
35003 \end_layout
35004
35005 \begin_layout Itemize
35006 If the starting number is not zero and a check for the lower boundary of
35007  the jump-table can thus be eliminated SDCC might insert dummy cases 0,
35008  ...
35009  .
35010 \end_layout
35011
35012 \begin_layout Standard
35013 Switch statements which have large gaps in the numeric sequence or those
35014  that have too many case labels can be split into more than one switch statement
35015  for efficient code generation, e.g.:
35016 \end_layout
35017
35018 \begin_layout Verse
35019
35020 \family typewriter
35021 switch (i) { 
35022 \newline
35023 \InsetSpace ~
35024 \InsetSpace ~
35025 case 1: ...
35026  
35027 \newline
35028 \InsetSpace ~
35029 \InsetSpace ~
35030 case 2: ...
35031  
35032 \newline
35033 \InsetSpace ~
35034 \InsetSpace ~
35035 case 3: ...
35036  
35037 \newline
35038 \InsetSpace ~
35039 \InsetSpace ~
35040 case 4: ...
35041  
35042 \newline
35043 \InsetSpace ~
35044 \InsetSpace ~
35045 case 5: ...
35046  
35047 \newline
35048 \InsetSpace ~
35049 \InsetSpace ~
35050 case 6: ...
35051  
35052 \newline
35053 \InsetSpace ~
35054 \InsetSpace ~
35055 case 7: ...
35056  
35057 \newline
35058 \InsetSpace ~
35059 \InsetSpace ~
35060 case 101: ...
35061  
35062 \newline
35063 \InsetSpace ~
35064 \InsetSpace ~
35065 case 102: ...
35066  
35067 \newline
35068 \InsetSpace ~
35069 \InsetSpace ~
35070 case 103: ...
35071  
35072 \newline
35073 \InsetSpace ~
35074 \InsetSpace ~
35075 case 104: ...
35076  
35077 \newline
35078 \InsetSpace ~
35079 \InsetSpace ~
35080 case 105: ...
35081  
35082 \newline
35083 \InsetSpace ~
35084 \InsetSpace ~
35085 case 106: ...
35086  
35087 \newline
35088 \InsetSpace ~
35089 \InsetSpace ~
35090 case 107: ...
35091  
35092 \newline
35093 }
35094 \end_layout
35095
35096 \begin_layout Standard
35097 If the above switch statement is broken down into two switch statements
35098 \end_layout
35099
35100 \begin_layout Verse
35101
35102 \family typewriter
35103 switch (i) { 
35104 \newline
35105 \InsetSpace ~
35106 \InsetSpace ~
35107 case 1: ...
35108  
35109 \newline
35110 \InsetSpace ~
35111 \InsetSpace ~
35112 case 2: ...
35113  
35114 \newline
35115 \InsetSpace ~
35116 \InsetSpace ~
35117 case 3: ...
35118  
35119 \newline
35120 \InsetSpace ~
35121 \InsetSpace ~
35122 case 4: ...
35123  
35124 \newline
35125 \InsetSpace ~
35126 \InsetSpace ~
35127 case 5: ...
35128  
35129 \newline
35130 \InsetSpace ~
35131 \InsetSpace ~
35132 case 6: ...
35133  
35134 \newline
35135 \InsetSpace ~
35136 \InsetSpace ~
35137 case 7: ...
35138  
35139 \newline
35140 }
35141 \end_layout
35142
35143 \begin_layout Standard
35144 and
35145 \end_layout
35146
35147 \begin_layout Verse
35148
35149 \family typewriter
35150 switch (i) { 
35151 \newline
35152 \InsetSpace ~
35153 \InsetSpace ~
35154 case 101: ...
35155  
35156 \newline
35157 \InsetSpace ~
35158 \InsetSpace ~
35159 case 102: ...
35160  
35161 \newline
35162 \InsetSpace ~
35163 \InsetSpace ~
35164 case 103: ...
35165  
35166 \newline
35167 \InsetSpace ~
35168 \InsetSpace ~
35169 case 104: ...
35170  
35171 \newline
35172 \InsetSpace ~
35173 \InsetSpace ~
35174 case 105: ...
35175  
35176 \newline
35177 \InsetSpace ~
35178 \InsetSpace ~
35179 case 106: ...
35180  
35181 \newline
35182 \InsetSpace ~
35183 \InsetSpace ~
35184 case 107: ...
35185  
35186 \newline
35187 }
35188 \end_layout
35189
35190 \begin_layout Standard
35191 then both the switch statements will be implemented using jump-tables whereas
35192  the unmodified switch statement will not be.
35193 \end_layout
35194
35195 \begin_layout Standard
35196 \begin_inset Note Note
35197 status collapsed
35198
35199 \begin_layout Standard
35200 There might be reasons which SDCC cannot know about to either favour or
35201  not favour jump tables.
35202  If the target system has to be as quick for the last switch case as for
35203  the first (pro jump table), or if the switch argument is known to be zero
35204  in the majority of the cases (contra jump table).
35205 \end_layout
35206
35207 \end_inset
35208
35209
35210 \end_layout
35211
35212 \begin_layout Standard
35213 The pragma nojtbound
35214 \begin_inset LatexCommand \index{\#pragma nojtbound}
35215
35216 \end_inset
35217
35218  can be used to turn off checking the 
35219 \emph on
35220 j
35221 \emph default
35222 ump 
35223 \emph on
35224 t
35225 \emph default
35226 able 
35227 \emph on
35228 bound
35229 \emph default
35230 aries.
35231  It has no effect if a default label is supplied.
35232  Use of this pragma is dangerous: if the switch
35233 \begin_inset LatexCommand \index{switch statement}
35234
35235 \end_inset
35236
35237  argument is not matched by a case statement the processor will happily
35238  jump into Nirvana.
35239 \end_layout
35240
35241 \begin_layout Subsection
35242 Bit-shifting Operations
35243 \begin_inset LatexCommand \index{Bit shifting}
35244
35245 \end_inset
35246
35247 .
35248 \end_layout
35249
35250 \begin_layout Standard
35251 Bit shifting is one of the most frequently used operation in embedded programmin
35252 g.
35253  SDCC tries to implement bit-shift operations in the most efficient way
35254  possible, e.g.:
35255 \end_layout
35256
35257 \begin_layout Verse
35258
35259 \family typewriter
35260 unsigned char i;
35261 \newline
35262 ...
35263  
35264 \newline
35265 i >>= 4; 
35266 \newline
35267 ...
35268 \end_layout
35269
35270 \begin_layout Standard
35271 generates the following code:
35272 \end_layout
35273
35274 \begin_layout Verse
35275
35276 \family typewriter
35277 mov\InsetSpace ~
35278  a,_i 
35279 \newline
35280 swap a 
35281 \newline
35282 anl\InsetSpace ~
35283  a,#0x0f 
35284 \newline
35285 mov\InsetSpace ~
35286  _i,a
35287 \end_layout
35288
35289 \begin_layout Standard
35290 In general SDCC will never setup a loop if the shift count is known.
35291  Another example:
35292 \end_layout
35293
35294 \begin_layout Verse
35295
35296 \family typewriter
35297 unsigned int i; 
35298 \newline
35299 ...
35300  
35301 \newline
35302 i >>= 9; 
35303 \newline
35304 ...
35305 \end_layout
35306
35307 \begin_layout Standard
35308 will generate:
35309 \end_layout
35310
35311 \begin_layout Verse
35312
35313 \family typewriter
35314 mov\InsetSpace ~
35315 \InsetSpace ~
35316 a,(_i + 1) 
35317 \newline
35318 mov\InsetSpace ~
35319 \InsetSpace ~
35320 (_i + 1),#0x00 
35321 \newline
35322 clr\InsetSpace ~
35323 \InsetSpace ~
35324
35325 \newline
35326 rrc\InsetSpace ~
35327 \InsetSpace ~
35328
35329 \newline
35330 mov\InsetSpace ~
35331 \InsetSpace ~
35332 _i,a
35333 \end_layout
35334
35335 \begin_layout Subsection
35336 Bit-rotation
35337 \begin_inset LatexCommand \index{Bit rotation}
35338
35339 \end_inset
35340
35341
35342 \end_layout
35343
35344 \begin_layout Standard
35345 A special case of the bit-shift operation is bit rotation
35346 \begin_inset LatexCommand \index{rotating bits}
35347
35348 \end_inset
35349
35350 , SDCC recognizes the following expression to be a left bit-rotation:
35351 \end_layout
35352
35353 \begin_layout Verse
35354
35355 \family typewriter
35356 \series bold
35357 unsigned
35358 \series default
35359 \InsetSpace ~
35360 \InsetSpace ~
35361 char i;\InsetSpace ~
35362 \InsetSpace ~
35363 \InsetSpace ~
35364 \InsetSpace ~
35365 \InsetSpace ~
35366 \InsetSpace ~
35367 \InsetSpace ~
35368 \InsetSpace ~
35369 \InsetSpace ~
35370 \InsetSpace ~
35371 \InsetSpace ~
35372 /* unsigned is needed for rotation */ 
35373 \newline
35374 ...
35375  
35376 \newline
35377 i = ((i << 1) | (i >> 7)); 
35378 \family default
35379
35380 \newline
35381
35382 \family typewriter
35383 ...
35384 \end_layout
35385
35386 \begin_layout Standard
35387 will generate the following code:
35388 \end_layout
35389
35390 \begin_layout Verse
35391
35392 \family typewriter
35393 mov\InsetSpace ~
35394 \InsetSpace ~
35395 a,_i 
35396 \newline
35397 rl\InsetSpace ~
35398 \InsetSpace ~
35399 \InsetSpace ~
35400
35401 \newline
35402 mov\InsetSpace ~
35403 \InsetSpace ~
35404 _i,a
35405 \end_layout
35406
35407 \begin_layout Standard
35408 SDCC uses pattern matching on the parse tree to determine this operation.Variatio
35409 ns of this case will also be recognized as bit-rotation, i.e.: 
35410 \end_layout
35411
35412 \begin_layout Verse
35413
35414 \family typewriter
35415 i = ((i >> 7) | (i << 1)); /* left-bit rotation */
35416 \end_layout
35417
35418 \begin_layout Subsection
35419 Nibble and Byte Swapping
35420 \end_layout
35421
35422 \begin_layout Standard
35423 Other special cases of the bit-shift operations are nibble or byte swapping
35424 \begin_inset LatexCommand \index{swapping nibbles/bytes}
35425
35426 \end_inset
35427
35428 , SDCC recognizes the following expressions:
35429 \end_layout
35430
35431 \begin_layout Verse
35432
35433 \family typewriter
35434 \series bold
35435 unsigned
35436 \series default
35437 \InsetSpace ~
35438 \InsetSpace ~
35439 char i; 
35440 \newline
35441
35442 \series bold
35443 unsigned
35444 \series default
35445 \InsetSpace ~
35446 \InsetSpace ~
35447 int j; 
35448 \newline
35449 ...
35450  
35451 \newline
35452 i = ((i << 4) | (i >> 4)); 
35453 \family default
35454
35455 \newline
35456
35457 \family typewriter
35458 j = ((j << 8) | (j >> 8)); 
35459 \end_layout
35460
35461 \begin_layout Standard
35462 and generates a swap instruction for the nibble swapping
35463 \begin_inset LatexCommand \index{Nibble swapping}
35464
35465 \end_inset
35466
35467  or move instructions for the byte swapping
35468 \begin_inset LatexCommand \index{Byte swapping}
35469
35470 \end_inset
35471
35472 .
35473  The 
35474 \begin_inset Quotes sld
35475 \end_inset
35476
35477 j
35478 \begin_inset Quotes srd
35479 \end_inset
35480
35481  example can be used to convert from little to big-endian or vice versa.
35482  If you want to change the endianness of a 
35483 \emph on
35484 signed
35485 \emph default
35486  integer you have to cast to 
35487 \family typewriter
35488 (unsigned int)
35489 \family default
35490  first.
35491 \end_layout
35492
35493 \begin_layout Standard
35494 Note that SDCC stores numbers in little-endian
35495 \begin_inset Foot
35496 status open
35497
35498 \begin_layout Standard
35499 Usually 8-bit processors don't care much about endianness.
35500  This is not the case for the standard 8051 which only has an instruction
35501  to increment its 
35502 \emph on
35503 dptr
35504 \emph default
35505
35506 \begin_inset LatexCommand \index{DPTR}
35507
35508 \end_inset
35509
35510 -datapointer
35511 \emph on
35512  
35513 \emph default
35514 so little-endian is the more efficient byte order.
35515 \end_layout
35516
35517 \end_inset
35518
35519
35520 \begin_inset LatexCommand \index{little-endian}
35521
35522 \end_inset
35523
35524
35525 \begin_inset LatexCommand \index{Endianness}
35526
35527 \end_inset
35528
35529  format (i.e.
35530  lowest order first).
35531 \end_layout
35532
35533 \begin_layout Subsection
35534 Highest Order Bit
35535 \begin_inset LatexCommand \index{Highest Order Bit}
35536
35537 \end_inset
35538
35539  / Any Order Bit
35540 \begin_inset LatexCommand \index{Any Order Bit}
35541
35542 \end_inset
35543
35544
35545 \end_layout
35546
35547 \begin_layout Standard
35548 It is frequently required to obtain the highest order bit of an integral
35549  type (long, int, short or char types).
35550  Also obtaining any other order bit is not uncommon.
35551  SDCC recognizes the following expressions to yield the highest order bit
35552  and generates optimized code for it, e.g.:
35553 \end_layout
35554
35555 \begin_layout Verse
35556
35557 \family typewriter
35558 unsigned int gint; 
35559 \newline
35560
35561 \newline
35562 foo () { 
35563 \newline
35564 \InsetSpace ~
35565 \InsetSpace ~
35566 unsigned char hob1, aob1; 
35567 \newline
35568 \InsetSpace ~
35569 \InsetSpace ~
35570 bit hob2, hob3, aob2,
35571  aob3; 
35572 \newline
35573 \InsetSpace ~
35574 \InsetSpace ~
35575 ...
35576  
35577 \newline
35578 \InsetSpace ~
35579 \InsetSpace ~
35580 hob1 = (gint >> 15) & 1; 
35581 \newline
35582 \InsetSpace ~
35583 \InsetSpace ~
35584 hob2 = (gint >> 15) & 1; 
35585 \newline
35586 \InsetSpace ~
35587 \InsetSpace ~
35588 hob3 = gint & 0x8000;
35589  
35590 \newline
35591 \InsetSpace ~
35592 \InsetSpace ~
35593 aob1 = (gint >> 9) & 1; 
35594 \newline
35595 \InsetSpace ~
35596 \InsetSpace ~
35597 aob2 = (gint >> 8) & 1; 
35598 \newline
35599 \InsetSpace ~
35600 \InsetSpace ~
35601 aob3 = gint & 0x0800; 
35602 \newline
35603 \InsetSpace ~
35604 \InsetSpace ~
35605 ..
35606  
35607 \newline
35608 }
35609 \end_layout
35610
35611 \begin_layout Standard
35612 will generate the following code:
35613 \end_layout
35614
35615 \begin_layout Verse
35616
35617 \family typewriter
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 \InsetSpace ~
35633 \InsetSpace ~
35634 \InsetSpace ~
35635 \InsetSpace ~
35636 \InsetSpace ~
35637 \InsetSpace ~
35638 \InsetSpace ~
35639 \InsetSpace ~
35640 \InsetSpace ~
35641 \InsetSpace ~
35642 \InsetSpace ~
35643  61 ;\InsetSpace ~
35644  hob.c 7 
35645 \newline
35646 000A E5*01\InsetSpace ~
35647 \InsetSpace ~
35648 \InsetSpace ~
35649 \InsetSpace ~
35650 \InsetSpace ~
35651 \InsetSpace ~
35652 \InsetSpace ~
35653 \InsetSpace ~
35654 \InsetSpace ~
35655 \InsetSpace ~
35656 \InsetSpace ~
35657 \InsetSpace ~
35658 \InsetSpace ~
35659 \InsetSpace ~
35660 \InsetSpace ~
35661  62\InsetSpace ~
35662 \InsetSpace ~
35663 \InsetSpace ~
35664 \InsetSpace ~
35665 \InsetSpace ~
35666 \InsetSpace ~
35667 \InsetSpace ~
35668 \InsetSpace ~
35669  mov\InsetSpace ~
35670 \InsetSpace ~
35671  a,(_gint + 1) 
35672 \newline
35673 000C 23\InsetSpace ~
35674 \InsetSpace ~
35675 \InsetSpace ~
35676 \InsetSpace ~
35677 \InsetSpace ~
35678 \InsetSpace ~
35679 \InsetSpace ~
35680 \InsetSpace ~
35681 \InsetSpace ~
35682 \InsetSpace ~
35683 \InsetSpace ~
35684 \InsetSpace ~
35685 \InsetSpace ~
35686 \InsetSpace ~
35687 \InsetSpace ~
35688 \InsetSpace ~
35689 \InsetSpace ~
35690 \InsetSpace ~
35691  63\InsetSpace ~
35692 \InsetSpace ~
35693 \InsetSpace ~
35694 \InsetSpace ~
35695 \InsetSpace ~
35696 \InsetSpace ~
35697 \InsetSpace ~
35698 \InsetSpace ~
35699  rl\InsetSpace ~
35700 \InsetSpace ~
35701 \InsetSpace ~
35702  a 
35703 \newline
35704 000D 54 01\InsetSpace ~
35705 \InsetSpace ~
35706 \InsetSpace ~
35707 \InsetSpace ~
35708 \InsetSpace ~
35709 \InsetSpace ~
35710 \InsetSpace ~
35711 \InsetSpace ~
35712 \InsetSpace ~
35713 \InsetSpace ~
35714 \InsetSpace ~
35715 \InsetSpace ~
35716 \InsetSpace ~
35717 \InsetSpace ~
35718 \InsetSpace ~
35719
35720  64\InsetSpace ~
35721 \InsetSpace ~
35722 \InsetSpace ~
35723 \InsetSpace ~
35724 \InsetSpace ~
35725 \InsetSpace ~
35726 \InsetSpace ~
35727 \InsetSpace ~
35728  anl\InsetSpace ~
35729 \InsetSpace ~
35730  a,#0x01 
35731 \newline
35732 000F F5*02\InsetSpace ~
35733 \InsetSpace ~
35734 \InsetSpace ~
35735 \InsetSpace ~
35736 \InsetSpace ~
35737 \InsetSpace ~
35738 \InsetSpace ~
35739 \InsetSpace ~
35740 \InsetSpace ~
35741 \InsetSpace ~
35742 \InsetSpace ~
35743 \InsetSpace ~
35744 \InsetSpace ~
35745 \InsetSpace ~
35746 \InsetSpace ~
35747  65\InsetSpace ~
35748 \InsetSpace ~
35749 \InsetSpace ~
35750 \InsetSpace ~
35751 \InsetSpace ~
35752 \InsetSpace ~
35753 \InsetSpace ~
35754 \InsetSpace ~
35755  mov\InsetSpace ~
35756 \InsetSpace ~
35757  _foo_hob1_1_1,a 
35758 \newline
35759 \InsetSpace ~
35760 \InsetSpace ~
35761 \InsetSpace ~
35762 \InsetSpace ~
35763 \InsetSpace ~
35764 \InsetSpace ~
35765 \InsetSpace ~
35766 \InsetSpace ~
35767 \InsetSpace ~
35768 \InsetSpace ~
35769 \InsetSpace ~
35770 \InsetSpace ~
35771 \InsetSpace ~
35772 \InsetSpace ~
35773 \InsetSpace ~
35774 \InsetSpace ~
35775 \InsetSpace ~
35776 \InsetSpace ~
35777 \InsetSpace ~
35778 \InsetSpace ~
35779 \InsetSpace ~
35780 \InsetSpace ~
35781 \InsetSpace ~
35782 \InsetSpace ~
35783 \InsetSpace ~
35784  66 ;\InsetSpace ~
35785  hob.c 8 
35786 \newline
35787 0011 E5*01\InsetSpace ~
35788 \InsetSpace ~
35789 \InsetSpace ~
35790 \InsetSpace ~
35791 \InsetSpace ~
35792 \InsetSpace ~
35793 \InsetSpace ~
35794 \InsetSpace ~
35795 \InsetSpace ~
35796 \InsetSpace ~
35797 \InsetSpace ~
35798 \InsetSpace ~
35799 \InsetSpace ~
35800 \InsetSpace ~
35801 \InsetSpace ~
35802
35803  67\InsetSpace ~
35804 \InsetSpace ~
35805 \InsetSpace ~
35806 \InsetSpace ~
35807 \InsetSpace ~
35808 \InsetSpace ~
35809 \InsetSpace ~
35810 \InsetSpace ~
35811  mov\InsetSpace ~
35812 \InsetSpace ~
35813  a,(_gint + 1) 
35814 \newline
35815 0013 33\InsetSpace ~
35816 \InsetSpace ~
35817 \InsetSpace ~
35818 \InsetSpace ~
35819 \InsetSpace ~
35820 \InsetSpace ~
35821 \InsetSpace ~
35822 \InsetSpace ~
35823 \InsetSpace ~
35824 \InsetSpace ~
35825 \InsetSpace ~
35826 \InsetSpace ~
35827 \InsetSpace ~
35828 \InsetSpace ~
35829 \InsetSpace ~
35830 \InsetSpace ~
35831 \InsetSpace ~
35832 \InsetSpace ~
35833  68\InsetSpace ~
35834 \InsetSpace ~
35835 \InsetSpace ~
35836 \InsetSpace ~
35837 \InsetSpace ~
35838 \InsetSpace ~
35839 \InsetSpace ~
35840 \InsetSpace ~
35841  rlc\InsetSpace ~
35842 \InsetSpace ~
35843  a 
35844 \newline
35845 0014 92*00\InsetSpace ~
35846 \InsetSpace ~
35847 \InsetSpace ~
35848 \InsetSpace ~
35849 \InsetSpace ~
35850 \InsetSpace ~
35851 \InsetSpace ~
35852 \InsetSpace ~
35853 \InsetSpace ~
35854 \InsetSpace ~
35855 \InsetSpace ~
35856 \InsetSpace ~
35857 \InsetSpace ~
35858 \InsetSpace ~
35859 \InsetSpace ~
35860  69\InsetSpace ~
35861 \InsetSpace ~
35862 \InsetSpace ~
35863 \InsetSpace ~
35864 \InsetSpace ~
35865 \InsetSpace ~
35866 \InsetSpace ~
35867 \InsetSpace ~
35868  mov\InsetSpace ~
35869 \InsetSpace ~
35870  _foo_hob2_1_1,c
35871  
35872 \newline
35873 \InsetSpace ~
35874 \InsetSpace ~
35875 \InsetSpace ~
35876 \InsetSpace ~
35877 \InsetSpace ~
35878 \InsetSpace ~
35879 \InsetSpace ~
35880 \InsetSpace ~
35881 \InsetSpace ~
35882 \InsetSpace ~
35883 \InsetSpace ~
35884 \InsetSpace ~
35885 \InsetSpace ~
35886 \InsetSpace ~
35887 \InsetSpace ~
35888 \InsetSpace ~
35889 \InsetSpace ~
35890 \InsetSpace ~
35891 \InsetSpace ~
35892 \InsetSpace ~
35893 \InsetSpace ~
35894 \InsetSpace ~
35895 \InsetSpace ~
35896 \InsetSpace ~
35897 \InsetSpace ~
35898  66 ;\InsetSpace ~
35899  hob.c 9 
35900 \newline
35901 0016 E5*01\InsetSpace ~
35902 \InsetSpace ~
35903 \InsetSpace ~
35904 \InsetSpace ~
35905 \InsetSpace ~
35906 \InsetSpace ~
35907 \InsetSpace ~
35908 \InsetSpace ~
35909 \InsetSpace ~
35910 \InsetSpace ~
35911 \InsetSpace ~
35912 \InsetSpace ~
35913 \InsetSpace ~
35914 \InsetSpace ~
35915 \InsetSpace ~
35916  67\InsetSpace ~
35917 \InsetSpace ~
35918 \InsetSpace ~
35919 \InsetSpace ~
35920 \InsetSpace ~
35921 \InsetSpace ~
35922 \InsetSpace ~
35923 \InsetSpace ~
35924  mov\InsetSpace ~
35925 \InsetSpace ~
35926  a,(_gint + 1) 
35927 \newline
35928 0018 33\InsetSpace ~
35929 \InsetSpace ~
35930 \InsetSpace ~
35931 \InsetSpace ~
35932 \InsetSpace ~
35933 \InsetSpace ~
35934 \InsetSpace ~
35935 \InsetSpace ~
35936 \InsetSpace ~
35937 \InsetSpace ~
35938 \InsetSpace ~
35939 \InsetSpace ~
35940 \InsetSpace ~
35941 \InsetSpace ~
35942 \InsetSpace ~
35943 \InsetSpace ~
35944 \InsetSpace ~
35945 \InsetSpace ~
35946  68\InsetSpace ~
35947 \InsetSpace ~
35948 \InsetSpace ~
35949 \InsetSpace ~
35950 \InsetSpace ~
35951 \InsetSpace ~
35952 \InsetSpace ~
35953 \InsetSpace ~
35954  rlc\InsetSpace ~
35955 \InsetSpace ~
35956  a 
35957 \newline
35958 0019 92*01\InsetSpace ~
35959 \InsetSpace ~
35960 \InsetSpace ~
35961 \InsetSpace ~
35962 \InsetSpace ~
35963 \InsetSpace ~
35964 \InsetSpace ~
35965 \InsetSpace ~
35966 \InsetSpace ~
35967 \InsetSpace ~
35968 \InsetSpace ~
35969 \InsetSpace ~
35970 \InsetSpace ~
35971 \InsetSpace ~
35972 \InsetSpace ~
35973
35974  69\InsetSpace ~
35975 \InsetSpace ~
35976 \InsetSpace ~
35977 \InsetSpace ~
35978 \InsetSpace ~
35979 \InsetSpace ~
35980 \InsetSpace ~
35981 \InsetSpace ~
35982  mov\InsetSpace ~
35983 \InsetSpace ~
35984  _foo_hob3_1_1,c 
35985 \newline
35986 \InsetSpace ~
35987 \InsetSpace ~
35988 \InsetSpace ~
35989 \InsetSpace ~
35990 \InsetSpace ~
35991 \InsetSpace ~
35992 \InsetSpace ~
35993 \InsetSpace ~
35994 \InsetSpace ~
35995 \InsetSpace ~
35996 \InsetSpace ~
35997 \InsetSpace ~
35998 \InsetSpace ~
35999 \InsetSpace ~
36000 \InsetSpace ~
36001 \InsetSpace ~
36002 \InsetSpace ~
36003 \InsetSpace ~
36004 \InsetSpace ~
36005 \InsetSpace ~
36006 \InsetSpace ~
36007 \InsetSpace ~
36008 \InsetSpace ~
36009 \InsetSpace ~
36010 \InsetSpace ~
36011  70 ;\InsetSpace ~
36012  hob.c 10 
36013 \newline
36014 001B E5*01\InsetSpace ~
36015 \InsetSpace ~
36016 \InsetSpace ~
36017 \InsetSpace ~
36018 \InsetSpace ~
36019 \InsetSpace ~
36020 \InsetSpace ~
36021 \InsetSpace ~
36022 \InsetSpace ~
36023 \InsetSpace ~
36024 \InsetSpace ~
36025 \InsetSpace ~
36026 \InsetSpace ~
36027 \InsetSpace ~
36028 \InsetSpace ~
36029  71\InsetSpace ~
36030 \InsetSpace ~
36031 \InsetSpace ~
36032 \InsetSpace ~
36033 \InsetSpace ~
36034 \InsetSpace ~
36035 \InsetSpace ~
36036 \InsetSpace ~
36037  mov\InsetSpace ~
36038 \InsetSpace ~
36039  a,(_gint + 1) 
36040 \newline
36041 001D
36042  03\InsetSpace ~
36043 \InsetSpace ~
36044 \InsetSpace ~
36045 \InsetSpace ~
36046 \InsetSpace ~
36047 \InsetSpace ~
36048 \InsetSpace ~
36049 \InsetSpace ~
36050 \InsetSpace ~
36051 \InsetSpace ~
36052 \InsetSpace ~
36053 \InsetSpace ~
36054 \InsetSpace ~
36055 \InsetSpace ~
36056 \InsetSpace ~
36057 \InsetSpace ~
36058 \InsetSpace ~
36059 \InsetSpace ~
36060  72\InsetSpace ~
36061 \InsetSpace ~
36062 \InsetSpace ~
36063 \InsetSpace ~
36064 \InsetSpace ~
36065 \InsetSpace ~
36066 \InsetSpace ~
36067 \InsetSpace ~
36068  rr\InsetSpace ~
36069 \InsetSpace ~
36070 \InsetSpace ~
36071  a 
36072 \newline
36073 001E 54 01\InsetSpace ~
36074 \InsetSpace ~
36075 \InsetSpace ~
36076 \InsetSpace ~
36077 \InsetSpace ~
36078 \InsetSpace ~
36079 \InsetSpace ~
36080 \InsetSpace ~
36081 \InsetSpace ~
36082 \InsetSpace ~
36083 \InsetSpace ~
36084 \InsetSpace ~
36085 \InsetSpace ~
36086 \InsetSpace ~
36087 \InsetSpace ~
36088  73\InsetSpace ~
36089 \InsetSpace ~
36090 \InsetSpace ~
36091 \InsetSpace ~
36092 \InsetSpace ~
36093 \InsetSpace ~
36094 \InsetSpace ~
36095 \InsetSpace ~
36096  anl\InsetSpace ~
36097 \InsetSpace ~
36098  a,#0x01 
36099 \newline
36100 0020 F5*03\InsetSpace ~
36101 \InsetSpace ~
36102 \InsetSpace ~
36103 \InsetSpace ~
36104 \InsetSpace ~
36105 \InsetSpace ~
36106 \InsetSpace ~
36107 \InsetSpace ~
36108 \InsetSpace ~
36109 \InsetSpace ~
36110 \InsetSpace ~
36111 \InsetSpace ~
36112 \InsetSpace ~
36113 \InsetSpace ~
36114 \InsetSpace ~
36115  74\InsetSpace ~
36116 \InsetSpace ~
36117 \InsetSpace ~
36118 \InsetSpace ~
36119 \InsetSpace ~
36120 \InsetSpace ~
36121 \InsetSpace ~
36122 \InsetSpace ~
36123  mov\InsetSpace ~
36124 \InsetSpace ~
36125  _foo_aob1_1_1,a
36126  
36127 \newline
36128 \InsetSpace ~
36129 \InsetSpace ~
36130 \InsetSpace ~
36131 \InsetSpace ~
36132 \InsetSpace ~
36133 \InsetSpace ~
36134 \InsetSpace ~
36135 \InsetSpace ~
36136 \InsetSpace ~
36137 \InsetSpace ~
36138 \InsetSpace ~
36139 \InsetSpace ~
36140 \InsetSpace ~
36141 \InsetSpace ~
36142 \InsetSpace ~
36143 \InsetSpace ~
36144 \InsetSpace ~
36145 \InsetSpace ~
36146 \InsetSpace ~
36147 \InsetSpace ~
36148 \InsetSpace ~
36149 \InsetSpace ~
36150 \InsetSpace ~
36151 \InsetSpace ~
36152 \InsetSpace ~
36153  75 ;\InsetSpace ~
36154  hob.c 11 
36155 \newline
36156 0022 E5*01\InsetSpace ~
36157 \InsetSpace ~
36158 \InsetSpace ~
36159 \InsetSpace ~
36160 \InsetSpace ~
36161 \InsetSpace ~
36162 \InsetSpace ~
36163 \InsetSpace ~
36164 \InsetSpace ~
36165 \InsetSpace ~
36166 \InsetSpace ~
36167 \InsetSpace ~
36168 \InsetSpace ~
36169 \InsetSpace ~
36170 \InsetSpace ~
36171  76\InsetSpace ~
36172 \InsetSpace ~
36173 \InsetSpace ~
36174 \InsetSpace ~
36175 \InsetSpace ~
36176 \InsetSpace ~
36177 \InsetSpace ~
36178 \InsetSpace ~
36179  mov\InsetSpace ~
36180 \InsetSpace ~
36181  a,(_gint + 1) 
36182 \newline
36183 0024 13\InsetSpace ~
36184 \InsetSpace ~
36185 \InsetSpace ~
36186 \InsetSpace ~
36187 \InsetSpace ~
36188 \InsetSpace ~
36189 \InsetSpace ~
36190 \InsetSpace ~
36191 \InsetSpace ~
36192 \InsetSpace ~
36193 \InsetSpace ~
36194 \InsetSpace ~
36195 \InsetSpace ~
36196 \InsetSpace ~
36197 \InsetSpace ~
36198 \InsetSpace ~
36199 \InsetSpace ~
36200 \InsetSpace ~
36201  77\InsetSpace ~
36202 \InsetSpace ~
36203 \InsetSpace ~
36204 \InsetSpace ~
36205 \InsetSpace ~
36206 \InsetSpace ~
36207 \InsetSpace ~
36208 \InsetSpace ~
36209  rrc\InsetSpace ~
36210 \InsetSpace ~
36211  a 
36212 \newline
36213 0025 92*02\InsetSpace ~
36214 \InsetSpace ~
36215 \InsetSpace ~
36216 \InsetSpace ~
36217 \InsetSpace ~
36218 \InsetSpace ~
36219 \InsetSpace ~
36220 \InsetSpace ~
36221 \InsetSpace ~
36222 \InsetSpace ~
36223 \InsetSpace ~
36224 \InsetSpace ~
36225 \InsetSpace ~
36226 \InsetSpace ~
36227 \InsetSpace ~
36228
36229  78\InsetSpace ~
36230 \InsetSpace ~
36231 \InsetSpace ~
36232 \InsetSpace ~
36233 \InsetSpace ~
36234 \InsetSpace ~
36235 \InsetSpace ~
36236 \InsetSpace ~
36237  mov\InsetSpace ~
36238 \InsetSpace ~
36239  _foo_aob2_1_1,c 
36240 \newline
36241 \InsetSpace ~
36242 \InsetSpace ~
36243 \InsetSpace ~
36244 \InsetSpace ~
36245 \InsetSpace ~
36246 \InsetSpace ~
36247 \InsetSpace ~
36248 \InsetSpace ~
36249 \InsetSpace ~
36250 \InsetSpace ~
36251 \InsetSpace ~
36252 \InsetSpace ~
36253 \InsetSpace ~
36254 \InsetSpace ~
36255 \InsetSpace ~
36256 \InsetSpace ~
36257 \InsetSpace ~
36258 \InsetSpace ~
36259 \InsetSpace ~
36260 \InsetSpace ~
36261 \InsetSpace ~
36262 \InsetSpace ~
36263 \InsetSpace ~
36264 \InsetSpace ~
36265 \InsetSpace ~
36266  79 ;\InsetSpace ~
36267  hob.c 12 
36268 \newline
36269 0027 E5*01\InsetSpace ~
36270 \InsetSpace ~
36271 \InsetSpace ~
36272 \InsetSpace ~
36273 \InsetSpace ~
36274 \InsetSpace ~
36275 \InsetSpace ~
36276 \InsetSpace ~
36277 \InsetSpace ~
36278 \InsetSpace ~
36279 \InsetSpace ~
36280 \InsetSpace ~
36281 \InsetSpace ~
36282 \InsetSpace ~
36283 \InsetSpace ~
36284  80\InsetSpace ~
36285 \InsetSpace ~
36286 \InsetSpace ~
36287 \InsetSpace ~
36288 \InsetSpace ~
36289 \InsetSpace ~
36290 \InsetSpace ~
36291 \InsetSpace ~
36292  mov\InsetSpace ~
36293 \InsetSpace ~
36294  a,(_gint + 1) 
36295 \newline
36296 0029
36297  A2 E3\InsetSpace ~
36298 \InsetSpace ~
36299 \InsetSpace ~
36300 \InsetSpace ~
36301 \InsetSpace ~
36302 \InsetSpace ~
36303 \InsetSpace ~
36304 \InsetSpace ~
36305 \InsetSpace ~
36306 \InsetSpace ~
36307 \InsetSpace ~
36308 \InsetSpace ~
36309 \InsetSpace ~
36310 \InsetSpace ~
36311 \InsetSpace ~
36312  81\InsetSpace ~
36313 \InsetSpace ~
36314 \InsetSpace ~
36315 \InsetSpace ~
36316 \InsetSpace ~
36317 \InsetSpace ~
36318 \InsetSpace ~
36319 \InsetSpace ~
36320  mov\InsetSpace ~
36321 \InsetSpace ~
36322  c,acc[3] 
36323 \newline
36324 002B 92*03\InsetSpace ~
36325 \InsetSpace ~
36326 \InsetSpace ~
36327 \InsetSpace ~
36328 \InsetSpace ~
36329 \InsetSpace ~
36330 \InsetSpace ~
36331 \InsetSpace ~
36332 \InsetSpace ~
36333 \InsetSpace ~
36334 \InsetSpace ~
36335 \InsetSpace ~
36336 \InsetSpace ~
36337 \InsetSpace ~
36338 \InsetSpace ~
36339  82\InsetSpace ~
36340 \InsetSpace ~
36341 \InsetSpace ~
36342 \InsetSpace ~
36343 \InsetSpace ~
36344 \InsetSpace ~
36345 \InsetSpace ~
36346 \InsetSpace ~
36347  mov\InsetSpace ~
36348 \InsetSpace ~
36349  _foo_aob3_1_1,c 
36350 \end_layout
36351
36352 \begin_layout Standard
36353 Other variations of these cases however will 
36354 \emph on
36355 not
36356 \emph default
36357  be recognized.
36358  They are standard C expressions, so I heartily recommend these be the only
36359  way to get the highest order bit, (it is portable).
36360  Of course it will be recognized even if it is embedded in other expressions,
36361  e.g.:
36362 \end_layout
36363
36364 \begin_layout Verse
36365
36366 \family typewriter
36367 xyz = gint + ((gint >> 15) & 1);
36368 \end_layout
36369
36370 \begin_layout Standard
36371 will still be recognized.
36372 \end_layout
36373
36374 \begin_layout Subsection
36375 Higher Order Byte
36376 \begin_inset LatexCommand \index{Higher Order Byte}
36377
36378 \end_inset
36379
36380  / Higher Order Word
36381 \begin_inset LatexCommand \index{Higher Order Word}
36382
36383 \end_inset
36384
36385
36386 \end_layout
36387
36388 \begin_layout Standard
36389 It is also frequently required to obtain a higher order byte or word of
36390  a larger integral type (long, int or short types).
36391  SDCC recognizes the following expressions to yield the higher order byte
36392  or word and generates optimized code for it, e.g.:
36393 \end_layout
36394
36395 \begin_layout Verse
36396
36397 \family typewriter
36398 unsigned int gint; 
36399 \newline
36400 unsigned long int glong; 
36401 \newline
36402
36403 \newline
36404 foo () { 
36405 \newline
36406 \InsetSpace ~
36407 \InsetSpace ~
36408 unsigned char hob1,
36409  hob2; 
36410 \newline
36411 \InsetSpace ~
36412 \InsetSpace ~
36413 unsigned int how1, how2; 
36414 \newline
36415 \InsetSpace ~
36416 \InsetSpace ~
36417 ...
36418  
36419 \newline
36420 \InsetSpace ~
36421 \InsetSpace ~
36422 hob1 = (gint >> 8) & 0xFF; 
36423 \newline
36424 \InsetSpace ~
36425 \InsetSpace ~
36426 hob2 = glong >> 24; 
36427 \newline
36428 \InsetSpace ~
36429 \InsetSpace ~
36430 how1 = (glong >> 16) & 0xFFFF;
36431  
36432 \newline
36433 \InsetSpace ~
36434 \InsetSpace ~
36435 how2 = glong >> 8; 
36436 \newline
36437 \InsetSpace ~
36438 \InsetSpace ~
36439 ..
36440  
36441 \newline
36442 }
36443 \end_layout
36444
36445 \begin_layout Standard
36446 will generate the following code:
36447 \end_layout
36448
36449 \begin_layout Verse
36450
36451 \family typewriter
36452 \InsetSpace ~
36453 \InsetSpace ~
36454 \InsetSpace ~
36455 \InsetSpace ~
36456 \InsetSpace ~
36457 \InsetSpace ~
36458 \InsetSpace ~
36459 \InsetSpace ~
36460 \InsetSpace ~
36461 \InsetSpace ~
36462 \InsetSpace ~
36463 \InsetSpace ~
36464 \InsetSpace ~
36465 \InsetSpace ~
36466 \InsetSpace ~
36467 \InsetSpace ~
36468 \InsetSpace ~
36469 \InsetSpace ~
36470 \InsetSpace ~
36471 \InsetSpace ~
36472 \InsetSpace ~
36473 \InsetSpace ~
36474 \InsetSpace ~
36475 \InsetSpace ~
36476 \InsetSpace ~
36477  91 ;\InsetSpace ~
36478  hob.c 15 
36479 \newline
36480 0037 85*01*06\InsetSpace ~
36481 \InsetSpace ~
36482 \InsetSpace ~
36483 \InsetSpace ~
36484 \InsetSpace ~
36485 \InsetSpace ~
36486 \InsetSpace ~
36487 \InsetSpace ~
36488 \InsetSpace ~
36489 \InsetSpace ~
36490 \InsetSpace ~
36491 \InsetSpace ~
36492  92\InsetSpace ~
36493 \InsetSpace ~
36494 \InsetSpace ~
36495 \InsetSpace ~
36496 \InsetSpace ~
36497 \InsetSpace ~
36498 \InsetSpace ~
36499 \InsetSpace ~
36500  mov\InsetSpace ~
36501 \InsetSpace ~
36502  _foo_hob1_1_1,(_gint + 1) 
36503 \newline
36504 \InsetSpace ~
36505 \InsetSpace ~
36506 \InsetSpace ~
36507 \InsetSpace ~
36508 \InsetSpace ~
36509 \InsetSpace ~
36510 \InsetSpace ~
36511 \InsetSpace ~
36512 \InsetSpace ~
36513 \InsetSpace ~
36514 \InsetSpace ~
36515 \InsetSpace ~
36516 \InsetSpace ~
36517 \InsetSpace ~
36518 \InsetSpace ~
36519 \InsetSpace ~
36520 \InsetSpace ~
36521 \InsetSpace ~
36522 \InsetSpace ~
36523 \InsetSpace ~
36524 \InsetSpace ~
36525 \InsetSpace ~
36526 \InsetSpace ~
36527 \InsetSpace ~
36528 \InsetSpace ~
36529  93 ;\InsetSpace ~
36530  hob.c
36531  16 
36532 \newline
36533 003A 85*05*07\InsetSpace ~
36534 \InsetSpace ~
36535 \InsetSpace ~
36536 \InsetSpace ~
36537 \InsetSpace ~
36538 \InsetSpace ~
36539 \InsetSpace ~
36540 \InsetSpace ~
36541 \InsetSpace ~
36542 \InsetSpace ~
36543 \InsetSpace ~
36544 \InsetSpace ~
36545  94\InsetSpace ~
36546 \InsetSpace ~
36547 \InsetSpace ~
36548 \InsetSpace ~
36549 \InsetSpace ~
36550 \InsetSpace ~
36551 \InsetSpace ~
36552 \InsetSpace ~
36553  mov\InsetSpace ~
36554 \InsetSpace ~
36555  _foo_hob2_1_1,(_glong + 3) 
36556 \newline
36557 \InsetSpace ~
36558 \InsetSpace ~
36559 \InsetSpace ~
36560 \InsetSpace ~
36561 \InsetSpace ~
36562 \InsetSpace ~
36563 \InsetSpace ~
36564 \InsetSpace ~
36565 \InsetSpace ~
36566 \InsetSpace ~
36567 \InsetSpace ~
36568 \InsetSpace ~
36569 \InsetSpace ~
36570 \InsetSpace ~
36571 \InsetSpace ~
36572 \InsetSpace ~
36573 \InsetSpace ~
36574 \InsetSpace ~
36575 \InsetSpace ~
36576 \InsetSpace ~
36577 \InsetSpace ~
36578 \InsetSpace ~
36579 \InsetSpace ~
36580 \InsetSpace ~
36581 \InsetSpace ~
36582  95 ;\InsetSpace ~
36583  hob.c 17 
36584 \newline
36585 003D 85*04*08\InsetSpace ~
36586 \InsetSpace ~
36587 \InsetSpace ~
36588 \InsetSpace ~
36589 \InsetSpace ~
36590 \InsetSpace ~
36591 \InsetSpace ~
36592 \InsetSpace ~
36593 \InsetSpace ~
36594 \InsetSpace ~
36595 \InsetSpace ~
36596 \InsetSpace ~
36597
36598  96\InsetSpace ~
36599 \InsetSpace ~
36600 \InsetSpace ~
36601 \InsetSpace ~
36602 \InsetSpace ~
36603 \InsetSpace ~
36604 \InsetSpace ~
36605 \InsetSpace ~
36606  mov\InsetSpace ~
36607 \InsetSpace ~
36608  _foo_how1_1_1,(_glong + 2) 
36609 \newline
36610 0040 85*05*09\InsetSpace ~
36611 \InsetSpace ~
36612 \InsetSpace ~
36613 \InsetSpace ~
36614 \InsetSpace ~
36615 \InsetSpace ~
36616 \InsetSpace ~
36617 \InsetSpace ~
36618 \InsetSpace ~
36619 \InsetSpace ~
36620 \InsetSpace ~
36621 \InsetSpace ~
36622  97\InsetSpace ~
36623 \InsetSpace ~
36624 \InsetSpace ~
36625 \InsetSpace ~
36626 \InsetSpace ~
36627 \InsetSpace ~
36628 \InsetSpace ~
36629 \InsetSpace ~
36630  mov\InsetSpace ~
36631 \InsetSpace ~
36632  (_foo_how1_1_1 +
36633  1),(_glong + 3) 
36634 \newline
36635 0043 85*03*0A\InsetSpace ~
36636 \InsetSpace ~
36637 \InsetSpace ~
36638 \InsetSpace ~
36639 \InsetSpace ~
36640 \InsetSpace ~
36641 \InsetSpace ~
36642 \InsetSpace ~
36643 \InsetSpace ~
36644 \InsetSpace ~
36645 \InsetSpace ~
36646 \InsetSpace ~
36647  98\InsetSpace ~
36648 \InsetSpace ~
36649 \InsetSpace ~
36650 \InsetSpace ~
36651 \InsetSpace ~
36652 \InsetSpace ~
36653 \InsetSpace ~
36654 \InsetSpace ~
36655  mov\InsetSpace ~
36656 \InsetSpace ~
36657  _foo_how2_1_1,(_glong + 1) 
36658 \newline
36659 0046 85*04*0B\InsetSpace ~
36660 \InsetSpace ~
36661 \InsetSpace ~
36662 \InsetSpace ~
36663 \InsetSpace ~
36664 \InsetSpace ~
36665 \InsetSpace ~
36666 \InsetSpace ~
36667 \InsetSpace ~
36668 \InsetSpace ~
36669 \InsetSpace ~
36670 \InsetSpace ~
36671
36672  99\InsetSpace ~
36673 \InsetSpace ~
36674 \InsetSpace ~
36675 \InsetSpace ~
36676 \InsetSpace ~
36677 \InsetSpace ~
36678 \InsetSpace ~
36679 \InsetSpace ~
36680  mov\InsetSpace ~
36681 \InsetSpace ~
36682  (_foo_how2_1_1 + 1),(_glong + 2) 
36683 \end_layout
36684
36685 \begin_layout Standard
36686 Again, variations of these cases may 
36687 \emph on
36688 not
36689 \emph default
36690  be recognized.
36691  They are standard C expressions, so I heartily recommend these be the only
36692  way to get the higher order byte/word, (it is portable).
36693  Of course it will be recognized even if it is embedded in other expressions,
36694  e.g.:
36695 \end_layout
36696
36697 \begin_layout Verse
36698
36699 \family typewriter
36700 xyz = gint + ((gint >> 8) & 0xFF);
36701 \end_layout
36702
36703 \begin_layout Standard
36704 will still be recognized.
36705 \end_layout
36706
36707 \begin_layout Subsection
36708 Peephole Optimizer
36709 \begin_inset LatexCommand \label{sub:Peephole-Optimizer}
36710
36711 \end_inset
36712
36713
36714 \begin_inset LatexCommand \index{Peephole optimizer}
36715
36716 \end_inset
36717
36718
36719 \end_layout
36720
36721 \begin_layout Standard
36722 The compiler uses a rule based, pattern matching and re-writing mechanism
36723  for peep-hole optimization.
36724  It is inspired by 
36725 \emph on
36726 copt
36727 \emph default
36728  a peep-hole optimizer by Christopher W.
36729  Fraser (cwfraser\InsetSpace ~
36730 @\InsetSpace ~
36731 microsoft.com).
36732  A default set of rules are compiled into the compiler, additional rules
36733  may be added with the 
36734 \emph on
36735 -
36736 \begin_inset ERT
36737 status collapsed
36738
36739 \begin_layout Standard
36740
36741
36742 \backslash
36743 /
36744 \end_layout
36745
36746 \end_inset
36747
36748 -peep-file
36749 \begin_inset LatexCommand \index{-\/-peep-file}
36750
36751 \end_inset
36752
36753  <filename>
36754 \emph default
36755  option.
36756  The rule language is best illustrated with examples.
36757 \end_layout
36758
36759 \begin_layout Verse
36760
36761 \family typewriter
36762 replace { 
36763 \newline
36764 \InsetSpace ~
36765 \InsetSpace ~
36766 mov %1,a 
36767 \newline
36768 \InsetSpace ~
36769 \InsetSpace ~
36770 mov a,%1
36771 \newline
36772 } by {
36773 \newline
36774 \InsetSpace ~
36775 \InsetSpace ~
36776 mov %1,a
36777 \newline
36778 }
36779 \end_layout
36780
36781 \begin_layout Standard
36782 The above rule will change the following assembly
36783 \begin_inset LatexCommand \index{Assembler routines}
36784
36785 \end_inset
36786
36787  sequence:
36788 \end_layout
36789
36790 \begin_layout Verse
36791
36792 \family typewriter
36793 mov r1,a 
36794 \newline
36795 mov a,r1
36796 \end_layout
36797
36798 \begin_layout Standard
36799 to
36800 \end_layout
36801
36802 \begin_layout Verse
36803
36804 \family typewriter
36805 mov r1,a
36806 \end_layout
36807
36808 \begin_layout Standard
36809 Note: All occurrences of a 
36810 \emph on
36811 %n
36812 \emph default
36813  (pattern variable) must denote the same string.
36814  With the above rule, the assembly sequence:
36815 \end_layout
36816
36817 \begin_layout Verse
36818
36819 \family typewriter
36820 mov r1,a 
36821 \newline
36822 mov a,r2
36823 \end_layout
36824
36825 \begin_layout Standard
36826 will remain unmodified.
36827 \newline
36828
36829 \newline
36830 Other special case optimizations may be added by the
36831  user (via 
36832 \emph on
36833 -
36834 \begin_inset ERT
36835 status collapsed
36836
36837 \begin_layout Standard
36838
36839
36840 \backslash
36841 /
36842 \end_layout
36843
36844 \end_inset
36845
36846 -peep-file option
36847 \emph default
36848 ).
36849  E.g.
36850  some variants of the 8051 MCU
36851 \begin_inset LatexCommand \index{MCS51 variants}
36852
36853 \end_inset
36854
36855  allow only 
36856 \family typewriter
36857 ajmp
36858 \family default
36859  and 
36860 \family typewriter
36861 acall
36862 \family default
36863 .
36864  The following two rules will change all 
36865 \family typewriter
36866 ljmp
36867 \family default
36868  and 
36869 \family typewriter
36870 lcall
36871 \family default
36872  to 
36873 \family typewriter
36874 ajmp
36875 \family default
36876  and 
36877 \family typewriter
36878 acall
36879 \end_layout
36880
36881 \begin_layout Verse
36882
36883 \family typewriter
36884 replace { lcall %1 } by { acall %1 } 
36885 \newline
36886 replace { ljmp %1 } by { ajmp %1 }
36887 \end_layout
36888
36889 \begin_layout Standard
36890 (NOTE: from version 2.7.3 on, you can use option -
36891 \emph on
36892
36893 \begin_inset ERT
36894 status collapsed
36895
36896 \begin_layout Standard
36897
36898
36899 \backslash
36900 /
36901 \end_layout
36902
36903 \end_inset
36904
36905
36906 \emph default
36907 -acall-ajmp
36908 \begin_inset LatexCommand \index{-\/-acall-ajmp}
36909
36910 \end_inset
36911
36912 , which also takes care of aligning the interrupt vectors properly.)
36913 \newline
36914
36915 \end_layout
36916
36917 \begin_layout Standard
36918 The 
36919 \emph on
36920 inline-assembler code
36921 \emph default
36922  is also passed through the peep hole optimizer, thus the peephole optimizer
36923  can also be used as an assembly level macro expander.
36924  The rules themselves are MCU dependent whereas the rule language infra-structur
36925 e is MCU independent.
36926  Peephole optimization rules for other MCU can be easily programmed using
36927  the rule language.
36928 \newline
36929
36930 \newline
36931 The syntax for a rule is as follows:
36932 \end_layout
36933
36934 \begin_layout Verse
36935
36936 \family typewriter
36937 rule := replace [ restart ] '{' <assembly sequence> '
36938 \backslash
36939 n' 
36940 \newline
36941 \InsetSpace ~
36942  \InsetSpace ~
36943  \InsetSpace ~
36944  \InsetSpace ~
36945  \InsetSpace ~
36946  \InsetSpace ~
36947  \InsetSpace ~
36948  \InsetSpace ~
36949  \InsetSpace ~
36950  \InsetSpace ~
36951  \InsetSpace ~
36952  \InsetSpace ~
36953  \InsetSpace ~
36954  \InsetSpace ~
36955  '}' by '{' '
36956 \backslash
36957 n' 
36958 \newline
36959 \InsetSpace ~
36960  \InsetSpace ~
36961  \InsetSpace ~
36962  \InsetSpace ~
36963  \InsetSpace ~
36964  \InsetSpace ~
36965  \InsetSpace ~
36966  \InsetSpace ~
36967  \InsetSpace ~
36968  \InsetSpace ~
36969  \InsetSpace ~
36970  \InsetSpace ~
36971  \InsetSpace ~
36972  \InsetSpace ~
36973  \InsetSpace ~
36974  \InsetSpace ~
36975  <assembly sequence> '
36976 \backslash
36977 n' 
36978 \newline
36979 \InsetSpace ~
36980  \InsetSpace ~
36981  \InsetSpace ~
36982  \InsetSpace ~
36983  \InsetSpace ~
36984  \InsetSpace ~
36985  \InsetSpace ~
36986  \InsetSpace ~
36987  \InsetSpace ~
36988  \InsetSpace ~
36989  \InsetSpace ~
36990  \InsetSpace ~
36991  \InsetSpace ~
36992  \InsetSpace ~
36993  '}' [if <functionName> ] '
36994 \backslash
36995 n' 
36996 \end_layout
36997
36998 \begin_layout Standard
36999 <assembly sequence> := assembly instruction (each instruction including
37000  labels must be on a separate line).
37001 \newline
37002
37003 \newline
37004 The optimizer will apply to the rules
37005  one by one from the top in the sequence of their appearance, it will terminate
37006  when all rules are exhausted.
37007  If the 'restart' option is specified, then the optimizer will start matching
37008  the rules again from the top, this option for a rule is expensive (performance)
37009 , it is intended to be used in situations where a transformation will trigger
37010  the same rule again.
37011  An example of this (not a good one, it has side effects) is the following
37012  rule:
37013 \end_layout
37014
37015 \begin_layout Verse
37016
37017 \family typewriter
37018 replace restart { 
37019 \newline
37020 \InsetSpace ~
37021 \InsetSpace ~
37022 pop %1 
37023 \newline
37024 \InsetSpace ~
37025 \InsetSpace ~
37026 push %1 } by { 
37027 \newline
37028 \InsetSpace ~
37029 \InsetSpace ~
37030 ; nop 
37031 \newline
37032 }
37033 \end_layout
37034
37035 \begin_layout Standard
37036 Note that the replace pattern cannot be a blank, but can be a comment line.
37037  Without the 'restart' option only the innermost 'pop' 'push' pair would
37038  be eliminated, i.e.:
37039 \end_layout
37040
37041 \begin_layout Verse
37042
37043 \family typewriter
37044 pop ar1 
37045 \newline
37046 pop ar2 
37047 \newline
37048 push ar2 
37049 \newline
37050 push ar1
37051 \end_layout
37052
37053 \begin_layout Standard
37054 would result in:
37055 \end_layout
37056
37057 \begin_layout Verse
37058
37059 \family typewriter
37060 pop ar1 
37061 \newline
37062 ; nop 
37063 \newline
37064 push ar1
37065 \end_layout
37066
37067 \begin_layout Standard
37068
37069 \emph on
37070 with
37071 \emph default
37072  the restart option the rule will be applied again to the resulting code
37073  and then all the pop-push pairs will be eliminated to yield:
37074 \end_layout
37075
37076 \begin_layout Verse
37077
37078 \family typewriter
37079 ; nop 
37080 \newline
37081 ; nop
37082 \end_layout
37083
37084 \begin_layout Standard
37085 A conditional function can be attached to a rule.
37086  Attaching rules are somewhat more involved, let me illustrate this with
37087  an example.
37088 \end_layout
37089
37090 \begin_layout Verse
37091
37092 \family typewriter
37093 replace { 
37094 \newline
37095 \InsetSpace ~
37096  \InsetSpace ~
37097  \InsetSpace ~
37098 ljmp %5 
37099 \newline
37100 %2:
37101 \newline
37102 } by { 
37103 \newline
37104 \InsetSpace ~
37105  \InsetSpace ~
37106  \InsetSpace ~
37107 sjmp %5 
37108 \newline
37109 %2:
37110 \newline
37111 } if labelInRange
37112 \end_layout
37113
37114 \begin_layout Standard
37115 The optimizer does a look-up of a function name table defined in function
37116  
37117 \emph on
37118 callFuncByName
37119 \emph default
37120  in the source file SDCCpeeph.c, with the name 
37121 \emph on
37122 labelInRange
37123 \emph default
37124 .
37125  If it finds a corresponding entry the function is called.
37126  Note there can be no parameters specified for these functions, in this
37127  case the use of 
37128 \emph on
37129 %5
37130 \emph default
37131  is crucial, since the function 
37132 \emph on
37133 labelInRange
37134 \emph default
37135  expects to find the label in that particular variable (the hash table containin
37136 g the variable bindings is passed as a parameter).
37137  If you want to code more such functions, take a close look at the function
37138  labelInRange and the calling mechanism in source file SDCCpeeph.c.
37139  Currently implemented are 
37140 \emph on
37141 labelInRange, labelRefCount, labelIsReturnOnly, operandsNotSame, xramMovcOption,
37142  24bitMode, portIsDS390, 24bitModeAndPortDS390 
37143 \emph default
37144 and
37145 \emph on
37146  notVolatile
37147 \emph default
37148 .
37149 \end_layout
37150
37151 \begin_layout Standard
37152 I know this whole thing is a little kludgey, but maybe some day we will
37153  have some better means.
37154  If you are looking at this file, you will see the default rules that are
37155  compiled into the compiler, you can add your own rules in the default set
37156  there if you get tired of specifying the -
37157 \begin_inset ERT
37158 status collapsed
37159
37160 \begin_layout Standard
37161
37162
37163 \backslash
37164 /
37165 \end_layout
37166
37167 \end_inset
37168
37169 -peep-file option.
37170 \end_layout
37171
37172 \begin_layout Section
37173 ANSI-Compliance
37174 \begin_inset LatexCommand \index{ANSI-compliance}
37175
37176 \end_inset
37177
37178
37179 \begin_inset LatexCommand \label{sub:ANSI-Compliance}
37180
37181 \end_inset
37182
37183
37184 \end_layout
37185
37186 \begin_layout Standard
37187 The latest publically available version of the standard 
37188 \emph on
37189 ISO/IEC 9899 - Programming languages - C
37190 \emph default
37191  should be available at: 
37192 \begin_inset LatexCommand \url{http://www.open-std.org/jtc1/sc22/wg14/www/standards.html#9899}
37193
37194 \end_inset
37195
37196 .
37197 \newline
37198
37199 \end_layout
37200
37201 \begin_layout Standard
37202 Deviations from the compliance:
37203 \end_layout
37204
37205 \begin_layout Itemize
37206 functions are not reentrant
37207 \begin_inset LatexCommand \index{reentrant}
37208
37209 \end_inset
37210
37211  unless explicitly declared as such or the 
37212 \series bold
37213 -
37214 \begin_inset ERT
37215 status collapsed
37216
37217 \begin_layout Standard
37218
37219
37220 \backslash
37221 /
37222 \end_layout
37223
37224 \end_inset
37225
37226 -stack-auto
37227 \begin_inset LatexCommand \index{-\/-stack-auto}
37228
37229 \end_inset
37230
37231
37232 \series default
37233  command line option is specified.
37234 \end_layout
37235
37236 \begin_layout Itemize
37237 structures
37238 \begin_inset LatexCommand \index{struct}
37239
37240 \end_inset
37241
37242  and unions
37243 \begin_inset LatexCommand \index{union}
37244
37245 \end_inset
37246
37247  cannot be assigned values directly, cannot be passed as function parameters
37248  or assigned to each other and cannot be a return value
37249 \begin_inset LatexCommand \index{return value}
37250
37251 \end_inset
37252
37253  from a function, e.g.:
37254 \end_layout
37255
37256 \begin_deeper
37257 \begin_layout Verse
37258
37259 \family typewriter
37260 struct s { ...
37261  }; 
37262 \newline
37263 struct s s1, s2; 
37264 \newline
37265 foo() 
37266 \newline
37267
37268 \newline
37269 \InsetSpace ~
37270 \InsetSpace ~
37271 \InsetSpace ~
37272 \InsetSpace ~
37273 ...
37274  
37275 \newline
37276 \InsetSpace ~
37277 \InsetSpace ~
37278 \InsetSpace ~
37279 \InsetSpace ~
37280 s1 = s2 ; /* is invalid in SDCC although allowed in ANSI */ 
37281 \newline
37282 \InsetSpace ~
37283 \InsetSpace ~
37284 \InsetSpace ~
37285 \InsetSpace ~
37286 ...
37287  
37288 \newline
37289 }
37290 \newline
37291
37292 \series bold
37293 struct
37294 \series default
37295  s foo1 (
37296 \series bold
37297 struct
37298 \series default
37299  s parms) /* invalid in SDCC although allowed in ANSI */
37300 \newline
37301
37302 \newline
37303 \InsetSpace ~
37304 \InsetSpace ~
37305 \InsetSpace ~
37306 \InsetSpace ~
37307 struct s rets;
37308  
37309 \newline
37310 \InsetSpace ~
37311 \InsetSpace ~
37312 \InsetSpace ~
37313 \InsetSpace ~
37314 ...
37315  
37316 \newline
37317 \InsetSpace ~
37318 \InsetSpace ~
37319 \InsetSpace ~
37320 \InsetSpace ~
37321 return rets; /* is invalid in SDCC although allowed in ANSI */ 
37322 \newline
37323 }
37324 \end_layout
37325
37326 \end_deeper
37327 \begin_layout Itemize
37328 initialization of structure arrays must be fully braced.
37329 \end_layout
37330
37331 \begin_deeper
37332 \begin_layout Verse
37333
37334 \family typewriter
37335 struct s { char x } a[] = {1, 2};\InsetSpace ~
37336 \InsetSpace ~
37337 \InsetSpace ~
37338 \InsetSpace ~
37339 \InsetSpace ~
37340 /* invalid in SDCC */
37341 \newline
37342 struct s { char x
37343  } a[] = {{1}, {2}}; /* OK */
37344 \end_layout
37345
37346 \end_deeper
37347 \begin_layout Itemize
37348 'long long
37349 \begin_inset LatexCommand \index{long long (not supported)}
37350
37351 \end_inset
37352
37353 ' (64 bit integers
37354 \begin_inset LatexCommand \index{int (64 bit) (not supported)}
37355
37356 \end_inset
37357
37358 ) not supported.
37359 \end_layout
37360
37361 \begin_layout Itemize
37362 'double
37363 \begin_inset LatexCommand \index{double (not supported)}
37364
37365 \end_inset
37366
37367 ' precision floating point 
37368 \begin_inset LatexCommand \index{Floating point support}
37369
37370 \end_inset
37371
37372 not supported.
37373 \end_layout
37374
37375 \begin_layout Itemize
37376 Old K&R style
37377 \begin_inset LatexCommand \index{K\&R style}
37378
37379 \end_inset
37380
37381  function declarations are NOT allowed.
37382 \end_layout
37383
37384 \begin_deeper
37385 \begin_layout Verse
37386
37387 \family typewriter
37388 foo(i,j) /* this old style of function declarations */ 
37389 \newline
37390 int i,j; /* is valid
37391  in ANSI but not valid in SDCC */ 
37392 \newline
37393
37394 \newline
37395 \InsetSpace ~
37396 \InsetSpace ~
37397 \InsetSpace ~
37398 \InsetSpace ~
37399 ...
37400  
37401 \newline
37402 }
37403 \end_layout
37404
37405 \end_deeper
37406 \begin_layout Itemize
37407 Most enhancements in C99 are not supported, e.g.:
37408 \end_layout
37409
37410 \begin_deeper
37411 \begin_layout Verse
37412
37413 \family typewriter
37414 for (
37415 \series bold
37416 int
37417 \series default
37418  i=0; i<10; i++) /* is invalid in SDCC although allowed in C99 */
37419 \end_layout
37420
37421 \end_deeper
37422 \begin_layout Itemize
37423 But some have been added recently in SDCC 2.7.0.
37424  They must be considered alpha quality however.
37425 \end_layout
37426
37427 \begin_deeper
37428 \begin_layout Verse
37429
37430 \family typewriter
37431 \series bold
37432 inline
37433 \begin_inset LatexCommand \index{inline (not supported)}
37434
37435 \end_inset
37436
37437
37438 \series default
37439  int increment (int a) { return a+1; } /* inlines the increment without
37440  function call overhead */
37441 \newline
37442 int * 
37443 \series bold
37444 restrict
37445 \begin_inset LatexCommand \index{inline (not supported)}
37446
37447 \end_inset
37448
37449
37450 \series default
37451  p; /* accepted but ignored */
37452 \end_layout
37453
37454 \end_deeper
37455 \begin_layout Itemize
37456 Certain words that are valid identifiers in the standard may be reserved
37457  words in SDCC unless the 
37458 \series bold
37459 -
37460 \begin_inset ERT
37461 status collapsed
37462
37463 \begin_layout Standard
37464
37465
37466 \backslash
37467 /
37468 \end_layout
37469
37470 \end_inset
37471
37472 -std-c89
37473 \begin_inset LatexCommand \index{-\/-std-c89}
37474
37475 \end_inset
37476
37477  
37478 \series default
37479 or
37480 \series bold
37481  -
37482 \begin_inset ERT
37483 status collapsed
37484
37485 \begin_layout Standard
37486
37487
37488 \backslash
37489 /
37490 \end_layout
37491
37492 \end_inset
37493
37494 -std-c99
37495 \begin_inset LatexCommand \index{-\/-std-c99}
37496
37497 \end_inset
37498
37499
37500 \series default
37501  command line options are used.
37502  These may include (depending on the selected processor): 'at', 'banked',
37503  'bit', 'code', 'critical', 'data', 'eeprom', 'far', 'flash', 'idata', 'interrup
37504 t', 'near', 'nonbanked', 'pdata', 'reentrant', 'sbit', 'sfr', 'shadowregs',
37505  'sram', 'using', 'wparam', 'xdata', '_overlay', '_asm', '_endasm', and
37506  '_naked'.
37507  Compliant equivalents of these keywords are always available in a form
37508  that begin with two underscores
37509 \begin_inset LatexCommand \index{\_\_ (prefix for extended keywords)}
37510
37511 \end_inset
37512
37513 , f.e.
37514  '__data' instead of 'data'.
37515 \end_layout
37516
37517 \begin_layout Itemize
37518 Integer promotion of variable arguments is not performed if the argument
37519  is explicitly taypecasted unless the
37520 \series bold
37521  -
37522 \begin_inset ERT
37523 status collapsed
37524
37525 \begin_layout Standard
37526
37527
37528 \backslash
37529 /
37530 \end_layout
37531
37532 \end_inset
37533
37534 -std-c89
37535 \begin_inset LatexCommand \index{-\/-std-c89}
37536
37537 \end_inset
37538
37539  
37540 \series default
37541 or
37542 \series bold
37543  -
37544 \begin_inset ERT
37545 status collapsed
37546
37547 \begin_layout Standard
37548
37549
37550 \backslash
37551 /
37552 \end_layout
37553
37554 \end_inset
37555
37556 -std-c99
37557 \begin_inset LatexCommand \index{-\/-std-c99}
37558
37559 \end_inset
37560
37561
37562 \series default
37563  command line options are used.
37564 \end_layout
37565
37566 \begin_deeper
37567 \begin_layout Verse
37568
37569 \family typewriter
37570 void vararg_func (char *str, ...) { str; }
37571 \newline
37572
37573 \newline
37574 void main (void)
37575 \newline
37576 {
37577 \newline
37578 \InsetSpace ~
37579 \InsetSpace ~
37580 char c = 10;
37581 \newline
37582
37583 \newline
37584 \InsetSpace ~
37585 \InsetSpace ~
37586 /* argument
37587  u is promoted to int before
37588 \newline
37589 \InsetSpace ~
37590 \InsetSpace ~
37591 \InsetSpace ~
37592 * passing to function */
37593 \newline
37594 \InsetSpace ~
37595 \InsetSpace ~
37596 vararg_func ("%c", c);
37597 \newline
37598
37599 \newline
37600 \InsetSpace ~
37601 \InsetSpace ~
37602 /*
37603  argument u is not promoted to int,
37604 \newline
37605 \InsetSpace ~
37606 \InsetSpace ~
37607 \InsetSpace ~
37608 * it is passed as char to function
37609 \newline
37610 \InsetSpace ~
37611 \InsetSpace ~
37612 \InsetSpace ~
37613 * if
37614  --std-cXX is not defined;
37615 \newline
37616 \InsetSpace ~
37617 \InsetSpace ~
37618 \InsetSpace ~
37619 * is promoted to int before passing
37620 \newline
37621 \InsetSpace ~
37622 \InsetSpace ~
37623 \InsetSpace ~
37624 * to function
37625  if --std-cXX is defined */
37626 \newline
37627 \InsetSpace ~
37628 \InsetSpace ~
37629 vararg_func ("%bc", (char)u);
37630 \newline
37631 }
37632 \end_layout
37633
37634 \end_deeper
37635 \begin_layout Section
37636 Cyclomatic Complexity
37637 \begin_inset LatexCommand \index{Cyclomatic complexity}
37638
37639 \end_inset
37640
37641
37642 \end_layout
37643
37644 \begin_layout Standard
37645 Cyclomatic complexity of a function is defined as the number of independent
37646  paths the program can take during execution of the function.
37647  This is an important number since it defines the number test cases you
37648  have to generate to validate the function.
37649  The accepted industry standard for complexity number is 10, if the cyclomatic
37650  complexity reported by SDCC exceeds 10 you should think about simplification
37651  of the function logic.
37652  Note that the complexity level is not related to the number of lines of
37653  code in a function.
37654  Large functions can have low complexity, and small functions can have large
37655  complexity levels.
37656  
37657 \newline
37658
37659 \newline
37660 SDCC uses the following formula to compute the complexity:
37661 \newline
37662
37663 \end_layout
37664
37665 \begin_layout Standard
37666 complexity = (number of edges in control flow graph) - (number of nodes
37667  in control flow graph) + 2;
37668 \newline
37669
37670 \newline
37671 Having said that the industry standard is 10,
37672  you should be aware that in some cases it be may unavoidable to have a
37673  complexity level of less than 10.
37674  For example if you have switch statement with more than 10 case labels,
37675  each case label adds one to the complexity level.
37676  The complexity level is by no means an absolute measure of the algorithmic
37677  complexity of the function, it does however provide a good starting point
37678  for which functions you might look at for further optimization.
37679 \end_layout
37680
37681 \begin_layout Section
37682 Retargetting for other Processors
37683 \end_layout
37684
37685 \begin_layout Standard
37686 The issues for retargetting the compiler are far too numerous to be covered
37687  by this document.
37688  What follows is a brief description of each of the seven phases of the
37689  compiler and its MCU dependency.
37690 \end_layout
37691
37692 \begin_layout Itemize
37693 Parsing the source and building the annotated parse tree.
37694  This phase is largely MCU independent (except for the language extensions).
37695  Syntax & semantic checks are also done in this phase, along with some initial
37696  optimizations like back patching labels and the pattern matching optimizations
37697  like bit-rotation etc.
37698 \end_layout
37699
37700 \begin_layout Itemize
37701 The second phase involves generating an intermediate code which can be easy
37702  manipulated during the later phases.
37703  This phase is entirely MCU independent.
37704  The intermediate code generation assumes the target machine has unlimited
37705  number of registers, and designates them with the name iTemp.
37706  The compiler can be made to dump a human readable form of the code generated
37707  by using the -
37708 \begin_inset ERT
37709 status collapsed
37710
37711 \begin_layout Standard
37712
37713
37714 \backslash
37715 /
37716 \end_layout
37717
37718 \end_inset
37719
37720 -dumpraw option.
37721 \end_layout
37722
37723 \begin_layout Itemize
37724 This phase does the bulk of the standard optimizations and is also MCU independe
37725 nt.
37726  This phase can be broken down into several sub-phases:
37727 \newline
37728
37729 \newline
37730 Break down intermediate
37731  code (iCode) into basic blocks.
37732 \newline
37733 Do control flow & data flow analysis on the
37734  basic blocks.
37735 \newline
37736 Do local common subexpression elimination, then global subexpressio
37737 n elimination
37738 \newline
37739 Dead code elimination
37740 \newline
37741 Loop optimizations
37742 \newline
37743 If loop optimizations
37744  caused any changes then do 'global subexpression elimination' and 'dead
37745  code elimination' again.
37746 \end_layout
37747
37748 \begin_layout Itemize
37749 This phase determines the live-ranges; by live range I mean those iTemp
37750  variables defined by the compiler that still survive after all the optimization
37751 s.
37752  Live range analysis
37753 \begin_inset LatexCommand \index{Live range analysis}
37754
37755 \end_inset
37756
37757  is essential for register allocation, since these computation determines
37758  which of these iTemps will be assigned to registers, and for how long.
37759 \end_layout
37760
37761 \begin_layout Itemize
37762 Phase five is register allocation.
37763  There are two parts to this process.
37764 \newline
37765
37766 \newline
37767 The first part I call 'register packing'
37768  (for lack of a better term).
37769  In this case several MCU specific expression folding is done to reduce
37770  register pressure.
37771 \newline
37772
37773 \newline
37774 The second part is more MCU independent and deals with
37775  allocating registers to the remaining live ranges.
37776  A lot of MCU specific code does creep into this phase because of the limited
37777  number of index registers available in the 8051.
37778 \end_layout
37779
37780 \begin_layout Itemize
37781 The Code generation phase is (unhappily), entirely MCU dependent and very
37782  little (if any at all) of this code can be reused for other MCU.
37783  However the scheme for allocating a homogenized assembler operand for each
37784  iCode operand may be reused.
37785 \end_layout
37786
37787 \begin_layout Itemize
37788 As mentioned in the optimization section the peep-hole optimizer is rule
37789  based system, which can reprogrammed for other MCUs.
37790 \end_layout
37791
37792 \begin_layout Standard
37793 More information is available on SDCC Wiki
37794 \begin_inset LatexCommand \index{wiki}
37795
37796 \end_inset
37797
37798  (preliminary link 
37799 \begin_inset LatexCommand \url{http://sdcc.wiki.sourceforge.net/SDCC+internals+and+porting}
37800
37801 \end_inset
37802
37803 ) and in the thread 
37804 \begin_inset LatexCommand \url{http://sf.net/mailarchive/message.php?msg_id=13954144}
37805
37806 \end_inset
37807
37808  .
37809 \end_layout
37810
37811 \begin_layout Chapter
37812 Compiler internals
37813 \begin_inset LatexCommand \index{Compiler internals}
37814
37815 \end_inset
37816
37817
37818 \end_layout
37819
37820 \begin_layout Section
37821 The anatomy of the compiler
37822 \begin_inset LatexCommand \label{sub:The-anatomy-of}
37823
37824 \end_inset
37825
37826
37827 \end_layout
37828
37829 \begin_layout Standard
37830
37831 \shape italic
37832 This is an excerpt from an article published in Circuit Cellar Magazine
37833  in 
37834 \series bold
37835 August 2000
37836 \series default
37837 .
37838  It's a little outdated (the compiler is much more efficient now and user/develo
37839 per friendly), but pretty well exposes the guts of it all.
37840 \shape default
37841
37842 \newline
37843
37844 \newline
37845 The current version of SDCC can generate code for Intel 8051 and Z80 MCU.
37846  It is fairly easy to retarget for other 8-bit MCU.
37847  Here we take a look at some of the internals of the compiler.
37848  
37849 \end_layout
37850
37851 \begin_layout Paragraph*
37852 Parsing
37853 \begin_inset LatexCommand \index{Parsing}
37854
37855 \end_inset
37856
37857  
37858 \end_layout
37859
37860 \begin_layout Standard
37861 Parsing the input source file and creating an AST (Annotated Syntax Tree
37862 \begin_inset LatexCommand \index{Annotated syntax tree}
37863
37864 \end_inset
37865
37866 ).
37867  This phase also involves propagating types (annotating each node of the
37868  parse tree with type information) and semantic analysis.
37869  There are some MCU specific parsing rules.
37870  For example the storage classes, the extended storage classes are MCU specific
37871  while there may be a xdata storage class for 8051 there is no such storage
37872  class for z80 or Atmel AVR.
37873  SDCC allows MCU specific storage class extensions, i.e.
37874  xdata will be treated as a storage class specifier when parsing 8051 C
37875  code but will be treated as a C identifier when parsing z80 or ATMEL AVR
37876  C code.
37877 \end_layout
37878
37879 \begin_layout Paragraph*
37880 Generating iCode
37881 \begin_inset LatexCommand \index{iCode}
37882
37883 \end_inset
37884
37885
37886 \end_layout
37887
37888 \begin_layout Standard
37889 Intermediate code generation.
37890  In this phase the AST is broken down into three-operand form (iCode).
37891  These three operand forms are represented as doubly linked lists.
37892  ICode is the term given to the intermediate form generated by the compiler.
37893  ICode example section shows some examples of iCode generated for some simple
37894  C source functions.
37895 \end_layout
37896
37897 \begin_layout Paragraph*
37898 Optimizations
37899 \begin_inset LatexCommand \index{Optimizations}
37900
37901 \end_inset
37902
37903 .
37904 \end_layout
37905
37906 \begin_layout Standard
37907 Bulk of the target independent optimizations is performed in this phase.
37908  The optimizations include constant propagation, common sub-expression eliminati
37909 on, loop invariant code movement, strength reduction of loop induction variables
37910  and dead-code elimination.
37911 \end_layout
37912
37913 \begin_layout Paragraph*
37914 Live range analysis
37915 \begin_inset LatexCommand \index{Live range analysis}
37916
37917 \end_inset
37918
37919
37920 \end_layout
37921
37922 \begin_layout Standard
37923 During intermediate code generation phase, the compiler assumes the target
37924  machine has infinite number of registers and generates a lot of temporary
37925  variables.
37926  The live range computation determines the lifetime of each of these compiler-ge
37927 nerated temporaries.
37928  A picture speaks a thousand words.
37929  ICode example sections show the live range annotations for each of the
37930  operand.
37931  It is important to note here, each iCode is assigned a number in the order
37932  of its execution in the function.
37933  The live ranges are computed in terms of these numbers.
37934  The from number is the number of the iCode which first defines the operand
37935  and the to number signifies the iCode which uses this operand last.
37936 \end_layout
37937
37938 \begin_layout Paragraph*
37939 Register Allocation
37940 \begin_inset LatexCommand \index{Register allocation}
37941
37942 \end_inset
37943
37944
37945 \end_layout
37946
37947 \begin_layout Standard
37948 The register allocation determines the type and number of registers needed
37949  by each operand.
37950  In most MCUs only a few registers can be used for indirect addressing.
37951  In case of 8051 for example the registers R0 & R1 can be used to indirectly
37952  address the internal ram and DPTR to indirectly address the external ram.
37953  The compiler will try to allocate the appropriate register to pointer variables
37954  if it can.
37955  ICode example section shows the operands annotated with the registers assigned
37956  to them.
37957  The compiler will try to keep operands in registers as much as possible;
37958  there are several schemes the compiler uses to do achieve this.
37959  When the compiler runs out of registers the compiler will check to see
37960  if there are any live operands which is not used or defined in the current
37961  basic block being processed, if there are any found then it will push that
37962  operand and use the registers in this block, the operand will then be popped
37963  at the end of the basic block.
37964  
37965 \end_layout
37966
37967 \begin_layout Standard
37968 There are other MCU specific considerations in this phase.
37969  Some MCUs have an accumulator; very short-lived operands could be assigned
37970  to the accumulator instead of a general-purpose register.
37971 \end_layout
37972
37973 \begin_layout Paragraph*
37974 Code generation
37975 \end_layout
37976
37977 \begin_layout Standard
37978 Figure II gives a table of iCode
37979 \begin_inset LatexCommand \index{iCode}
37980
37981 \end_inset
37982
37983  operations supported by the compiler.
37984  The code generation involves translating these operations into corresponding
37985  assembly code for the processor.
37986  This sounds overly simple but that is the essence of code generation.
37987  Some of the iCode operations are generated on a MCU specific manner for
37988  example, the z80 port does not use registers to pass parameters so the
37989  SEND and RECV iCode operations will not be generated, and it also does
37990  not support JUMPTABLES.
37991  
37992 \newline
37993
37994 \end_layout
37995
37996 \begin_layout Standard
37997
37998 \size footnotesize
37999 Figure II 
38000 \begin_inset Tabular
38001 <lyxtabular version="3" rows="39" columns="4">
38002 <features islongtable="true" headBottomDL="true">
38003 <column alignment="block" valignment="top" leftline="true" width="13col%">
38004 <column alignment="left" valignment="top" leftline="true" width="13col%">
38005 <column alignment="block" valignment="top" leftline="true" width="22col%">
38006 <column alignment="block" valignment="top" leftline="true" rightline="true" width="40col%">
38007 <row topline="true" bottomline="true" endhead="true">
38008 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38009 \begin_inset Text
38010
38011 \begin_layout Standard
38012
38013 \series bold
38014 iCode
38015 \series default
38016
38017 \begin_inset LatexCommand \index{iCode}
38018
38019 \end_inset
38020
38021
38022 \end_layout
38023
38024 \end_inset
38025 </cell>
38026 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38027 \begin_inset Text
38028
38029 \begin_layout Standard
38030
38031 \series bold
38032 Operands
38033 \end_layout
38034
38035 \end_inset
38036 </cell>
38037 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38038 \begin_inset Text
38039
38040 \begin_layout Standard
38041
38042 \series bold
38043 Description
38044 \end_layout
38045
38046 \end_inset
38047 </cell>
38048 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
38049 \begin_inset Text
38050
38051 \begin_layout Standard
38052
38053 \series bold
38054 C Equivalent
38055 \end_layout
38056
38057 \end_inset
38058 </cell>
38059 </row>
38060 <row topline="true">
38061 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38062 \begin_inset Text
38063
38064 \begin_layout Standard
38065
38066 \size footnotesize
38067 '!'
38068 \end_layout
38069
38070 \end_inset
38071 </cell>
38072 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38073 \begin_inset Text
38074
38075 \begin_layout Standard
38076
38077 \size footnotesize
38078 IC_LEFT() IC_RESULT()
38079 \end_layout
38080
38081 \end_inset
38082 </cell>
38083 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38084 \begin_inset Text
38085
38086 \begin_layout Standard
38087
38088 \size footnotesize
38089 NOT operation 
38090 \end_layout
38091
38092 \end_inset
38093 </cell>
38094 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
38095 \begin_inset Text
38096
38097 \begin_layout Standard
38098
38099 \size footnotesize
38100 IC_RESULT = ! IC_LEFT;
38101 \end_layout
38102
38103 \end_inset
38104 </cell>
38105 </row>
38106 <row topline="true">
38107 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38108 \begin_inset Text
38109
38110 \begin_layout Standard
38111
38112 \size footnotesize
38113 '~'
38114 \end_layout
38115
38116 \end_inset
38117 </cell>
38118 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38119 \begin_inset Text
38120
38121 \begin_layout Standard
38122
38123 \size footnotesize
38124 IC_LEFT() IC_RESULT()
38125 \end_layout
38126
38127 \end_inset
38128 </cell>
38129 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38130 \begin_inset Text
38131
38132 \begin_layout Standard
38133
38134 \size footnotesize
38135 Bitwise complement of 
38136 \end_layout
38137
38138 \end_inset
38139 </cell>
38140 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
38141 \begin_inset Text
38142
38143 \begin_layout Standard
38144
38145 \size footnotesize
38146 IC_RESULT = ~IC_LEFT;
38147 \end_layout
38148
38149 \end_inset
38150 </cell>
38151 </row>
38152 <row topline="true">
38153 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38154 \begin_inset Text
38155
38156 \begin_layout Standard
38157
38158 \size footnotesize
38159 RRC
38160 \end_layout
38161
38162 \end_inset
38163 </cell>
38164 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38165 \begin_inset Text
38166
38167 \begin_layout Standard
38168
38169 \size footnotesize
38170 IC_LEFT() IC_RESULT()
38171 \end_layout
38172
38173 \end_inset
38174 </cell>
38175 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38176 \begin_inset Text
38177
38178 \begin_layout Standard
38179
38180 \size footnotesize
38181 Rotate right with carry
38182 \end_layout
38183
38184 \end_inset
38185 </cell>
38186 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
38187 \begin_inset Text
38188
38189 \begin_layout Standard
38190
38191 \size footnotesize
38192 IC_RESULT = (IC_LEFT << 1) | (IC_LEFT >> (sizeof(IC_LEFT)*8-1));
38193 \end_layout
38194
38195 \end_inset
38196 </cell>
38197 </row>
38198 <row topline="true">
38199 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38200 \begin_inset Text
38201
38202 \begin_layout Standard
38203
38204 \size footnotesize
38205 RLC
38206 \end_layout
38207
38208 \end_inset
38209 </cell>
38210 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38211 \begin_inset Text
38212
38213 \begin_layout Standard
38214
38215 \size footnotesize
38216 IC_LEFT() IC_RESULT()
38217 \end_layout
38218
38219 \end_inset
38220 </cell>
38221 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38222 \begin_inset Text
38223
38224 \begin_layout Standard
38225
38226 \size footnotesize
38227 Rotate left with carry
38228 \end_layout
38229
38230 \end_inset
38231 </cell>
38232 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
38233 \begin_inset Text
38234
38235 \begin_layout Standard
38236
38237 \size footnotesize
38238 IC_RESULT = (IC_LEFT << (sizeof(LC_LEFT)*8-1) ) | (IC_LEFT >> 1);
38239 \end_layout
38240
38241 \end_inset
38242 </cell>
38243 </row>
38244 <row topline="true">
38245 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38246 \begin_inset Text
38247
38248 \begin_layout Standard
38249
38250 \size footnotesize
38251 GETHBIT
38252 \end_layout
38253
38254 \end_inset
38255 </cell>
38256 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38257 \begin_inset Text
38258
38259 \begin_layout Standard
38260
38261 \size footnotesize
38262 IC_LEFT() IC_RESULT()
38263 \end_layout
38264
38265 \end_inset
38266 </cell>
38267 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38268 \begin_inset Text
38269
38270 \begin_layout Standard
38271
38272 \size footnotesize
38273 Get the highest order bit of IC_LEFT
38274 \end_layout
38275
38276 \end_inset
38277 </cell>
38278 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
38279 \begin_inset Text
38280
38281 \begin_layout Standard
38282
38283 \size footnotesize
38284 IC_RESULT = (IC_LEFT >> (sizeof(IC_LEFT)*8 -1));
38285 \end_layout
38286
38287 \end_inset
38288 </cell>
38289 </row>
38290 <row topline="true">
38291 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38292 \begin_inset Text
38293
38294 \begin_layout Standard
38295
38296 \size footnotesize
38297 UNARYMINUS
38298 \end_layout
38299
38300 \end_inset
38301 </cell>
38302 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38303 \begin_inset Text
38304
38305 \begin_layout Standard
38306
38307 \size footnotesize
38308 IC_LEFT() IC_RESULT()
38309 \end_layout
38310
38311 \end_inset
38312 </cell>
38313 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38314 \begin_inset Text
38315
38316 \begin_layout Standard
38317
38318 \size footnotesize
38319 Unary minus
38320 \end_layout
38321
38322 \end_inset
38323 </cell>
38324 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
38325 \begin_inset Text
38326
38327 \begin_layout Standard
38328
38329 \size footnotesize
38330 IC_RESULT = - IC_LEFT;
38331 \end_layout
38332
38333 \end_inset
38334 </cell>
38335 </row>
38336 <row topline="true">
38337 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38338 \begin_inset Text
38339
38340 \begin_layout Standard
38341
38342 \size footnotesize
38343 IPUSH
38344 \end_layout
38345
38346 \end_inset
38347 </cell>
38348 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38349 \begin_inset Text
38350
38351 \begin_layout Standard
38352
38353 \size footnotesize
38354 IC_LEFT()
38355 \end_layout
38356
38357 \end_inset
38358 </cell>
38359 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38360 \begin_inset Text
38361
38362 \begin_layout Standard
38363
38364 \size footnotesize
38365 Push the operand into stack
38366 \end_layout
38367
38368 \end_inset
38369 </cell>
38370 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
38371 \begin_inset Text
38372
38373 \begin_layout Standard
38374
38375 \size footnotesize
38376 NONE
38377 \end_layout
38378
38379 \end_inset
38380 </cell>
38381 </row>
38382 <row topline="true">
38383 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38384 \begin_inset Text
38385
38386 \begin_layout Standard
38387
38388 \size footnotesize
38389 IPOP
38390 \end_layout
38391
38392 \end_inset
38393 </cell>
38394 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38395 \begin_inset Text
38396
38397 \begin_layout Standard
38398
38399 \size footnotesize
38400 IC_LEFT()
38401 \end_layout
38402
38403 \end_inset
38404 </cell>
38405 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38406 \begin_inset Text
38407
38408 \begin_layout Standard
38409
38410 \size footnotesize
38411 Pop the operand from the stack 
38412 \end_layout
38413
38414 \end_inset
38415 </cell>
38416 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
38417 \begin_inset Text
38418
38419 \begin_layout Standard
38420
38421 \size footnotesize
38422 NONE
38423 \end_layout
38424
38425 \end_inset
38426 </cell>
38427 </row>
38428 <row topline="true">
38429 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38430 \begin_inset Text
38431
38432 \begin_layout Standard
38433
38434 \size footnotesize
38435 CALL
38436 \end_layout
38437
38438 \end_inset
38439 </cell>
38440 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38441 \begin_inset Text
38442
38443 \begin_layout Standard
38444
38445 \size footnotesize
38446 IC_LEFT() IC_RESULT()
38447 \end_layout
38448
38449 \end_inset
38450 </cell>
38451 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38452 \begin_inset Text
38453
38454 \begin_layout Standard
38455
38456 \size footnotesize
38457 Call the function represented by IC_LEFT 
38458 \end_layout
38459
38460 \end_inset
38461 </cell>
38462 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
38463 \begin_inset Text
38464
38465 \begin_layout Standard
38466
38467 \size footnotesize
38468 IC_RESULT = IC_LEFT();
38469 \end_layout
38470
38471 \end_inset
38472 </cell>
38473 </row>
38474 <row topline="true">
38475 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38476 \begin_inset Text
38477
38478 \begin_layout Standard
38479
38480 \size footnotesize
38481 PCALL
38482 \end_layout
38483
38484 \end_inset
38485 </cell>
38486 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38487 \begin_inset Text
38488
38489 \begin_layout Standard
38490
38491 \size footnotesize
38492 IC_LEFT() IC_RESULT()
38493 \end_layout
38494
38495 \end_inset
38496 </cell>
38497 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38498 \begin_inset Text
38499
38500 \begin_layout Standard
38501
38502 \size footnotesize
38503 Call via function pointer
38504 \end_layout
38505
38506 \end_inset
38507 </cell>
38508 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
38509 \begin_inset Text
38510
38511 \begin_layout Standard
38512
38513 \size footnotesize
38514 IC_RESULT = (*IC_LEFT)();
38515 \end_layout
38516
38517 \end_inset
38518 </cell>
38519 </row>
38520 <row topline="true">
38521 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38522 \begin_inset Text
38523
38524 \begin_layout Standard
38525
38526 \size footnotesize
38527 RETURN
38528 \end_layout
38529
38530 \end_inset
38531 </cell>
38532 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38533 \begin_inset Text
38534
38535 \begin_layout Standard
38536
38537 \size footnotesize
38538 IC_LEFT()
38539 \end_layout
38540
38541 \end_inset
38542 </cell>
38543 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38544 \begin_inset Text
38545
38546 \begin_layout Standard
38547
38548 \size footnotesize
38549 Return the value in operand IC_LEFT 
38550 \end_layout
38551
38552 \end_inset
38553 </cell>
38554 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
38555 \begin_inset Text
38556
38557 \begin_layout Standard
38558
38559 \size footnotesize
38560 return IC_LEFT;
38561 \end_layout
38562
38563 \end_inset
38564 </cell>
38565 </row>
38566 <row topline="true">
38567 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38568 \begin_inset Text
38569
38570 \begin_layout Standard
38571
38572 \size footnotesize
38573 LABEL
38574 \end_layout
38575
38576 \end_inset
38577 </cell>
38578 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38579 \begin_inset Text
38580
38581 \begin_layout Standard
38582
38583 \size footnotesize
38584 IC_LABEL() 
38585 \end_layout
38586
38587 \end_inset
38588 </cell>
38589 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38590 \begin_inset Text
38591
38592 \begin_layout Standard
38593
38594 \size footnotesize
38595 Label
38596 \end_layout
38597
38598 \end_inset
38599 </cell>
38600 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
38601 \begin_inset Text
38602
38603 \begin_layout Standard
38604
38605 \size footnotesize
38606 IC_LABEL:
38607 \end_layout
38608
38609 \end_inset
38610 </cell>
38611 </row>
38612 <row topline="true">
38613 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38614 \begin_inset Text
38615
38616 \begin_layout Standard
38617
38618 \size footnotesize
38619 GOTO
38620 \end_layout
38621
38622 \end_inset
38623 </cell>
38624 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38625 \begin_inset Text
38626
38627 \begin_layout Standard
38628
38629 \size footnotesize
38630 IC_LABEL() 
38631 \end_layout
38632
38633 \end_inset
38634 </cell>
38635 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38636 \begin_inset Text
38637
38638 \begin_layout Standard
38639
38640 \size footnotesize
38641 Goto label
38642 \end_layout
38643
38644 \end_inset
38645 </cell>
38646 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
38647 \begin_inset Text
38648
38649 \begin_layout Standard
38650
38651 \size footnotesize
38652 goto IC_LABEL();
38653 \end_layout
38654
38655 \end_inset
38656 </cell>
38657 </row>
38658 <row topline="true">
38659 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38660 \begin_inset Text
38661
38662 \begin_layout Standard
38663
38664 \size footnotesize
38665 '+'
38666 \end_layout
38667
38668 \end_inset
38669 </cell>
38670 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38671 \begin_inset Text
38672
38673 \begin_layout Standard
38674
38675 \size footnotesize
38676 IC_LEFT() IC_RIGHT() IC_RESULT()
38677 \end_layout
38678
38679 \end_inset
38680 </cell>
38681 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38682 \begin_inset Text
38683
38684 \begin_layout Standard
38685
38686 \size footnotesize
38687 Addition
38688 \end_layout
38689
38690 \end_inset
38691 </cell>
38692 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
38693 \begin_inset Text
38694
38695 \begin_layout Standard
38696
38697 \size footnotesize
38698 IC_RESULT = IC_LEFT + IC_RIGHT
38699 \end_layout
38700
38701 \end_inset
38702 </cell>
38703 </row>
38704 <row topline="true">
38705 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38706 \begin_inset Text
38707
38708 \begin_layout Standard
38709
38710 \size footnotesize
38711 '-'
38712 \end_layout
38713
38714 \end_inset
38715 </cell>
38716 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38717 \begin_inset Text
38718
38719 \begin_layout Standard
38720
38721 \size footnotesize
38722 IC_LEFT() IC_RIGHT() IC_RESULT()
38723 \end_layout
38724
38725 \end_inset
38726 </cell>
38727 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38728 \begin_inset Text
38729
38730 \begin_layout Standard
38731
38732 \size footnotesize
38733 Subtraction
38734 \end_layout
38735
38736 \end_inset
38737 </cell>
38738 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
38739 \begin_inset Text
38740
38741 \begin_layout Standard
38742
38743 \size footnotesize
38744 IC_RESULT = IC_LEFT - IC_RIGHT 
38745 \end_layout
38746
38747 \end_inset
38748 </cell>
38749 </row>
38750 <row topline="true">
38751 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38752 \begin_inset Text
38753
38754 \begin_layout Standard
38755
38756 \size footnotesize
38757 '*'
38758 \end_layout
38759
38760 \end_inset
38761 </cell>
38762 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38763 \begin_inset Text
38764
38765 \begin_layout Standard
38766
38767 \size footnotesize
38768 IC_LEFT() IC_RIGHT() IC_RESULT()
38769 \end_layout
38770
38771 \end_inset
38772 </cell>
38773 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38774 \begin_inset Text
38775
38776 \begin_layout Standard
38777
38778 \size footnotesize
38779 Multiplication 
38780 \end_layout
38781
38782 \end_inset
38783 </cell>
38784 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
38785 \begin_inset Text
38786
38787 \begin_layout Standard
38788
38789 \size footnotesize
38790 IC_RESULT = IC_LEFT * IC_RIGHT;
38791 \end_layout
38792
38793 \end_inset
38794 </cell>
38795 </row>
38796 <row topline="true">
38797 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38798 \begin_inset Text
38799
38800 \begin_layout Standard
38801
38802 \size footnotesize
38803 '/'
38804 \end_layout
38805
38806 \end_inset
38807 </cell>
38808 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38809 \begin_inset Text
38810
38811 \begin_layout Standard
38812
38813 \size footnotesize
38814 IC_LEFT() IC_RIGHT() IC_RESULT()
38815 \end_layout
38816
38817 \end_inset
38818 </cell>
38819 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38820 \begin_inset Text
38821
38822 \begin_layout Standard
38823
38824 \size footnotesize
38825 Division
38826 \end_layout
38827
38828 \end_inset
38829 </cell>
38830 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
38831 \begin_inset Text
38832
38833 \begin_layout Standard
38834
38835 \size footnotesize
38836 IC_RESULT = IC_LEFT / IC_RIGHT;
38837 \end_layout
38838
38839 \end_inset
38840 </cell>
38841 </row>
38842 <row topline="true">
38843 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38844 \begin_inset Text
38845
38846 \begin_layout Standard
38847
38848 \size footnotesize
38849 '%'
38850 \end_layout
38851
38852 \end_inset
38853 </cell>
38854 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38855 \begin_inset Text
38856
38857 \begin_layout Standard
38858
38859 \size footnotesize
38860 IC_LEFT() IC_RIGHT() IC_RESULT()
38861 \end_layout
38862
38863 \end_inset
38864 </cell>
38865 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38866 \begin_inset Text
38867
38868 \begin_layout Standard
38869
38870 \size footnotesize
38871 Modulus
38872 \end_layout
38873
38874 \end_inset
38875 </cell>
38876 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
38877 \begin_inset Text
38878
38879 \begin_layout Standard
38880
38881 \size footnotesize
38882 IC_RESULT = IC_LEFT % IC_RIGHT;
38883 \end_layout
38884
38885 \end_inset
38886 </cell>
38887 </row>
38888 <row topline="true">
38889 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38890 \begin_inset Text
38891
38892 \begin_layout Standard
38893
38894 \size footnotesize
38895 '<'
38896 \end_layout
38897
38898 \end_inset
38899 </cell>
38900 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38901 \begin_inset Text
38902
38903 \begin_layout Standard
38904
38905 \size footnotesize
38906 IC_LEFT() IC_RIGHT() IC_RESULT()
38907 \end_layout
38908
38909 \end_inset
38910 </cell>
38911 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38912 \begin_inset Text
38913
38914 \begin_layout Standard
38915
38916 \size footnotesize
38917 Less than
38918 \end_layout
38919
38920 \end_inset
38921 </cell>
38922 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
38923 \begin_inset Text
38924
38925 \begin_layout Standard
38926
38927 \size footnotesize
38928 IC_RESULT = IC_LEFT < IC_RIGHT;
38929 \end_layout
38930
38931 \end_inset
38932 </cell>
38933 </row>
38934 <row topline="true">
38935 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38936 \begin_inset Text
38937
38938 \begin_layout Standard
38939
38940 \size footnotesize
38941 '>'
38942 \end_layout
38943
38944 \end_inset
38945 </cell>
38946 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38947 \begin_inset Text
38948
38949 \begin_layout Standard
38950
38951 \size footnotesize
38952 IC_LEFT() IC_RIGHT() IC_RESULT()
38953 \end_layout
38954
38955 \end_inset
38956 </cell>
38957 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38958 \begin_inset Text
38959
38960 \begin_layout Standard
38961
38962 \size footnotesize
38963 Greater than 
38964 \end_layout
38965
38966 \end_inset
38967 </cell>
38968 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
38969 \begin_inset Text
38970
38971 \begin_layout Standard
38972
38973 \size footnotesize
38974 IC_RESULT = IC_LEFT > IC_RIGHT;
38975 \end_layout
38976
38977 \end_inset
38978 </cell>
38979 </row>
38980 <row topline="true">
38981 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38982 \begin_inset Text
38983
38984 \begin_layout Standard
38985
38986 \size footnotesize
38987 EQ_OP
38988 \end_layout
38989
38990 \end_inset
38991 </cell>
38992 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38993 \begin_inset Text
38994
38995 \begin_layout Standard
38996
38997 \size footnotesize
38998 IC_LEFT() IC_RIGHT() IC_RESULT()
38999 \end_layout
39000
39001 \end_inset
39002 </cell>
39003 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39004 \begin_inset Text
39005
39006 \begin_layout Standard
39007
39008 \size footnotesize
39009 Equal to 
39010 \end_layout
39011
39012 \end_inset
39013 </cell>
39014 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
39015 \begin_inset Text
39016
39017 \begin_layout Standard
39018
39019 \size footnotesize
39020 IC_RESULT = IC_LEFT == IC_RIGHT;
39021 \end_layout
39022
39023 \end_inset
39024 </cell>
39025 </row>
39026 <row topline="true">
39027 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39028 \begin_inset Text
39029
39030 \begin_layout Standard
39031
39032 \size footnotesize
39033 AND_OP
39034 \end_layout
39035
39036 \end_inset
39037 </cell>
39038 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39039 \begin_inset Text
39040
39041 \begin_layout Standard
39042
39043 \size footnotesize
39044 IC_LEFT() IC_RIGHT() IC_RESULT() 
39045 \end_layout
39046
39047 \end_inset
39048 </cell>
39049 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39050 \begin_inset Text
39051
39052 \begin_layout Standard
39053
39054 \size footnotesize
39055 Logical and operation
39056 \end_layout
39057
39058 \end_inset
39059 </cell>
39060 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
39061 \begin_inset Text
39062
39063 \begin_layout Standard
39064
39065 \size footnotesize
39066 IC_RESULT = IC_LEFT && IC_RIGHT; 
39067 \end_layout
39068
39069 \end_inset
39070 </cell>
39071 </row>
39072 <row topline="true">
39073 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39074 \begin_inset Text
39075
39076 \begin_layout Standard
39077
39078 \size footnotesize
39079 OR_OP
39080 \end_layout
39081
39082 \end_inset
39083 </cell>
39084 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39085 \begin_inset Text
39086
39087 \begin_layout Standard
39088
39089 \size footnotesize
39090 IC_LEFT() IC_RIGHT() IC_RESULT() 
39091 \end_layout
39092
39093 \end_inset
39094 </cell>
39095 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39096 \begin_inset Text
39097
39098 \begin_layout Standard
39099
39100 \size footnotesize
39101 Logical or operation 
39102 \end_layout
39103
39104 \end_inset
39105 </cell>
39106 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
39107 \begin_inset Text
39108
39109 \begin_layout Standard
39110
39111 \size footnotesize
39112 IC_RESULT = IC_LEFT || IC_RIGHT; 
39113 \end_layout
39114
39115 \end_inset
39116 </cell>
39117 </row>
39118 <row topline="true">
39119 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39120 \begin_inset Text
39121
39122 \begin_layout Standard
39123
39124 \size footnotesize
39125 '^'
39126 \end_layout
39127
39128 \end_inset
39129 </cell>
39130 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39131 \begin_inset Text
39132
39133 \begin_layout Standard
39134
39135 \size footnotesize
39136 IC_LEFT() IC_RIGHT() IC_RESULT() 
39137 \end_layout
39138
39139 \end_inset
39140 </cell>
39141 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39142 \begin_inset Text
39143
39144 \begin_layout Standard
39145
39146 \size footnotesize
39147 Exclusive OR
39148 \end_layout
39149
39150 \end_inset
39151 </cell>
39152 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
39153 \begin_inset Text
39154
39155 \begin_layout Standard
39156
39157 \size footnotesize
39158 IC_RESULT = IC_LEFT ^ IC_RIGHT;
39159 \end_layout
39160
39161 \end_inset
39162 </cell>
39163 </row>
39164 <row topline="true">
39165 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39166 \begin_inset Text
39167
39168 \begin_layout Standard
39169
39170 \size footnotesize
39171 '|'
39172 \end_layout
39173
39174 \end_inset
39175 </cell>
39176 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39177 \begin_inset Text
39178
39179 \begin_layout Standard
39180
39181 \size footnotesize
39182 IC_LEFT() IC_RIGHT() IC_RESULT() 
39183 \end_layout
39184
39185 \end_inset
39186 </cell>
39187 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39188 \begin_inset Text
39189
39190 \begin_layout Standard
39191
39192 \size footnotesize
39193 Bitwise OR 
39194 \end_layout
39195
39196 \end_inset
39197 </cell>
39198 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
39199 \begin_inset Text
39200
39201 \begin_layout Standard
39202
39203 \size footnotesize
39204 IC_RESULT = IC_LEFT | IC_RIGHT;
39205 \end_layout
39206
39207 \end_inset
39208 </cell>
39209 </row>
39210 <row topline="true">
39211 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39212 \begin_inset Text
39213
39214 \begin_layout Standard
39215
39216 \size footnotesize
39217 BITWISEAND
39218 \end_layout
39219
39220 \end_inset
39221 </cell>
39222 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39223 \begin_inset Text
39224
39225 \begin_layout Standard
39226
39227 \size footnotesize
39228 IC_LEFT() IC_RIGHT() IC_RESULT()
39229 \end_layout
39230
39231 \end_inset
39232 </cell>
39233 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39234 \begin_inset Text
39235
39236 \begin_layout Standard
39237
39238 \size footnotesize
39239 Bitwise AND 
39240 \end_layout
39241
39242 \end_inset
39243 </cell>
39244 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
39245 \begin_inset Text
39246
39247 \begin_layout Standard
39248
39249 \size footnotesize
39250 IC_RESULT = IC_LEFT & IC_RIGHT;
39251 \end_layout
39252
39253 \end_inset
39254 </cell>
39255 </row>
39256 <row topline="true">
39257 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39258 \begin_inset Text
39259
39260 \begin_layout Standard
39261
39262 \size footnotesize
39263 LEFT_OP
39264 \end_layout
39265
39266 \end_inset
39267 </cell>
39268 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39269 \begin_inset Text
39270
39271 \begin_layout Standard
39272
39273 \size footnotesize
39274 IC_LEFT() IC_RIGHT() IC_RESULT()
39275 \end_layout
39276
39277 \end_inset
39278 </cell>
39279 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39280 \begin_inset Text
39281
39282 \begin_layout Standard
39283
39284 \size footnotesize
39285 Left shift 
39286 \end_layout
39287
39288 \end_inset
39289 </cell>
39290 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
39291 \begin_inset Text
39292
39293 \begin_layout Standard
39294
39295 \size footnotesize
39296 IC_RESULT = IC_LEFT << IC_RIGHT 
39297 \end_layout
39298
39299 \end_inset
39300 </cell>
39301 </row>
39302 <row topline="true">
39303 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39304 \begin_inset Text
39305
39306 \begin_layout Standard
39307
39308 \size footnotesize
39309 RIGHT_OP
39310 \end_layout
39311
39312 \end_inset
39313 </cell>
39314 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39315 \begin_inset Text
39316
39317 \begin_layout Standard
39318
39319 \size footnotesize
39320 IC_LEFT() IC_RIGHT() IC_RESULT()
39321 \end_layout
39322
39323 \end_inset
39324 </cell>
39325 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39326 \begin_inset Text
39327
39328 \begin_layout Standard
39329
39330 \size footnotesize
39331 Right shift
39332 \end_layout
39333
39334 \end_inset
39335 </cell>
39336 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
39337 \begin_inset Text
39338
39339 \begin_layout Standard
39340
39341 \size footnotesize
39342 IC_RESULT = IC_LEFT >> IC_RIGHT 
39343 \end_layout
39344
39345 \end_inset
39346 </cell>
39347 </row>
39348 <row topline="true">
39349 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39350 \begin_inset Text
39351
39352 \begin_layout Standard
39353
39354 \size footnotesize
39355 GET_VALUE_
39356 \newline
39357 AT_ ADDRESS
39358 \end_layout
39359
39360 \end_inset
39361 </cell>
39362 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39363 \begin_inset Text
39364
39365 \begin_layout Standard
39366
39367 \size footnotesize
39368 IC_LEFT() IC_RESULT()
39369 \end_layout
39370
39371 \end_inset
39372 </cell>
39373 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39374 \begin_inset Text
39375
39376 \begin_layout Standard
39377
39378 \size footnotesize
39379 Indirect fetch 
39380 \end_layout
39381
39382 \end_inset
39383 </cell>
39384 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
39385 \begin_inset Text
39386
39387 \begin_layout Standard
39388
39389 \size footnotesize
39390 IC_RESULT = (*IC_LEFT);
39391 \end_layout
39392
39393 \end_inset
39394 </cell>
39395 </row>
39396 <row topline="true">
39397 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39398 \begin_inset Text
39399
39400 \begin_layout Standard
39401
39402 \size footnotesize
39403 POINTER_SET
39404 \end_layout
39405
39406 \end_inset
39407 </cell>
39408 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39409 \begin_inset Text
39410
39411 \begin_layout Standard
39412
39413 \size footnotesize
39414 IC_RIGHT() IC_RESULT() 
39415 \end_layout
39416
39417 \end_inset
39418 </cell>
39419 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39420 \begin_inset Text
39421
39422 \begin_layout Standard
39423
39424 \size footnotesize
39425 Indirect set
39426 \end_layout
39427
39428 \end_inset
39429 </cell>
39430 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
39431 \begin_inset Text
39432
39433 \begin_layout Standard
39434
39435 \size footnotesize
39436 (*IC_RESULT) = IC_RIGHT;
39437 \end_layout
39438
39439 \end_inset
39440 </cell>
39441 </row>
39442 <row topline="true">
39443 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39444 \begin_inset Text
39445
39446 \begin_layout Standard
39447
39448 \size footnotesize
39449 '='
39450 \end_layout
39451
39452 \end_inset
39453 </cell>
39454 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39455 \begin_inset Text
39456
39457 \begin_layout Standard
39458
39459 \size footnotesize
39460 IC_RIGHT() IC_RESULT()
39461 \end_layout
39462
39463 \end_inset
39464 </cell>
39465 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39466 \begin_inset Text
39467
39468 \begin_layout Standard
39469
39470 \size footnotesize
39471 Assignment
39472 \end_layout
39473
39474 \end_inset
39475 </cell>
39476 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
39477 \begin_inset Text
39478
39479 \begin_layout Standard
39480
39481 \size footnotesize
39482 IC_RESULT = IC_RIGHT;
39483 \end_layout
39484
39485 \end_inset
39486 </cell>
39487 </row>
39488 <row topline="true">
39489 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39490 \begin_inset Text
39491
39492 \begin_layout Standard
39493
39494 \size footnotesize
39495 IFX
39496 \end_layout
39497
39498 \end_inset
39499 </cell>
39500 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39501 \begin_inset Text
39502
39503 \begin_layout Standard
39504
39505 \size footnotesize
39506 IC_COND IC_TRUE IC_LABEL
39507 \end_layout
39508
39509 \end_inset
39510 </cell>
39511 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39512 \begin_inset Text
39513
39514 \begin_layout Standard
39515
39516 \size footnotesize
39517 Conditional jump.
39518  If true label is present then jump to true label if condition is true else
39519  jump to false label if condition is false 
39520 \end_layout
39521
39522 \end_inset
39523 </cell>
39524 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
39525 \begin_inset Text
39526
39527 \begin_layout Standard
39528
39529 \size footnotesize
39530 if (IC_COND) goto IC_TRUE; 
39531 \newline
39532 \InsetSpace ~
39533 \InsetSpace ~
39534 Or 
39535 \newline
39536 If (!IC_COND) goto IC_FALSE;
39537 \end_layout
39538
39539 \end_inset
39540 </cell>
39541 </row>
39542 <row topline="true">
39543 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39544 \begin_inset Text
39545
39546 \begin_layout Standard
39547
39548 \size footnotesize
39549 ADDRESS_OF
39550 \end_layout
39551
39552 \end_inset
39553 </cell>
39554 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39555 \begin_inset Text
39556
39557 \begin_layout Standard
39558
39559 \size footnotesize
39560 IC_LEFT() IC_RESULT()
39561 \end_layout
39562
39563 \end_inset
39564 </cell>
39565 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39566 \begin_inset Text
39567
39568 \begin_layout Standard
39569
39570 \size footnotesize
39571 Address of 
39572 \end_layout
39573
39574 \end_inset
39575 </cell>
39576 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
39577 \begin_inset Text
39578
39579 \begin_layout Standard
39580
39581 \size footnotesize
39582 IC_RESULT = &IC_LEFT();
39583 \end_layout
39584
39585 \end_inset
39586 </cell>
39587 </row>
39588 <row topline="true">
39589 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39590 \begin_inset Text
39591
39592 \begin_layout Standard
39593
39594 \size footnotesize
39595 JUMPTABLE
39596 \end_layout
39597
39598 \end_inset
39599 </cell>
39600 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39601 \begin_inset Text
39602
39603 \begin_layout Standard
39604
39605 \size footnotesize
39606 IC_JTCOND IC_JTLABELS
39607 \end_layout
39608
39609 \end_inset
39610 </cell>
39611 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39612 \begin_inset Text
39613
39614 \begin_layout Standard
39615
39616 \size footnotesize
39617 Jump to list of labels depending on the value of JTCOND
39618 \end_layout
39619
39620 \end_inset
39621 </cell>
39622 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
39623 \begin_inset Text
39624
39625 \begin_layout Standard
39626
39627 \size footnotesize
39628 Switch statement
39629 \end_layout
39630
39631 \end_inset
39632 </cell>
39633 </row>
39634 <row topline="true">
39635 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39636 \begin_inset Text
39637
39638 \begin_layout Standard
39639
39640 \size footnotesize
39641 CAST
39642 \end_layout
39643
39644 \end_inset
39645 </cell>
39646 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39647 \begin_inset Text
39648
39649 \begin_layout Standard
39650
39651 \size footnotesize
39652 IC_RIGHT() IC_LEFT() IC_RESULT()
39653 \end_layout
39654
39655 \end_inset
39656 </cell>
39657 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39658 \begin_inset Text
39659
39660 \begin_layout Standard
39661
39662 \size footnotesize
39663 Cast types 
39664 \end_layout
39665
39666 \end_inset
39667 </cell>
39668 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
39669 \begin_inset Text
39670
39671 \begin_layout Standard
39672
39673 \size footnotesize
39674 IC_RESULT = (typeof IC_LEFT) IC_RIGHT;
39675 \end_layout
39676
39677 \end_inset
39678 </cell>
39679 </row>
39680 <row topline="true">
39681 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39682 \begin_inset Text
39683
39684 \begin_layout Standard
39685
39686 \size footnotesize
39687 SEND
39688 \end_layout
39689
39690 \end_inset
39691 </cell>
39692 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39693 \begin_inset Text
39694
39695 \begin_layout Standard
39696
39697 \size footnotesize
39698 IC_LEFT()
39699 \end_layout
39700
39701 \end_inset
39702 </cell>
39703 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39704 \begin_inset Text
39705
39706 \begin_layout Standard
39707
39708 \size footnotesize
39709 This is used for passing parameters in registers; 
39710 \newline
39711 move IC_LEFT to the next
39712  available parameter register.
39713 \end_layout
39714
39715 \end_inset
39716 </cell>
39717 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
39718 \begin_inset Text
39719
39720 \begin_layout Standard
39721
39722 \size footnotesize
39723 None
39724 \end_layout
39725
39726 \end_inset
39727 </cell>
39728 </row>
39729 <row topline="true">
39730 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39731 \begin_inset Text
39732
39733 \begin_layout Standard
39734
39735 \size footnotesize
39736 RECV
39737 \end_layout
39738
39739 \end_inset
39740 </cell>
39741 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39742 \begin_inset Text
39743
39744 \begin_layout Standard
39745
39746 \size footnotesize
39747 IC_RESULT()
39748 \end_layout
39749
39750 \end_inset
39751 </cell>
39752 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39753 \begin_inset Text
39754
39755 \begin_layout Standard
39756
39757 \size footnotesize
39758 This is used for receiving parameters passed in registers;
39759 \newline
39760 Move the values
39761  in the next parameter register to IC_RESULT 
39762 \end_layout
39763
39764 \end_inset
39765 </cell>
39766 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
39767 \begin_inset Text
39768
39769 \begin_layout Standard
39770
39771 \size footnotesize
39772 None
39773 \end_layout
39774
39775 \end_inset
39776 </cell>
39777 </row>
39778 <row topline="true" bottomline="true">
39779 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39780 \begin_inset Text
39781
39782 \begin_layout Standard
39783
39784 \shape slanted
39785 \size footnotesize
39786 (some more have been added)
39787 \end_layout
39788
39789 \end_inset
39790 </cell>
39791 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39792 \begin_inset Text
39793
39794 \begin_layout Standard
39795
39796 \end_layout
39797
39798 \end_inset
39799 </cell>
39800 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39801 \begin_inset Text
39802
39803 \begin_layout Standard
39804
39805 \end_layout
39806
39807 \end_inset
39808 </cell>
39809 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
39810 \begin_inset Text
39811
39812 \begin_layout Standard
39813
39814 \shape slanted
39815 \size footnotesize
39816 see f.e.
39817  
39818 \family typewriter
39819 gen51Code()
39820 \family default
39821  in 
39822 \family typewriter
39823 src/mcs51/gen.c
39824 \end_layout
39825
39826 \end_inset
39827 </cell>
39828 </row>
39829 </lyxtabular>
39830
39831 \end_inset
39832
39833
39834 \end_layout
39835
39836 \begin_layout Standard
39837 \begin_inset Note Note
39838 status collapsed
39839
39840 \begin_layout Standard
39841 In the original article Figure II was announced to be downloadable on 
39842 \shape italic
39843 Circuit Cellar
39844 \shape default
39845 's web site.
39846  ftp://ftp.circuitcellar.com/pub/Circuit_Cellar/2000/121/dutta.ZIP
39847 \end_layout
39848
39849 \end_inset
39850
39851
39852 \end_layout
39853
39854 \begin_layout Paragraph*
39855 ICode Example
39856 \begin_inset LatexCommand \index{iCode}
39857
39858 \end_inset
39859
39860
39861 \end_layout
39862
39863 \begin_layout Standard
39864 This section shows some details of iCode.
39865  The example C code does not do anything useful; it is used as an example
39866  to illustrate the intermediate code generated by the compiler.
39867 \end_layout
39868
39869 \begin_layout Verse
39870
39871 \family typewriter
39872 1.\InsetSpace ~
39873 xdata int * p;
39874 \newline
39875 2.\InsetSpace ~
39876 int gint;
39877 \newline
39878 3.\InsetSpace ~
39879 /* This function does nothing useful.
39880  It is used
39881 \newline
39882 4.\InsetSpace ~
39883 \InsetSpace ~
39884 \InsetSpace ~
39885 \InsetSpace ~
39886 for the purpose of explaining iCode */
39887 \newline
39888 5.\InsetSpace ~
39889 short function (data
39890  int *x)
39891 \newline
39892 6.\InsetSpace ~
39893 {
39894 \newline
39895 7.\InsetSpace ~
39896 \InsetSpace ~
39897 \InsetSpace ~
39898 short i=10; \InsetSpace ~
39899 \InsetSpace ~
39900 /* dead initialization eliminated */
39901 \newline
39902 8.\InsetSpace ~
39903 \InsetSpace ~
39904 \InsetSpace ~
39905 short sum=10;
39906  /* dead initialization eliminated */
39907 \newline
39908 9.\InsetSpace ~
39909 \InsetSpace ~
39910 \InsetSpace ~
39911 short mul;
39912 \newline
39913 10.\InsetSpace ~
39914 \InsetSpace ~
39915 int j ;
39916 \newline
39917 11.\InsetSpace ~
39918 \InsetSpace ~
39919 while (*x) *x++
39920  = *p++; 
39921 \newline
39922 12.\InsetSpace ~
39923 \InsetSpace ~
39924 \InsetSpace ~
39925 \InsetSpace ~
39926 sum = 0 ; 
39927 \newline
39928 13.\InsetSpace ~
39929 \InsetSpace ~
39930 mul = 0;
39931 \newline
39932 14.\InsetSpace ~
39933 \InsetSpace ~
39934 /* compiler detects i,j to be induction
39935  variables */
39936 \newline
39937 15.\InsetSpace ~
39938 \InsetSpace ~
39939 for (i = 0, j = 10 ; i < 10 ; i++, j
39940 \family default
39941 -
39942 \begin_inset ERT
39943 status collapsed
39944
39945 \begin_layout Standard
39946
39947
39948 \backslash
39949 /
39950 \end_layout
39951
39952 \end_inset
39953
39954 -
39955 \family typewriter
39956 ) {
39957 \newline
39958 16.\InsetSpace ~
39959 \InsetSpace ~
39960 \InsetSpace ~
39961 \InsetSpace ~
39962 sum += i;
39963 \newline
39964 17.\InsetSpace ~
39965 \InsetSpace ~
39966 \InsetSpace ~
39967 \InsetSpace ~
39968 mul += i * 3; \InsetSpace ~
39969 \InsetSpace ~
39970 /* this multiplication remains */
39971 \newline
39972 18.\InsetSpace ~
39973 \InsetSpace ~
39974 \InsetSpace ~
39975 \InsetSpace ~
39976 gint +=
39977  j * 3;\InsetSpace ~
39978 \InsetSpace ~
39979 /* this multiplication changed to addition */
39980 \newline
39981 19.\InsetSpace ~
39982 \InsetSpace ~
39983 }
39984 \newline
39985 20.\InsetSpace ~
39986 \InsetSpace ~
39987 return sum+mul;
39988 \newline
39989 21.\InsetSpace ~
39990 }
39991 \end_layout
39992
39993 \begin_layout Standard
39994 In addition to the operands each iCode contains information about the filename
39995  and line it corresponds to in the source file.
39996  The first field in the listing should be interpreted as follows:
39997 \newline
39998
39999 \shape italic
40000 \size footnotesize
40001 Filename(linenumber: iCode Execution sequence number : ICode hash table
40002  key : loop depth of the iCode).
40003 \shape default
40004 \size default
40005
40006 \newline
40007 Then follows the human readable form of the ICode operation.
40008  Each operand of this triplet form can be of three basic types a) compiler
40009  generated temporary b) user defined variable c) a constant value.
40010  Note that local variables and parameters are replaced by compiler generated
40011  temporaries.
40012  Live ranges
40013 \begin_inset LatexCommand \index{Live range analysis}
40014
40015 \end_inset
40016
40017  are computed only for temporaries (i.e.
40018  live ranges are not computed for global variables).
40019  Registers
40020 \begin_inset LatexCommand \index{Register allocation}
40021
40022 \end_inset
40023
40024  are allocated for temporaries only.
40025  Operands are formatted in the following manner:
40026 \newline
40027
40028 \shape italic
40029 \size footnotesize
40030 Operand Name [lr live-from : live-to ] { type information } [ registers
40031  allocated ].
40032 \shape default
40033 \size default
40034
40035 \newline
40036 As mentioned earlier the live ranges are computed in terms of the execution
40037  sequence number of the iCodes, for example 
40038 \newline
40039 the iTemp0 is live from (i.e.
40040  first defined in iCode with execution sequence number 3, and is last used
40041  in the iCode with sequence number 5).
40042  For induction variables such as iTemp21 the live range computation extends
40043  the lifetime from the start to the end of the loop.
40044 \newline
40045 The register allocator
40046  used the live range information to allocate registers, the same registers
40047  may be used for different temporaries if their live ranges do not overlap,
40048  for example r0 is allocated to both iTemp6 and to iTemp17 since their live
40049  ranges do not overlap.
40050  In addition the allocator also takes into consideration the type and usage
40051  of a temporary, for example itemp6 is a pointer to near space and is used
40052  as to fetch data from (i.e.
40053  used in GET_VALUE_AT_ADDRESS) so it is allocated a pointer register (r0).
40054  Some short lived temporaries are allocated to special registers which have
40055  meaning to the code generator e.g.
40056  iTemp13 is allocated to a pseudo register CC which tells the back end that
40057  the temporary is used only for a conditional jump the code generation makes
40058  use of this information to optimize a compare and jump ICode.
40059 \newline
40060 There are several
40061  loop optimizations
40062 \begin_inset LatexCommand \index{Loop optimization}
40063
40064 \end_inset
40065
40066  performed by the compiler.
40067  It can detect induction variables iTemp21(i) and iTemp23(j).
40068  Also note the compiler does selective strength reduction
40069 \begin_inset LatexCommand \index{Strength reduction}
40070
40071 \end_inset
40072
40073 , i.e.
40074  the multiplication of an induction variable in line 18 (gint = j * 3) is
40075  changed to addition, a new temporary iTemp17 is allocated and assigned
40076  a initial value, a constant 3 is then added for each iteration of the loop.
40077  The compiler does not change the multiplication
40078 \begin_inset LatexCommand \index{Multiplication}
40079
40080 \end_inset
40081
40082  in line 17 however since the processor does support an 8 * 8 bit multiplication.
40083 \newline
40084
40085 Note the dead code elimination
40086 \begin_inset LatexCommand \index{Dead-code elimination}
40087
40088 \end_inset
40089
40090  optimization eliminated the dead assignments in line 7 & 8 to I and sum
40091  respectively.
40092 \newline
40093
40094 \end_layout
40095
40096 \begin_layout Standard
40097
40098 \size footnotesize
40099 Sample.c (5:1:0:0) _entry($9) :
40100 \end_layout
40101
40102 \begin_layout Standard
40103
40104 \size footnotesize
40105 Sample.c(5:2:1:0) proc _function [lr0:0]{function short}
40106 \end_layout
40107
40108 \begin_layout Standard
40109
40110 \size footnotesize
40111 Sample.c(11:3:2:0) iTemp0 [lr3:5]{_near * int}[r2] = recv 
40112 \end_layout
40113
40114 \begin_layout Standard
40115
40116 \size footnotesize
40117 Sample.c(11:4:53:0) preHeaderLbl0($11) :
40118 \end_layout
40119
40120 \begin_layout Standard
40121
40122 \size footnotesize
40123 Sample.c(11:5:55:0) iTemp6 [lr5:16]{_near * int}[r0] := iTemp0 [lr3:5]{_near
40124  * int}[r2]
40125 \end_layout
40126
40127 \begin_layout Standard
40128
40129 \size footnotesize
40130 Sample.c(11:6:5:1) _whilecontinue_0($1) :
40131 \end_layout
40132
40133 \begin_layout Standard
40134
40135 \size footnotesize
40136 Sample.c(11:7:7:1) iTemp4 [lr7:8]{int}[r2 r3] = @[iTemp6 [lr5:16]{_near *
40137  int}[r0]]
40138 \end_layout
40139
40140 \begin_layout Standard
40141
40142 \size footnotesize
40143 Sample.c(11:8:8:1) if iTemp4 [lr7:8]{int}[r2 r3] == 0 goto _whilebreak_0($3)
40144 \end_layout
40145
40146 \begin_layout Standard
40147
40148 \size footnotesize
40149 Sample.c(11:9:14:1) iTemp7 [lr9:13]{_far * int}[DPTR] := _p [lr0:0]{_far
40150  * int}
40151 \end_layout
40152
40153 \begin_layout Standard
40154
40155 \size footnotesize
40156 Sample.c(11:10:15:1) _p [lr0:0]{_far * int} = _p [lr0:0]{_far * int} + 0x2
40157  {short}
40158 \end_layout
40159
40160 \begin_layout Standard
40161
40162 \size footnotesize
40163 Sample.c(11:13:18:1) iTemp10 [lr13:14]{int}[r2 r3] = @[iTemp7 [lr9:13]{_far
40164  * int}[DPTR]]
40165 \end_layout
40166
40167 \begin_layout Standard
40168
40169 \size footnotesize
40170 Sample.c(11:14:19:1) *(iTemp6 [lr5:16]{_near * int}[r0]) := iTemp10 [lr13:14]{int
40171 }[r2 r3]
40172 \end_layout
40173
40174 \begin_layout Standard
40175
40176 \size footnotesize
40177 Sample.c(11:15:12:1) iTemp6 [lr5:16]{_near * int}[r0] = iTemp6 [lr5:16]{_near
40178  * int}[r0] + 0x2 {short}
40179 \end_layout
40180
40181 \begin_layout Standard
40182
40183 \size footnotesize
40184 Sample.c(11:16:20:1) goto _whilecontinue_0($1)
40185 \end_layout
40186
40187 \begin_layout Standard
40188
40189 \size footnotesize
40190 Sample.c(11:17:21:0)_whilebreak_0($3) :
40191 \end_layout
40192
40193 \begin_layout Standard
40194
40195 \size footnotesize
40196 Sample.c(12:18:22:0) iTemp2 [lr18:40]{short}[r2] := 0x0 {short}
40197 \end_layout
40198
40199 \begin_layout Standard
40200
40201 \size footnotesize
40202 Sample.c(13:19:23:0) iTemp11 [lr19:40]{short}[r3] := 0x0 {short}
40203 \end_layout
40204
40205 \begin_layout Standard
40206
40207 \size footnotesize
40208 Sample.c(15:20:54:0)preHeaderLbl1($13) :
40209 \end_layout
40210
40211 \begin_layout Standard
40212
40213 \size footnotesize
40214 Sample.c(15:21:56:0) iTemp21 [lr21:38]{short}[r4] := 0x0 {short}
40215 \end_layout
40216
40217 \begin_layout Standard
40218
40219 \size footnotesize
40220 Sample.c(15:22:57:0) iTemp23 [lr22:38]{int}[r5 r6] := 0xa {int}
40221 \end_layout
40222
40223 \begin_layout Standard
40224
40225 \size footnotesize
40226 Sample.c(15:23:58:0) iTemp17 [lr23:38]{int}[r7 r0] := 0x1e {int}
40227 \end_layout
40228
40229 \begin_layout Standard
40230
40231 \size footnotesize
40232 Sample.c(15:24:26:1)_forcond_0($4) :
40233 \end_layout
40234
40235 \begin_layout Standard
40236
40237 \size footnotesize
40238 Sample.c(15:25:27:1) iTemp13 [lr25:26]{char}[CC] = iTemp21 [lr21:38]{short}[r4]
40239  < 0xa {short}
40240 \end_layout
40241
40242 \begin_layout Standard
40243
40244 \size footnotesize
40245 Sample.c(15:26:28:1) if iTemp13 [lr25:26]{char}[CC] == 0 goto _forbreak_0($7)
40246 \end_layout
40247
40248 \begin_layout Standard
40249
40250 \size footnotesize
40251 Sample.c(16:27:31:1) iTemp2 [lr18:40]{short}[r2] = iTemp2 [lr18:40]{short}[r2]
40252  + ITemp21 [lr21:38]{short}[r4]
40253 \end_layout
40254
40255 \begin_layout Standard
40256
40257 \size footnotesize
40258 Sample.c(17:29:33:1) iTemp15 [lr29:30]{short}[r1] = iTemp21 [lr21:38]{short}[r4]
40259  * 0x3 {short}
40260 \end_layout
40261
40262 \begin_layout Standard
40263
40264 \size footnotesize
40265 Sample.c(17:30:34:1) iTemp11 [lr19:40]{short}[r3] = iTemp11 [lr19:40]{short}[r3]
40266  + iTemp15 [lr29:30]{short}[r1]
40267 \end_layout
40268
40269 \begin_layout Standard
40270
40271 \size footnotesize
40272 Sample.c(18:32:36:1:1) iTemp17 [lr23:38]{int}[r7 r0]= iTemp17 [lr23:38]{int}[r7
40273  r0]- 0x3 {short}
40274 \end_layout
40275
40276 \begin_layout Standard
40277
40278 \size footnotesize
40279 Sample.c(18:33:37:1) _gint [lr0:0]{int} = _gint [lr0:0]{int} + iTemp17 [lr23:38]{
40280 int}[r7 r0]
40281 \end_layout
40282
40283 \begin_layout Standard
40284
40285 \size footnotesize
40286 Sample.c(15:36:42:1) iTemp21 [lr21:38]{short}[r4] = iTemp21 [lr21:38]{short}[r4]
40287  + 0x1 {short}
40288 \end_layout
40289
40290 \begin_layout Standard
40291
40292 \size footnotesize
40293 Sample.c(15:37:45:1) iTemp23 [lr22:38]{int}[r5 r6]= iTemp23 [lr22:38]{int}[r5
40294  r6]- 0x1 {short}
40295 \end_layout
40296
40297 \begin_layout Standard
40298
40299 \size footnotesize
40300 Sample.c(19:38:47:1) goto _forcond_0($4)
40301 \end_layout
40302
40303 \begin_layout Standard
40304
40305 \size footnotesize
40306 Sample.c(19:39:48:0)_forbreak_0($7) :
40307 \end_layout
40308
40309 \begin_layout Standard
40310
40311 \size footnotesize
40312 Sample.c(20:40:49:0) iTemp24 [lr40:41]{short}[DPTR] = iTemp2 [lr18:40]{short}[r2]
40313  + ITemp11 [lr19:40]{short}[r3]
40314 \end_layout
40315
40316 \begin_layout Standard
40317
40318 \size footnotesize
40319 Sample.c(20:41:50:0) ret iTemp24 [lr40:41]{short}
40320 \end_layout
40321
40322 \begin_layout Standard
40323
40324 \size footnotesize
40325 Sample.c(20:42:51:0)_return($8) :
40326 \end_layout
40327
40328 \begin_layout Standard
40329
40330 \size footnotesize
40331 Sample.c(20:43:52:0) eproc _function [lr0:0]{ ia0 re0 rm0}{function short}
40332 \size default
40333
40334 \newline
40335
40336 \newline
40337 Finally the code generated for this function:
40338 \newline
40339
40340 \end_layout
40341
40342 \begin_layout Standard
40343
40344 \size footnotesize
40345 .area DSEG (DATA)
40346 \end_layout
40347
40348 \begin_layout Standard
40349
40350 \size footnotesize
40351 _p::
40352 \end_layout
40353
40354 \begin_layout Standard
40355
40356 \size footnotesize
40357 \InsetSpace ~
40358 \InsetSpace ~
40359 .ds 2
40360 \end_layout
40361
40362 \begin_layout Standard
40363
40364 \size footnotesize
40365 _gint::
40366 \end_layout
40367
40368 \begin_layout Standard
40369
40370 \size footnotesize
40371 \InsetSpace ~
40372 \InsetSpace ~
40373 .ds 2
40374 \end_layout
40375
40376 \begin_layout Standard
40377
40378 \size footnotesize
40379 ; sample.c 5
40380 \end_layout
40381
40382 \begin_layout Standard
40383
40384 \size footnotesize
40385 ; ----------------------------------------------
40386 \end_layout
40387
40388 \begin_layout Standard
40389
40390 \size footnotesize
40391 ; function function
40392 \end_layout
40393
40394 \begin_layout Standard
40395
40396 \size footnotesize
40397 ; ----------------------------------------------
40398 \end_layout
40399
40400 \begin_layout Standard
40401
40402 \size footnotesize
40403 _function:
40404 \end_layout
40405
40406 \begin_layout Standard
40407
40408 \size footnotesize
40409 ; iTemp0 [lr3:5]{_near * int}[r2] = recv 
40410 \end_layout
40411
40412 \begin_layout Standard
40413
40414 \size footnotesize
40415 \InsetSpace ~
40416 \InsetSpace ~
40417 mov r2,dpl
40418 \end_layout
40419
40420 \begin_layout Standard
40421
40422 \size footnotesize
40423 ; iTemp6 [lr5:16]{_near * int}[r0] := iTemp0 [lr3:5]{_near * int}[r2]
40424 \end_layout
40425
40426 \begin_layout Standard
40427
40428 \size footnotesize
40429 \InsetSpace ~
40430 \InsetSpace ~
40431 mov ar0,r2
40432 \end_layout
40433
40434 \begin_layout Standard
40435
40436 \size footnotesize
40437 ;_whilecontinue_0($1) :
40438 \end_layout
40439
40440 \begin_layout Standard
40441
40442 \size footnotesize
40443 00101$:
40444 \end_layout
40445
40446 \begin_layout Standard
40447
40448 \size footnotesize
40449 ; iTemp4 [lr7:8]{int}[r2 r3] = @[iTemp6 [lr5:16]{_near * int}[r0]]
40450 \end_layout
40451
40452 \begin_layout Standard
40453
40454 \size footnotesize
40455 ; if iTemp4 [lr7:8]{int}[r2 r3] == 0 goto _whilebreak_0($3)
40456 \end_layout
40457
40458 \begin_layout Standard
40459
40460 \size footnotesize
40461 \InsetSpace ~
40462 \InsetSpace ~
40463 mov ar2,@r0
40464 \end_layout
40465
40466 \begin_layout Standard
40467
40468 \size footnotesize
40469 \InsetSpace ~
40470 \InsetSpace ~
40471 inc r0
40472 \end_layout
40473
40474 \begin_layout Standard
40475
40476 \size footnotesize
40477 \InsetSpace ~
40478 \InsetSpace ~
40479 mov ar3,@r0
40480 \end_layout
40481
40482 \begin_layout Standard
40483
40484 \size footnotesize
40485 \InsetSpace ~
40486 \InsetSpace ~
40487 dec r0
40488 \end_layout
40489
40490 \begin_layout Standard
40491
40492 \size footnotesize
40493 \InsetSpace ~
40494 \InsetSpace ~
40495 mov a,r2
40496 \end_layout
40497
40498 \begin_layout Standard
40499
40500 \size footnotesize
40501 \InsetSpace ~
40502 \InsetSpace ~
40503 orl a,r3
40504 \end_layout
40505
40506 \begin_layout Standard
40507
40508 \size footnotesize
40509 \InsetSpace ~
40510 \InsetSpace ~
40511 jz 00103$
40512 \end_layout
40513
40514 \begin_layout Standard
40515
40516 \size footnotesize
40517 00114$:
40518 \end_layout
40519
40520 \begin_layout Standard
40521
40522 \size footnotesize
40523 ; iTemp7 [lr9:13]{_far * int}[DPTR] := _p [lr0:0]{_far * int}
40524 \end_layout
40525
40526 \begin_layout Standard
40527
40528 \size footnotesize
40529 \InsetSpace ~
40530 \InsetSpace ~
40531 mov dpl,_p
40532 \end_layout
40533
40534 \begin_layout Standard
40535
40536 \size footnotesize
40537 \InsetSpace ~
40538 \InsetSpace ~
40539 mov dph,(_p + 1)
40540 \end_layout
40541
40542 \begin_layout Standard
40543
40544 \size footnotesize
40545 ; _p [lr0:0]{_far * int} = _p [lr0:0]{_far * int} + 0x2 {short}
40546 \end_layout
40547
40548 \begin_layout Standard
40549
40550 \size footnotesize
40551 \InsetSpace ~
40552 \InsetSpace ~
40553 mov a,#0x02
40554 \end_layout
40555
40556 \begin_layout Standard
40557
40558 \size footnotesize
40559 \InsetSpace ~
40560 \InsetSpace ~
40561 add a,_p
40562 \end_layout
40563
40564 \begin_layout Standard
40565
40566 \size footnotesize
40567 \InsetSpace ~
40568 \InsetSpace ~
40569 mov _p,a
40570 \end_layout
40571
40572 \begin_layout Standard
40573
40574 \size footnotesize
40575 \InsetSpace ~
40576 \InsetSpace ~
40577 clr a
40578 \end_layout
40579
40580 \begin_layout Standard
40581
40582 \size footnotesize
40583 \InsetSpace ~
40584 \InsetSpace ~
40585 addc a,(_p + 1)
40586 \end_layout
40587
40588 \begin_layout Standard
40589
40590 \size footnotesize
40591 \InsetSpace ~
40592 \InsetSpace ~
40593 mov (_p + 1),a
40594 \end_layout
40595
40596 \begin_layout Standard
40597
40598 \size footnotesize
40599 ; iTemp10 [lr13:14]{int}[r2 r3] = @[iTemp7 [lr9:13]{_far * int}[DPTR]]
40600 \end_layout
40601
40602 \begin_layout Standard
40603
40604 \size footnotesize
40605 \InsetSpace ~
40606 \InsetSpace ~
40607 movx a,@dptr
40608 \end_layout
40609
40610 \begin_layout Standard
40611
40612 \size footnotesize
40613 \InsetSpace ~
40614 \InsetSpace ~
40615 mov r2,a
40616 \end_layout
40617
40618 \begin_layout Standard
40619
40620 \size footnotesize
40621 \InsetSpace ~
40622 \InsetSpace ~
40623 inc dptr
40624 \end_layout
40625
40626 \begin_layout Standard
40627
40628 \size footnotesize
40629 \InsetSpace ~
40630 \InsetSpace ~
40631 movx a,@dptr
40632 \end_layout
40633
40634 \begin_layout Standard
40635
40636 \size footnotesize
40637 \InsetSpace ~
40638 \InsetSpace ~
40639 mov r3,a
40640 \end_layout
40641
40642 \begin_layout Standard
40643
40644 \size footnotesize
40645 ; *(iTemp6 [lr5:16]{_near * int}[r0]) := iTemp10 [lr13:14]{int}[r2 r3]
40646 \end_layout
40647
40648 \begin_layout Standard
40649
40650 \size footnotesize
40651 \InsetSpace ~
40652 \InsetSpace ~
40653 mov @r0,ar2
40654 \end_layout
40655
40656 \begin_layout Standard
40657
40658 \size footnotesize
40659 \InsetSpace ~
40660 \InsetSpace ~
40661 inc r0
40662 \end_layout
40663
40664 \begin_layout Standard
40665
40666 \size footnotesize
40667 \InsetSpace ~
40668 \InsetSpace ~
40669 mov @r0,ar3
40670 \end_layout
40671
40672 \begin_layout Standard
40673
40674 \size footnotesize
40675 ; iTemp6 [lr5:16]{_near * int}[r0] = 
40676 \end_layout
40677
40678 \begin_layout Standard
40679
40680 \size footnotesize
40681 ; iTemp6 [lr5:16]{_near * int}[r0] + 
40682 \end_layout
40683
40684 \begin_layout Standard
40685
40686 \size footnotesize
40687 ; 0x2 {short}
40688 \end_layout
40689
40690 \begin_layout Standard
40691
40692 \size footnotesize
40693 \InsetSpace ~
40694 \InsetSpace ~
40695 inc r0
40696 \end_layout
40697
40698 \begin_layout Standard
40699
40700 \size footnotesize
40701 ; goto _whilecontinue_0($1)
40702 \end_layout
40703
40704 \begin_layout Standard
40705
40706 \size footnotesize
40707 \InsetSpace ~
40708 \InsetSpace ~
40709 sjmp 00101$
40710 \end_layout
40711
40712 \begin_layout Standard
40713
40714 \size footnotesize
40715 ; _whilebreak_0($3) :
40716 \end_layout
40717
40718 \begin_layout Standard
40719
40720 \size footnotesize
40721 00103$:
40722 \end_layout
40723
40724 \begin_layout Standard
40725
40726 \size footnotesize
40727 ; iTemp2 [lr18:40]{short}[r2] := 0x0 {short}
40728 \end_layout
40729
40730 \begin_layout Standard
40731
40732 \size footnotesize
40733 \InsetSpace ~
40734 \InsetSpace ~
40735 mov r2,#0x00
40736 \end_layout
40737
40738 \begin_layout Standard
40739
40740 \size footnotesize
40741 ; iTemp11 [lr19:40]{short}[r3] := 0x0 {short}
40742 \end_layout
40743
40744 \begin_layout Standard
40745
40746 \size footnotesize
40747 \InsetSpace ~
40748 \InsetSpace ~
40749 mov r3,#0x00
40750 \end_layout
40751
40752 \begin_layout Standard
40753
40754 \size footnotesize
40755 ; iTemp21 [lr21:38]{short}[r4] := 0x0 {short}
40756 \end_layout
40757
40758 \begin_layout Standard
40759
40760 \size footnotesize
40761 \InsetSpace ~
40762 \InsetSpace ~
40763 mov r4,#0x00
40764 \end_layout
40765
40766 \begin_layout Standard
40767
40768 \size footnotesize
40769 ; iTemp23 [lr22:38]{int}[r5 r6] := 0xa {int}
40770 \end_layout
40771
40772 \begin_layout Standard
40773
40774 \size footnotesize
40775 \InsetSpace ~
40776 \InsetSpace ~
40777 mov r5,#0x0A
40778 \end_layout
40779
40780 \begin_layout Standard
40781
40782 \size footnotesize
40783 \InsetSpace ~
40784 \InsetSpace ~
40785 mov r6,#0x00
40786 \end_layout
40787
40788 \begin_layout Standard
40789
40790 \size footnotesize
40791 ; iTemp17 [lr23:38]{int}[r7 r0] := 0x1e {int}
40792 \end_layout
40793
40794 \begin_layout Standard
40795
40796 \size footnotesize
40797 \InsetSpace ~
40798 \InsetSpace ~
40799 mov r7,#0x1E
40800 \end_layout
40801
40802 \begin_layout Standard
40803
40804 \size footnotesize
40805 \InsetSpace ~
40806 \InsetSpace ~
40807 mov r0,#0x00
40808 \end_layout
40809
40810 \begin_layout Standard
40811
40812 \size footnotesize
40813 ; _forcond_0($4) :
40814 \end_layout
40815
40816 \begin_layout Standard
40817
40818 \size footnotesize
40819 00104$:
40820 \end_layout
40821
40822 \begin_layout Standard
40823
40824 \size footnotesize
40825 ; iTemp13 [lr25:26]{char}[CC] = iTemp21 [lr21:38]{short}[r4] < 0xa {short}
40826 \end_layout
40827
40828 \begin_layout Standard
40829
40830 \size footnotesize
40831 ; if iTemp13 [lr25:26]{char}[CC] == 0 goto _forbreak_0($7)
40832 \end_layout
40833
40834 \begin_layout Standard
40835
40836 \size footnotesize
40837 \InsetSpace ~
40838 \InsetSpace ~
40839 clr c
40840 \end_layout
40841
40842 \begin_layout Standard
40843
40844 \size footnotesize
40845 \InsetSpace ~
40846 \InsetSpace ~
40847 mov a,r4
40848 \end_layout
40849
40850 \begin_layout Standard
40851
40852 \size footnotesize
40853 \InsetSpace ~
40854 \InsetSpace ~
40855 xrl a,#0x80
40856 \end_layout
40857
40858 \begin_layout Standard
40859
40860 \size footnotesize
40861 \InsetSpace ~
40862 \InsetSpace ~
40863 subb a,#0x8a
40864 \end_layout
40865
40866 \begin_layout Standard
40867
40868 \size footnotesize
40869 \InsetSpace ~
40870 \InsetSpace ~
40871 jnc 00107$
40872 \end_layout
40873
40874 \begin_layout Standard
40875
40876 \size footnotesize
40877 00115$:
40878 \end_layout
40879
40880 \begin_layout Standard
40881
40882 \size footnotesize
40883 ; iTemp2 [lr18:40]{short}[r2] = iTemp2 [lr18:40]{short}[r2] + 
40884 \end_layout
40885
40886 \begin_layout Standard
40887
40888 \size footnotesize
40889 ; iTemp21 [lr21:38]{short}[r4]
40890 \end_layout
40891
40892 \begin_layout Standard
40893
40894 \size footnotesize
40895 \InsetSpace ~
40896 \InsetSpace ~
40897 mov a,r4
40898 \end_layout
40899
40900 \begin_layout Standard
40901
40902 \size footnotesize
40903 \InsetSpace ~
40904 \InsetSpace ~
40905 add a,r2
40906 \end_layout
40907
40908 \begin_layout Standard
40909
40910 \size footnotesize
40911 \InsetSpace ~
40912 \InsetSpace ~
40913 mov r2,a
40914 \end_layout
40915
40916 \begin_layout Standard
40917
40918 \size footnotesize
40919 ; iTemp15 [lr29:30]{short}[r1] = iTemp21 [lr21:38]{short}[r4] * 0x3 {short}
40920 \end_layout
40921
40922 \begin_layout Standard
40923
40924 \size footnotesize
40925 \InsetSpace ~
40926 \InsetSpace ~
40927 mov b,#0x03
40928 \end_layout
40929
40930 \begin_layout Standard
40931
40932 \size footnotesize
40933 \InsetSpace ~
40934 \InsetSpace ~
40935 mov a,r4
40936 \end_layout
40937
40938 \begin_layout Standard
40939
40940 \size footnotesize
40941 \InsetSpace ~
40942 \InsetSpace ~
40943 mul ab
40944 \end_layout
40945
40946 \begin_layout Standard
40947
40948 \size footnotesize
40949 \InsetSpace ~
40950 \InsetSpace ~
40951 mov r1,a
40952 \end_layout
40953
40954 \begin_layout Standard
40955
40956 \size footnotesize
40957 ; iTemp11 [lr19:40]{short}[r3] = iTemp11 [lr19:40]{short}[r3] + 
40958 \end_layout
40959
40960 \begin_layout Standard
40961
40962 \size footnotesize
40963 ; iTemp15 [lr29:30]{short}[r1]
40964 \end_layout
40965
40966 \begin_layout Standard
40967
40968 \size footnotesize
40969 \InsetSpace ~
40970 \InsetSpace ~
40971 add a,r3
40972 \end_layout
40973
40974 \begin_layout Standard
40975
40976 \size footnotesize
40977 \InsetSpace ~
40978 \InsetSpace ~
40979 mov r3,a
40980 \end_layout
40981
40982 \begin_layout Standard
40983
40984 \size footnotesize
40985 ; iTemp17 [lr23:38]{int}[r7 r0]= iTemp17 [lr23:38]{int}[r7 r0]- 0x3 {short}
40986 \end_layout
40987
40988 \begin_layout Standard
40989
40990 \size footnotesize
40991 \InsetSpace ~
40992 \InsetSpace ~
40993 mov a,r7
40994 \end_layout
40995
40996 \begin_layout Standard
40997
40998 \size footnotesize
40999 \InsetSpace ~
41000 \InsetSpace ~
41001 add a,#0xfd
41002 \end_layout
41003
41004 \begin_layout Standard
41005
41006 \size footnotesize
41007 \InsetSpace ~
41008 \InsetSpace ~
41009 mov r7,a
41010 \end_layout
41011
41012 \begin_layout Standard
41013
41014 \size footnotesize
41015 \InsetSpace ~
41016 \InsetSpace ~
41017 mov a,r0
41018 \end_layout
41019
41020 \begin_layout Standard
41021
41022 \size footnotesize
41023 \InsetSpace ~
41024 \InsetSpace ~
41025 addc a,#0xff
41026 \end_layout
41027
41028 \begin_layout Standard
41029
41030 \size footnotesize
41031 \InsetSpace ~
41032 \InsetSpace ~
41033 mov r0,a
41034 \end_layout
41035
41036 \begin_layout Standard
41037
41038 \size footnotesize
41039 ; _gint [lr0:0]{int} = _gint [lr0:0]{int} + iTemp17 [lr23:38]{int}[r7 r0]
41040 \end_layout
41041
41042 \begin_layout Standard
41043
41044 \size footnotesize
41045 \InsetSpace ~
41046 \InsetSpace ~
41047 mov a,r7
41048 \end_layout
41049
41050 \begin_layout Standard
41051
41052 \size footnotesize
41053 \InsetSpace ~
41054 \InsetSpace ~
41055 add a,_gint
41056 \end_layout
41057
41058 \begin_layout Standard
41059
41060 \size footnotesize
41061 \InsetSpace ~
41062 \InsetSpace ~
41063 mov _gint,a
41064 \end_layout
41065
41066 \begin_layout Standard
41067
41068 \size footnotesize
41069 \InsetSpace ~
41070 \InsetSpace ~
41071 mov a,r0
41072 \end_layout
41073
41074 \begin_layout Standard
41075
41076 \size footnotesize
41077 \InsetSpace ~
41078 \InsetSpace ~
41079 addc a,(_gint + 1)
41080 \end_layout
41081
41082 \begin_layout Standard
41083
41084 \size footnotesize
41085 \InsetSpace ~
41086 \InsetSpace ~
41087 mov (_gint + 1),a
41088 \end_layout
41089
41090 \begin_layout Standard
41091
41092 \size footnotesize
41093 ; iTemp21 [lr21:38]{short}[r4] = iTemp21 [lr21:38]{short}[r4] + 0x1 {short}
41094 \end_layout
41095
41096 \begin_layout Standard
41097
41098 \size footnotesize
41099 \InsetSpace ~
41100 \InsetSpace ~
41101 inc r4
41102 \end_layout
41103
41104 \begin_layout Standard
41105
41106 \size footnotesize
41107 ; iTemp23 [lr22:38]{int}[r5 r6]= iTemp23 [lr22:38]{int}[r5 r6]- 0x1 {short}
41108 \end_layout
41109
41110 \begin_layout Standard
41111
41112 \size footnotesize
41113 \InsetSpace ~
41114 \InsetSpace ~
41115 dec r5
41116 \end_layout
41117
41118 \begin_layout Standard
41119
41120 \size footnotesize
41121 \InsetSpace ~
41122 \InsetSpace ~
41123 cjne r5,#0xff,00104$
41124 \end_layout
41125
41126 \begin_layout Standard
41127
41128 \size footnotesize
41129 \InsetSpace ~
41130 \InsetSpace ~
41131 dec r6
41132 \end_layout
41133
41134 \begin_layout Standard
41135
41136 \size footnotesize
41137 ; goto _forcond_0($4)
41138 \end_layout
41139
41140 \begin_layout Standard
41141
41142 \size footnotesize
41143 \InsetSpace ~
41144 \InsetSpace ~
41145 sjmp 00104$
41146 \end_layout
41147
41148 \begin_layout Standard
41149
41150 \size footnotesize
41151 ; _forbreak_0($7) :
41152 \end_layout
41153
41154 \begin_layout Standard
41155
41156 \size footnotesize
41157 00107$:
41158 \end_layout
41159
41160 \begin_layout Standard
41161
41162 \size footnotesize
41163 ; ret iTemp24 [lr40:41]{short}
41164 \end_layout
41165
41166 \begin_layout Standard
41167
41168 \size footnotesize
41169 \InsetSpace ~
41170 \InsetSpace ~
41171 mov a,r3
41172 \end_layout
41173
41174 \begin_layout Standard
41175
41176 \size footnotesize
41177 \InsetSpace ~
41178 \InsetSpace ~
41179 add a,r2
41180 \end_layout
41181
41182 \begin_layout Standard
41183
41184 \size footnotesize
41185 \InsetSpace ~
41186 \InsetSpace ~
41187 mov dpl,a
41188 \end_layout
41189
41190 \begin_layout Standard
41191
41192 \size footnotesize
41193 ; _return($8) :
41194 \end_layout
41195
41196 \begin_layout Standard
41197
41198 \size footnotesize
41199 00108$:
41200 \end_layout
41201
41202 \begin_layout Standard
41203
41204 \size footnotesize
41205 \InsetSpace ~
41206 \InsetSpace ~
41207 ret
41208 \newline
41209
41210 \end_layout
41211
41212 \begin_layout Section
41213 A few words about basic block successors, predecessors and dominators
41214 \end_layout
41215
41216 \begin_layout Standard
41217 Successors are basic blocks
41218 \begin_inset LatexCommand \index{Basic blocks}
41219
41220 \end_inset
41221
41222  that might execute after this basic block.
41223 \newline
41224 Predecessors are basic blocks
41225  that might execute before reaching this basic block.
41226 \newline
41227 Dominators are basic
41228  blocks that WILL execute before reaching this basic block.
41229 \newline
41230
41231 \end_layout
41232
41233 \begin_layout Standard
41234 [basic block 1]
41235 \end_layout
41236
41237 \begin_layout Standard
41238 if (something)
41239 \end_layout
41240
41241 \begin_layout Standard
41242 \InsetSpace ~
41243 \InsetSpace ~
41244 \InsetSpace ~
41245 \InsetSpace ~
41246 [basic block 2]
41247 \end_layout
41248
41249 \begin_layout Standard
41250 else
41251 \end_layout
41252
41253 \begin_layout Standard
41254 \InsetSpace ~
41255 \InsetSpace ~
41256 \InsetSpace ~
41257 \InsetSpace ~
41258 [basic block 3]
41259 \end_layout
41260
41261 \begin_layout Standard
41262 [basic block 4]
41263 \newline
41264
41265 \end_layout
41266
41267 \begin_layout Standard
41268 a) succList of [BB2] = [BB4], of [BB3] = [BB4], of [BB1] = [BB2,BB3]
41269 \end_layout
41270
41271 \begin_layout Standard
41272 b) predList of [BB2] = [BB1], of [BB3] = [BB1], of [BB4] = [BB2,BB3]
41273 \end_layout
41274
41275 \begin_layout Standard
41276 c) domVect of [BB4] = BB1 ...
41277  here we are not sure if BB2 or BB3 was executed but we are SURE that BB1
41278  was executed.
41279 \end_layout
41280
41281 \begin_layout Chapter
41282 Acknowledgments
41283 \end_layout
41284
41285 \begin_layout Standard
41286 \begin_inset LatexCommand \url{http://sdcc.sourceforge.net/#Who}
41287
41288 \end_inset
41289
41290
41291 \newline
41292
41293 \newline
41294
41295 \emph on
41296 Thanks to all the other volunteer developers who have helped with coding,
41297  testing, web-page creation, distribution sets, etc.
41298  You know who you are :-)
41299 \emph default
41300
41301 \newline
41302
41303 \newline
41304
41305 \emph on
41306 Thanks to Sourceforge 
41307 \begin_inset LatexCommand \url{http://www.sf.net}
41308
41309 \end_inset
41310
41311  which has hosted the project since 1999 and donates significant download
41312  bandwidth.
41313 \emph default
41314
41315 \newline
41316
41317 \newline
41318
41319 \emph on
41320 Also thanks to all SDCC Distributed Compile Farm members for donating CPU
41321  cycles and bandwidth for snapshot builds.
41322 \newline
41323
41324 \end_layout
41325
41326 \begin_layout Standard
41327 This document was initially written by Sandeep Dutta
41328 \end_layout
41329
41330 \begin_layout Standard
41331 All product names mentioned herein may be trademarks
41332 \begin_inset LatexCommand \index{Trademarks}
41333
41334 \end_inset
41335
41336  of their respective companies.
41337  
41338 \end_layout
41339
41340 \begin_layout Section*
41341 Alphabetical index
41342 \end_layout
41343
41344 \begin_layout Standard
41345 To avoid confusion, the installation and building options for SDCC itself
41346  (chapter 2) are not part of the index.
41347 \end_layout
41348
41349 \begin_layout Standard
41350 \begin_inset LatexCommand \printindex{}
41351
41352 \end_inset
41353
41354
41355 \end_layout
41356
41357 \end_body
41358 \end_document