* doc/sdccman.lyx:
[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: 2008-11-16#$ 
112 \newline
113 $Revision: 5272$
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 
1163 \series bold
1164 -
1165 \begin_inset ERT
1166 status collapsed
1167
1168 \begin_layout Standard
1169
1170
1171 \backslash
1172 /
1173 \end_layout
1174
1175 \end_inset
1176
1177 -std-c99
1178 \begin_inset LatexCommand \index{-\/-std-c99}
1179
1180 \end_inset
1181
1182
1183 \series default
1184  regardless of the 
1185 \series bold
1186 -
1187 \begin_inset ERT
1188 status collapsed
1189
1190 \begin_layout Standard
1191
1192
1193 \backslash
1194 /
1195 \end_layout
1196
1197 \end_inset
1198
1199 -std-xxx
1200 \series default
1201  setting.
1202  This is no longer true, and can cause compilation failures on code built
1203  with 
1204 \series bold
1205 -
1206 \begin_inset ERT
1207 status collapsed
1208
1209 \begin_layout Standard
1210
1211
1212 \backslash
1213 /
1214 \end_layout
1215
1216 \end_inset
1217
1218 -std-c89
1219 \begin_inset LatexCommand \index{-\/-std-c89}
1220
1221 \end_inset
1222
1223
1224 \series default
1225  but using c99 preprocessor features, such as one-line (//) comments
1226 \end_layout
1227
1228 \begin_layout Itemize
1229 in versions older then 2.8.4 the pic16 *printf() and printf_tiny() library
1230  functions supported undocumented and not standard compliant 'b' binary
1231  format specifier ("%b", "%hb" and "%lb").
1232  The 'b' specifier is now disabled by default.
1233  It can be enabled by defining BINARY_SPECIFIER macro in files device/lib/pic16/
1234 libc/stdio/vfprintf.c and device/lib/pic16/libc/stdio/printf_tiny.c and recompilin
1235 g the library.
1236 \end_layout
1237
1238 \begin_layout Itemize
1239 in versions older then 2.8.5 the unnamed bitfield structure members participated
1240  in initialization, which is not conforming with ISO/IEC 9899:1999 standard
1241  (see section Section 6.7.8 Initialization, clause 9)
1242 \newline
1243
1244 \newline
1245 Old behavior, before
1246  version 2.8.5:
1247 \family typewriter
1248
1249 \newline
1250 \InsetSpace ~
1251 \InsetSpace ~
1252 struct {
1253 \newline
1254 \InsetSpace ~
1255 \InsetSpace ~
1256 \InsetSpace ~
1257 \InsetSpace ~
1258 int a : 2;
1259 \newline
1260 \InsetSpace ~
1261 \InsetSpace ~
1262 \InsetSpace ~
1263 \InsetSpace ~
1264 char\InsetSpace ~
1265  : 2;
1266 \newline
1267 \InsetSpace ~
1268 \InsetSpace ~
1269 \InsetSpace ~
1270 \InsetSpace ~
1271 int b : 2;
1272 \newline
1273 \InsetSpace ~
1274 \InsetSpace ~
1275 } s = {1, 2, 3};
1276 \family default
1277
1278 \newline
1279
1280 \family typewriter
1281 /* s.a = 1, s.b = 3 */
1282 \family default
1283
1284 \newline
1285
1286 \newline
1287 New behavior:
1288 \family typewriter
1289
1290 \newline
1291 \InsetSpace ~
1292 \InsetSpace ~
1293 struct {
1294 \newline
1295 \InsetSpace ~
1296 \InsetSpace ~
1297 \InsetSpace ~
1298 \InsetSpace ~
1299 int a : 2;
1300 \newline
1301 \InsetSpace ~
1302 \InsetSpace ~
1303 \InsetSpace ~
1304 \InsetSpace ~
1305 char\InsetSpace ~
1306  : 2;
1307 \newline
1308 \InsetSpace ~
1309 \InsetSpace ~
1310 \InsetSpace ~
1311 \InsetSpace ~
1312 int b : 2;
1313 \newline
1314 \InsetSpace ~
1315 \InsetSpace ~
1316 } s = {1, 2};
1317 \family default
1318
1319 \newline
1320
1321 \family typewriter
1322 /* s.a = 1, s.b = 2 */
1323 \end_layout
1324
1325 \begin_layout Section
1326 System Requirements
1327 \end_layout
1328
1329 \begin_layout Standard
1330 What do you need before you start installation of SDCC? A computer, and
1331  a desire to compute.
1332  The preferred method of installation is to compile SDCC from source using
1333  GNU gcc and make.
1334  For Windows some pre-compiled binary distributions are available for your
1335  convenience.
1336  You should have some experience with command line tools and compiler use.
1337 \end_layout
1338
1339 \begin_layout Section
1340 Other Resources
1341 \end_layout
1342
1343 \begin_layout Standard
1344 The SDCC home page at 
1345 \begin_inset LatexCommand \url{http://sdcc.sourceforge.net/}
1346
1347 \end_inset
1348
1349  is a great place to find distribution sets.
1350  You can also find links to the user mailing lists that offer help or discuss
1351  SDCC with other SDCC users.
1352  Web links to other SDCC related sites can also be found here.
1353  This document can be found in the DOC directory of the source package as
1354  a text or HTML file.
1355  A pdf version of this document is available at 
1356 \begin_inset LatexCommand \url{http://sdcc.sourceforge.net/doc/sdccman.pdf}
1357
1358 \end_inset
1359
1360 .
1361  Some of the other tools (simulator and assembler) included with SDCC contain
1362  their own documentation and can be found in the source distribution.
1363  If you want the latest unreleased software, the complete source package
1364  is available directly from Subversion on https://sdcc.svn.sourceforge.net/svnroot/
1365 sdcc/trunk/sdcc.
1366 \end_layout
1367
1368 \begin_layout Section
1369 Wishes for the future
1370 \end_layout
1371
1372 \begin_layout Standard
1373 There are (and always will be) some things that could be done.
1374  Here are some I can think of:
1375 \newline
1376
1377 \end_layout
1378
1379 \begin_layout Standard
1380
1381 \family typewriter
1382 char KernelFunction3(char p) at 0x340;
1383 \newline
1384
1385 \end_layout
1386
1387 \begin_layout Standard
1388
1389 \family typewriter
1390 better code banking
1391 \begin_inset LatexCommand \index{code banking (limited support)}
1392
1393 \end_inset
1394
1395  support for mcs51
1396 \newline
1397
1398 \newline
1399
1400 \family default
1401 If you can think of some more, please see the section 
1402 \begin_inset LatexCommand \ref{sub:Requesting-Features}
1403
1404 \end_inset
1405
1406  about filing feature requests
1407 \begin_inset LatexCommand \index{Requesting features}
1408
1409 \end_inset
1410
1411
1412 \begin_inset LatexCommand \index{Feature request}
1413
1414 \end_inset
1415
1416 .
1417 \newline
1418
1419 \end_layout
1420
1421 \begin_layout Chapter
1422 Installing SDCC
1423 \begin_inset LatexCommand \index{Installation}
1424
1425 \end_inset
1426
1427
1428 \end_layout
1429
1430 \begin_layout Standard
1431 For most users it is sufficient to skip to either section 
1432 \begin_inset LatexCommand \ref{sub:Building-SDCC-on-Linux}
1433
1434 \end_inset
1435
1436  (Unix) or section 
1437 \begin_inset LatexCommand \ref{sub:Windows-Install}
1438
1439 \end_inset
1440
1441  (Windows).
1442  More detailed instructions follow below.
1443 \end_layout
1444
1445 \begin_layout Section
1446 Configure Options
1447 \begin_inset LatexCommand \index{Options SDCC configuration}
1448
1449 \end_inset
1450
1451
1452 \end_layout
1453
1454 \begin_layout Standard
1455 The install paths, search paths and other options are defined when running
1456  'configure'.
1457  The defaults can be overridden by:
1458 \end_layout
1459
1460 \begin_layout List
1461 \labelwidthstring 00.00.0000
1462 -
1463 \begin_inset ERT
1464 status collapsed
1465
1466 \begin_layout Standard
1467
1468
1469 \backslash
1470 /
1471 \end_layout
1472
1473 \end_inset
1474
1475 -prefix see table below
1476 \end_layout
1477
1478 \begin_layout List
1479 \labelwidthstring 00.00.0000
1480 -
1481 \begin_inset ERT
1482 status collapsed
1483
1484 \begin_layout Standard
1485
1486
1487 \backslash
1488 /
1489 \end_layout
1490
1491 \end_inset
1492
1493 -exec_prefix see table below
1494 \end_layout
1495
1496 \begin_layout List
1497 \labelwidthstring 00.00.0000
1498 -
1499 \begin_inset ERT
1500 status collapsed
1501
1502 \begin_layout Standard
1503
1504
1505 \backslash
1506 /
1507 \end_layout
1508
1509 \end_inset
1510
1511 -bindir see table below
1512 \end_layout
1513
1514 \begin_layout List
1515 \labelwidthstring 00.00.0000
1516 -
1517 \begin_inset ERT
1518 status collapsed
1519
1520 \begin_layout Standard
1521
1522
1523 \backslash
1524 /
1525 \end_layout
1526
1527 \end_inset
1528
1529 -datadir see table below
1530 \end_layout
1531
1532 \begin_layout List
1533 \labelwidthstring 00.00.0000
1534 -
1535 \begin_inset ERT
1536 status collapsed
1537
1538 \begin_layout Standard
1539
1540
1541 \backslash
1542 /
1543 \end_layout
1544
1545 \end_inset
1546
1547 -datarootdir see table below
1548 \newline
1549
1550 \end_layout
1551
1552 \begin_layout List
1553 \labelwidthstring 00.00.0000
1554 \InsetSpace ~
1555 \InsetSpace ~
1556 docdir environment variable, see table below
1557 \end_layout
1558
1559 \begin_layout List
1560 \labelwidthstring 00.00.0000
1561 \InsetSpace ~
1562 \InsetSpace ~
1563 include_dir_suffix environment variable, see table below
1564 \end_layout
1565
1566 \begin_layout List
1567 \labelwidthstring 00.00.0000
1568 \InsetSpace ~
1569 \InsetSpace ~
1570 lib_dir_suffix environment variable, see table below
1571 \end_layout
1572
1573 \begin_layout List
1574 \labelwidthstring 00.00.0000
1575 \InsetSpace ~
1576 \InsetSpace ~
1577 sdccconf_h_dir_separator environment variable, either / or 
1578 \backslash
1579
1580 \backslash
1581  makes sense here.
1582  This character will only be used in sdccconf.h; don't forget it's a C-header,
1583  therefore a double-backslash is needed there.
1584 \newline
1585
1586 \end_layout
1587
1588 \begin_layout List
1589 \labelwidthstring 00.00.0000
1590 -
1591 \begin_inset ERT
1592 status collapsed
1593
1594 \begin_layout Standard
1595
1596
1597 \backslash
1598 /
1599 \end_layout
1600
1601 \end_inset
1602
1603 -disable-mcs51-port Excludes the Intel mcs51 port
1604 \end_layout
1605
1606 \begin_layout List
1607 \labelwidthstring 00.00.0000
1608 -
1609 \begin_inset ERT
1610 status collapsed
1611
1612 \begin_layout Standard
1613
1614
1615 \backslash
1616 /
1617 \end_layout
1618
1619 \end_inset
1620
1621 -disable-gbz80-port Excludes the Gameboy gbz80 port
1622 \end_layout
1623
1624 \begin_layout List
1625 \labelwidthstring 00.00.0000
1626 -
1627 \begin_inset ERT
1628 status collapsed
1629
1630 \begin_layout Standard
1631
1632
1633 \backslash
1634 /
1635 \end_layout
1636
1637 \end_inset
1638
1639 -disable-z80-port Excludes the z80 port
1640 \end_layout
1641
1642 \begin_layout List
1643 \labelwidthstring 00.00.0000
1644 -
1645 \begin_inset ERT
1646 status collapsed
1647
1648 \begin_layout Standard
1649
1650
1651 \backslash
1652 /
1653 \end_layout
1654
1655 \end_inset
1656
1657 -disable-avr-port Excludes the AVR port
1658 \end_layout
1659
1660 \begin_layout List
1661 \labelwidthstring 00.00.0000
1662 -
1663 \begin_inset ERT
1664 status collapsed
1665
1666 \begin_layout Standard
1667
1668
1669 \backslash
1670 /
1671 \end_layout
1672
1673 \end_inset
1674
1675 -disable-ds390-port Excludes the DS390 port
1676 \end_layout
1677
1678 \begin_layout List
1679 \labelwidthstring 00.00.0000
1680 -
1681 \begin_inset ERT
1682 status collapsed
1683
1684 \begin_layout Standard
1685
1686
1687 \backslash
1688 /
1689 \end_layout
1690
1691 \end_inset
1692
1693 -disable-hc08-port Excludes the HC08 port
1694 \end_layout
1695
1696 \begin_layout List
1697 \labelwidthstring 00.00.0000
1698 -
1699 \begin_inset ERT
1700 status collapsed
1701
1702 \begin_layout Standard
1703
1704
1705 \backslash
1706 /
1707 \end_layout
1708
1709 \end_inset
1710
1711 -disable-pic-port Excludes the PIC14 port
1712 \end_layout
1713
1714 \begin_layout List
1715 \labelwidthstring 00.00.0000
1716 -
1717 \begin_inset ERT
1718 status collapsed
1719
1720 \begin_layout Standard
1721
1722
1723 \backslash
1724 /
1725 \end_layout
1726
1727 \end_inset
1728
1729 -disable-pic16-port Excludes the PIC16 port
1730 \end_layout
1731
1732 \begin_layout List
1733 \labelwidthstring 00.00.0000
1734 -
1735 \begin_inset ERT
1736 status collapsed
1737
1738 \begin_layout Standard
1739
1740
1741 \backslash
1742 /
1743 \end_layout
1744
1745 \end_inset
1746
1747 -disable-xa51-port Excludes the XA51 port
1748 \end_layout
1749
1750 \begin_layout List
1751 \labelwidthstring 00.00.0000
1752 -
1753 \begin_inset ERT
1754 status collapsed
1755
1756 \begin_layout Standard
1757
1758
1759 \backslash
1760 /
1761 \end_layout
1762
1763 \end_inset
1764
1765 -disable-ucsim Disables configuring and building of ucsim
1766 \end_layout
1767
1768 \begin_layout List
1769 \labelwidthstring 00.00.0000
1770 -
1771 \begin_inset ERT
1772 status collapsed
1773
1774 \begin_layout Standard
1775
1776
1777 \backslash
1778 /
1779 \end_layout
1780
1781 \end_inset
1782
1783 -disable-device-lib Disables automatically building device libraries
1784 \end_layout
1785
1786 \begin_layout List
1787 \labelwidthstring 00.00.0000
1788 -
1789 \begin_inset ERT
1790 status collapsed
1791
1792 \begin_layout Standard
1793
1794
1795 \backslash
1796 /
1797 \end_layout
1798
1799 \end_inset
1800
1801 -disable-packihx Disables building packihx
1802 \newline
1803
1804 \end_layout
1805
1806 \begin_layout List
1807 \labelwidthstring 00.00.0000
1808 -
1809 \begin_inset ERT
1810 status collapsed
1811
1812 \begin_layout Standard
1813
1814
1815 \backslash
1816 /
1817 \end_layout
1818
1819 \end_inset
1820
1821 -enable-doc Build pdf, html and txt files from the lyx sources
1822 \end_layout
1823
1824 \begin_layout List
1825 \labelwidthstring 00.00.0000
1826 -
1827 \begin_inset ERT
1828 status collapsed
1829
1830 \begin_layout Standard
1831
1832
1833 \backslash
1834 /
1835 \end_layout
1836
1837 \end_inset
1838
1839 -enable-libgc Use the Bohem memory allocator.
1840  Lower runtime footprint.
1841 \end_layout
1842
1843 \begin_layout List
1844 \labelwidthstring 00.00.0000
1845 -
1846 \begin_inset ERT
1847 status collapsed
1848
1849 \begin_layout Standard
1850
1851
1852 \backslash
1853 /
1854 \end_layout
1855
1856 \end_inset
1857
1858 -without-ccache Do not use ccache even if available
1859 \end_layout
1860
1861 \begin_layout Standard
1862 Furthermore the environment variables CC, CFLAGS, ...
1863  the tools and their arguments can be influenced.
1864  Please see `configure -
1865 \begin_inset ERT
1866 status collapsed
1867
1868 \begin_layout Standard
1869
1870
1871 \backslash
1872 /
1873 \end_layout
1874
1875 \end_inset
1876
1877 -help' and the man/info pages of `configure' for details.
1878 \newline
1879
1880 \newline
1881 The names of the
1882  standard libraries STD_LIB, STD_INT_LIB, STD_LONG_LIB, STD_FP_LIB, STD_DS390_LI
1883 B, STD_XA51_LIB and the environment variables SDCC_DIR_NAME, SDCC_INCLUDE_NAME,
1884  SDCC_LIB_NAME are defined by `configure' too.
1885  At the moment it's not possible to change the default settings (it was
1886  simply never required).
1887 \newline
1888
1889 \newline
1890 These configure options are compiled into the binaries,
1891  and can only be changed by rerunning 'configure' and recompiling SDCC.
1892  The configure options are written in 
1893 \emph on
1894 italics
1895 \emph default
1896  to distinguish them from run time environment variables (see section search
1897  paths).
1898 \newline
1899
1900 \newline
1901 The settings for 
1902 \begin_inset Quotes sld
1903 \end_inset
1904
1905 Win32 builds
1906 \begin_inset Quotes srd
1907 \end_inset
1908
1909  are used by the SDCC team to build the official Win32 binaries.
1910  The SDCC team uses Mingw32 to build the official Windows binaries, because
1911  it's
1912 \end_layout
1913
1914 \begin_layout Enumerate
1915 open source, 
1916 \end_layout
1917
1918 \begin_layout Enumerate
1919 a gcc compiler and last but not least
1920 \end_layout
1921
1922 \begin_layout Enumerate
1923 the binaries can be built by cross compiling on SDCC Distributed Compile
1924  Farm.
1925 \end_layout
1926
1927 \begin_layout Standard
1928 See the examples, how to pass the Win32 settings to 'configure'.
1929  The other Win32 builds using Borland, VC or whatever don't use 'configure',
1930  but a header file sdcc_vc_in.h is the same as sdccconf.h built by 'configure'
1931  for Win32.
1932 \newline
1933
1934 \newline
1935 These defaults are:
1936 \newline
1937
1938 \end_layout
1939
1940 \begin_layout Standard
1941 \align center
1942 \begin_inset Tabular
1943 <lyxtabular version="3" rows="9" columns="3">
1944 <features>
1945 <column alignment="block" valignment="top" leftline="true" width="0in">
1946 <column alignment="block" valignment="top" leftline="true" width="0in">
1947 <column alignment="block" valignment="top" leftline="true" rightline="true" width="0in">
1948 <row topline="true" bottomline="true">
1949 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1950 \begin_inset Text
1951
1952 \begin_layout Standard
1953 Variable
1954 \end_layout
1955
1956 \end_inset
1957 </cell>
1958 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1959 \begin_inset Text
1960
1961 \begin_layout Standard
1962 default
1963 \end_layout
1964
1965 \end_inset
1966 </cell>
1967 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1968 \begin_inset Text
1969
1970 \begin_layout Standard
1971 Win32 builds
1972 \end_layout
1973
1974 \end_inset
1975 </cell>
1976 </row>
1977 <row topline="true">
1978 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1979 \begin_inset Text
1980
1981 \begin_layout Standard
1982
1983 \emph on
1984 PREFIX
1985 \end_layout
1986
1987 \end_inset
1988 </cell>
1989 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1990 \begin_inset Text
1991
1992 \begin_layout Standard
1993 /usr/local
1994 \end_layout
1995
1996 \end_inset
1997 </cell>
1998 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1999 \begin_inset Text
2000
2001 \begin_layout Standard
2002
2003 \backslash
2004 sdcc
2005 \end_layout
2006
2007 \end_inset
2008 </cell>
2009 </row>
2010 <row topline="true">
2011 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2012 \begin_inset Text
2013
2014 \begin_layout Standard
2015
2016 \emph on
2017 EXEC_PREFIX
2018 \end_layout
2019
2020 \end_inset
2021 </cell>
2022 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2023 \begin_inset Text
2024
2025 \begin_layout Standard
2026
2027 \emph on
2028 $PREFIX
2029 \end_layout
2030
2031 \end_inset
2032 </cell>
2033 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2034 \begin_inset Text
2035
2036 \begin_layout Standard
2037
2038 \emph on
2039 $PREFIX
2040 \end_layout
2041
2042 \end_inset
2043 </cell>
2044 </row>
2045 <row topline="true">
2046 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2047 \begin_inset Text
2048
2049 \begin_layout Standard
2050
2051 \emph on
2052 BINDIR
2053 \end_layout
2054
2055 \end_inset
2056 </cell>
2057 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2058 \begin_inset Text
2059
2060 \begin_layout Standard
2061
2062 \emph on
2063 $EXEC_PREFIX
2064 \emph default
2065 /bin
2066 \end_layout
2067
2068 \end_inset
2069 </cell>
2070 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2071 \begin_inset Text
2072
2073 \begin_layout Standard
2074
2075 \emph on
2076 $EXEC_PREFIX
2077 \emph default
2078
2079 \backslash
2080 bin
2081 \end_layout
2082
2083 \end_inset
2084 </cell>
2085 </row>
2086 <row topline="true">
2087 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2088 \begin_inset Text
2089
2090 \begin_layout Standard
2091
2092 \emph on
2093 DATADIR
2094 \end_layout
2095
2096 \end_inset
2097 </cell>
2098 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2099 \begin_inset Text
2100
2101 \begin_layout Standard
2102
2103 \emph on
2104 $DATAROOTDIR
2105 \end_layout
2106
2107 \end_inset
2108 </cell>
2109 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2110 \begin_inset Text
2111
2112 \begin_layout Standard
2113
2114 \emph on
2115 $DATAROOTDIR
2116 \end_layout
2117
2118 \end_inset
2119 </cell>
2120 </row>
2121 <row topline="true">
2122 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2123 \begin_inset Text
2124
2125 \begin_layout Standard
2126
2127 \emph on
2128 DATAROOTDIR
2129 \end_layout
2130
2131 \end_inset
2132 </cell>
2133 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2134 \begin_inset Text
2135
2136 \begin_layout Standard
2137
2138 \emph on
2139 $PREFIX
2140 \emph default
2141 /share
2142 \end_layout
2143
2144 \end_inset
2145 </cell>
2146 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2147 \begin_inset Text
2148
2149 \begin_layout Standard
2150
2151 \emph on
2152 $PREFIX
2153 \end_layout
2154
2155 \end_inset
2156 </cell>
2157 </row>
2158 <row topline="true">
2159 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2160 \begin_inset Text
2161
2162 \begin_layout Standard
2163
2164 \emph on
2165 DOCDIR
2166 \end_layout
2167
2168 \end_inset
2169 </cell>
2170 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2171 \begin_inset Text
2172
2173 \begin_layout Standard
2174
2175 \emph on
2176 $DATAROOTDIR
2177 \emph default
2178 /sdcc/doc
2179 \end_layout
2180
2181 \end_inset
2182 </cell>
2183 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2184 \begin_inset Text
2185
2186 \begin_layout Standard
2187
2188 \emph on
2189 $DATAROOTDIR
2190 \emph default
2191
2192 \backslash
2193 doc
2194 \end_layout
2195
2196 \end_inset
2197 </cell>
2198 </row>
2199 <row topline="true">
2200 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2201 \begin_inset Text
2202
2203 \begin_layout Standard
2204
2205 \emph on
2206 INCLUDE_DIR_SUFFIX
2207 \end_layout
2208
2209 \end_inset
2210 </cell>
2211 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2212 \begin_inset Text
2213
2214 \begin_layout Standard
2215 sdcc/include
2216 \end_layout
2217
2218 \end_inset
2219 </cell>
2220 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2221 \begin_inset Text
2222
2223 \begin_layout Standard
2224 include
2225 \end_layout
2226
2227 \end_inset
2228 </cell>
2229 </row>
2230 <row topline="true" bottomline="true">
2231 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2232 \begin_inset Text
2233
2234 \begin_layout Standard
2235
2236 \emph on
2237 LIB_DIR_SUFFIX
2238 \end_layout
2239
2240 \end_inset
2241 </cell>
2242 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2243 \begin_inset Text
2244
2245 \begin_layout Standard
2246 sdcc/lib
2247 \end_layout
2248
2249 \end_inset
2250 </cell>
2251 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2252 \begin_inset Text
2253
2254 \begin_layout Standard
2255 lib
2256 \end_layout
2257
2258 \end_inset
2259 </cell>
2260 </row>
2261 </lyxtabular>
2262
2263 \end_inset
2264
2265
2266 \newline
2267
2268 \end_layout
2269
2270 \begin_layout Standard
2271 \noindent
2272 'configure' also computes relative paths.
2273  This is needed for full relocatability of a binary package and to complete
2274  search paths (see section search paths below):
2275 \newline
2276  
2277 \end_layout
2278
2279 \begin_layout Standard
2280 \align center
2281 \begin_inset Tabular
2282 <lyxtabular version="3" rows="4" columns="3">
2283 <features>
2284 <column alignment="block" valignment="top" leftline="true" width="0in">
2285 <column alignment="block" valignment="top" leftline="true" width="0in">
2286 <column alignment="block" valignment="top" leftline="true" rightline="true" width="0in">
2287 <row topline="true" bottomline="true">
2288 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2289 \begin_inset Text
2290
2291 \begin_layout Standard
2292 Variable (computed)
2293 \end_layout
2294
2295 \end_inset
2296 </cell>
2297 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2298 \begin_inset Text
2299
2300 \begin_layout Standard
2301 default
2302 \end_layout
2303
2304 \end_inset
2305 </cell>
2306 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2307 \begin_inset Text
2308
2309 \begin_layout Standard
2310 Win32 builds
2311 \end_layout
2312
2313 \end_inset
2314 </cell>
2315 </row>
2316 <row topline="true" bottomline="true">
2317 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2318 \begin_inset Text
2319
2320 \begin_layout Standard
2321
2322 \emph on
2323 BIN2DATA_DIR
2324 \end_layout
2325
2326 \end_inset
2327 </cell>
2328 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2329 \begin_inset Text
2330
2331 \begin_layout Standard
2332 ../share
2333 \end_layout
2334
2335 \end_inset
2336 </cell>
2337 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2338 \begin_inset Text
2339
2340 \begin_layout Standard
2341 ..
2342 \end_layout
2343
2344 \end_inset
2345 </cell>
2346 </row>
2347 <row bottomline="true">
2348 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2349 \begin_inset Text
2350
2351 \begin_layout Standard
2352
2353 \emph on
2354 PREFIX2BIN_DIR
2355 \end_layout
2356
2357 \end_inset
2358 </cell>
2359 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2360 \begin_inset Text
2361
2362 \begin_layout Standard
2363 bin
2364 \end_layout
2365
2366 \end_inset
2367 </cell>
2368 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2369 \begin_inset Text
2370
2371 \begin_layout Standard
2372 bin
2373 \end_layout
2374
2375 \end_inset
2376 </cell>
2377 </row>
2378 <row bottomline="true">
2379 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2380 \begin_inset Text
2381
2382 \begin_layout Standard
2383
2384 \emph on
2385 PREFIX2DATA_DIR
2386 \end_layout
2387
2388 \end_inset
2389 </cell>
2390 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2391 \begin_inset Text
2392
2393 \begin_layout Standard
2394 share/sdcc
2395 \end_layout
2396
2397 \end_inset
2398 </cell>
2399 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2400 \begin_inset Text
2401
2402 \begin_layout Standard
2403
2404 \end_layout
2405
2406 \end_inset
2407 </cell>
2408 </row>
2409 </lyxtabular>
2410
2411 \end_inset
2412
2413
2414 \newline
2415
2416 \end_layout
2417
2418 \begin_layout Standard
2419 \noindent
2420 Examples:
2421 \end_layout
2422
2423 \begin_layout LyX-Code
2424 ./configure
2425 \newline
2426 ./configure -
2427 \begin_inset ERT
2428 status collapsed
2429
2430 \begin_layout Standard
2431
2432
2433 \backslash
2434 /
2435 \end_layout
2436
2437 \end_inset
2438
2439 -prefix=
2440 \begin_inset Quotes srd
2441 \end_inset
2442
2443 /usr/bin
2444 \begin_inset Quotes srd
2445 \end_inset
2446
2447  -
2448 \begin_inset ERT
2449 status collapsed
2450
2451 \begin_layout Standard
2452
2453
2454 \backslash
2455 /
2456 \end_layout
2457
2458 \end_inset
2459
2460 -datarootdir=
2461 \begin_inset Quotes srd
2462 \end_inset
2463
2464 /usr/share
2465 \begin_inset Quotes srd
2466 \end_inset
2467
2468
2469 \newline
2470 ./configure -
2471 \begin_inset ERT
2472 status collapsed
2473
2474 \begin_layout Standard
2475
2476
2477 \backslash
2478 /
2479 \end_layout
2480
2481 \end_inset
2482
2483 -disable-avr-port -
2484 \begin_inset ERT
2485 status collapsed
2486
2487 \begin_layout Standard
2488
2489
2490 \backslash
2491 /
2492 \end_layout
2493
2494 \end_inset
2495
2496 -disable-xa51-port
2497 \end_layout
2498
2499 \begin_layout Standard
2500 To cross compile on linux for Mingw32 (see also 'sdcc/support/scripts/sdcc_mingw
2501 32'):
2502 \end_layout
2503
2504 \begin_layout LyX-Code
2505 ./configure 
2506 \backslash
2507
2508 \newline
2509 CC=
2510 \begin_inset Quotes srd
2511 \end_inset
2512
2513 i586-mingw32msvc-gcc
2514 \begin_inset Quotes srd
2515 \end_inset
2516
2517  CXX=
2518 \begin_inset Quotes srd
2519 \end_inset
2520
2521 i586-mingw32msvc-g++
2522 \begin_inset Quotes srd
2523 \end_inset
2524
2525  
2526 \backslash
2527  
2528 \newline
2529 RANLIB=
2530 \begin_inset Quotes srd
2531 \end_inset
2532
2533 i586-mingw32msvc-ranlib
2534 \begin_inset Quotes srd
2535 \end_inset
2536
2537  
2538 \backslash
2539
2540 \newline
2541 STRIP=
2542 \begin_inset Quotes srd
2543 \end_inset
2544
2545 i586-mingw32msvc-strip
2546 \begin_inset Quotes srd
2547 \end_inset
2548
2549  
2550 \backslash
2551
2552 \newline
2553 -
2554 \begin_inset ERT
2555 status collapsed
2556
2557 \begin_layout Standard
2558
2559
2560 \backslash
2561 /
2562 \end_layout
2563
2564 \end_inset
2565
2566 -prefix=
2567 \begin_inset Quotes srd
2568 \end_inset
2569
2570 /sdcc
2571 \begin_inset Quotes srd
2572 \end_inset
2573
2574  
2575 \backslash
2576
2577 \newline
2578 -
2579 \begin_inset ERT
2580 status collapsed
2581
2582 \begin_layout Standard
2583
2584
2585 \backslash
2586 /
2587 \end_layout
2588
2589 \end_inset
2590
2591 -datarootdir=
2592 \begin_inset Quotes srd
2593 \end_inset
2594
2595 /sdcc
2596 \begin_inset Quotes srd
2597 \end_inset
2598
2599  
2600 \backslash
2601
2602 \newline
2603 docdir=
2604 \begin_inset Quotes srd
2605 \end_inset
2606
2607
2608 \backslash
2609 ${datarootdir}/doc
2610 \begin_inset Quotes srd
2611 \end_inset
2612
2613  
2614 \backslash
2615
2616 \newline
2617 include_dir_suffix=
2618 \begin_inset Quotes srd
2619 \end_inset
2620
2621 include
2622 \begin_inset Quotes srd
2623 \end_inset
2624
2625  
2626 \backslash
2627
2628 \newline
2629 lib_dir_suffix=
2630 \begin_inset Quotes srd
2631 \end_inset
2632
2633 lib
2634 \begin_inset Quotes srd
2635 \end_inset
2636
2637  
2638 \backslash
2639
2640 \newline
2641 sdccconf_h_dir_separator=
2642 \begin_inset Quotes srd
2643 \end_inset
2644
2645
2646 \backslash
2647
2648 \backslash
2649
2650 \backslash
2651
2652 \backslash
2653
2654 \begin_inset Quotes srd
2655 \end_inset
2656
2657  
2658 \backslash
2659
2660 \newline
2661 -
2662 \begin_inset ERT
2663 status collapsed
2664
2665 \begin_layout Standard
2666
2667
2668 \backslash
2669 /
2670 \end_layout
2671
2672 \end_inset
2673
2674 -disable-device-lib
2675 \backslash
2676
2677 \newline
2678 -
2679 \begin_inset ERT
2680 status collapsed
2681
2682 \begin_layout Standard
2683
2684
2685 \backslash
2686 /
2687 \end_layout
2688
2689 \end_inset
2690
2691 -host=i586-mingw32msvc
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 -build=unknown-unknown-linux-gnu
2709 \end_layout
2710
2711 \begin_layout Standard
2712 To 
2713 \begin_inset Quotes sld
2714 \end_inset
2715
2716 cross
2717 \begin_inset Quotes srd
2718 \end_inset
2719
2720 compile on Cygwin for Mingw32 (see also sdcc/support/scripts/sdcc_cygwin_mingw32
2721 ):
2722 \end_layout
2723
2724 \begin_layout LyX-Code
2725 ./configure -C 
2726 \backslash
2727
2728 \newline
2729 -
2730 \begin_inset ERT
2731 status collapsed
2732
2733 \begin_layout Standard
2734
2735
2736 \backslash
2737 /
2738 \end_layout
2739
2740 \end_inset
2741
2742 -prefix=
2743 \begin_inset Quotes srd
2744 \end_inset
2745
2746 /sdcc
2747 \begin_inset Quotes srd
2748 \end_inset
2749
2750  
2751 \backslash
2752
2753 \newline
2754 -
2755 \begin_inset ERT
2756 status collapsed
2757
2758 \begin_layout Standard
2759
2760
2761 \backslash
2762 /
2763 \end_layout
2764
2765 \end_inset
2766
2767 -datarootdir=
2768 \begin_inset Quotes srd
2769 \end_inset
2770
2771 /sdcc
2772 \begin_inset Quotes srd
2773 \end_inset
2774
2775  
2776 \backslash
2777
2778 \newline
2779 docdir=
2780 \begin_inset Quotes srd
2781 \end_inset
2782
2783
2784 \backslash
2785 ${datarootdir}/doc
2786 \begin_inset Quotes srd
2787 \end_inset
2788
2789  
2790 \backslash
2791  
2792 \newline
2793 include_dir_suffix=
2794 \begin_inset Quotes srd
2795 \end_inset
2796
2797 include
2798 \begin_inset Quotes srd
2799 \end_inset
2800
2801  
2802 \backslash
2803
2804 \newline
2805 lib_dir_suffix=
2806 \begin_inset Quotes srd
2807 \end_inset
2808
2809 lib
2810 \begin_inset Quotes srd
2811 \end_inset
2812
2813  
2814 \backslash
2815
2816 \newline
2817 sdccconf_h_dir_separator=
2818 \begin_inset Quotes srd
2819 \end_inset
2820
2821
2822 \backslash
2823
2824 \backslash
2825
2826 \backslash
2827
2828 \backslash
2829
2830 \begin_inset Quotes srd
2831 \end_inset
2832
2833  
2834 \backslash
2835
2836 \newline
2837 CC=
2838 \begin_inset Quotes srd
2839 \end_inset
2840
2841 gcc -mno-cygwin
2842 \begin_inset Quotes srd
2843 \end_inset
2844
2845  
2846 \backslash
2847
2848 \newline
2849 CXX=
2850 \begin_inset Quotes srd
2851 \end_inset
2852
2853 g++ -mno-cygwin
2854 \begin_inset Quotes srd
2855 \end_inset
2856
2857  
2858 \end_layout
2859
2860 \begin_layout Standard
2861 'configure' is quite slow on Cygwin (at least on windows before Win2000/XP).
2862  The option '-
2863 \begin_inset ERT
2864 status collapsed
2865
2866 \begin_layout Standard
2867
2868
2869 \backslash
2870 /
2871 \end_layout
2872
2873 \end_inset
2874
2875 -C' turns on caching, which gives a little bit extra speed.
2876  However if options are changed, it can be necessary to delete the config.cache
2877  file.
2878 \end_layout
2879
2880 \begin_layout Section
2881 Install paths
2882 \begin_inset LatexCommand \label{sub:Install-paths}
2883
2884 \end_inset
2885
2886
2887 \begin_inset LatexCommand \index{Install paths}
2888
2889 \end_inset
2890
2891
2892 \end_layout
2893
2894 \begin_layout Standard
2895 \begin_inset VSpace medskip
2896 \end_inset
2897
2898
2899 \end_layout
2900
2901 \begin_layout Standard
2902 \align center
2903 \begin_inset Tabular
2904 <lyxtabular version="3" rows="5" columns="4">
2905 <features>
2906 <column alignment="left" valignment="top" leftline="true" width="0">
2907 <column alignment="left" valignment="top" leftline="true" width="0">
2908 <column alignment="left" valignment="top" leftline="true" width="0">
2909 <column alignment="left" valignment="top" leftline="true" rightline="true" width="0">
2910 <row topline="true" bottomline="true">
2911 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2912 \begin_inset Text
2913
2914 \begin_layout Standard
2915
2916 \series bold
2917 Description
2918 \end_layout
2919
2920 \end_inset
2921 </cell>
2922 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2923 \begin_inset Text
2924
2925 \begin_layout Standard
2926
2927 \series bold
2928 Path
2929 \end_layout
2930
2931 \end_inset
2932 </cell>
2933 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2934 \begin_inset Text
2935
2936 \begin_layout Standard
2937
2938 \series bold
2939 Default
2940 \end_layout
2941
2942 \end_inset
2943 </cell>
2944 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2945 \begin_inset Text
2946
2947 \begin_layout Standard
2948
2949 \series bold
2950 Win32 builds
2951 \end_layout
2952
2953 \end_inset
2954 </cell>
2955 </row>
2956 <row topline="true">
2957 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2958 \begin_inset Text
2959
2960 \begin_layout Standard
2961 Binary files*
2962 \end_layout
2963
2964 \end_inset
2965 </cell>
2966 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2967 \begin_inset Text
2968
2969 \begin_layout Standard
2970
2971 \emph on
2972 $EXEC_PREFIX
2973 \end_layout
2974
2975 \end_inset
2976 </cell>
2977 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2978 \begin_inset Text
2979
2980 \begin_layout Standard
2981 /usr/local/bin
2982 \end_layout
2983
2984 \end_inset
2985 </cell>
2986 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2987 \begin_inset Text
2988
2989 \begin_layout Standard
2990
2991 \backslash
2992 sdcc
2993 \backslash
2994 bin
2995 \end_layout
2996
2997 \end_inset
2998 </cell>
2999 </row>
3000 <row topline="true">
3001 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3002 \begin_inset Text
3003
3004 \begin_layout Standard
3005 Include files
3006 \end_layout
3007
3008 \end_inset
3009 </cell>
3010 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3011 \begin_inset Text
3012
3013 \begin_layout Standard
3014
3015 \emph on
3016 $DATADIR/ $INCLUDE_DIR_SUFFIX
3017 \end_layout
3018
3019 \end_inset
3020 </cell>
3021 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3022 \begin_inset Text
3023
3024 \begin_layout Standard
3025 /usr/local/share/sdcc/include
3026 \end_layout
3027
3028 \end_inset
3029 </cell>
3030 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3031 \begin_inset Text
3032
3033 \begin_layout Standard
3034
3035 \backslash
3036 sdcc
3037 \backslash
3038 include
3039 \end_layout
3040
3041 \end_inset
3042 </cell>
3043 </row>
3044 <row topline="true">
3045 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3046 \begin_inset Text
3047
3048 \begin_layout Standard
3049 Library file**
3050 \end_layout
3051
3052 \end_inset
3053 </cell>
3054 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3055 \begin_inset Text
3056
3057 \begin_layout Standard
3058
3059 \emph on
3060 $DATADIR/$LIB_DIR_SUFFIX
3061 \end_layout
3062
3063 \end_inset
3064 </cell>
3065 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3066 \begin_inset Text
3067
3068 \begin_layout Standard
3069 /usr/local/share/sdcc/lib
3070 \end_layout
3071
3072 \end_inset
3073 </cell>
3074 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3075 \begin_inset Text
3076
3077 \begin_layout Standard
3078
3079 \backslash
3080 sdcc
3081 \backslash
3082 lib
3083 \end_layout
3084
3085 \end_inset
3086 </cell>
3087 </row>
3088 <row topline="true" bottomline="true">
3089 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3090 \begin_inset Text
3091
3092 \begin_layout Standard
3093 Documentation
3094 \end_layout
3095
3096 \end_inset
3097 </cell>
3098 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3099 \begin_inset Text
3100
3101 \begin_layout Standard
3102
3103 \emph on
3104 $DOCDIR
3105 \end_layout
3106
3107 \end_inset
3108 </cell>
3109 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3110 \begin_inset Text
3111
3112 \begin_layout Standard
3113 /usr/local/share/sdcc/doc
3114 \end_layout
3115
3116 \end_inset
3117 </cell>
3118 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3119 \begin_inset Text
3120
3121 \begin_layout Standard
3122
3123 \backslash
3124 sdcc
3125 \backslash
3126 doc
3127 \end_layout
3128
3129 \end_inset
3130 </cell>
3131 </row>
3132 </lyxtabular>
3133
3134 \end_inset
3135
3136
3137 \end_layout
3138
3139 \begin_layout Verse
3140
3141 \size footnotesize
3142 *compiler, preprocessor, assembler, and linker
3143 \newline
3144 **the 
3145 \shape italic
3146 model
3147 \shape default
3148  is auto-appended by the compiler, e.g.
3149  small, large, z80, ds390 etc
3150 \end_layout
3151
3152 \begin_layout Standard
3153 \noindent
3154 The install paths can still be changed during `make install' with e.g.:
3155 \end_layout
3156
3157 \begin_layout LyX-Code
3158 make install prefix=$(HOME)/local/sdcc
3159 \end_layout
3160
3161 \begin_layout Standard
3162 Of course this doesn't change the search paths compiled into the binaries.
3163 \newline
3164
3165 \newline
3166 Moreove
3167 r the install path can be changed by defining DESTDIR
3168 \begin_inset LatexCommand \index{DESTDIR}
3169
3170 \end_inset
3171
3172 :
3173 \end_layout
3174
3175 \begin_layout LyX-Code
3176 make install DESTDIR=$(HOME)/sdcc.rpm/
3177 \end_layout
3178
3179 \begin_layout Standard
3180 Please note that DESTDIR must have a trailing slash!
3181 \end_layout
3182
3183 \begin_layout Section
3184 Search Paths
3185 \begin_inset LatexCommand \label{sub:Search-Paths}
3186
3187 \end_inset
3188
3189
3190 \begin_inset LatexCommand \index{Search path}
3191
3192 \end_inset
3193
3194
3195 \end_layout
3196
3197 \begin_layout Standard
3198 Some search paths or parts of them are determined by configure variables
3199  (in 
3200 \emph on
3201 italics
3202 \emph default
3203 , see section above).
3204  Further search paths are determined by environment variables during runtime.
3205  
3206 \newline
3207 The paths searched when running the compiler are as follows (the first
3208  catch wins):
3209 \newline
3210
3211 \newline
3212 1.
3213  Binary files (preprocessor, assembler and linker)
3214 \newline
3215
3216 \end_layout
3217
3218 \begin_layout Standard
3219 \align center
3220 \begin_inset Tabular
3221 <lyxtabular version="3" rows="4" columns="3">
3222 <features>
3223 <column alignment="block" valignment="top" leftline="true" width="0in">
3224 <column alignment="block" valignment="top" leftline="true" width="0in">
3225 <column alignment="block" valignment="top" leftline="true" rightline="true" width="0in">
3226 <row topline="true" bottomline="true">
3227 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3228 \begin_inset Text
3229
3230 \begin_layout Standard
3231 Search path
3232 \end_layout
3233
3234 \end_inset
3235 </cell>
3236 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3237 \begin_inset Text
3238
3239 \begin_layout Standard
3240 default
3241 \end_layout
3242
3243 \end_inset
3244 </cell>
3245 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3246 \begin_inset Text
3247
3248 \begin_layout Standard
3249 Win32 builds
3250 \end_layout
3251
3252 \end_inset
3253 </cell>
3254 </row>
3255 <row topline="true">
3256 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3257 \begin_inset Text
3258
3259 \begin_layout Standard
3260 $SDCC_HOME/
3261 \emph on
3262 $PPREFIX2BIN_DIR
3263 \end_layout
3264
3265 \end_inset
3266 </cell>
3267 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3268 \begin_inset Text
3269
3270 \begin_layout Standard
3271 $SDCC_HOME/bin
3272 \end_layout
3273
3274 \end_inset
3275 </cell>
3276 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3277 \begin_inset Text
3278
3279 \begin_layout Standard
3280 $SDCC_HOME
3281 \backslash
3282 bin
3283 \end_layout
3284
3285 \end_inset
3286 </cell>
3287 </row>
3288 <row topline="true">
3289 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3290 \begin_inset Text
3291
3292 \begin_layout Standard
3293 Path of argv[0] (if available)
3294 \end_layout
3295
3296 \end_inset
3297 </cell>
3298 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3299 \begin_inset Text
3300
3301 \begin_layout Standard
3302 Path of argv[0]
3303 \end_layout
3304
3305 \end_inset
3306 </cell>
3307 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3308 \begin_inset Text
3309
3310 \begin_layout Standard
3311 Path of argv[0]
3312 \end_layout
3313
3314 \end_inset
3315 </cell>
3316 </row>
3317 <row topline="true" bottomline="true">
3318 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3319 \begin_inset Text
3320
3321 \begin_layout Standard
3322 $PATH
3323 \end_layout
3324
3325 \end_inset
3326 </cell>
3327 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3328 \begin_inset Text
3329
3330 \begin_layout Standard
3331 $PATH
3332 \end_layout
3333
3334 \end_inset
3335 </cell>
3336 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3337 \begin_inset Text
3338
3339 \begin_layout Standard
3340 $PATH
3341 \end_layout
3342
3343 \end_inset
3344 </cell>
3345 </row>
3346 </lyxtabular>
3347
3348 \end_inset
3349
3350  
3351 \newline
3352
3353 \end_layout
3354
3355 \begin_layout Standard
3356 \noindent
3357 2.
3358  Include files
3359 \newline
3360
3361 \end_layout
3362
3363 \begin_layout Standard
3364 \align center
3365 \begin_inset Tabular
3366 <lyxtabular version="3" rows="6" columns="3">
3367 <features>
3368 <column alignment="block" valignment="top" leftline="true" width="1.5in">
3369 <column alignment="block" valignment="top" leftline="true" width="1.5in">
3370 <column alignment="block" valignment="top" leftline="true" rightline="true" width="0in">
3371 <row topline="true" bottomline="true">
3372 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3373 \begin_inset Text
3374
3375 \begin_layout Standard
3376 Search path
3377 \end_layout
3378
3379 \end_inset
3380 </cell>
3381 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3382 \begin_inset Text
3383
3384 \begin_layout Standard
3385 default
3386 \end_layout
3387
3388 \end_inset
3389 </cell>
3390 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3391 \begin_inset Text
3392
3393 \begin_layout Standard
3394 Win32 builds
3395 \end_layout
3396
3397 \end_inset
3398 </cell>
3399 </row>
3400 <row topline="true">
3401 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3402 \begin_inset Text
3403
3404 \begin_layout Standard
3405 -
3406 \begin_inset ERT
3407 status collapsed
3408
3409 \begin_layout Standard
3410
3411
3412 \backslash
3413 /
3414 \end_layout
3415
3416 \end_inset
3417
3418 -I dir
3419 \end_layout
3420
3421 \end_inset
3422 </cell>
3423 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3424 \begin_inset Text
3425
3426 \begin_layout Standard
3427 -
3428 \begin_inset ERT
3429 status collapsed
3430
3431 \begin_layout Standard
3432
3433
3434 \backslash
3435 /
3436 \end_layout
3437
3438 \end_inset
3439
3440 -I dir
3441 \end_layout
3442
3443 \end_inset
3444 </cell>
3445 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3446 \begin_inset Text
3447
3448 \begin_layout Standard
3449 -
3450 \begin_inset ERT
3451 status collapsed
3452
3453 \begin_layout Standard
3454
3455
3456 \backslash
3457 /
3458 \end_layout
3459
3460 \end_inset
3461
3462 -I dir
3463 \end_layout
3464
3465 \end_inset
3466 </cell>
3467 </row>
3468 <row topline="true">
3469 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
3470 \begin_inset Text
3471
3472 \begin_layout Standard
3473 $SDCC_INCLUDE
3474 \end_layout
3475
3476 \end_inset
3477 </cell>
3478 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3479 \begin_inset Text
3480
3481 \begin_layout Standard
3482 $SDCC_INCLUDE
3483 \end_layout
3484
3485 \end_inset
3486 </cell>
3487 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3488 \begin_inset Text
3489
3490 \begin_layout Standard
3491 $SDCC_INCLUDE
3492 \end_layout
3493
3494 \end_inset
3495 </cell>
3496 </row>
3497 <row topline="true">
3498 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
3499 \begin_inset Text
3500
3501 \begin_layout Standard
3502 $SDCC_HOME/
3503 \newline
3504
3505 \emph on
3506 $PREFIX2DATA_DIR/
3507 \newline
3508 $INCLUDE_DIR_SUFFIX
3509 \end_layout
3510
3511 \end_inset
3512 </cell>
3513 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
3514 \begin_inset Text
3515
3516 \begin_layout Standard
3517 $SDCC_ HOME/
3518 \newline
3519 share/sdcc/
3520 \newline
3521 include
3522 \end_layout
3523
3524 \end_inset
3525 </cell>
3526 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3527 \begin_inset Text
3528
3529 \begin_layout Standard
3530 $SDCC_HOME
3531 \backslash
3532 include
3533 \end_layout
3534
3535 \end_inset
3536 </cell>
3537 </row>
3538 <row topline="true">
3539 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
3540 \begin_inset Text
3541
3542 \begin_layout Standard
3543 path(argv[0])/
3544 \newline
3545
3546 \emph on
3547 $BIN2DATADIR/
3548 \emph default
3549
3550 \newline
3551
3552 \emph on
3553 $INCLUDE_DIR_SUFFIX
3554 \end_layout
3555
3556 \end_inset
3557 </cell>
3558 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3559 \begin_inset Text
3560
3561 \begin_layout Standard
3562 path(argv[0])/
3563 \newline
3564 ../sdcc/include
3565 \newline
3566 \InsetSpace ~
3567 \InsetSpace ~
3568 \InsetSpace ~
3569 \InsetSpace ~
3570 \InsetSpace ~
3571 \InsetSpace ~
3572 \InsetSpace ~
3573 \InsetSpace ~
3574 \InsetSpace ~
3575 \InsetSpace ~
3576 \InsetSpace ~
3577 \InsetSpace ~
3578 \InsetSpace ~
3579 \InsetSpace ~
3580 \InsetSpace ~
3581 \InsetSpace ~
3582 \InsetSpace ~
3583 \InsetSpace ~
3584 \InsetSpace ~
3585 \InsetSpace ~
3586 \InsetSpace ~
3587 \InsetSpace ~
3588 \InsetSpace ~
3589 \InsetSpace ~
3590 \InsetSpace ~
3591 \InsetSpace ~
3592 \InsetSpace ~
3593 \InsetSpace ~
3594 \InsetSpace ~
3595 \InsetSpace ~
3596 \InsetSpace ~
3597 \InsetSpace ~
3598 \InsetSpace ~
3599 \InsetSpace ~
3600 \InsetSpace ~
3601 \InsetSpace ~
3602 \InsetSpace ~
3603 \InsetSpace ~
3604
3605 \end_layout
3606
3607 \end_inset
3608 </cell>
3609 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3610 \begin_inset Text
3611
3612 \begin_layout Standard
3613 path(argv[0])
3614 \backslash
3615 ..
3616 \backslash
3617 include
3618 \end_layout
3619
3620 \end_inset
3621 </cell>
3622 </row>
3623 <row topline="true" bottomline="true">
3624 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
3625 \begin_inset Text
3626
3627 \begin_layout Standard
3628
3629 \emph on
3630 $DATADIR/
3631 \emph default
3632
3633 \newline
3634
3635 \emph on
3636 $INCLUDE_DIR_SUFFIX
3637 \end_layout
3638
3639 \end_inset
3640 </cell>
3641 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
3642 \begin_inset Text
3643
3644 \begin_layout Standard
3645 /usr/local/share/sdcc/
3646 \newline
3647 include
3648 \end_layout
3649
3650 \end_inset
3651 </cell>
3652 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3653 \begin_inset Text
3654
3655 \begin_layout Standard
3656 (not on Win32)
3657 \end_layout
3658
3659 \end_inset
3660 </cell>
3661 </row>
3662 </lyxtabular>
3663
3664 \end_inset
3665
3666  
3667 \newline
3668
3669 \end_layout
3670
3671 \begin_layout Standard
3672 \noindent
3673 The option -
3674 \begin_inset ERT
3675 status collapsed
3676
3677 \begin_layout Standard
3678
3679
3680 \backslash
3681 /
3682 \end_layout
3683
3684 \end_inset
3685
3686 -nostdinc disables the last two search paths.
3687 \newline
3688
3689 \newline
3690 3.
3691  Library files 
3692 \newline
3693
3694 \end_layout
3695
3696 \begin_layout Standard
3697 With the exception of 
3698 \begin_inset Quotes sld
3699 \end_inset
3700
3701 -
3702 \begin_inset ERT
3703 status collapsed
3704
3705 \begin_layout Standard
3706
3707
3708 \backslash
3709 /
3710 \end_layout
3711
3712 \end_inset
3713
3714 -L dir
3715 \begin_inset Quotes srd
3716 \end_inset
3717
3718  the 
3719 \shape italic
3720 model
3721 \shape default
3722  is auto-appended by the compiler (e.g.
3723  small, large, z80, ds390 etc.).
3724  
3725 \newline
3726
3727 \end_layout
3728
3729 \begin_layout Standard
3730 \align center
3731 \begin_inset Tabular
3732 <lyxtabular version="3" rows="6" columns="3">
3733 <features>
3734 <column alignment="block" valignment="top" leftline="true" width="1.7in">
3735 <column alignment="block" valignment="top" leftline="true" width="1.2in">
3736 <column alignment="block" valignment="top" leftline="true" rightline="true" width="1.2in">
3737 <row topline="true" bottomline="true">
3738 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
3739 \begin_inset Text
3740
3741 \begin_layout Standard
3742 Search path
3743 \end_layout
3744
3745 \end_inset
3746 </cell>
3747 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
3748 \begin_inset Text
3749
3750 \begin_layout Standard
3751 default
3752 \end_layout
3753
3754 \end_inset
3755 </cell>
3756 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3757 \begin_inset Text
3758
3759 \begin_layout Standard
3760 Win32 builds
3761 \end_layout
3762
3763 \end_inset
3764 </cell>
3765 </row>
3766 <row topline="true">
3767 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
3768 \begin_inset Text
3769
3770 \begin_layout Standard
3771 -
3772 \begin_inset ERT
3773 status collapsed
3774
3775 \begin_layout Standard
3776
3777
3778 \backslash
3779 /
3780 \end_layout
3781
3782 \end_inset
3783
3784 -L dir
3785 \end_layout
3786
3787 \end_inset
3788 </cell>
3789 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3790 \begin_inset Text
3791
3792 \begin_layout Standard
3793 -
3794 \begin_inset ERT
3795 status collapsed
3796
3797 \begin_layout Standard
3798
3799
3800 \backslash
3801 /
3802 \end_layout
3803
3804 \end_inset
3805
3806 -L dir
3807 \end_layout
3808
3809 \end_inset
3810 </cell>
3811 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3812 \begin_inset Text
3813
3814 \begin_layout Standard
3815 -
3816 \begin_inset ERT
3817 status collapsed
3818
3819 \begin_layout Standard
3820
3821
3822 \backslash
3823 /
3824 \end_layout
3825
3826 \end_inset
3827
3828 -L dir
3829 \end_layout
3830
3831 \end_inset
3832 </cell>
3833 </row>
3834 <row topline="true">
3835 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3836 \begin_inset Text
3837
3838 \begin_layout Standard
3839 $SDCC_LIB/
3840 \newline
3841
3842 \emph on
3843 <model>
3844 \end_layout
3845
3846 \end_inset
3847 </cell>
3848 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
3849 \begin_inset Text
3850
3851 \begin_layout Standard
3852 $SDCC_LIB/
3853 \newline
3854
3855 \emph on
3856 <model>
3857 \end_layout
3858
3859 \end_inset
3860 </cell>
3861 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3862 \begin_inset Text
3863
3864 \begin_layout Standard
3865 $SDCC_LIB
3866 \backslash
3867
3868 \newline
3869
3870 \emph on
3871 <model>
3872 \end_layout
3873
3874 \end_inset
3875 </cell>
3876 </row>
3877 <row topline="true">
3878 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
3879 \begin_inset Text
3880
3881 \begin_layout Standard
3882 $SDCC_HOME/
3883 \newline
3884
3885 \emph on
3886 $PREFIX2DATA_DIR/
3887 \newline
3888 $LIB_DIR_SUFFIX/<model>
3889 \end_layout
3890
3891 \end_inset
3892 </cell>
3893 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
3894 \begin_inset Text
3895
3896 \begin_layout Standard
3897 $SDCC_HOME/
3898 \newline
3899 share/sdcc/
3900 \newline
3901 lib/
3902 \emph on
3903 <model>
3904 \end_layout
3905
3906 \end_inset
3907 </cell>
3908 <cell alignment="left" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3909 \begin_inset Text
3910
3911 \begin_layout Standard
3912 $SDCC_HOME
3913 \backslash
3914 lib
3915 \backslash
3916
3917 \emph on
3918
3919 \newline
3920 <model>
3921 \end_layout
3922
3923 \end_inset
3924 </cell>
3925 </row>
3926 <row topline="true">
3927 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
3928 \begin_inset Text
3929
3930 \begin_layout Standard
3931 path(argv[0])/
3932 \newline
3933
3934 \emph on
3935 $BIN2DATADIR/
3936 \emph default
3937
3938 \newline
3939
3940 \emph on
3941 $LIB_DIR_SUFFIX/<model>
3942 \end_layout
3943
3944 \end_inset
3945 </cell>
3946 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
3947 \begin_inset Text
3948
3949 \begin_layout Standard
3950 path(argv[0])/
3951 \newline
3952 ../sdcc/lib/
3953 \emph on
3954 <model>
3955 \newline
3956 \InsetSpace ~
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 \InsetSpace ~
3993 \InsetSpace ~
3994 \InsetSpace ~
3995
3996 \end_layout
3997
3998 \end_inset
3999 </cell>
4000 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
4001 \begin_inset Text
4002
4003 \begin_layout Standard
4004 path(argv[0])
4005 \backslash
4006
4007 \newline
4008 ..
4009 \backslash
4010 lib
4011 \backslash
4012
4013 \emph on
4014 <model>
4015 \newline
4016 \InsetSpace ~
4017 \InsetSpace ~
4018 \InsetSpace ~
4019 \InsetSpace ~
4020 \InsetSpace ~
4021 \InsetSpace ~
4022 \InsetSpace ~
4023 \InsetSpace ~
4024 \InsetSpace ~
4025 \InsetSpace ~
4026 \InsetSpace ~
4027 \InsetSpace ~
4028 \InsetSpace ~
4029 \InsetSpace ~
4030 \InsetSpace ~
4031 \InsetSpace ~
4032 \InsetSpace ~
4033 \InsetSpace ~
4034 \InsetSpace ~
4035 \InsetSpace ~
4036 \InsetSpace ~
4037 \InsetSpace ~
4038 \InsetSpace ~
4039 \InsetSpace ~
4040 \InsetSpace ~
4041 \InsetSpace ~
4042 \InsetSpace ~
4043 \InsetSpace ~
4044 \InsetSpace ~
4045 \InsetSpace ~
4046 \InsetSpace ~
4047 \InsetSpace ~
4048 \InsetSpace ~
4049 \InsetSpace ~
4050 \InsetSpace ~
4051
4052 \end_layout
4053
4054 \end_inset
4055 </cell>
4056 </row>
4057 <row topline="true" bottomline="true">
4058 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
4059 \begin_inset Text
4060
4061 \begin_layout Standard
4062
4063 \emph on
4064 $DATADIR/
4065 \newline
4066 $LIB_DIR_SUFFIX/<model>
4067 \end_layout
4068
4069 \end_inset
4070 </cell>
4071 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
4072 \begin_inset Text
4073
4074 \begin_layout Standard
4075 /usr/local/share/sdcc/
4076 \newline
4077 lib/
4078 \emph on
4079 <model>
4080 \end_layout
4081
4082 \end_inset
4083 </cell>
4084 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
4085 \begin_inset Text
4086
4087 \begin_layout Standard
4088 (not on Win32)
4089 \end_layout
4090
4091 \end_inset
4092 </cell>
4093 </row>
4094 </lyxtabular>
4095
4096 \end_inset
4097
4098
4099 \newline
4100
4101 \end_layout
4102
4103 \begin_layout Standard
4104 \begin_inset Note Note
4105 status collapsed
4106
4107 \begin_layout Standard
4108 Don't delete any of the stray spaces in the table above without checking
4109  the HTML output (last line)!
4110 \end_layout
4111
4112 \end_inset
4113
4114
4115 \end_layout
4116
4117 \begin_layout Standard
4118 \InsetSpace ~
4119
4120 \newline
4121 The option -
4122 \begin_inset ERT
4123 status collapsed
4124
4125 \begin_layout Standard
4126
4127
4128 \backslash
4129 /
4130 \end_layout
4131
4132 \end_inset
4133
4134 -nostdlib disables the last two search paths.
4135 \end_layout
4136
4137 \begin_layout Section
4138 Building SDCC
4139 \begin_inset LatexCommand \index{Building SDCC}
4140
4141 \end_inset
4142
4143
4144 \end_layout
4145
4146 \begin_layout Subsection
4147 Building SDCC on Linux
4148 \begin_inset LatexCommand \label{sub:Building-SDCC-on-Linux}
4149
4150 \end_inset
4151
4152
4153 \end_layout
4154
4155 \begin_layout Enumerate
4156
4157 \series medium
4158 Download the source package
4159 \series default
4160  either from the SDCC Subversion repository or from snapshot builds
4161 \series medium
4162 , it will be named something like sdcc
4163 \series default
4164 -src
4165 \series medium
4166 -yyyymmdd-rrrr.t
4167 \series default
4168 ar.
4169 \series medium
4170 bz2
4171 \series default
4172  
4173 \begin_inset LatexCommand \url{http://sdcc.sourceforge.net/snap.php}
4174
4175 \end_inset
4176
4177 .
4178 \end_layout
4179
4180 \begin_layout Enumerate
4181
4182 \series medium
4183 Bring up a command line terminal, such as xterm.
4184 \end_layout
4185
4186 \begin_layout Enumerate
4187
4188 \series medium
4189 Unpack the file using a command like: 
4190 \family sans
4191 \series bold
4192 "tar -xvzf sdcc-src-yyyymmdd-rrrr.tar.bz2
4193 \begin_inset Quotes srd
4194 \end_inset
4195
4196
4197 \family default
4198 \series medium
4199 , this will create a sub-directory called sdcc with all of the sources.
4200 \end_layout
4201
4202 \begin_layout Enumerate
4203 Change directory into the main SDCC directory, for example type: 
4204 \family sans
4205 \series bold
4206 "cd sdcc
4207 \series default
4208 ".
4209 \end_layout
4210
4211 \begin_layout Enumerate
4212
4213 \series medium
4214 Type 
4215 \family sans
4216 \series bold
4217 "./configure
4218 \family default
4219 \series default
4220 ".
4221  This configures the package for compilation on your system.
4222 \end_layout
4223
4224 \begin_layout Enumerate
4225
4226 \series medium
4227 Type 
4228 \family sans
4229 \series bold
4230 "make
4231 \family default
4232 \series default
4233 "
4234 \series medium
4235 .
4236
4237 \series default
4238  All of the source packages will compile, this can take a while.
4239 \end_layout
4240
4241 \begin_layout Enumerate
4242
4243 \series medium
4244 Type 
4245 \family sans
4246 \series bold
4247 "make install"
4248 \family default
4249 \series default
4250  as root
4251 \series medium
4252 .
4253
4254 \series default
4255  This copies the binary executables, the include files, the libraries and
4256  the documentation to the install directories.
4257  Proceed with section 
4258 \begin_inset LatexCommand \ref{sec:Testing-the-SDCC}
4259
4260 \end_inset
4261
4262 .
4263 \end_layout
4264
4265 \begin_layout Subsection
4266 Building SDCC on Mac OS X
4267 \end_layout
4268
4269 \begin_layout Standard
4270 Follow the instruction for Linux.
4271 \newline
4272
4273 \newline
4274 On Mac OS X 10.2.x it was reported, that the
4275  default gcc (version 3.1 20020420 (prerelease)) fails to compile SDCC.
4276  Fortunately there's also gcc 2.9.x installed, which works fine.
4277  This compiler can be selected by running 'configure' with:
4278 \end_layout
4279
4280 \begin_layout LyX-Code
4281 ./configure CC=gcc2 CXX=g++2
4282 \end_layout
4283
4284 \begin_layout Standard
4285 Universal (ppc and i386) binaries can be produced on Mac OS X 10.4.x with
4286  Xcode.
4287  Run 'configure' with:
4288 \end_layout
4289
4290 \begin_layout LyX-Code
4291 ./configure 
4292 \backslash
4293
4294 \end_layout
4295
4296 \begin_layout LyX-Code
4297 LDFLAGS="-Wl,-syslibroot,/Developer/SDKs/MacOSX10.4u.sdk -arch i386 -arch
4298  ppc" 
4299 \backslash
4300
4301 \end_layout
4302
4303 \begin_layout LyX-Code
4304 CXXFLAGS = "-O2 -isysroot /Developer/SDKs/MacOSX10.4u.sdk -arch i386 -arch
4305  ppc" 
4306 \backslash
4307
4308 \end_layout
4309
4310 \begin_layout LyX-Code
4311 CFLAGS = "-O2 -isysroot /Developer/SDKs/MacOSX10.4u.sdk -arch i386 -arch ppc"
4312 \end_layout
4313
4314 \begin_layout Subsection
4315 Cross compiling SDCC on Linux for Windows
4316 \end_layout
4317
4318 \begin_layout Standard
4319 With the Mingw32 gcc cross compiler it's easy to compile SDCC for Win32.
4320  See section 'Configure Options'.
4321 \end_layout
4322
4323 \begin_layout Subsection
4324 Building SDCC using Cygwin and Mingw32
4325 \end_layout
4326
4327 \begin_layout Standard
4328 For building and installing a Cygwin executable follow the instructions
4329  for Linux.
4330 \newline
4331
4332 \newline
4333 On Cygwin a 
4334 \begin_inset Quotes sld
4335 \end_inset
4336
4337 native
4338 \begin_inset Quotes srd
4339 \end_inset
4340
4341  Win32-binary can be built, which will not need the Cygwin-DLL.
4342  For the necessary 'configure' options see section 'configure options' or
4343  the script 'sdcc/support/scripts/sdcc_cygwin_mingw32'.
4344 \newline
4345
4346 \newline
4347 In order to install
4348  Cygwin on Windows download setup.exe from 
4349 \begin_inset LatexCommand \url[www.cygwin.com]{http://www.cygwin.com/}
4350
4351 \end_inset
4352
4353 .
4354  Run it, set the 
4355 \begin_inset Quotes sld
4356 \end_inset
4357
4358 default text file type
4359 \begin_inset Quotes srd
4360 \end_inset
4361
4362  to 
4363 \begin_inset Quotes sld
4364 \end_inset
4365
4366 unix
4367 \begin_inset Quotes srd
4368 \end_inset
4369
4370  and download/install at least the following packages.
4371  Some packages are selected by default, others will be automatically selected
4372  because of dependencies with the manually selected packages.
4373  Never deselect these packages!
4374 \end_layout
4375
4376 \begin_layout Itemize
4377 flex
4378 \end_layout
4379
4380 \begin_layout Itemize
4381 bison
4382 \end_layout
4383
4384 \begin_layout Itemize
4385 gcc ; version 3.x is fine, no need to use the old 2.9x
4386 \end_layout
4387
4388 \begin_layout Itemize
4389 binutils ; selected with gcc
4390 \end_layout
4391
4392 \begin_layout Itemize
4393 make
4394 \end_layout
4395
4396 \begin_layout Itemize
4397 rxvt ; a nice console, which makes life much easier under windoze (see below)
4398 \end_layout
4399
4400 \begin_layout Itemize
4401 man ; not really needed for building SDCC, but you'll miss it sooner or
4402  later
4403 \end_layout
4404
4405 \begin_layout Itemize
4406 less ; not really needed for building SDCC, but you'll miss it sooner or
4407  later
4408 \end_layout
4409
4410 \begin_layout Itemize
4411 svn ; only if you use Subversion access
4412 \end_layout
4413
4414 \begin_layout Standard
4415 If you want to develop something you'll need:
4416 \end_layout
4417
4418 \begin_layout Itemize
4419 python ; for the regression tests
4420 \end_layout
4421
4422 \begin_layout Itemize
4423 gdb ; the gnu debugger, together with the nice GUI 
4424 \begin_inset Quotes sld
4425 \end_inset
4426
4427 insight
4428 \begin_inset Quotes srd
4429 \end_inset
4430
4431
4432 \end_layout
4433
4434 \begin_layout Itemize
4435 openssh ; to access the CF or commit changes
4436 \end_layout
4437
4438 \begin_layout Itemize
4439 autoconf and autoconf-devel ; if you want to fight with 'configure', don't
4440  use autoconf-stable!
4441 \end_layout
4442
4443 \begin_layout Standard
4444 rxvt is a nice console with history.
4445  Replace in your cygwin.bat the line
4446 \end_layout
4447
4448 \begin_layout LyX-Code
4449 bash -
4450 \begin_inset ERT
4451 status collapsed
4452
4453 \begin_layout Standard
4454
4455
4456 \backslash
4457 /
4458 \end_layout
4459
4460 \end_inset
4461
4462 -login -i 
4463 \end_layout
4464
4465 \begin_layout Standard
4466 with (one line):
4467 \end_layout
4468
4469 \begin_layout LyX-Code
4470 rxvt -sl 1000 -fn "Lucida Console-12" -sr -cr red
4471 \end_layout
4472
4473 \begin_layout LyX-Code
4474      -bg black -fg white -geometry 100x65 -e bash -
4475 \begin_inset ERT
4476 status collapsed
4477
4478 \begin_layout Standard
4479
4480
4481 \backslash
4482 /
4483 \end_layout
4484
4485 \end_inset
4486
4487 -login
4488 \end_layout
4489
4490 \begin_layout Standard
4491 Text selected with the mouse is automatically copied to the clipboard, pasting
4492  works with shift-insert.
4493 \newline
4494
4495 \newline
4496 The other good tip is to make sure you have no //c/-styl
4497 e paths anywhere, use /cygdrive/c/ instead.
4498  Using // invokes a network lookup which is very slow.
4499  If you think 
4500 \begin_inset Quotes sld
4501 \end_inset
4502
4503 cygdrive
4504 \begin_inset Quotes srd
4505 \end_inset
4506
4507  is too long, you can change it with e.g.
4508 \end_layout
4509
4510 \begin_layout LyX-Code
4511 mount -s -u -c /mnt
4512 \end_layout
4513
4514 \begin_layout Standard
4515 SDCC sources use the unix line ending LF.
4516  Life is much easier, if you store the source tree on a drive which is mounted
4517  in binary mode.
4518  And use an editor which can handle LF-only line endings.
4519  Make sure not to commit files with windows line endings.
4520  The tabulator spacing
4521 \begin_inset LatexCommand \index{tabulator spacing (8 columns)}
4522
4523 \end_inset
4524
4525  used in the project is 8.
4526  Although a tabulator spacing of 8 is a sensible choice for programmers
4527  (it's a power of 2 and allows to display 8/16 bit signed variables without
4528  loosing columns) the plan is to move towards using only spaces in the source.
4529 \end_layout
4530
4531 \begin_layout Subsection
4532 Building SDCC Using Microsoft Visual C++ 6.0/NET (MSVC)
4533 \end_layout
4534
4535 \begin_layout Standard
4536
4537 \series medium
4538 Download the source package
4539 \series default
4540  either from the SDCC Subversion repository or from the 
4541 \begin_inset LatexCommand \url[snapshot builds]{http://sdcc.sourceforge.net/snap.php}
4542
4543 \end_inset
4544
4545
4546 \series medium
4547 , it will be named something like sdcc
4548 \series default
4549 -src
4550 \series medium
4551 -yyyymmdd-rrrr.tar.bz2.
4552
4553 \series default
4554  SDCC is distributed with all the projects, workspaces, and files you need
4555  to build it using Visual C++ 6.0/NET (except for SDCDB and ucSim).
4556  The workspace name is 'sdcc.dsw'.
4557  Please note that as it is now, all the executables are created in a folder
4558  called sdcc
4559 \backslash
4560 bin_vc.
4561  Once built you need to copy the executables from sdcc
4562 \backslash
4563 bin_vc to sdcc
4564 \backslash
4565 bin before running SDCC.
4566  
4567 \newline
4568
4569 \newline
4570 WARNING: Visual studio is very picky with line terminations; it expects
4571  the 0x0d, 0x0a DOS style line endings, not the 0x0a Unix style line endings.
4572  When using the Subversion repository it's easiest to configure the svn
4573  client to convert automatically for you.
4574  If however you are getting a message such as "This makefile was not generated
4575  by Developer Studio etc.
4576  etc.
4577 \begin_inset Quotes srd
4578 \end_inset
4579
4580  when opening the sdcc.dsw workspace or any of the *.dsp projects, then you
4581  need to convert the Unix style line endings to DOS style line endings.
4582  To do so you can use the 
4583 \begin_inset Quotes sld
4584 \end_inset
4585
4586 unix2dos
4587 \begin_inset Quotes srd
4588 \end_inset
4589
4590  utility freely available on the internet.
4591  Doug Hawkins reported in the sdcc-user list that this works:
4592 \newline
4593
4594 \newline
4595 C:
4596 \backslash
4597 Programming
4598 \backslash
4599 SDCC> unix2dos sdcc.dsw
4600 \newline
4601 C:
4602 \backslash
4603 Programming
4604 \backslash
4605 SDCC> for /R %I in (*.dsp) do @unix2dos "%I"
4606 \newline
4607
4608 \newline
4609 In order to build SDCC with MSVC
4610  you need win32 executables of bison.exe, flex.exe, and gawk.exe.
4611  One good place to get them is 
4612 \begin_inset LatexCommand \url[here]{http://unxutils.sourceforge.net}
4613
4614 \end_inset
4615
4616
4617 \newline
4618
4619 \newline
4620 Download the file UnxUtils
4621 \begin_inset LatexCommand \index{UnxUtils}
4622
4623 \end_inset
4624
4625 .zip.
4626  Now you have to install the utilities and setup MSVC so it can locate the
4627  required programs.
4628  Here there are two alternatives (choose one!):
4629 \end_layout
4630
4631 \begin_layout Enumerate
4632 The easy way:
4633 \newline
4634
4635 \newline
4636 a) Extract UnxUtils.zip to your C:
4637 \backslash
4638  hard disk PRESERVING the original paths, otherwise bison won't work.
4639  (If you are using WinZip make certain that 'Use folder names' is selected)
4640 \newline
4641
4642 \newline
4643 b)
4644  In the Visual C++ IDE click Tools, Options, select the Directory tab, in
4645  'Show directories for:' select 'Executable files', and in the directories
4646  window add a new path: 'C:
4647 \backslash
4648 user
4649 \backslash
4650 local
4651 \backslash
4652 wbin', click ok.
4653 \newline
4654
4655 \newline
4656 (As a side effect, you get a bunch of Unix utilities that
4657  could be useful, such as diff and patch.)
4658 \end_layout
4659
4660 \begin_layout Enumerate
4661 A more compact way:
4662 \newline
4663
4664 \newline
4665 This one avoids extracting a bunch of files you may not
4666  use, but requires some extra work:
4667 \newline
4668
4669 \newline
4670 a) Create a directory were to put the
4671  tools needed, or use a directory already present.
4672  Say for example 'C:
4673 \backslash
4674 util'.
4675 \newline
4676
4677 \newline
4678 b) Extract 'bison.exe', 'bison.hairy', 'bison.simple', 'flex.exe', and
4679  gawk.exe to such directory WITHOUT preserving the original paths.
4680  (If you are using WinZip make certain that 'Use folder names' is not selected)
4681 \newline
4682
4683 \newline
4684 c
4685 ) Rename bison.exe to '_bison.exe'.
4686 \newline
4687
4688 \newline
4689 d) Create a batch file 'bison.bat' in 'C:
4690 \backslash
4691 util
4692 \backslash
4693 ' and add these lines: 
4694 \newline
4695 \InsetSpace ~
4696 \InsetSpace ~
4697 set BISON_SIMPLE=C:
4698 \backslash
4699 util
4700 \backslash
4701 bison.simple 
4702 \newline
4703 \InsetSpace ~
4704 \InsetSpace ~
4705 set BISON_HAIRY=C:
4706 \backslash
4707 util
4708 \backslash
4709 bison.hairy
4710 \newline
4711 \InsetSpace ~
4712 \InsetSpace ~
4713 _bison %1 %2 %3 %4 %5 %6 %7 %8 %9
4714 \newline
4715
4716 \newline
4717 Steps 'c' and 'd' are needed
4718  because bison requires by default that the files 'bison.simple' and 'bison.hairy'
4719  reside in some weird Unix directory, '/usr/local/share/' I think.
4720  So it is necessary to tell bison where those files are located if they
4721  are not in such directory.
4722  That is the function of the environment variables BISON_SIMPLE and BISON_HAIRY.
4723 \newline
4724
4725 \newline
4726 e
4727 ) In the Visual C++ IDE click Tools, Options, select the Directory tab,
4728  in 'Show directories for:' select 'Executable files', and in the directories
4729  window add a new path: 'c:
4730 \backslash
4731 util', click ok.
4732  Note that you can use any other path instead of 'c:
4733 \backslash
4734 util', even the path where the Visual C++ tools are, probably: 'C:
4735 \backslash
4736 Program Files
4737 \backslash
4738 Microsoft Visual Studio
4739 \backslash
4740 Common
4741 \backslash
4742 Tools'.
4743  So you don't have to execute step 'e' :)
4744 \end_layout
4745
4746 \begin_layout Standard
4747 That is it.
4748  Open 'sdcc.dsw' in Visual Studio, click 'build all', when it finishes copy
4749  the executables from sdcc
4750 \backslash
4751 bin_vc to sdcc
4752 \backslash
4753 bin, and you can compile using SDCC.
4754 \end_layout
4755
4756 \begin_layout Subsection
4757 Building SDCC Using Borland
4758 \end_layout
4759
4760 \begin_layout Enumerate
4761 From the sdcc directory, run the command "make -f Makefile.bcc".
4762  This should regenerate all the .exe files in the bin directory except for
4763  SDCDB and ucSim.
4764 \end_layout
4765
4766 \begin_layout Enumerate
4767 If you modify any source files and need to rebuild, be aware that the dependenci
4768 es may not be correctly calculated.
4769  The safest option is to delete all .obj files and run the build again.
4770  From a Cygwin BASH prompt, this can easily be done with the command (be
4771  sure you are in the sdcc directory):
4772 \newline
4773
4774 \newline
4775
4776 \family sans
4777 \series bold
4778 find .
4779  
4780 \backslash
4781 ( -name '*.obj' -o -name '*.lib' -o -name '*.rul' 
4782 \backslash
4783 ) -print -exec rm {} 
4784 \backslash
4785 ;
4786 \family default
4787 \series default
4788
4789 \newline
4790
4791 \newline
4792 or on Windows NT/2000/XP from the command prompt with the command:
4793 \newline
4794
4795 \family sans
4796 \series bold
4797
4798 \newline
4799 del /s *.obj *.lib *.rul
4800 \family default
4801 \series default
4802  from the sdcc directory.
4803 \end_layout
4804
4805 \begin_layout Subsection
4806 Windows Install Using a ZIP Package
4807 \end_layout
4808
4809 \begin_layout Enumerate
4810 Download the binary zip package from 
4811 \begin_inset LatexCommand \url{http://sdcc.sf.net/snap.php}
4812
4813 \end_inset
4814
4815  and unpack it using your favorite unpacking tool (gunzip, WinZip, etc).
4816  This should unpack to a group of sub-directories.
4817  An example directory structure after unpacking the mingw32 package is:
4818  c:
4819 \backslash
4820 sdcc
4821 \backslash
4822 bin for the executables, c:
4823 \backslash
4824 sdcc
4825 \backslash
4826 include and c:
4827 \backslash
4828 sdcc
4829 \backslash
4830 lib for the include and libraries.
4831 \end_layout
4832
4833 \begin_layout Enumerate
4834 Adjust your environment variable PATH to include the location of the bin
4835  directory or start sdcc using the full path.
4836 \end_layout
4837
4838 \begin_layout Subsection
4839 Windows Install Using the Setup Program
4840 \begin_inset LatexCommand \label{sub:Windows-Install}
4841
4842 \end_inset
4843
4844
4845 \end_layout
4846
4847 \begin_layout Standard
4848 Download the setup program 
4849 \emph on
4850 sdcc-x.y.z-setup.exe
4851 \emph default
4852  for an official release from 
4853 \newline
4854
4855 \begin_inset LatexCommand \url{http://sf.net/project/showfiles.php?group_id=599}
4856
4857 \end_inset
4858
4859  or a setup program for one of the snapshots 
4860 \emph on
4861 sdcc-yyyymmdd-xxxx-setup.exe
4862 \emph default
4863  from 
4864 \begin_inset LatexCommand \url{http://sdcc.sf.net/snap.php}
4865
4866 \end_inset
4867
4868  and execute it.
4869  A windows typical installer will guide you through the installation process.
4870 \end_layout
4871
4872 \begin_layout Subsection
4873 VPATH
4874 \begin_inset LatexCommand \index{VPATH}
4875
4876 \end_inset
4877
4878  feature
4879 \end_layout
4880
4881 \begin_layout Standard
4882 SDCC supports the VPATH feature provided by configure and make.
4883  It allows to separate the source and build trees.
4884  Here's an example:
4885 \end_layout
4886
4887 \begin_layout Standard
4888
4889 \family typewriter
4890 cd ~\InsetSpace ~
4891 \InsetSpace ~
4892 \InsetSpace ~
4893 \InsetSpace ~
4894 \InsetSpace ~
4895 \InsetSpace ~
4896 \InsetSpace ~
4897 \InsetSpace ~
4898 \InsetSpace ~
4899 \InsetSpace ~
4900 \InsetSpace ~
4901 \InsetSpace ~
4902 \InsetSpace ~
4903 \InsetSpace ~
4904 \InsetSpace ~
4905 \InsetSpace ~
4906 \InsetSpace ~
4907 \InsetSpace ~
4908 \InsetSpace ~
4909 \InsetSpace ~
4910 \InsetSpace ~
4911 # cd $HOME
4912 \end_layout
4913
4914 \begin_layout Standard
4915
4916 \family typewriter
4917 tar -xzf sdcc.src.tar.gz\InsetSpace ~
4918 # extract source to directory sdcc
4919 \end_layout
4920
4921 \begin_layout Standard
4922
4923 \family typewriter
4924 mkdir sdcc.build\InsetSpace ~
4925 \InsetSpace ~
4926 \InsetSpace ~
4927 \InsetSpace ~
4928 \InsetSpace ~
4929 \InsetSpace ~
4930 \InsetSpace ~
4931 \InsetSpace ~
4932 \InsetSpace ~
4933 # put output in sdcc.build
4934 \end_layout
4935
4936 \begin_layout Standard
4937
4938 \family typewriter
4939 cd sdcc.build
4940 \end_layout
4941
4942 \begin_layout Standard
4943
4944 \family typewriter
4945 ../sdcc/configure\InsetSpace ~
4946 \InsetSpace ~
4947 \InsetSpace ~
4948 \InsetSpace ~
4949 \InsetSpace ~
4950 \InsetSpace ~
4951 \InsetSpace ~
4952 \InsetSpace ~
4953 # configure is doing all the magic!
4954 \end_layout
4955
4956 \begin_layout Standard
4957
4958 \family typewriter
4959 make
4960 \end_layout
4961
4962 \begin_layout Standard
4963 \noindent
4964 That's it! 
4965 \series bold
4966 configure
4967 \series default
4968  will create the directory tree will all the necessary Makefiles in ~/sdcc.build.
4969  It automagically computes the variables srcdir, top_srcdir and top_buildir
4970  for each directory.
4971  After running 
4972 \series bold
4973 make
4974 \series default
4975  the generated files will be in ~/sdcc.build, while the source files stay
4976  in ~/sdcc.
4977 \newline
4978 This is not only usefull for building different binaries, e.g.
4979  when cross compiling.
4980  It also gives you a much better overview in the source tree when all the
4981  generated files are not scattered between the source files.
4982  And the best thing is: if you want to change a file you can leave the original
4983  file untouched in the source directory.
4984  Simply copy it to the build directory, edit it, enter `make clean', `rm
4985  Makefile.dep' and `make'.
4986  
4987 \series bold
4988 make
4989 \series default
4990  will do the rest for you!
4991 \end_layout
4992
4993 \begin_layout Section
4994 Building the Documentation
4995 \end_layout
4996
4997 \begin_layout Standard
4998 Add -
4999 \begin_inset ERT
5000 status collapsed
5001
5002 \begin_layout Standard
5003
5004
5005 \backslash
5006 /
5007 \end_layout
5008
5009 \end_inset
5010
5011 -enable-doc to the configure arguments to build the documentation together
5012  with all the other stuff.
5013  You will need several tools (LyX, LaTeX, LaTeX2HTML, pdflatex, dvipdf,
5014  dvips and makeindex) to get the job done.
5015  Another possibility is to change to the doc directory and to type 
5016 \family sans
5017 \series bold
5018
5019 \begin_inset Quotes srd
5020 \end_inset
5021
5022 make
5023 \begin_inset Quotes srd
5024 \end_inset
5025
5026
5027 \family default
5028 \series default
5029  there.
5030  You're invited to make changes and additions to this manual (sdcc/doc/sdccman.ly
5031 x).
5032  Using LyX 
5033 \begin_inset LatexCommand \url{http://www.lyx.org}
5034
5035 \end_inset
5036
5037  as editor is straightforward.
5038  Prebuilt documentation in html and pdf format is available from 
5039 \begin_inset LatexCommand \url{http://sdcc.sf.net/snap.php}
5040
5041 \end_inset
5042
5043 .
5044 \end_layout
5045
5046 \begin_layout Section
5047 Reading the Documentation
5048 \begin_inset LatexCommand \index{Documentation}
5049
5050 \end_inset
5051
5052
5053 \end_layout
5054
5055 \begin_layout Standard
5056 Currently reading the document in pdf format is recommended, as for unknown
5057  reason the hyperlinks are working there whereas in the html version they
5058  are not
5059 \begin_inset Foot
5060 status open
5061
5062 \begin_layout Standard
5063 If you should know why please drop us a note
5064 \end_layout
5065
5066 \end_inset
5067
5068 .
5069  
5070 \newline
5071 You'll find the pdf version
5072 \begin_inset LatexCommand \index{PDF version of this document}
5073
5074 \end_inset
5075
5076  at 
5077 \begin_inset LatexCommand \url{http://sdcc.sf.net/doc/sdccman.pdf}
5078
5079 \end_inset
5080
5081 .
5082  
5083 \newline
5084 A html version
5085 \begin_inset LatexCommand \index{HTML version of this document}
5086
5087 \end_inset
5088
5089  should be online at 
5090 \begin_inset LatexCommand \url{http://sdcc.sf.net/doc/sdccman.html/index.html}
5091
5092 \end_inset
5093
5094 .
5095 \newline
5096 This documentation is in some aspects different from a commercial documentation:
5097  
5098 \end_layout
5099
5100 \begin_layout Itemize
5101 It tries to document SDCC for several processor architectures in one document
5102  (commercially these probably would be separate documents/products).
5103  This document
5104 \begin_inset LatexCommand \index{Status of documentation}
5105
5106 \end_inset
5107
5108  currently matches SDCC for mcs51 and DS390 best and does give too few informati
5109 on about f.e.
5110  Z80, PIC14, PIC16 and HC08.
5111 \end_layout
5112
5113 \begin_layout Itemize
5114 There are many references pointing away from this documentation.
5115  Don't let this distract you.
5116  If there f.e.
5117  was a reference like 
5118 \begin_inset LatexCommand \url{http://www.opencores.org}
5119
5120 \end_inset
5121
5122  together with a statement 
5123 \begin_inset Quotes sld
5124 \end_inset
5125
5126 some processors which are targetted by SDCC can be implemented in a 
5127 \emph on
5128 f
5129 \emph default
5130 ield 
5131 \emph on
5132 p
5133 \emph default
5134 rogrammable 
5135 \emph on
5136 g
5137 \emph default
5138 ate 
5139 \emph on
5140 a
5141 \emph default
5142 rray
5143 \begin_inset LatexCommand \index{FPGA (field programmable gate array)}
5144
5145 \end_inset
5146
5147
5148 \begin_inset Quotes srd
5149 \end_inset
5150
5151  or 
5152 \begin_inset LatexCommand \url{http://sf.net/projects/fpgac}
5153
5154 \end_inset
5155
5156
5157 \begin_inset LatexCommand \index{FpgaC ((subset of) C to FPGA compiler)}
5158
5159 \end_inset
5160
5161  
5162 \begin_inset Quotes sld
5163 \end_inset
5164
5165 have you ever heard of an open source compiler that compiles a subset of
5166  C for an FPGA?
5167 \begin_inset Quotes srd
5168 \end_inset
5169
5170  we expect you to have a quick look there and come back.
5171  If you read this you are on the right track.
5172 \end_layout
5173
5174 \begin_layout Itemize
5175 Some sections attribute more space to problems, restrictions and warnings
5176  than to the solution.
5177 \end_layout
5178
5179 \begin_layout Itemize
5180 The installation section and the section about the debugger is intimidating.
5181 \end_layout
5182
5183 \begin_layout Itemize
5184 There are still lots of typos and there are more different writing styles
5185  than pictures.
5186 \end_layout
5187
5188 \begin_layout Section
5189 Testing the SDCC Compiler
5190 \begin_inset LatexCommand \label{sec:Testing-the-SDCC}
5191
5192 \end_inset
5193
5194
5195 \end_layout
5196
5197 \begin_layout Standard
5198 The first thing you should do after installing your SDCC compiler is to
5199  see if it runs.
5200  Type 
5201 \family sans
5202 \series bold
5203 "sdcc -
5204 \begin_inset ERT
5205 status collapsed
5206
5207 \begin_layout Standard
5208
5209
5210 \backslash
5211 /
5212 \end_layout
5213
5214 \end_inset
5215
5216 -version"
5217 \begin_inset LatexCommand \index{version}
5218
5219 \end_inset
5220
5221
5222 \family default
5223 \series default
5224  at the prompt, and the program should run and output its version like:
5225  
5226 \newline
5227
5228 \family typewriter
5229 SDCC : mcs51/z80/avr/ds390/pic16/pic14/ds400/hc08 2.5.6 #4169 (May 8 2006)
5230  (UNIX)
5231 \end_layout
5232
5233 \begin_layout Standard
5234 If it doesn't run, or gives a message about not finding sdcc program, then
5235  you need to check over your installation.
5236  Make sure that the sdcc bin directory is in your executable search path
5237  defined by the PATH environment setting (
5238 \series medium
5239 see 
5240 \series default
5241 section 
5242 \begin_inset LatexCommand \ref{sub:Install-Trouble-shooting}
5243
5244 \end_inset
5245
5246 \InsetSpace ~
5247
5248 \series medium
5249 Install trouble-shooting for suggestions
5250 \series default
5251 ).
5252  Make sure that the sdcc program is in the bin folder, if not perhaps something
5253  did not install correctly.
5254 \newline
5255
5256 \newline
5257
5258 \series medium
5259 SDCC 
5260 \series default
5261 is commonly installed as described in section 
5262 \begin_inset Quotes sld
5263 \end_inset
5264
5265 Install and search paths
5266 \begin_inset Quotes srd
5267 \end_inset
5268
5269 .
5270 \newline
5271
5272 \newline
5273
5274 \series medium
5275 Make sure the compiler works on a very simple example.
5276  Type in the following test.c program using your favorite 
5277 \series default
5278 ASCII 
5279 \series medium
5280 editor:
5281 \end_layout
5282
5283 \begin_layout Verse
5284
5285 \family typewriter
5286 char test;
5287 \newline
5288
5289 \newline
5290 void main(void) {
5291 \newline
5292 \InsetSpace ~
5293 \InsetSpace ~
5294 \InsetSpace ~
5295 \InsetSpace ~
5296 test=0;
5297 \newline
5298 }
5299 \end_layout
5300
5301 \begin_layout Standard
5302
5303 \series medium
5304 Compile this using the following command: 
5305 \family sans
5306 \series bold
5307 "sdcc -c test.c".
5308
5309 \family default
5310 \series default
5311  
5312 \series medium
5313 If all goes well, the compiler will generate a test.asm and test.rel file.
5314  Congratulations, you've just compiled your first program with SDCC.
5315  We used the -c option to tell SDCC not to link the generated code, just
5316  to keep things simple for this step.
5317 \series default
5318
5319 \newline
5320
5321 \newline
5322
5323 \series medium
5324 The next step is to try it with the linker.
5325  Type in 
5326 \family sans
5327 \series bold
5328 "sdcc test.c
5329 \family default
5330 \series default
5331 "
5332 \series medium
5333 .
5334  If all goes well the compiler will link with the libraries and produce
5335  a test.ihx output file.
5336  If this step fails
5337 \series default
5338  
5339 \series medium
5340 (no test.ihx, and the linker generates warnings), then the problem is most
5341  likely that 
5342 \series default
5343 SDCC
5344 \series medium
5345  cannot find the 
5346 \series default
5347 /
5348 \series medium
5349 usr/local/share/sdcc/lib directory
5350 \series default
5351  
5352 \series medium
5353 (see 
5354 \series default
5355 section 
5356 \begin_inset LatexCommand \ref{sub:Install-Trouble-shooting}
5357
5358 \end_inset
5359
5360 \InsetSpace ~
5361
5362 \series medium
5363 Install trouble-shooting for suggestions).
5364 \series default
5365
5366 \newline
5367
5368 \newline
5369
5370 \series medium
5371 The final test is to ensure 
5372 \series default
5373 SDCC
5374 \series medium
5375  can use the 
5376 \series default
5377 standard
5378 \series medium
5379  header files and libraries.
5380  Edit test.c and change it to the following:
5381 \end_layout
5382
5383 \begin_layout Verse
5384
5385 \family typewriter
5386 #include <string.h>
5387 \newline
5388
5389 \newline
5390 char str1[10];
5391 \newline
5392
5393 \newline
5394 void main(void) {
5395 \newline
5396 \InsetSpace ~
5397 \InsetSpace ~
5398 strcpy(str1, "testing");
5399 \newline
5400 }
5401 \end_layout
5402
5403 \begin_layout Standard
5404
5405 \series medium
5406 Compile this by typing 
5407 \family sans
5408 \series bold
5409 "sdcc test.c"
5410 \family default
5411 \series medium
5412 .
5413  This should generate a test.ihx output file, and it should give no warnings
5414  such as not finding the string.h file.
5415  If it cannot find the string.h file, then the problem is that 
5416 \series default
5417 SDCC
5418 \series medium
5419  cannot find the /usr/local/share/sdcc/include directory
5420 \series default
5421  
5422 \series medium
5423 (see the 
5424 \series default
5425 section 
5426 \begin_inset LatexCommand \ref{sub:Install-Trouble-shooting}
5427
5428 \end_inset
5429
5430 \InsetSpace ~
5431
5432 \series medium
5433 Install trouble-shooting section for suggestions).
5434
5435 \series default
5436  Use option 
5437 \series bold
5438 -
5439 \begin_inset ERT
5440 status collapsed
5441
5442 \begin_layout Standard
5443
5444
5445 \backslash
5446 /
5447 \end_layout
5448
5449 \end_inset
5450
5451 -print-search-dirs
5452 \series default
5453
5454 \begin_inset LatexCommand \index{-\/-print-search-dirs}
5455
5456 \end_inset
5457
5458  to find exactly where SDCC is looking for the include and lib files.
5459 \end_layout
5460
5461 \begin_layout Section
5462 Install Trouble-shooting
5463 \begin_inset LatexCommand \label{sub:Install-Trouble-shooting}
5464
5465 \end_inset
5466
5467
5468 \begin_inset LatexCommand \index{Install trouble-shooting}
5469
5470 \end_inset
5471
5472
5473 \end_layout
5474
5475 \begin_layout Subsection
5476 If SDCC does not build correctly
5477 \end_layout
5478
5479 \begin_layout Standard
5480 A thing to try is starting from scratch by unpacking the .tgz source package
5481  again in an empty directory.
5482  Configure it like:
5483 \newline
5484
5485 \newline
5486
5487 \family sans
5488 \series bold
5489 ./configure 2>&1 | tee configure.log
5490 \family default
5491 \series default
5492
5493 \newline
5494
5495 \newline
5496 and build it like:
5497 \newline
5498
5499 \newline
5500
5501 \family sans
5502 \series bold
5503 make 2>&1 | tee make.log
5504 \family default
5505 \series default
5506
5507 \newline
5508
5509 \newline
5510 If anything goes wrong, you can review the log files to locate the problem.
5511  Or a relevant part of this can be attached to an email that could be helpful
5512  when requesting help from the mailing list.
5513 \end_layout
5514
5515 \begin_layout Subsection
5516 What the 
5517 \begin_inset Quotes sld
5518 \end_inset
5519
5520 ./configure
5521 \begin_inset Quotes srd
5522 \end_inset
5523
5524  does
5525 \end_layout
5526
5527 \begin_layout Standard
5528 The 
5529 \begin_inset Quotes sld
5530 \end_inset
5531
5532 ./configure
5533 \begin_inset Quotes srd
5534 \end_inset
5535
5536  command is a script that analyzes your system and performs some configuration
5537  to ensure the source package compiles on your system.
5538  It will take a few minutes to run, and will compile a few tests to determine
5539  what compiler features are installed.
5540 \end_layout
5541
5542 \begin_layout Subsection
5543 What the 
5544 \begin_inset Quotes sld
5545 \end_inset
5546
5547 make
5548 \begin_inset Quotes srd
5549 \end_inset
5550
5551  does
5552 \end_layout
5553
5554 \begin_layout Standard
5555 This runs the GNU make tool, which automatically compiles all the source
5556  packages into the final installed binary executables.
5557 \end_layout
5558
5559 \begin_layout Subsection
5560 What the 
5561 \begin_inset Quotes sld
5562 \end_inset
5563
5564 make install
5565 \begin_inset Quotes erd
5566 \end_inset
5567
5568  command does.
5569 \end_layout
5570
5571 \begin_layout Standard
5572 This will install the compiler, other executables libraries and include
5573  files into the appropriate directories.
5574  See sections 
5575 \begin_inset LatexCommand \ref{sub:Install-paths}
5576
5577 \end_inset
5578
5579 ,\InsetSpace ~
5580
5581 \begin_inset LatexCommand \ref{sub:Search-Paths}
5582
5583 \end_inset
5584
5585 \InsetSpace ~
5586 about install and search paths.
5587 \newline
5588 On most systems you will need super-user privilege
5589 s to do this.
5590 \end_layout
5591
5592 \begin_layout Section
5593 Components of SDCC
5594 \end_layout
5595
5596 \begin_layout Standard
5597 SDCC is not just a compiler, but a collection of tools by various developers.
5598  These include linkers, assemblers, simulators and other components.
5599  Here is a summary of some of the components.
5600  Note that the included simulator and assembler have separate documentation
5601  which you can find in the source package in their respective directories.
5602  As SDCC grows to include support for other processors, other packages from
5603  various developers are included and may have their own sets of documentation.
5604 \newline
5605
5606 \newline
5607 You
5608  might want to look at the files which are installed in <installdir>.
5609  At the time of this writing, we find the following programs for gcc-builds:
5610 \newline
5611
5612  
5613 \newline
5614 In <installdir>/bin:
5615 \end_layout
5616
5617 \begin_layout Itemize
5618 sdcc - The compiler.
5619 \end_layout
5620
5621 \begin_layout Itemize
5622 sdcpp - The C preprocessor.
5623 \end_layout
5624
5625 \begin_layout Itemize
5626 asx8051 - The assembler for 8051 type processors.
5627 \end_layout
5628
5629 \begin_layout Itemize
5630 as-z80
5631 \series bold
5632
5633 \series default
5634 as-gbz80 - The Z80 and GameBoy Z80 assemblers.
5635 \end_layout
5636
5637 \begin_layout Itemize
5638 aslink -The linker for 8051 type processors.
5639 \end_layout
5640
5641 \begin_layout Itemize
5642 link-z80
5643 \series bold
5644
5645 \series default
5646 link-gbz80 - The Z80 and GameBoy Z80 linkers.
5647 \end_layout
5648
5649 \begin_layout Itemize
5650 s51 - The ucSim 8051 simulator.
5651 \end_layout
5652
5653 \begin_layout Itemize
5654 sdcdb - The source debugger.
5655 \end_layout
5656
5657 \begin_layout Itemize
5658 packihx - A tool to pack (compress) Intel hex files.
5659 \end_layout
5660
5661 \begin_layout Standard
5662 In <installdir>/share/sdcc/include
5663 \end_layout
5664
5665 \begin_layout Itemize
5666 the include files
5667 \end_layout
5668
5669 \begin_layout Standard
5670 In <installdir>/share/sdcc/lib
5671 \end_layout
5672
5673 \begin_layout Itemize
5674 the subdirs src and small, large, z80, gbz80 and ds390 with the precompiled
5675  relocatables.
5676 \end_layout
5677
5678 \begin_layout Standard
5679 In <installdir>/share/sdcc/doc
5680 \end_layout
5681
5682 \begin_layout Itemize
5683 the documentation
5684 \end_layout
5685
5686 \begin_layout Standard
5687 As development for other processors proceeds, this list will expand to include
5688  executables to support processors like AVR, PIC, etc.
5689 \end_layout
5690
5691 \begin_layout Subsection
5692 sdcc - The Compiler
5693 \end_layout
5694
5695 \begin_layout Standard
5696 This is the actual compiler, it in turn uses the c-preprocessor and invokes
5697  the assembler and linkage editor.
5698 \end_layout
5699
5700 \begin_layout Subsection
5701 sdcpp - The C-Preprocessor
5702 \end_layout
5703
5704 \begin_layout Standard
5705 The preprocessor
5706 \begin_inset LatexCommand \index{sdcpp (preprocessor)}
5707
5708 \end_inset
5709
5710  is a modified version of the GNU cpp
5711 \begin_inset LatexCommand \index{cpp|see{sdcpp}}
5712
5713 \end_inset
5714
5715  preprocessor 
5716 \begin_inset LatexCommand \url{http://gcc.gnu.org/}
5717
5718 \end_inset
5719
5720 .
5721  The C preprocessor is used to pull in #include sources, process #ifdef
5722  statements, #defines and so on.
5723 \end_layout
5724
5725 \begin_layout Subsection
5726 as
5727 \emph on
5728 xxxx
5729 \emph default
5730 , aslink, link-
5731 \emph on
5732 xxx
5733 \emph default
5734  - The Assemblers and Linkage Editors
5735 \end_layout
5736
5737 \begin_layout Standard
5738 This is retargettable assembler & linkage editor, it was developed by Alan
5739  Baldwin.
5740  John Hartman created the version for 8051, and I (Sandeep) have made some
5741  enhancements and bug fixes for it to work properly with SDCC.
5742 \end_layout
5743
5744 \begin_layout Subsection
5745 s51 - The Simulator
5746 \end_layout
5747
5748 \begin_layout Standard
5749 S51
5750 \begin_inset LatexCommand \index{s51}
5751
5752 \end_inset
5753
5754  is a free open source simulator developed by Daniel Drotos.
5755  The simulator is built as part of the build process.
5756  For more information visit Daniel's web site at: 
5757 \begin_inset LatexCommand \url{http://mazsola.iit.uni-miskolc.hu/~drdani/embedded/s51}
5758
5759 \end_inset
5760
5761 .
5762  It currently supports the core mcs51, the Dallas DS80C390 and the Phillips
5763  XA51 family.
5764 \end_layout
5765
5766 \begin_layout Subsection
5767 sdcdb - Source Level Debugger
5768 \end_layout
5769
5770 \begin_layout Standard
5771 SDCDB
5772 \begin_inset LatexCommand \index{SDCDB (debugger)}
5773
5774 \end_inset
5775
5776  is the companion source level debugger.
5777  More about SDCDB in section 
5778 \begin_inset LatexCommand \ref{cha:Debugging-with-SDCDB}
5779
5780 \end_inset
5781
5782 .
5783  The current version of the debugger uses Daniel's Simulator S51
5784 \begin_inset LatexCommand \index{s51}
5785
5786 \end_inset
5787
5788 , but can be easily changed to use other simulators.
5789 \end_layout
5790
5791 \begin_layout Chapter
5792 Using SDCC
5793 \end_layout
5794
5795 \begin_layout Section
5796 Compiling
5797 \end_layout
5798
5799 \begin_layout Subsection
5800 Single Source File Projects
5801 \end_layout
5802
5803 \begin_layout Standard
5804 For single source file 8051 projects the process is very simple.
5805  Compile your programs with the following command 
5806 \family sans
5807 \series bold
5808 "sdcc sourcefile.c".
5809
5810 \family default
5811 \series default
5812  This will compile, assemble and link your source file.
5813  Output files are as follows:
5814 \end_layout
5815
5816 \begin_layout Itemize
5817 sourcefile.asm
5818 \begin_inset LatexCommand \index{<file>.asm}
5819
5820 \end_inset
5821
5822  - Assembler source
5823 \begin_inset LatexCommand \index{Assembler source}
5824
5825 \end_inset
5826
5827  file created by the compiler
5828 \end_layout
5829
5830 \begin_layout Itemize
5831 sourcefile.lst
5832 \begin_inset LatexCommand \index{<file>.lst}
5833
5834 \end_inset
5835
5836  - Assembler listing
5837 \begin_inset LatexCommand \index{Assembler listing}
5838
5839 \end_inset
5840
5841  file created by the Assembler
5842 \end_layout
5843
5844 \begin_layout Itemize
5845 sourcefile.rst
5846 \begin_inset LatexCommand \index{<file>.rst}
5847
5848 \end_inset
5849
5850  - Assembler listing
5851 \begin_inset LatexCommand \index{Assembler listing}
5852
5853 \end_inset
5854
5855  file updated with linkedit information, created by linkage editor
5856 \end_layout
5857
5858 \begin_layout Itemize
5859 sourcefile.sym
5860 \begin_inset LatexCommand \index{<file>.sym}
5861
5862 \end_inset
5863
5864  - symbol listing
5865 \begin_inset LatexCommand \index{Symbol listing}
5866
5867 \end_inset
5868
5869  for the sourcefile, created by the assembler
5870 \end_layout
5871
5872 \begin_layout Itemize
5873 sourcefile.rel
5874 \begin_inset LatexCommand \index{<file>.rel}
5875
5876 \end_inset
5877
5878  or sourcefile.o
5879 \begin_inset LatexCommand \index{<file>.o}
5880
5881 \end_inset
5882
5883  - Object file
5884 \begin_inset LatexCommand \index{Object file}
5885
5886 \end_inset
5887
5888  created by the assembler, input to Linkage editor
5889 \end_layout
5890
5891 \begin_layout Itemize
5892 sourcefile.map
5893 \begin_inset LatexCommand \index{<file>.map}
5894
5895 \end_inset
5896
5897  - The memory map
5898 \begin_inset LatexCommand \index{Memory map}
5899
5900 \end_inset
5901
5902  for the load module, created by the Linker
5903 \end_layout
5904
5905 \begin_layout Itemize
5906 sourcefile.mem
5907 \begin_inset LatexCommand \index{<file>.mem}
5908
5909 \end_inset
5910
5911  - A file with a summary of the memory usage
5912 \end_layout
5913
5914 \begin_layout Itemize
5915 sourcefile.ihx
5916 \begin_inset LatexCommand \index{<file>.ihx}
5917
5918 \end_inset
5919
5920  - The load module in Intel hex format
5921 \begin_inset LatexCommand \index{Intel hex format}
5922
5923 \end_inset
5924
5925  (you can select the Motorola S19 format
5926 \begin_inset LatexCommand \index{Motorola S19 format}
5927
5928 \end_inset
5929
5930  with -
5931 \begin_inset ERT
5932 status collapsed
5933
5934 \begin_layout Standard
5935
5936
5937 \backslash
5938 /
5939 \end_layout
5940
5941 \end_inset
5942
5943 -out-fmt-s19
5944 \begin_inset LatexCommand \index{-\/-out-fmt-s19}
5945
5946 \end_inset
5947
5948 .
5949  If you need another format you might want to use 
5950 \family sans
5951 \shape italic
5952 objdump
5953 \family default
5954 \shape default
5955
5956 \begin_inset LatexCommand \index{objdump (tool)}
5957
5958 \end_inset
5959
5960  or
5961 \family sans
5962 \shape italic
5963  srecord
5964 \family default
5965 \shape default
5966
5967 \begin_inset LatexCommand \index{srecord (bin, hex, ... tool)}
5968
5969 \end_inset
5970
5971
5972 \begin_inset Note Note
5973 status collapsed
5974
5975 \begin_layout Standard
5976 hyperlinks needed
5977 \end_layout
5978
5979 \end_inset
5980
5981  - see also section 
5982 \begin_inset LatexCommand \vref{sub:Postprocessing-the-Intel}
5983
5984 \end_inset
5985
5986 ).
5987  Both formats are documented in the documentation of srecord
5988 \begin_inset LatexCommand \index{srecord (bin, hex, ... tool)}
5989
5990 \end_inset
5991
5992
5993 \end_layout
5994
5995 \begin_layout Itemize
5996 sourcefile.adb
5997 \begin_inset LatexCommand \index{<file>.adb}
5998
5999 \end_inset
6000
6001  - An intermediate file containing debug information needed to create the
6002  .cdb file (with -
6003 \begin_inset ERT
6004 status collapsed
6005
6006 \begin_layout Standard
6007
6008
6009 \backslash
6010 /
6011 \end_layout
6012
6013 \end_inset
6014
6015 -debug
6016 \begin_inset LatexCommand \index{-\/-debug}
6017
6018 \end_inset
6019
6020
6021 \end_layout
6022
6023 \begin_layout Itemize
6024 sourcefile.cdb
6025 \begin_inset LatexCommand \index{<file>.cdb}
6026
6027 \end_inset
6028
6029  - An optional file (with -
6030 \begin_inset ERT
6031 status collapsed
6032
6033 \begin_layout Standard
6034
6035
6036 \backslash
6037 /
6038 \end_layout
6039
6040 \end_inset
6041
6042 -debug) containing debug information.
6043  The format is documented in cdbfileformat.pdf
6044 \end_layout
6045
6046 \begin_layout Itemize
6047 sourcefile.
6048  - (no extension)
6049 \begin_inset LatexCommand \index{<file> (no extension)}
6050
6051 \end_inset
6052
6053  An optional AOMF or AOMF51
6054 \begin_inset LatexCommand \index{AOMF, AOMF51}
6055
6056 \end_inset
6057
6058  
6059 \begin_inset LatexCommand \label{OMF file}
6060
6061 \end_inset
6062
6063 file containing debug information (generated with option -
6064 \begin_inset ERT
6065 status collapsed
6066
6067 \begin_layout Standard
6068
6069
6070 \backslash
6071 /
6072 \end_layout
6073
6074 \end_inset
6075
6076 -debug).
6077  The (Intel)
6078 \emph on
6079  a
6080 \emph default
6081 bsolute 
6082 \emph on
6083 o
6084 \emph default
6085 bject 
6086 \emph on
6087 m
6088 \emph default
6089 odule 
6090 \emph on
6091 f
6092 \emph default
6093 ormat is a subformat of the OMF51 format and is commonly used by third party
6094  tools (debuggers
6095 \begin_inset LatexCommand \index{Debugger}
6096
6097 \end_inset
6098
6099 , simulators, emulators).
6100 \end_layout
6101
6102 \begin_layout Itemize
6103 sourcefile.dump*
6104 \begin_inset LatexCommand \index{<file>.dump*}
6105
6106 \end_inset
6107
6108  - Dump file to debug the compiler it self (generated with option -
6109 \begin_inset ERT
6110 status collapsed
6111
6112 \begin_layout Standard
6113
6114
6115 \backslash
6116 /
6117 \end_layout
6118
6119 \end_inset
6120
6121 -dumpall) (see section 
6122 \begin_inset LatexCommand \ref{sub:Intermediate-Dump-Options}
6123
6124 \end_inset
6125
6126 \InsetSpace ~
6127  and section 
6128 \begin_inset LatexCommand \ref{sub:The-anatomy-of}
6129
6130 \end_inset
6131
6132 \InsetSpace ~
6133
6134 \begin_inset Quotes sld
6135 \end_inset
6136
6137 Anatomy of the compiler
6138 \begin_inset Quotes srd
6139 \end_inset
6140
6141 ).
6142 \end_layout
6143
6144 \begin_layout Subsection
6145 Postprocessing the Intel Hex
6146 \begin_inset LatexCommand \index{Intel hex format}
6147
6148 \end_inset
6149
6150  file
6151 \begin_inset LatexCommand \label{sub:Postprocessing-the-Intel}
6152
6153 \end_inset
6154
6155
6156 \end_layout
6157
6158 \begin_layout Standard
6159 In most cases this won't be needed but the Intel Hex file
6160 \begin_inset LatexCommand \index{<file>.ihx}
6161
6162 \end_inset
6163
6164  which is generated by SDCC might include lines of varying length and the
6165  addresses within the file are not guaranteed to be strictly ascending.
6166  If your toolchain or a bootloader does not like this you can use the tool
6167  
6168 \family typewriter
6169 packihx
6170 \family default
6171
6172 \begin_inset LatexCommand \index{packihx (tool)}
6173
6174 \end_inset
6175
6176  which is part of the SDCC distribution: 
6177 \newline
6178
6179 \newline
6180
6181 \family sans
6182 \series bold
6183  packihx sourcefile.ihx >sourcefile.hex
6184 \family default
6185 \series default
6186
6187 \newline
6188
6189 \newline
6190 The separately available
6191 \emph on
6192  srecord
6193 \emph default
6194
6195 \begin_inset LatexCommand \index{srecord (bin, hex, ... tool)}
6196
6197 \end_inset
6198
6199  package additionally allows to set undefined locations to a predefined
6200  value, to insert checksums
6201 \begin_inset LatexCommand \index{checksum}
6202
6203 \end_inset
6204
6205  of various flavours (crc, add, xor) and to perform other manipulations
6206  (convert, split, crop, offset, ...).
6207  
6208 \newline
6209
6210 \newline
6211
6212 \family sans
6213 \series bold
6214 srec_cat\InsetSpace ~
6215 \InsetSpace ~
6216 sourcefile.ihx -intel\InsetSpace ~
6217 \InsetSpace ~
6218 -o sourcefile.hex -intel
6219 \newline
6220
6221 \newline
6222
6223 \family default
6224 \series default
6225 An example for a more complex command line
6226 \begin_inset Foot
6227 status open
6228
6229 \begin_layout Standard
6230 the command backfills
6231 \begin_inset LatexCommand \index{backfill unused memory}
6232
6233 \end_inset
6234
6235  unused memory with 0x12 and the overall 16 bit sum of the complete 64 kByte
6236  block is zero.
6237  If the program counter on an mcs51 runs wild the backfill pattern 0x12
6238  will be interpreted as an 
6239 \family typewriter
6240 lcall
6241 \family default
6242  to address 
6243 \family typewriter
6244 0x1212
6245 \family default
6246  (where an emergency routine could sit).
6247 \end_layout
6248
6249 \end_inset
6250
6251  could look like:
6252 \newline
6253
6254 \newline
6255
6256 \family sans
6257 \series bold
6258 \size footnotesize
6259 srec_cat\InsetSpace ~
6260 sourcefile.ihx -intel\InsetSpace ~
6261 \InsetSpace ~
6262 -fill 0x12 0x0000 0xfffe\InsetSpace ~
6263 -little-endian-checksum-nega
6264 tive 0xfffe 0x02 0x02\InsetSpace ~
6265 \InsetSpace ~
6266 -o sourcefile.hex -intel
6267 \size default
6268
6269 \newline
6270
6271 \newline
6272
6273 \family default
6274 \series default
6275 The srecord package is available at 
6276 \begin_inset LatexCommand \url{http://sf.net/projects/srecord}
6277
6278 \end_inset
6279
6280  .
6281 \end_layout
6282
6283 \begin_layout Subsection
6284 Projects with Multiple Source Files
6285 \end_layout
6286
6287 \begin_layout Standard
6288 SDCC can compile only ONE file at a time.
6289  Let us for example assume that you have a project containing the following
6290  files:
6291 \newline
6292
6293 \newline
6294 foo1.c (contains some functions)
6295 \newline
6296 foo2.c (contains some more functions)
6297 \newline
6298 foomai
6299 n.c (contains more functions and the function main)
6300 \newline
6301
6302 \size footnotesize
6303
6304 \newline
6305
6306 \size default
6307 The first two files will need to be compiled separately with the commands:
6308 \size footnotesize
6309  
6310 \size default
6311
6312 \newline
6313
6314 \newline
6315
6316 \family sans
6317 \series bold
6318 sdcc\InsetSpace ~
6319 -c\InsetSpace ~
6320 foo1.c
6321 \family default
6322 \series default
6323 \size footnotesize
6324
6325 \newline
6326
6327 \family sans
6328 \series bold
6329 \size default
6330 sdcc\InsetSpace ~
6331 -c\InsetSpace ~
6332 foo2.c
6333 \family default
6334 \series default
6335
6336 \newline
6337
6338 \newline
6339 Then compile the source file containing the 
6340 \emph on
6341 main()
6342 \emph default
6343  function and link
6344 \begin_inset LatexCommand \index{Linker}
6345
6346 \end_inset
6347
6348  the files together with the following command: 
6349 \newline
6350
6351 \newline
6352
6353 \family sans
6354 \series bold
6355 sdcc\InsetSpace ~
6356 foomain.c\InsetSpace ~
6357 foo1.rel\InsetSpace ~
6358 foo2.rel
6359 \family default
6360 \series default
6361
6362 \begin_inset LatexCommand \index{<file>.rel}
6363
6364 \end_inset
6365
6366
6367 \newline
6368
6369 \newline
6370 Alternatively, 
6371 \emph on
6372 foomain.c 
6373 \emph default
6374 can be separately compiled as well: 
6375 \family sans
6376 \series bold
6377
6378 \newline
6379
6380 \newline
6381 sdcc\InsetSpace ~
6382 -c\InsetSpace ~
6383 foomain.c
6384 \newline
6385 sdcc foomain.rel foo1.rel foo2.rel
6386 \newline
6387
6388 \newline
6389
6390 \family default
6391 \series default
6392 The file containing the 
6393 \emph on
6394 main()
6395 \emph default
6396  function
6397 \emph on
6398  
6399 \emph default
6400 \noun on
6401 must
6402 \noun default
6403  be the 
6404 \noun on
6405 first
6406 \noun default
6407  file specified in the command line, since the linkage editor processes
6408  file in the order they are presented to it.
6409  The linker is invoked from SDCC using a script file with extension .lnk
6410 \begin_inset LatexCommand \index{<file>.lnk}
6411
6412 \end_inset
6413
6414 .
6415  You can view this file to troubleshoot linking problems such as those arising
6416  from missing libraries.
6417 \end_layout
6418
6419 \begin_layout Subsection
6420 Projects with Additional Libraries
6421 \begin_inset LatexCommand \index{Libraries}
6422
6423 \end_inset
6424
6425
6426 \end_layout
6427
6428 \begin_layout Standard
6429 Some reusable routines may be compiled into a library, see the documentation
6430  for the assembler and linkage editor (which are in <installdir>/share/sdcc/doc)
6431  for how to create a 
6432 \emph on
6433 .lib
6434 \begin_inset LatexCommand \index{<file>.lib}
6435
6436 \end_inset
6437
6438
6439 \emph default
6440  library file.
6441  Libraries created in this manner can be included in the command line.
6442  Make sure you include the -L <library-path> option to tell the linker where
6443  to look for these files if they are not in the current directory.
6444  Here is an example, assuming you have the source file 
6445 \emph on
6446 foomain.c
6447 \emph default
6448  and a library
6449 \emph on
6450  foolib.lib
6451 \emph default
6452  in the directory 
6453 \emph on
6454 mylib
6455 \emph default
6456  (if that is not the same as your current project):
6457 \newline
6458
6459 \newline
6460
6461 \family sans
6462 \series bold
6463 sdcc foomain.c foolib.lib -L mylib
6464 \newline
6465
6466 \newline
6467
6468 \family default
6469 \series default
6470 Note here that
6471 \emph on
6472  mylib
6473 \emph default
6474  must be an absolute path name.
6475 \newline
6476
6477 \newline
6478 The most efficient way to use libraries is
6479  to keep separate modules in separate source files.
6480  The lib file now should name all the modules.rel
6481 \begin_inset LatexCommand \index{<file>.rel}
6482
6483 \end_inset
6484
6485  files.
6486  For an example see the standard library file 
6487 \emph on
6488 libsdcc.lib
6489 \emph default
6490  in the directory <installdir>/share/lib/small.
6491 \end_layout
6492
6493 \begin_layout Subsection
6494 Using sdcclib to Create and Manage Libraries
6495 \begin_inset LatexCommand \index{sdcclib}
6496
6497 \end_inset
6498
6499
6500 \end_layout
6501
6502 \begin_layout Standard
6503 Alternatively, instead of having a .rel file for each entry on the library
6504  file as described in the preceding section, sdcclib can be used to embed
6505  all the modules belonging to such library in the library file itself.
6506  This results in a larger library file, but it greatly reduces the number
6507  of disk files accessed by the linker.
6508   Additionally, the packed library file contains an index of all include
6509  modules and symbols that significantly speeds up the linking process.
6510  To display a list of options supported by sdcclib type:
6511 \newline
6512
6513 \end_layout
6514
6515 \begin_layout Standard
6516
6517 \family sans
6518 \series bold
6519 sdcclib -?
6520 \begin_inset LatexCommand \index{sdcclib}
6521
6522 \end_inset
6523
6524
6525 \newline
6526
6527 \newline
6528
6529 \family default
6530 \series default
6531 To create a new library file, start by compiling all the required modules.
6532  For example:
6533 \newline
6534
6535 \end_layout
6536
6537 \begin_layout Standard
6538
6539 \family sans
6540 \series bold
6541 sdcc -c _divsint.c
6542 \end_layout
6543
6544 \begin_layout Standard
6545
6546 \family sans
6547 \series bold
6548 sdcc -c _divuint.c
6549 \end_layout
6550
6551 \begin_layout Standard
6552
6553 \family sans
6554 \series bold
6555 sdcc -c _modsint.c
6556 \end_layout
6557
6558 \begin_layout Standard
6559
6560 \family sans
6561 \series bold
6562 sdcc -c _moduint.c
6563 \end_layout
6564
6565 \begin_layout Standard
6566
6567 \family sans
6568 \series bold
6569 sdcc -c _mulint.c
6570 \newline
6571
6572 \end_layout
6573
6574 \begin_layout Standard
6575 This will create files _divsint.rel, _divuint.rel, _modsint.rel, _moduint.rel,
6576  and _mulint.rel.
6577  The next step is to add the .rel files to the library file:
6578 \newline
6579
6580 \end_layout
6581
6582 \begin_layout Standard
6583
6584 \family sans
6585 \series bold
6586 sdcclib libint.lib _divsint.rel
6587 \family default
6588
6589 \begin_inset LatexCommand \index{sdcclib}
6590
6591 \end_inset
6592
6593
6594 \end_layout
6595
6596 \begin_layout Standard
6597
6598 \family sans
6599 \series bold
6600 sdcclib libint.lib _divuint.rel
6601 \end_layout
6602
6603 \begin_layout Standard
6604
6605 \family sans
6606 \series bold
6607 sdcclib libint.lib _modsint.rel
6608 \end_layout
6609
6610 \begin_layout Standard
6611
6612 \family sans
6613 \series bold
6614 sdcclib libint.lib _moduint.rel
6615 \end_layout
6616
6617 \begin_layout Standard
6618
6619 \family sans
6620 \series bold
6621 sdcclib libint.lib _mulint.rel
6622 \family default
6623 \series default
6624
6625 \newline
6626
6627 \end_layout
6628
6629 \begin_layout Standard
6630 Or, if you preffer:
6631 \family sans
6632 \series bold
6633
6634 \newline
6635
6636 \end_layout
6637
6638 \begin_layout Standard
6639
6640 \family sans
6641 \series bold
6642 sdcclib libint.lib _divsint.rel _divuint.rel _modsint.rel _moduint.rel _mulint.rel
6643 \family default
6644 \series default
6645
6646 \newline
6647
6648 \end_layout
6649
6650 \begin_layout Standard
6651 If the file already exists in the library, it will be replaced.
6652  If a list of .rel files is available, you can tell sdcclib to add those
6653  files to a library.
6654  For example, if the file 'myliblist.txt' contains
6655 \family sans
6656 \series bold
6657
6658 \newline
6659
6660 \end_layout
6661
6662 \begin_layout Standard
6663
6664 \family sans
6665 \series bold
6666 _divsint.rel
6667 \end_layout
6668
6669 \begin_layout Standard
6670
6671 \family sans
6672 \series bold
6673 _divuint.rel
6674 \end_layout
6675
6676 \begin_layout Standard
6677
6678 \family sans
6679 \series bold
6680 _modsint.rel
6681 \end_layout
6682
6683 \begin_layout Standard
6684
6685 \family sans
6686 \series bold
6687 _moduint.rel
6688 \end_layout
6689
6690 \begin_layout Standard
6691
6692 \family sans
6693 \series bold
6694 _mulint.rel
6695 \family default
6696 \series default
6697
6698 \newline
6699
6700 \end_layout
6701
6702 \begin_layout Standard
6703 Use
6704 \family sans
6705 \series bold
6706
6707 \newline
6708
6709 \end_layout
6710
6711 \begin_layout Standard
6712
6713 \family sans
6714 \series bold
6715 sdcclib -l libint.lib myliblist.txt
6716 \family default
6717 \series default
6718
6719 \newline
6720
6721 \end_layout
6722
6723 \begin_layout Standard
6724 Additionally, you can instruct sdcclib to compiles the files before adding
6725  them to the library.
6726  This is achieved using the environment variables SDCCLIB_CC and/or SDCCLIB_AS.
6727  For example:
6728 \family sans
6729 \series bold
6730
6731 \newline
6732
6733 \end_layout
6734
6735 \begin_layout Standard
6736
6737 \family sans
6738 \series bold
6739 set SDCCLIB_CC=sdcc -c
6740 \end_layout
6741
6742 \begin_layout Standard
6743
6744 \family sans
6745 \series bold
6746 sdcclib -l libint.lib myliblist.txt
6747 \family default
6748 \series default
6749
6750 \newline
6751
6752 \end_layout
6753
6754 \begin_layout Standard
6755 To see what modules and symbols are included in the library, options -s
6756  and -m are available.
6757  For example:
6758 \newline
6759
6760 \newline
6761
6762 \family sans
6763 \series bold
6764 sdcclib -s libint.lib
6765 \family default
6766
6767 \begin_inset LatexCommand \index{sdcclib}
6768
6769 \end_inset
6770
6771
6772 \newline
6773
6774 \family typewriter
6775 \series default
6776 _divsint.rel:
6777 \end_layout
6778
6779 \begin_layout Standard
6780
6781 \family typewriter
6782 __divsint_a_1_1
6783 \end_layout
6784
6785 \begin_layout Standard
6786
6787 \family typewriter
6788 __divsint_PARM_2
6789 \end_layout
6790
6791 \begin_layout Standard
6792
6793 \family typewriter
6794 __divsint
6795 \newline
6796 _divuint.rel:
6797 \end_layout
6798
6799 \begin_layout Standard
6800
6801 \family typewriter
6802 __divuint_a_1_1
6803 \end_layout
6804
6805 \begin_layout Standard
6806
6807 \family typewriter
6808 __divuint_PARM_2
6809 \end_layout
6810
6811 \begin_layout Standard
6812
6813 \family typewriter
6814 __divuint_reste_1_1
6815 \end_layout
6816
6817 \begin_layout Standard
6818
6819 \family typewriter
6820 __divuint_count_1_1
6821 \end_layout
6822
6823 \begin_layout Standard
6824
6825 \family typewriter
6826 __divuint
6827 \newline
6828 _modsint.rel:
6829 \end_layout
6830
6831 \begin_layout Standard
6832
6833 \family typewriter
6834 __modsint_a_1_1
6835 \end_layout
6836
6837 \begin_layout Standard
6838
6839 \family typewriter
6840 __modsint_PARM_2
6841 \end_layout
6842
6843 \begin_layout Standard
6844
6845 \family typewriter
6846 __modsint
6847 \newline
6848 _moduint.rel:
6849 \end_layout
6850
6851 \begin_layout Standard
6852
6853 \family typewriter
6854 __moduint_a_1_1
6855 \end_layout
6856
6857 \begin_layout Standard
6858
6859 \family typewriter
6860 __moduint_PARM_2
6861 \end_layout
6862
6863 \begin_layout Standard
6864
6865 \family typewriter
6866 __moduint_count_1_1
6867 \end_layout
6868
6869 \begin_layout Standard
6870
6871 \family typewriter
6872 __moduint
6873 \newline
6874 _mulint.rel:
6875 \end_layout
6876
6877 \begin_layout Standard
6878
6879 \family typewriter
6880 __mulint_PARM_2
6881 \end_layout
6882
6883 \begin_layout Standard
6884
6885 \family typewriter
6886 __mulint
6887 \family default
6888 \series bold
6889
6890 \newline
6891
6892 \end_layout
6893
6894 \begin_layout Standard
6895 If the source files are compiled using -
6896 \begin_inset ERT
6897 status collapsed
6898
6899 \begin_layout Standard
6900
6901
6902 \backslash
6903 /
6904 \end_layout
6905
6906 \end_inset
6907
6908 -debug
6909 \begin_inset LatexCommand \index{-\/-debug}
6910
6911 \end_inset
6912
6913 , the corresponding debug information file .adb will be include in the library
6914  file as well.
6915  The library files created with sdcclib are plain text files, so they can
6916  be viewed with a text editor.
6917  It is not recomended to modify a library file created with sdcclib using
6918  a text editor, as there are file indexes numbers located accross the file
6919  used by the linker to quickly locate the required module to link.
6920  Once a .rel file (as well as a .adb file) is added to a library using sdcclib,
6921  it can be safely deleted, since all the information required for linking
6922  is embedded in the library file itself.
6923  Library files created using sdcclib are used as described in the preceding
6924  sections.
6925 \begin_inset VSpace bigskip
6926 \end_inset
6927
6928
6929 \end_layout
6930
6931 \begin_layout Section
6932 Command Line Options
6933 \begin_inset LatexCommand \index{Command Line Options}
6934
6935 \end_inset
6936
6937
6938 \begin_inset LatexCommand \label{sec:Command-Line-Options}
6939
6940 \end_inset
6941
6942
6943 \end_layout
6944
6945 \begin_layout Subsection
6946 Processor Selection Options
6947 \begin_inset LatexCommand \index{Options processor selection}
6948
6949 \end_inset
6950
6951
6952 \begin_inset LatexCommand \index{Processor selection options}
6953
6954 \end_inset
6955
6956
6957 \end_layout
6958
6959 \begin_layout List
6960 \labelwidthstring 00.00.0000
6961
6962 \series bold
6963 -mmcs51
6964 \begin_inset LatexCommand \index{-mmcs51}
6965
6966 \end_inset
6967
6968
6969 \series default
6970  Generate code for the Intel MCS51
6971 \begin_inset LatexCommand \index{MCS51}
6972
6973 \end_inset
6974
6975  family of processors.
6976  This is the default processor target.
6977 \end_layout
6978
6979 \begin_layout List
6980 \labelwidthstring 00.00.0000
6981
6982 \series bold
6983 -mds390
6984 \begin_inset LatexCommand \index{-mds390}
6985
6986 \end_inset
6987
6988
6989 \series default
6990  Generate code for the Dallas DS80C390
6991 \begin_inset LatexCommand \index{DS80C390}
6992
6993 \end_inset
6994
6995  processor.
6996 \end_layout
6997
6998 \begin_layout List
6999 \labelwidthstring 00.00.0000
7000
7001 \series bold
7002 -mds400
7003 \begin_inset LatexCommand \index{-mds400}
7004
7005 \end_inset
7006
7007
7008 \series default
7009  Generate code for the Dallas DS80C400
7010 \begin_inset LatexCommand \index{DS80C400}
7011
7012 \end_inset
7013
7014  processor.
7015 \end_layout
7016
7017 \begin_layout List
7018 \labelwidthstring 00.00.0000
7019
7020 \series bold
7021 -mhc08
7022 \begin_inset LatexCommand \index{-mhc08}
7023
7024 \end_inset
7025
7026
7027 \series default
7028  Generate code for the Freescale/Motorola HC08
7029 \begin_inset LatexCommand \index{HC08}
7030
7031 \end_inset
7032
7033  family of processors.
7034 \end_layout
7035
7036 \begin_layout List
7037 \labelwidthstring 00.00.0000
7038
7039 \series bold
7040 -mz80
7041 \begin_inset LatexCommand \index{-mz80}
7042
7043 \end_inset
7044
7045
7046 \series default
7047  Generate code for the Zilog Z80
7048 \begin_inset LatexCommand \index{Z80}
7049
7050 \end_inset
7051
7052  family of processors.
7053 \end_layout
7054
7055 \begin_layout List
7056 \labelwidthstring 00.00.0000
7057
7058 \series bold
7059 -mgbz80
7060 \begin_inset LatexCommand \index{-mgbz80}
7061
7062 \end_inset
7063
7064
7065 \series default
7066  Generate code for the GameBoy Z80
7067 \begin_inset LatexCommand \index{gbz80 (GameBoy Z80)}
7068
7069 \end_inset
7070
7071  processor (Not actively maintained).
7072 \end_layout
7073
7074 \begin_layout List
7075 \labelwidthstring 00.00.0000
7076
7077 \series bold
7078 -mavr
7079 \begin_inset LatexCommand \index{-mavr}
7080
7081 \end_inset
7082
7083
7084 \series default
7085  Generate code for the Atmel AVR
7086 \begin_inset LatexCommand \index{AVR}
7087
7088 \end_inset
7089
7090  processor (Not maintained, not complete).
7091  AVR users should probably have a look at winavr 
7092 \begin_inset LatexCommand \url{http://sourceforge.net/projects/winavr}
7093
7094 \end_inset
7095
7096  or 
7097 \begin_inset LatexCommand \url{http://www.avrfreaks.net/index.php?name=PNphpBB2&file=index}
7098
7099 \end_inset
7100
7101 , which is based on AVR-port of the gcc compiler.
7102 \end_layout
7103
7104 \begin_layout Standard
7105 \begin_inset Note Note
7106 status collapsed
7107
7108 \begin_layout Standard
7109 I think it is fair to direct users there for now.
7110  Open source is also about avoiding unnecessary work .
7111  But I didn't find the 'official' link.
7112 \end_layout
7113
7114 \end_inset
7115
7116
7117 \end_layout
7118
7119 \begin_layout List
7120 \labelwidthstring 00.00.0000
7121
7122 \series bold
7123 -mpic14
7124 \begin_inset LatexCommand \index{-mpic14}
7125
7126 \end_inset
7127
7128
7129 \series default
7130  Generate code for the Microchip PIC 14
7131 \begin_inset LatexCommand \index{PIC14}
7132
7133 \end_inset
7134
7135 -bit processors (p16f84 and variants.
7136  In development, not complete).
7137 \end_layout
7138
7139 \begin_layout Standard
7140 \begin_inset Note Note
7141 status collapsed
7142
7143 \begin_layout Standard
7144 p16f627 p16f628 p16f84 p16f873 p16f877?
7145 \end_layout
7146
7147 \end_inset
7148
7149
7150 \end_layout
7151
7152 \begin_layout List
7153 \labelwidthstring 00.00.0000
7154
7155 \series bold
7156 -mpic16
7157 \begin_inset LatexCommand \index{-mpic16}
7158
7159 \end_inset
7160
7161
7162 \series default
7163  Generate code for the Microchip PIC 16
7164 \begin_inset LatexCommand \index{PIC16}
7165
7166 \end_inset
7167
7168 -bit processors (p18f452 and variants.
7169  In development, not complete).
7170 \end_layout
7171
7172 \begin_layout List
7173 \labelwidthstring 00.00.0000
7174
7175 \series bold
7176 -mtlcs900h
7177 \series default
7178  Generate code for the Toshiba TLCS-900H
7179 \begin_inset LatexCommand \index{TLCS-900H}
7180
7181 \end_inset
7182
7183  processor (Not maintained, not complete).
7184 \end_layout
7185
7186 \begin_layout List
7187 \labelwidthstring 00.00.0000
7188
7189 \series bold
7190 -mxa51
7191 \begin_inset LatexCommand \index{-mxa51}
7192
7193 \end_inset
7194
7195
7196 \series default
7197  Generate code for the Phillips XA51
7198 \begin_inset LatexCommand \index{XA51}
7199
7200 \end_inset
7201
7202  processor (Not maintained, not complete).
7203 \end_layout
7204
7205 \begin_layout Standard
7206 \begin_inset VSpace bigskip
7207 \end_inset
7208
7209
7210 \end_layout
7211
7212 \begin_layout Subsection
7213 Preprocessor Options
7214 \begin_inset LatexCommand \index{Options preprocessor}
7215
7216 \end_inset
7217
7218
7219 \begin_inset LatexCommand \index{Preprocessor options}
7220
7221 \end_inset
7222
7223
7224 \begin_inset LatexCommand \index{sdcpp (preprocessor)}
7225
7226 \end_inset
7227
7228
7229 \end_layout
7230
7231 \begin_layout List
7232 \labelwidthstring 00.00.0000
7233
7234 \series bold
7235 -I<path>
7236 \begin_inset LatexCommand \index{-I<path>}
7237
7238 \end_inset
7239
7240
7241 \series default
7242  The additional location where the preprocessor will look for <..h> or 
7243 \begin_inset Quotes eld
7244 \end_inset
7245
7246 ..h
7247 \begin_inset Quotes erd
7248 \end_inset
7249
7250  files.
7251 \end_layout
7252
7253 \begin_layout List
7254 \labelwidthstring 00.00.0000
7255
7256 \series bold
7257 -D<macro[=value]>
7258 \begin_inset LatexCommand \index{-D<macro[=value]>}
7259
7260 \end_inset
7261
7262
7263 \series default
7264  Command line definition of macros.
7265  Passed to the preprocessor.
7266 \end_layout
7267
7268 \begin_layout List
7269 \labelwidthstring 00.00.0000
7270
7271 \series bold
7272 -M
7273 \begin_inset LatexCommand \index{-M}
7274
7275 \end_inset
7276
7277
7278 \series default
7279  Tell the preprocessor to output a rule suitable for make describing the
7280  dependencies of each object file.
7281  For each source file, the preprocessor outputs one make-rule whose target
7282  is the object file name for that source file and whose dependencies are
7283  all the files `#include'd in it.
7284  This rule may be a single line or may be continued with `
7285 \backslash
7286 '-newline if it is long.
7287  The list of rules is printed on standard output instead of the preprocessed
7288  C program.
7289  `-M' implies `-E
7290 \begin_inset LatexCommand \index{-E}
7291
7292 \end_inset
7293
7294 '.
7295 \end_layout
7296
7297 \begin_layout List
7298 \labelwidthstring 00.00.0000
7299
7300 \series bold
7301 -C
7302 \begin_inset LatexCommand \index{-C}
7303
7304 \end_inset
7305
7306
7307 \series default
7308  Tell the preprocessor not to discard comments.
7309  Used with the `-E' option.
7310 \end_layout
7311
7312 \begin_layout List
7313 \labelwidthstring 00.00.0000
7314
7315 \series bold
7316 -MM
7317 \begin_inset LatexCommand \index{-MM}
7318
7319 \end_inset
7320
7321
7322 \size large
7323 \bar under
7324  
7325 \series default
7326 \size default
7327 \bar default
7328 Like `-M' but the output mentions only the user header files included with
7329  `#include 
7330 \begin_inset Quotes eld
7331 \end_inset
7332
7333 file"'.
7334  System header files included with `#include <file>' are omitted.
7335 \end_layout
7336
7337 \begin_layout List
7338 \labelwidthstring 00.00.0000
7339
7340 \series bold
7341 -Aquestion(answer)
7342 \begin_inset LatexCommand \index{-Aquestion(answer)}
7343
7344 \end_inset
7345
7346
7347 \series default
7348  Assert the answer answer for question, in case it is tested with a preprocessor
7349  conditional such as `#if #question(answer)'.
7350  `-A-' disables the standard assertions that normally describe the target
7351  machine.
7352 \end_layout
7353
7354 \begin_layout List
7355 \labelwidthstring 00.00.0000
7356
7357 \series bold
7358 -Umacro
7359 \begin_inset LatexCommand \index{-Umacro}
7360
7361 \end_inset
7362
7363
7364 \series default
7365  Undefine macro macro.
7366  `-U' options are evaluated after all `-D' options, but before any `-include'
7367  and `-imacros' options.
7368 \end_layout
7369
7370 \begin_layout List
7371 \labelwidthstring 00.00.0000
7372
7373 \series bold
7374 -dM
7375 \begin_inset LatexCommand \index{-dM}
7376
7377 \end_inset
7378
7379
7380 \series default
7381  Tell the preprocessor to output only a list of the macro definitions that
7382  are in effect at the end of preprocessing.
7383  Used with the `-E' option.
7384 \end_layout
7385
7386 \begin_layout List
7387 \labelwidthstring 00.00.0000
7388
7389 \series bold
7390 -dD
7391 \begin_inset LatexCommand \index{-dD}
7392
7393 \end_inset
7394
7395
7396 \series default
7397  Tell the preprocessor to pass all macro definitions into the output, in
7398  their proper sequence in the rest of the output.
7399 \end_layout
7400
7401 \begin_layout List
7402 \labelwidthstring 00.00.0000
7403
7404 \series bold
7405 -dN
7406 \begin_inset LatexCommand \index{-dN}
7407
7408 \end_inset
7409
7410
7411 \size large
7412 \bar under
7413  
7414 \series default
7415 \size default
7416 \bar default
7417 Like `-dD' except that the macro arguments and contents are omitted.
7418  Only `#define name' is included in the output.
7419 \end_layout
7420
7421 \begin_layout List
7422 \labelwidthstring 00.00.0000
7423
7424 \series bold
7425 -pedantic-parse-number
7426 \begin_inset LatexCommand \index{pedantic}
7427
7428 \end_inset
7429
7430
7431 \begin_inset LatexCommand \index{-pedantic-parse-number}
7432
7433 \end_inset
7434
7435
7436 \size large
7437 \bar under
7438
7439 \begin_inset LatexCommand \label{lyx:-pedantic-parse-number}
7440
7441 \end_inset
7442
7443  
7444 \series default
7445 \size default
7446 \bar default
7447 Pedantic parse numbers so that situations like 0xfe-LO_B(3) are parsed properly
7448  and the macro LO_B(3) gets expanded.
7449  See also #pragma pedantic_parse_number 
7450 \begin_inset LatexCommand \vpageref{ite:pedantic_parse_number}
7451
7452 \end_inset
7453
7454  in section
7455 \begin_inset LatexCommand \ref{sec:Pragmas}
7456
7457 \end_inset
7458
7459  
7460 \emph on
7461 Note: this functionality is not in conformance with C99 standard!
7462 \end_layout
7463
7464 \begin_layout List
7465 \labelwidthstring 00.00.0000
7466
7467 \series bold
7468 -Wp\InsetSpace ~
7469 preprocessorOption[,preprocessorOption]
7470 \series default
7471
7472 \begin_inset LatexCommand \index{-Wp preprocessorOption[,preprocessorOption]}
7473
7474 \end_inset
7475
7476 ...
7477  Pass the preprocessorOption to the preprocessor 
7478 \family typewriter
7479 sdcpp
7480 \family default
7481
7482 \begin_inset LatexCommand \index{sdcpp (preprocessor)}
7483
7484 \end_inset
7485
7486 .
7487  SDCC uses an adapted version of the preprocessor 
7488 \emph on
7489 cpp
7490 \emph default
7491  of the GNU Compiler Collection
7492 \begin_inset LatexCommand \index{gcc (GNU Compiler Collection)}
7493
7494 \end_inset
7495
7496  (
7497 \emph on
7498 gcc
7499 \emph default
7500  
7501 \begin_inset LatexCommand \url{http://gcc.gnu.org/}
7502
7503 \end_inset
7504
7505 ), if you need more dedicated options please refer to the GCC\InsetSpace ~
7506 4.1.1\InsetSpace ~
7507 CPP\InsetSpace ~
7508 Manual
7509  at 
7510 \begin_inset LatexCommand \htmlurl{http://www.gnu.org/software/gcc/onlinedocs/}
7511
7512 \end_inset
7513
7514 .
7515 \end_layout
7516
7517 \begin_layout Standard
7518 \begin_inset VSpace bigskip
7519 \end_inset
7520
7521
7522 \end_layout
7523
7524 \begin_layout Subsection
7525 Linker Options
7526 \begin_inset LatexCommand \index{Options linker}
7527
7528 \end_inset
7529
7530
7531 \begin_inset LatexCommand \index{Linker options}
7532
7533 \end_inset
7534
7535
7536 \end_layout
7537
7538 \begin_layout List
7539 \labelwidthstring 00.00.0000
7540
7541 \series bold
7542 -L\InsetSpace ~
7543 -
7544 \series default
7545
7546 \begin_inset ERT
7547 status collapsed
7548
7549 \begin_layout Standard
7550
7551
7552 \backslash
7553 /
7554 \end_layout
7555
7556 \end_inset
7557
7558
7559 \series bold
7560 -lib-path
7561 \begin_inset LatexCommand \index{-\/-lib-path <path>}
7562
7563 \end_inset
7564
7565
7566 \begin_inset LatexCommand \index{-L -\/-lib-path}
7567
7568 \end_inset
7569
7570
7571 \series default
7572 \InsetSpace ~
7573 <absolute path to additional libraries> This option is passed to the linkage
7574  editor's additional libraries
7575 \begin_inset LatexCommand \index{Libraries}
7576
7577 \end_inset
7578
7579  search path.
7580  The path name must be absolute.
7581  Additional library files may be specified in the command line.
7582  See section Compiling programs for more details.
7583 \end_layout
7584
7585 \begin_layout List
7586 \labelwidthstring 00.00.0000
7587
7588 \series bold
7589 -
7590 \begin_inset ERT
7591 status collapsed
7592
7593 \begin_layout Standard
7594
7595
7596 \backslash
7597 /
7598 \end_layout
7599
7600 \end_inset
7601
7602 -xram-loc
7603 \series default
7604
7605 \begin_inset LatexCommand \index{-\/-xram-loc <Value>}
7606
7607 \end_inset
7608
7609 \InsetSpace ~
7610 <Value> The start location of the external ram
7611 \begin_inset LatexCommand \index{xdata (mcs51, ds390 storage class)}
7612
7613 \end_inset
7614
7615 , default value is 0.
7616  The value entered can be in Hexadecimal or Decimal format, e.g.: -
7617 \begin_inset ERT
7618 status collapsed
7619
7620 \begin_layout Standard
7621
7622
7623 \backslash
7624 /
7625 \end_layout
7626
7627 \end_inset
7628
7629 -xram-loc 0x8000 or -
7630 \begin_inset ERT
7631 status collapsed
7632
7633 \begin_layout Standard
7634
7635
7636 \backslash
7637 /
7638 \end_layout
7639
7640 \end_inset
7641
7642 -xram-loc 32768.
7643 \end_layout
7644
7645 \begin_layout List
7646 \labelwidthstring 00.00.0000
7647
7648 \series bold
7649 -
7650 \begin_inset ERT
7651 status collapsed
7652
7653 \begin_layout Standard
7654
7655
7656 \backslash
7657 /
7658 \end_layout
7659
7660 \end_inset
7661
7662 -code-loc
7663 \series default
7664
7665 \begin_inset LatexCommand \index{-\/-code-loc <Value>}
7666
7667 \end_inset
7668
7669 \InsetSpace ~
7670 <Value> The start location of the code
7671 \begin_inset LatexCommand \index{code}
7672
7673 \end_inset
7674
7675  segment, default value 0.
7676  Note when this option is used the interrupt vector table
7677 \begin_inset LatexCommand \index{interrupt vector table}
7678
7679 \end_inset
7680
7681  is also relocated to the given address.
7682  The value entered can be in Hexadecimal or Decimal format, e.g.: -
7683 \begin_inset ERT
7684 status collapsed
7685
7686 \begin_layout Standard
7687
7688
7689 \backslash
7690 /
7691 \end_layout
7692
7693 \end_inset
7694
7695 -code-loc 0x8000 or -
7696 \begin_inset ERT
7697 status collapsed
7698
7699 \begin_layout Standard
7700
7701
7702 \backslash
7703 /
7704 \end_layout
7705
7706 \end_inset
7707
7708 -code-loc 32768.
7709 \end_layout
7710
7711 \begin_layout List
7712 \labelwidthstring 00.00.0000
7713
7714 \series bold
7715 -
7716 \begin_inset ERT
7717 status collapsed
7718
7719 \begin_layout Standard
7720
7721
7722 \backslash
7723 /
7724 \end_layout
7725
7726 \end_inset
7727
7728 -stack-loc
7729 \series default
7730
7731 \begin_inset LatexCommand \index{-\/-stack-loc <Value>}
7732
7733 \end_inset
7734
7735 \InsetSpace ~
7736 <Value> By default the stack
7737 \begin_inset LatexCommand \index{stack}
7738
7739 \end_inset
7740
7741  is placed after the data segment.
7742  Using this option the stack can be placed anywhere in the internal memory
7743  space of the 8051.
7744  The value entered can be in Hexadecimal or Decimal format, e.g.
7745  -
7746 \begin_inset ERT
7747 status collapsed
7748
7749 \begin_layout Standard
7750
7751
7752 \backslash
7753 /
7754 \end_layout
7755
7756 \end_inset
7757
7758 -stack-loc 0x20 or -
7759 \begin_inset ERT
7760 status collapsed
7761
7762 \begin_layout Standard
7763
7764
7765 \backslash
7766 /
7767 \end_layout
7768
7769 \end_inset
7770
7771 -stack-loc 32.
7772  Since the sp register is incremented before a push or call, the initial
7773  sp will be set to one byte prior the provided value.
7774  The provided value should not overlap any other memory areas such as used
7775  register banks or the data segment and with enough space for the current
7776  application.
7777  The 
7778 \series bold
7779 -
7780 \begin_inset ERT
7781 status collapsed
7782
7783 \begin_layout Standard
7784
7785
7786 \backslash
7787 /
7788 \end_layout
7789
7790 \end_inset
7791
7792 -pack-iram
7793 \series default
7794 \InsetSpace ~
7795
7796 \begin_inset LatexCommand \index{-\/-pack-iram}
7797
7798 \end_inset
7799
7800  option (which is now a default setting) will override this setting, so
7801  you should also specify the 
7802 \series bold
7803 -
7804 \begin_inset ERT
7805 status collapsed
7806
7807 \begin_layout Standard
7808
7809
7810 \backslash
7811 /
7812 \end_layout
7813
7814 \end_inset
7815
7816 -no-pack-iram
7817 \series default
7818 \InsetSpace ~
7819
7820 \begin_inset LatexCommand \index{-\/-no-pack-iram}
7821
7822 \end_inset
7823
7824  option if you need to manually place the stack.
7825 \end_layout
7826
7827 \begin_layout List
7828 \labelwidthstring 00.00.0000
7829
7830 \series bold
7831 -
7832 \begin_inset ERT
7833 status collapsed
7834
7835 \begin_layout Standard
7836
7837
7838 \backslash
7839 /
7840 \end_layout
7841
7842 \end_inset
7843
7844 -xstack-loc
7845 \series default
7846
7847 \begin_inset LatexCommand \index{-\/-xstack-loc <Value>}
7848
7849 \end_inset
7850
7851 \InsetSpace ~
7852 <Value> By default the external stack
7853 \begin_inset LatexCommand \index{xstack}
7854
7855 \end_inset
7856
7857  is placed after the pdata
7858 \begin_inset LatexCommand \index{pdata (mcs51, ds390 storage class)}
7859
7860 \end_inset
7861
7862  segment.
7863  Using this option the xstack can be placed anywhere in the external memory
7864  space of the 8051.
7865  The value entered can be in Hexadecimal or Decimal format, e.g.
7866  -
7867 \begin_inset ERT
7868 status collapsed
7869
7870 \begin_layout Standard
7871
7872
7873 \backslash
7874 /
7875 \end_layout
7876
7877 \end_inset
7878
7879 -xstack-loc 0x8000 or -
7880 \begin_inset ERT
7881 status collapsed
7882
7883 \begin_layout Standard
7884
7885
7886 \backslash
7887 /
7888 \end_layout
7889
7890 \end_inset
7891
7892 -stack-loc 32768.
7893  The provided value should not overlap any other memory areas such as the
7894  pdata or xdata segment and with enough space for the current application.
7895 \end_layout
7896
7897 \begin_layout List
7898 \labelwidthstring 00.00.0000
7899
7900 \series bold
7901 -
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
7915 \series default
7916
7917 \begin_inset LatexCommand \index{-\/-data-loc <Value>}
7918
7919 \end_inset
7920
7921 \InsetSpace ~
7922 <Value> The start location of the internal ram data
7923 \begin_inset LatexCommand \index{data (mcs51, ds390 storage class)}
7924
7925 \end_inset
7926
7927  segment.
7928  The value entered can be in Hexadecimal or Decimal format, eg.
7929  -
7930 \begin_inset ERT
7931 status collapsed
7932
7933 \begin_layout Standard
7934
7935
7936 \backslash
7937 /
7938 \end_layout
7939
7940 \end_inset
7941
7942 -data-loc 0x20 or -
7943 \begin_inset ERT
7944 status collapsed
7945
7946 \begin_layout Standard
7947
7948
7949 \backslash
7950 /
7951 \end_layout
7952
7953 \end_inset
7954
7955 -data-loc 32.
7956  (By default, the start location of the internal ram data segment  is set
7957  as low as possible in memory, taking into account the used register banks
7958  and the bit segment at address 0x20.
7959  For example if register banks 0 and 1 are used without bit variables, the
7960  data segment will be set, if -
7961 \begin_inset ERT
7962 status collapsed
7963
7964 \begin_layout Standard
7965
7966
7967 \backslash
7968 /
7969 \end_layout
7970
7971 \end_inset
7972
7973 -data-loc is not used, to location 0x10.)
7974 \end_layout
7975
7976 \begin_layout List
7977 \labelwidthstring 00.00.0000
7978
7979 \series bold
7980 -
7981 \begin_inset ERT
7982 status collapsed
7983
7984 \begin_layout Standard
7985
7986
7987 \backslash
7988 /
7989 \end_layout
7990
7991 \end_inset
7992
7993 -idata-loc
7994 \series default
7995
7996 \begin_inset LatexCommand \index{-\/-idata-loc <Value>}
7997
7998 \end_inset
7999
8000 \InsetSpace ~
8001 <Value> The start location of the indirectly addressable internal ram
8002 \begin_inset LatexCommand \index{idata (mcs51, ds390 storage class)}
8003
8004 \end_inset
8005
8006  of the 8051, default value is 0x80.
8007  The value entered can be in Hexadecimal or Decimal format, eg.
8008  -
8009 \begin_inset ERT
8010 status collapsed
8011
8012 \begin_layout Standard
8013
8014
8015 \backslash
8016 /
8017 \end_layout
8018
8019 \end_inset
8020
8021 -idata-loc 0x88 or -
8022 \begin_inset ERT
8023 status collapsed
8024
8025 \begin_layout Standard
8026
8027
8028 \backslash
8029 /
8030 \end_layout
8031
8032 \end_inset
8033
8034 -idata-loc 136.
8035 \end_layout
8036
8037 \begin_layout List
8038 \labelwidthstring 00.00.0000
8039
8040 \series bold
8041 -
8042 \begin_inset ERT
8043 status collapsed
8044
8045 \begin_layout Standard
8046
8047
8048 \backslash
8049 /
8050 \end_layout
8051
8052 \end_inset
8053
8054 -bit-loc
8055 \series default
8056 \InsetSpace ~
8057 <Value> The start location of the bit
8058 \begin_inset LatexCommand \index{bit}
8059
8060 \end_inset
8061
8062  addressable internal ram of the 8051.
8063  This is 
8064 \emph on
8065 not
8066 \emph default
8067  implemented yet.
8068  Instead an option can be passed directly to the linker: -Wl\InsetSpace ~
8069 -bBSEG=<Value>.
8070 \end_layout
8071
8072 \begin_layout List
8073 \labelwidthstring 00.00.0000
8074
8075 \series bold
8076 -
8077 \begin_inset ERT
8078 status collapsed
8079
8080 \begin_layout Standard
8081
8082
8083 \backslash
8084 /
8085 \end_layout
8086
8087 \end_inset
8088
8089 -out-fmt-ihx
8090 \begin_inset LatexCommand \index{-\/-out-fmt-ihx}
8091
8092 \end_inset
8093
8094
8095 \bar under
8096  
8097 \series default
8098 \bar default
8099 The linker output (final object code) is in Intel Hex format.
8100 \begin_inset LatexCommand \index{Intel hex format}
8101
8102 \end_inset
8103
8104  This is the default option.
8105  The format itself is documented in the documentation of srecord
8106 \begin_inset LatexCommand \index{srecord (bin, hex, ... tool)}
8107
8108 \end_inset
8109
8110 .
8111 \end_layout
8112
8113 \begin_layout List
8114 \labelwidthstring 00.00.0000
8115
8116 \series bold
8117 -
8118 \begin_inset ERT
8119 status collapsed
8120
8121 \begin_layout Standard
8122
8123
8124 \backslash
8125 /
8126 \end_layout
8127
8128 \end_inset
8129
8130 -out-fmt-s19
8131 \begin_inset LatexCommand \index{-\/-out-fmt-s19}
8132
8133 \end_inset
8134
8135
8136 \bar under
8137  
8138 \series default
8139 \bar default
8140 The linker output (final object code) is in Motorola S19 format
8141 \begin_inset LatexCommand \index{Motorola S19 format}
8142
8143 \end_inset
8144
8145 .
8146  The format itself is documented in the documentation of srecord.
8147 \end_layout
8148
8149 \begin_layout List
8150 \labelwidthstring 00.00.0000
8151
8152 \series bold
8153 -
8154 \begin_inset ERT
8155 status collapsed
8156
8157 \begin_layout Standard
8158
8159
8160 \backslash
8161 /
8162 \end_layout
8163
8164 \end_inset
8165
8166 -out-fmt-elf
8167 \begin_inset LatexCommand \index{-\/-out-fmt-s19}
8168
8169 \end_inset
8170
8171
8172 \begin_inset LatexCommand \index{HC08!Options!-\/-out-fmt-elf}
8173
8174 \end_inset
8175
8176
8177 \bar under
8178  
8179 \series default
8180 \bar default
8181 The linker output (final object code) is in ELF format
8182 \begin_inset LatexCommand \index{ELF format}
8183
8184 \end_inset
8185
8186 .
8187  (Currently only supported for the HC08
8188 \begin_inset LatexCommand \index{HC08}
8189
8190 \end_inset
8191
8192  processors)
8193 \end_layout
8194
8195 \begin_layout List
8196 \labelwidthstring 00.00.0000
8197
8198 \series bold
8199 -Wl\InsetSpace ~
8200 linkOption[,linkOption]
8201 \series default
8202
8203 \begin_inset LatexCommand \index{-Wl linkOption[,linkOption]}
8204
8205 \end_inset
8206
8207
8208 \begin_inset LatexCommand \label{lyx:-Wl option}
8209
8210 \end_inset
8211
8212 ...
8213  Pass the linkOption to the linker.
8214  If a bootloader is used an option like 
8215 \begin_inset Quotes sld
8216 \end_inset
8217
8218 -Wl\InsetSpace ~
8219 -bCSEG=0x1000
8220 \begin_inset Quotes srd
8221 \end_inset
8222
8223  would be typical to set the start of the code segment.
8224  Either use the double quotes around this option or use no space (e.g.
8225  -Wl-bCSEG=0x1000).
8226  See also #pragma constseg and #pragma codeseg in section 
8227 \begin_inset LatexCommand \ref{sec:Pragmas}
8228
8229 \end_inset
8230
8231  .
8232  File sdcc/as/doc/asxhtm.html has more on linker options.
8233 \end_layout
8234
8235 \begin_layout Standard
8236 \begin_inset VSpace bigskip
8237 \end_inset
8238
8239
8240 \end_layout
8241
8242 \begin_layout Subsection
8243 MCS51 Options
8244 \begin_inset LatexCommand \index{Options MCS51}
8245
8246 \end_inset
8247
8248
8249 \begin_inset LatexCommand \index{MCS51 options}
8250
8251 \end_inset
8252
8253
8254 \end_layout
8255
8256 \begin_layout List
8257 \labelwidthstring 00.00.0000
8258
8259 \series bold
8260 -
8261 \begin_inset ERT
8262 status collapsed
8263
8264 \begin_layout Standard
8265
8266
8267 \backslash
8268 /
8269 \end_layout
8270
8271 \end_inset
8272
8273 -model-small
8274 \begin_inset LatexCommand \index{-\/-model-small}
8275
8276 \end_inset
8277
8278
8279 \series default
8280 \size large
8281 \emph on
8282  
8283 \size default
8284 \emph default
8285 Generate code for Small Model programs, see section Memory Models for more
8286  details.
8287  This is the default model.
8288 \end_layout
8289
8290 \begin_layout List
8291 \labelwidthstring 00.00.0000
8292
8293 \series bold
8294 -
8295 \begin_inset ERT
8296 status collapsed
8297
8298 \begin_layout Standard
8299
8300
8301 \backslash
8302 /
8303 \end_layout
8304
8305 \end_inset
8306
8307 -model-medium
8308 \begin_inset LatexCommand \index{-\/-model-medium}
8309
8310 \end_inset
8311
8312
8313 \series default
8314  Generate code for Medium model programs, see section Memory Models for
8315  more details.
8316  If this option is used all source files in the project have to be compiled
8317  with this option.
8318  It must also be used when invoking the linker.
8319 \end_layout
8320
8321 \begin_layout List
8322 \labelwidthstring 00.00.0000
8323
8324 \series bold
8325 -
8326 \begin_inset ERT
8327 status collapsed
8328
8329 \begin_layout Standard
8330
8331
8332 \backslash
8333 /
8334 \end_layout
8335
8336 \end_inset
8337
8338 -model-large
8339 \begin_inset LatexCommand \index{-\/-model-large}
8340
8341 \end_inset
8342
8343
8344 \series default
8345  Generate code for Large model programs, see section Memory Models for more
8346  details.
8347  If this option is used all source files in the project have to be compiled
8348  with this option.
8349  It must also be used when invoking the linker.
8350 \end_layout
8351
8352 \begin_layout List
8353 \labelwidthstring 00.00.0000
8354
8355 \series bold
8356 -
8357 \begin_inset ERT
8358 status collapsed
8359
8360 \begin_layout Standard
8361
8362
8363 \backslash
8364 /
8365 \end_layout
8366
8367 \end_inset
8368
8369 -xstack
8370 \begin_inset LatexCommand \index{-\/-xstack}
8371
8372 \end_inset
8373
8374
8375 \series default
8376  Uses a pseudo stack in the pdata
8377 \begin_inset LatexCommand \index{pdata (mcs51, ds390 storage class)}
8378
8379 \end_inset
8380
8381  area (usually the first 256 bytes in the external ram) for allocating variables
8382  and passing parameters.
8383  See section 
8384 \begin_inset LatexCommand \ref{sub:External-Stack}
8385
8386 \end_inset
8387
8388 \InsetSpace ~
8389  External Stack for more details.
8390 \end_layout
8391
8392 \begin_layout List
8393 \labelwidthstring 00.00.0000
8394
8395 \series bold
8396 -
8397 \begin_inset ERT
8398 status collapsed
8399
8400 \begin_layout Standard
8401
8402
8403 \backslash
8404 /
8405 \end_layout
8406
8407 \end_inset
8408
8409 -iram-size
8410 \series default
8411 \InsetSpace ~
8412 <Value>
8413 \begin_inset LatexCommand \index{-\/-iram-size <Value>}
8414
8415 \end_inset
8416
8417  Causes the linker to check if the internal ram usage is within limits of
8418  the given value.
8419 \end_layout
8420
8421 \begin_layout List
8422 \labelwidthstring 00.00.0000
8423
8424 \series bold
8425 -
8426 \begin_inset ERT
8427 status collapsed
8428
8429 \begin_layout Standard
8430
8431
8432 \backslash
8433 /
8434 \end_layout
8435
8436 \end_inset
8437
8438 -xram-size
8439 \series default
8440 \InsetSpace ~
8441 <Value>
8442 \begin_inset LatexCommand \index{-\/-xram-size <Value>}
8443
8444 \end_inset
8445
8446  Causes the linker to check if the external ram usage is within limits of
8447  the given value.
8448 \end_layout
8449
8450 \begin_layout List
8451 \labelwidthstring 00.00.0000
8452
8453 \series bold
8454 -
8455 \begin_inset ERT
8456 status collapsed
8457
8458 \begin_layout Standard
8459
8460
8461 \backslash
8462 /
8463 \end_layout
8464
8465 \end_inset
8466
8467 -code-size
8468 \series default
8469 \InsetSpace ~
8470 <Value>
8471 \begin_inset LatexCommand \index{-\/-code-size <Value>}
8472
8473 \end_inset
8474
8475  Causes the linker to check if the code memory usage is within limits of
8476  the given value.
8477 \end_layout
8478
8479 \begin_layout List
8480 \labelwidthstring 00.00.0000
8481
8482 \series bold
8483 -
8484 \begin_inset ERT
8485 status collapsed
8486
8487 \begin_layout Standard
8488
8489
8490 \backslash
8491 /
8492 \end_layout
8493
8494 \end_inset
8495
8496 -stack-size
8497 \series default
8498 \InsetSpace ~
8499 <Value>
8500 \begin_inset LatexCommand \index{-\/-stack-size <Value>}
8501
8502 \end_inset
8503
8504  Causes the linker to check if there is at minimum <Value> bytes for stack.
8505 \end_layout
8506
8507 \begin_layout List
8508 \labelwidthstring 00.00.0000
8509
8510 \series bold
8511 -
8512 \begin_inset ERT
8513 status collapsed
8514
8515 \begin_layout Standard
8516
8517
8518 \backslash
8519 /
8520 \end_layout
8521
8522 \end_inset
8523
8524 -pack-iram
8525 \series default
8526 \InsetSpace ~
8527
8528 \begin_inset LatexCommand \index{-\/-pack-iram}
8529
8530 \end_inset
8531
8532  Causes the linker to use unused register banks for data variables and pack
8533  data, idata and stack together.
8534  This is the default now.
8535 \end_layout
8536
8537 \begin_layout List
8538 \labelwidthstring 00.00.0000
8539
8540 \series bold
8541 -
8542 \begin_inset ERT
8543 status collapsed
8544
8545 \begin_layout Standard
8546
8547
8548 \backslash
8549 /
8550 \end_layout
8551
8552 \end_inset
8553
8554 -no-pack-iram
8555 \series default
8556 \InsetSpace ~
8557
8558 \begin_inset LatexCommand \index{-\/-no-pack-iram}
8559
8560 \end_inset
8561
8562  Causes the linker to use old style for allocating memory areas.
8563 \end_layout
8564
8565 \begin_layout List
8566 \labelwidthstring 00.00.0000
8567
8568 \series bold
8569 -
8570 \begin_inset ERT
8571 status collapsed
8572
8573 \begin_layout Standard
8574
8575
8576 \backslash
8577 /
8578 \end_layout
8579
8580 \end_inset
8581
8582 -acall-ajmp
8583 \series default
8584 \InsetSpace ~
8585
8586 \begin_inset LatexCommand \index{-\/-acall-ajmp}
8587
8588 \end_inset
8589
8590  Replaces the three byte instructions lcall/ljmp with the two byte instructions
8591  acall/ajmp.
8592  Only use this option if your code is in the same 2k block of memory.
8593  You may need to use this option for some 8051 derivatives which lack the
8594  lcall/ljmp instructions..
8595 \end_layout
8596
8597 \begin_layout Standard
8598 \begin_inset VSpace bigskip
8599 \end_inset
8600
8601
8602 \end_layout
8603
8604 \begin_layout Subsection
8605 DS390 / DS400 Options
8606 \begin_inset LatexCommand \index{Options DS390}
8607
8608 \end_inset
8609
8610
8611 \begin_inset LatexCommand \index{DS390}
8612
8613 \end_inset
8614
8615
8616 \end_layout
8617
8618 \begin_layout List
8619 \labelwidthstring 00.00.0000
8620
8621 \series bold
8622 -
8623 \begin_inset ERT
8624 status collapsed
8625
8626 \begin_layout Standard
8627
8628
8629 \backslash
8630 /
8631 \end_layout
8632
8633 \end_inset
8634
8635 -model-flat24
8636 \series default
8637
8638 \begin_inset LatexCommand \index{DS390!Options!-\/-model-flat24}
8639
8640 \end_inset
8641
8642
8643 \size large
8644 \emph on
8645  
8646 \size default
8647 \emph default
8648 Generate 24-bit flat mode code.
8649  This is the one and only that the ds390 code generator supports right now
8650  and is default when using 
8651 \emph on
8652 -mds390
8653 \emph default
8654 .
8655  See section Memory Models for more details.
8656 \end_layout
8657
8658 \begin_layout List
8659 \labelwidthstring 00.00.0000
8660
8661 \series bold
8662 -
8663 \begin_inset ERT
8664 status collapsed
8665
8666 \begin_layout Standard
8667
8668
8669 \backslash
8670 /
8671 \end_layout
8672
8673 \end_inset
8674
8675 -protect-sp-update
8676 \begin_inset LatexCommand \index{DS390!Options!-\/-protect-sp-update}
8677
8678 \end_inset
8679
8680
8681 \series default
8682  disable interrupts during ESP:SP updates.
8683 \end_layout
8684
8685 \begin_layout List
8686 \labelwidthstring 00.00.0000
8687
8688 \series bold
8689 -
8690 \begin_inset ERT
8691 status collapsed
8692
8693 \begin_layout Standard
8694
8695
8696 \backslash
8697 /
8698 \end_layout
8699
8700 \end_inset
8701
8702 -stack-10bit
8703 \series default
8704
8705 \begin_inset LatexCommand \index{DS390!Options!-\/-stack-10bit}
8706
8707 \end_inset
8708
8709  Generate code for the 10 bit stack mode of the Dallas DS80C390 part.
8710  This is the one and only that the ds390 code generator supports right now
8711  and is default when using 
8712 \emph on
8713 -mds390
8714 \emph default
8715 .
8716  In this mode, the stack is located in the lower 1K of the internal RAM,
8717  which is mapped to 0x400000.
8718  Note that the support is incomplete, since it still uses a single byte
8719  as the stack pointer.
8720  This means that only the lower 256 bytes of the potential 1K stack space
8721  will actually be used.
8722  However, this does allow you to reclaim the precious 256 bytes of low RAM
8723  for use for the DATA and IDATA segments.
8724  The compiler will not generate any code to put the processor into 10 bit
8725  stack mode.
8726  It is important to ensure that the processor is in this mode before calling
8727  any re-entrant functions compiled with this option.
8728  In principle, this should work with the 
8729 \emph on
8730 -
8731 \begin_inset ERT
8732 status collapsed
8733
8734 \begin_layout Standard
8735
8736
8737 \backslash
8738 /
8739 \end_layout
8740
8741 \end_inset
8742
8743 -stack-auto
8744 \begin_inset LatexCommand \index{-\/-stack-auto}
8745
8746 \end_inset
8747
8748
8749 \emph default
8750  option, but that has not been tested.
8751  It is incompatible with the 
8752 \emph on
8753 -
8754 \begin_inset ERT
8755 status collapsed
8756
8757 \begin_layout Standard
8758
8759
8760 \backslash
8761 /
8762 \end_layout
8763
8764 \end_inset
8765
8766 -xstack
8767 \begin_inset LatexCommand \index{-\/-xstack}
8768
8769 \end_inset
8770
8771
8772 \emph default
8773  option.
8774  It also only makes sense if the processor is in 24 bit contiguous addressing
8775  mode (see the 
8776 \emph on
8777 -
8778 \begin_inset ERT
8779 status collapsed
8780
8781 \begin_layout Standard
8782
8783
8784 \backslash
8785 /
8786 \end_layout
8787
8788 \end_inset
8789
8790 -model-flat24 option
8791 \emph default
8792 ).
8793 \series bold
8794
8795 \begin_inset Note Note
8796 status collapsed
8797
8798 \begin_layout List
8799 \labelwidthstring 00.00.0000
8800
8801 \series bold
8802 -
8803 \begin_inset ERT
8804 status open
8805
8806 \begin_layout Standard
8807
8808
8809 \backslash
8810 /
8811 \end_layout
8812
8813 \end_inset
8814
8815 -stack-8-bit - switches off the 10-bit mode
8816 \end_layout
8817
8818 \end_inset
8819
8820
8821 \end_layout
8822
8823 \begin_layout List
8824 \labelwidthstring 00.00.0000
8825
8826 \series bold
8827 -
8828 \begin_inset ERT
8829 status collapsed
8830
8831 \begin_layout Standard
8832
8833
8834 \backslash
8835 /
8836 \end_layout
8837
8838 \end_inset
8839
8840 -stack-probe
8841 \begin_inset LatexCommand \index{DS390!Options!-\/-stack-probe}
8842
8843 \end_inset
8844
8845
8846 \series default
8847  insert call to function __stack_probe at each function prologue.
8848 \end_layout
8849
8850 \begin_layout List
8851 \labelwidthstring 00.00.0000
8852
8853 \series bold
8854 -
8855 \begin_inset ERT
8856 status open
8857
8858 \begin_layout Standard
8859
8860
8861 \backslash
8862 /
8863 \end_layout
8864
8865 \end_inset
8866
8867 -tini-libid
8868 \begin_inset LatexCommand \index{DS390!Options!-\/-tini-libid}
8869
8870 \end_inset
8871
8872
8873 \series default
8874  <nnnn> LibraryID used in -mTININative.
8875  
8876 \end_layout
8877
8878 \begin_layout List
8879 \labelwidthstring 00.00.0000
8880
8881 \series bold
8882 -
8883 \begin_inset ERT
8884 status collapsed
8885
8886 \begin_layout Standard
8887
8888
8889 \backslash
8890 /
8891 \end_layout
8892
8893 \end_inset
8894
8895 -use-accelerator
8896 \begin_inset LatexCommand \index{DS390!Options!-\/-use-accelerator}
8897
8898 \end_inset
8899
8900
8901 \series default
8902  generate code for DS390 Arithmetic Accelerator.
8903  
8904 \end_layout
8905
8906 \begin_layout Standard
8907 \begin_inset VSpace bigskip
8908 \end_inset
8909
8910
8911 \end_layout
8912
8913 \begin_layout Subsection
8914 Z80 Options
8915 \begin_inset LatexCommand \index{Options Z80}
8916
8917 \end_inset
8918
8919
8920 \begin_inset LatexCommand \index{Z80}
8921
8922 \end_inset
8923
8924
8925 \end_layout
8926
8927 \begin_layout List
8928 \labelwidthstring 00.00.0000
8929
8930 \series bold
8931 -
8932 \begin_inset ERT
8933 status collapsed
8934
8935 \begin_layout Standard
8936
8937
8938 \backslash
8939 /
8940 \end_layout
8941
8942 \end_inset
8943
8944 -callee-saves-bc
8945 \series default
8946
8947 \begin_inset LatexCommand \index{Z80!Options!-\/-callee-saves-bc}
8948
8949 \end_inset
8950
8951
8952 \size large
8953 \emph on
8954  
8955 \size default
8956 \emph default
8957 Force a called function to always save BC.
8958 \end_layout
8959
8960 \begin_layout List
8961 \labelwidthstring 00.00.0000
8962
8963 \series bold
8964 -
8965 \begin_inset ERT
8966 status collapsed
8967
8968 \begin_layout Standard
8969
8970
8971 \backslash
8972 /
8973 \end_layout
8974
8975 \end_inset
8976
8977 -no-std-crt0
8978 \series default
8979
8980 \begin_inset LatexCommand \index{Z80!Options!-\/-no-std-crt0}
8981
8982 \end_inset
8983
8984  When linking, skip the standard crt0.o object file.
8985  You must provide your own crt0.o for your system when linking.
8986 \end_layout
8987
8988 \begin_layout List
8989 \labelwidthstring 00.00.0000
8990
8991 \series bold
8992 -
8993 \begin_inset ERT
8994 status collapsed
8995
8996 \begin_layout Standard
8997
8998
8999 \backslash
9000 /
9001 \end_layout
9002
9003 \end_inset
9004
9005 -portmode=
9006 \series default
9007 <Value>
9008 \begin_inset LatexCommand \index{Z80!Options!-\/-portmode=<Value>}
9009
9010 \end_inset
9011
9012  Determinate PORT I/O mode (<Value> is z80 or z180).
9013 \end_layout
9014
9015 \begin_layout List
9016 \labelwidthstring 00.00.0000
9017
9018 \series bold
9019 -
9020 \begin_inset ERT
9021 status collapsed
9022
9023 \begin_layout Standard
9024
9025
9026 \backslash
9027 /
9028 \end_layout
9029
9030 \end_inset
9031
9032 -asm=
9033 \series default
9034 <Value>
9035 \begin_inset LatexCommand \index{Z80!Options!-\/-asm=<Value>}
9036
9037 \end_inset
9038
9039  Define assembler name (<Value> is rgbds, asxxxx, isas or z80asm).
9040 \end_layout
9041
9042 \begin_layout List
9043 \labelwidthstring 00.00.0000
9044
9045 \series bold
9046 -
9047 \begin_inset ERT
9048 status collapsed
9049
9050 \begin_layout Standard
9051
9052
9053 \backslash
9054 /
9055 \end_layout
9056
9057 \end_inset
9058
9059 -codeseg
9060 \series default
9061 \InsetSpace ~
9062 <Value>
9063 \begin_inset LatexCommand \index{Z80!Options!-\/-codeseg <Value>}
9064
9065 \end_inset
9066
9067  Use <Value> for the code segment name.
9068 \end_layout
9069
9070 \begin_layout List
9071 \labelwidthstring 00.00.0000
9072
9073 \series bold
9074 -
9075 \begin_inset ERT
9076 status collapsed
9077
9078 \begin_layout Standard
9079
9080
9081 \backslash
9082 /
9083 \end_layout
9084
9085 \end_inset
9086
9087 -constseg
9088 \series default
9089 \InsetSpace ~
9090 <Value>
9091 \begin_inset LatexCommand \index{Z80!Options!-\/-constseg <Value>}
9092
9093 \end_inset
9094
9095  Use <Value> for the const segment name.
9096 \end_layout
9097
9098 \begin_layout List
9099 \labelwidthstring 00.00.0000
9100 \begin_inset VSpace bigskip
9101 \end_inset
9102
9103
9104 \end_layout
9105
9106 \begin_layout Subsection
9107 GBZ80 Options
9108 \begin_inset LatexCommand \index{Options GBZ80}
9109
9110 \end_inset
9111
9112
9113 \begin_inset LatexCommand \index{GBZ80}
9114
9115 \end_inset
9116
9117
9118 \end_layout
9119
9120 \begin_layout List
9121 \labelwidthstring 00.00.0000
9122
9123 \series bold
9124 -
9125 \begin_inset ERT
9126 status collapsed
9127
9128 \begin_layout Standard
9129
9130
9131 \backslash
9132 /
9133 \end_layout
9134
9135 \end_inset
9136
9137 -callee-saves-bc
9138 \series default
9139
9140 \begin_inset LatexCommand \index{GBZ80!Options!-\/-callee-saves-bc}
9141
9142 \end_inset
9143
9144
9145 \size large
9146 \emph on
9147  
9148 \size default
9149 \emph default
9150 Force a called function to always save BC.
9151 \end_layout
9152
9153 \begin_layout List
9154 \labelwidthstring 00.00.0000
9155
9156 \series bold
9157 -
9158 \begin_inset ERT
9159 status collapsed
9160
9161 \begin_layout Standard
9162
9163
9164 \backslash
9165 /
9166 \end_layout
9167
9168 \end_inset
9169
9170 -no-std-crt0
9171 \series default
9172
9173 \begin_inset LatexCommand \index{Z80!Options!-\/-no-std-crt0}
9174
9175 \end_inset
9176
9177  When linking, skip the standard crt0.o object file.
9178  You must provide your own crt0.o for your system when linking.
9179 \end_layout
9180
9181 \begin_layout List
9182 \labelwidthstring 00.00.0000
9183
9184 \series bold
9185 -bo
9186 \series default
9187 \InsetSpace ~
9188 <Num>
9189 \begin_inset LatexCommand \index{GBZ80!Options!-bo <Num>}
9190
9191 \end_inset
9192
9193  Use code bank <Num>.
9194 \end_layout
9195
9196 \begin_layout List
9197 \labelwidthstring 00.00.0000
9198
9199 \series bold
9200 -ba
9201 \series default
9202 \InsetSpace ~
9203 <Num>
9204 \begin_inset LatexCommand \index{GBZ80!Options!-ba <Num>}
9205
9206 \end_inset
9207
9208  Use data bank <Num>.
9209 \end_layout
9210
9211 \begin_layout List
9212 \labelwidthstring 00.00.0000
9213
9214 \series bold
9215 -
9216 \begin_inset ERT
9217 status collapsed
9218
9219 \begin_layout Standard
9220
9221
9222 \backslash
9223 /
9224 \end_layout
9225
9226 \end_inset
9227
9228 -codeseg
9229 \series default
9230 \InsetSpace ~
9231 <Value>
9232 \begin_inset LatexCommand \index{GBZ80!Options!-\/-codeseg <Value>}
9233
9234 \end_inset
9235
9236  Use <Value> for the code segment name.
9237 \end_layout
9238
9239 \begin_layout List
9240 \labelwidthstring 00.00.0000
9241
9242 \series bold
9243 -
9244 \begin_inset ERT
9245 status collapsed
9246
9247 \begin_layout Standard
9248
9249
9250 \backslash
9251 /
9252 \end_layout
9253
9254 \end_inset
9255
9256 -constseg
9257 \series default
9258 \InsetSpace ~
9259 <Value>
9260 \begin_inset LatexCommand \index{GBZ80!Options!-\/-constseg <Value>}
9261
9262 \end_inset
9263
9264  Use <Value> for the const segment name.
9265 \end_layout
9266
9267 \begin_layout Standard
9268 \begin_inset VSpace bigskip
9269 \end_inset
9270
9271
9272 \end_layout
9273
9274 \begin_layout Subsection
9275 Optimization Options
9276 \begin_inset LatexCommand \index{Options optimization}
9277
9278 \end_inset
9279
9280
9281 \begin_inset LatexCommand \index{Optimization options}
9282
9283 \end_inset
9284
9285
9286 \end_layout
9287
9288 \begin_layout List
9289 \labelwidthstring 00.00.0000
9290
9291 \series bold
9292 -
9293 \begin_inset ERT
9294 status collapsed
9295
9296 \begin_layout Standard
9297
9298
9299 \backslash
9300 /
9301 \end_layout
9302
9303 \end_inset
9304
9305 -nogcse
9306 \begin_inset LatexCommand \index{-\/-nogcse}
9307
9308 \end_inset
9309
9310
9311 \series default
9312  Will not do global subexpression elimination, this option may be used when
9313  the compiler creates undesirably large stack/data spaces to store compiler
9314  temporaries (
9315 \emph on
9316 s
9317 \emph default
9318 pill 
9319 \emph on
9320 loc
9321 \emph default
9322 ations, sloc
9323 \begin_inset LatexCommand \index{sloc (spill location)}
9324
9325 \end_inset
9326
9327 ).
9328  A warning message will be generated when this happens and the compiler
9329  will indicate the number of extra bytes it allocated.
9330  It is recommended that this option NOT be used, #pragma\InsetSpace ~
9331 nogcse
9332 \begin_inset LatexCommand \index{\#pragma nogcse}
9333
9334 \end_inset
9335
9336  can be used to turn off global subexpression elimination
9337 \begin_inset LatexCommand \index{Subexpression elimination}
9338
9339 \end_inset
9340
9341  for a given function only.
9342 \end_layout
9343
9344 \begin_layout List
9345 \labelwidthstring 00.00.0000
9346
9347 \series bold
9348 -
9349 \begin_inset ERT
9350 status collapsed
9351
9352 \begin_layout Standard
9353
9354
9355 \backslash
9356 /
9357 \end_layout
9358
9359 \end_inset
9360
9361 -noinvariant
9362 \begin_inset LatexCommand \index{-\/-noinvariant}
9363
9364 \end_inset
9365
9366
9367 \series default
9368  Will not do loop invariant optimizations, this may be turned off for reasons
9369  explained for the previous option.
9370  For more details of loop optimizations performed see Loop Invariants in
9371  section 
9372 \begin_inset LatexCommand \ref{sub:Loop-Optimizations}
9373
9374 \end_inset
9375
9376 .
9377  It is recommended that this option NOT be used, #pragma\InsetSpace ~
9378 noinvariant
9379 \begin_inset LatexCommand \index{\#pragma noinvariant}
9380
9381 \end_inset
9382
9383  can be used to turn off invariant optimizations for a given function only.
9384 \end_layout
9385
9386 \begin_layout List
9387 \labelwidthstring 00.00.0000
9388
9389 \series bold
9390 -
9391 \begin_inset ERT
9392 status collapsed
9393
9394 \begin_layout Standard
9395
9396
9397 \backslash
9398 /
9399 \end_layout
9400
9401 \end_inset
9402
9403 -noinduction
9404 \begin_inset LatexCommand \index{-\/-noinduction}
9405
9406 \end_inset
9407
9408
9409 \series default
9410  Will not do loop induction optimizations, see section strength reduction
9411  for more details.
9412  It is recommended that this option is NOT used, #pragma\InsetSpace ~
9413 noinduction
9414 \begin_inset LatexCommand \index{\#pragma noinduction}
9415
9416 \end_inset
9417
9418  can be used to turn off induction optimizations for a given function only.
9419 \end_layout
9420
9421 \begin_layout List
9422 \labelwidthstring 00.00.0000
9423
9424 \series bold
9425 -
9426 \begin_inset ERT
9427 status collapsed
9428
9429 \begin_layout Standard
9430
9431
9432 \backslash
9433 /
9434 \end_layout
9435
9436 \end_inset
9437
9438 -nojtbound
9439 \begin_inset LatexCommand \index{-\/-nojtbound}
9440
9441 \end_inset
9442
9443
9444 \size large
9445 \bar under
9446  
9447 \series default
9448 \size default
9449 \bar default
9450  Will not generate boundary condition check when switch statements
9451 \begin_inset LatexCommand \index{switch statement}
9452
9453 \end_inset
9454
9455  are implemented using jump-tables.
9456  See section 
9457 \begin_inset LatexCommand \ref{sub:'switch'-Statements}
9458
9459 \end_inset
9460
9461 \InsetSpace ~
9462 Switch Statements for more details.
9463  It is recommended that this option is NOT used, #pragma\InsetSpace ~
9464 nojtbound
9465 \begin_inset LatexCommand \index{\#pragma nojtbound}
9466
9467 \end_inset
9468
9469  can be used to turn off boundary checking for jump tables for a given function
9470  only.
9471 \end_layout
9472
9473 \begin_layout List
9474 \labelwidthstring 00.00.0000
9475
9476 \series bold
9477 -
9478 \begin_inset ERT
9479 status collapsed
9480
9481 \begin_layout Standard
9482
9483
9484 \backslash
9485 /
9486 \end_layout
9487
9488 \end_inset
9489
9490 -noloopreverse
9491 \begin_inset LatexCommand \index{-\/-noloopreverse}
9492
9493 \end_inset
9494
9495
9496 \series default
9497 \size large
9498  
9499 \size default
9500 Will not do loop reversal 
9501 \begin_inset LatexCommand \index{Loop reversing}
9502
9503 \end_inset
9504
9505 optimization.
9506 \end_layout
9507
9508 \begin_layout List
9509 \labelwidthstring 00.00.0000
9510 -
9511 \begin_inset ERT
9512 status collapsed
9513
9514 \begin_layout Standard
9515
9516
9517 \backslash
9518 /
9519 \end_layout
9520
9521 \end_inset
9522
9523 -
9524 \series bold
9525 nolabelopt
9526 \series default
9527  
9528 \begin_inset LatexCommand \index{-\/-nolabelopt }
9529
9530 \end_inset
9531
9532 Will not optimize labels (makes the dumpfiles more readable).
9533 \end_layout
9534
9535 \begin_layout List
9536 \labelwidthstring 00.00.0000
9537
9538 \series bold
9539 -
9540 \begin_inset ERT
9541 status collapsed
9542
9543 \begin_layout Standard
9544
9545
9546 \backslash
9547 /
9548 \end_layout
9549
9550 \end_inset
9551
9552 -no-xinit-opt
9553 \begin_inset LatexCommand \index{-\/-no-xinit-opt}
9554
9555 \end_inset
9556
9557
9558 \series default
9559  Will not memcpy initialized data from code space into xdata space.
9560  This saves a few bytes in code space if you don't have initialized data
9561 \begin_inset LatexCommand \index{Variable initialization}
9562
9563 \end_inset
9564
9565 .
9566 \end_layout
9567
9568 \begin_layout List
9569 \labelwidthstring 00.00.0000
9570
9571 \series bold
9572 -
9573 \begin_inset ERT
9574 status collapsed
9575
9576 \begin_layout Standard
9577
9578
9579 \backslash
9580 /
9581 \end_layout
9582
9583 \end_inset
9584
9585 -nooverlay
9586 \begin_inset LatexCommand \index{-\/-nooverlay}
9587
9588 \end_inset
9589
9590
9591 \series default
9592   The compiler will not overlay parameters and local variables of any function,
9593  see section Parameters and local variables for more details.
9594 \end_layout
9595
9596 \begin_layout List
9597 \labelwidthstring 00.00.0000
9598
9599 \series bold
9600 -
9601 \begin_inset ERT
9602 status collapsed
9603
9604 \begin_layout Standard
9605
9606
9607 \backslash
9608 /
9609 \end_layout
9610
9611 \end_inset
9612
9613 -no-peep
9614 \begin_inset LatexCommand \index{-\/-no-peep}
9615
9616 \end_inset
9617
9618
9619 \series default
9620  Disable peep-hole optimization with built-in rules.
9621 \end_layout
9622
9623 \begin_layout List
9624 \labelwidthstring 00.00.0000
9625
9626 \series bold
9627 -
9628 \begin_inset ERT
9629 status collapsed
9630
9631 \begin_layout Standard
9632
9633
9634 \backslash
9635 /
9636 \end_layout
9637
9638 \end_inset
9639
9640 -peep-file
9641 \series default
9642
9643 \begin_inset LatexCommand \index{-\/-peep-file}
9644
9645 \end_inset
9646
9647 \InsetSpace ~
9648 <filename> This option can be used to use additional rules to be used by
9649  the peep hole optimizer.
9650  See section 
9651 \begin_inset LatexCommand \ref{sub:Peephole-Optimizer}
9652
9653 \end_inset
9654
9655 \InsetSpace ~
9656 Peep Hole optimizations for details on how to write these rules.
9657 \end_layout
9658
9659 \begin_layout List
9660 \labelwidthstring 00.00.0000
9661
9662 \series bold
9663 -
9664 \begin_inset ERT
9665 status collapsed
9666
9667 \begin_layout Standard
9668
9669
9670 \backslash
9671 /
9672 \end_layout
9673
9674 \end_inset
9675
9676 -peep-asm
9677 \begin_inset LatexCommand \index{-\/-peep-asm}
9678
9679 \end_inset
9680
9681
9682 \series default
9683  Pass the inline assembler code through the peep hole optimizer.
9684  This can cause unexpected changes to inline assembler code, please go through
9685  the peephole optimizer
9686 \begin_inset LatexCommand \index{Peephole optimizer}
9687
9688 \end_inset
9689
9690  rules defined in the source file tree '<target>/peeph.def' before using
9691  this option.
9692 \end_layout
9693
9694 \begin_layout List
9695 \labelwidthstring 00.00.0000
9696
9697 \series bold
9698 -
9699 \begin_inset ERT
9700 status collapsed
9701
9702 \begin_layout Standard
9703
9704
9705 \backslash
9706 /
9707 \end_layout
9708
9709 \end_inset
9710
9711 -opt-code-speed
9712 \begin_inset LatexCommand \index{-\/-opt-code-speed}
9713
9714 \end_inset
9715
9716
9717 \series default
9718  The compiler will optimize code generation towards fast code, possibly
9719  at the expense of code size.
9720 \end_layout
9721
9722 \begin_layout List
9723 \labelwidthstring 00.00.0000
9724
9725 \series bold
9726 -
9727 \begin_inset ERT
9728 status collapsed
9729
9730 \begin_layout Standard
9731
9732
9733 \backslash
9734 /
9735 \end_layout
9736
9737 \end_inset
9738
9739 -opt-code-size
9740 \begin_inset LatexCommand \index{-\/-opt-code-size}
9741
9742 \end_inset
9743
9744
9745 \series default
9746  The compiler will optimize code generation towards compact code, possibly
9747  at the expense of code speed.
9748 \end_layout
9749
9750 \begin_layout Standard
9751 \begin_inset VSpace bigskip
9752 \end_inset
9753
9754
9755 \end_layout
9756
9757 \begin_layout Subsection
9758 Other Options
9759 \begin_inset LatexCommand \index{Options other}
9760
9761 \end_inset
9762
9763
9764 \end_layout
9765
9766 \begin_layout List
9767 \labelwidthstring 00.00.0000
9768
9769 \series bold
9770 -c\InsetSpace ~
9771 -
9772 \begin_inset ERT
9773 status collapsed
9774
9775 \begin_layout Standard
9776
9777
9778 \backslash
9779 /
9780 \end_layout
9781
9782 \end_inset
9783
9784 -compile-only
9785 \begin_inset LatexCommand \index{-\/-compile-only}
9786
9787 \end_inset
9788
9789
9790 \begin_inset LatexCommand \index{-c -\/-compile-only}
9791
9792 \end_inset
9793
9794
9795 \series default
9796  will compile and assemble the source, but will not call the linkage editor.
9797 \end_layout
9798
9799 \begin_layout List
9800 \labelwidthstring 00.00.0000
9801
9802 \series bold
9803 -
9804 \series default
9805
9806 \begin_inset ERT
9807 status collapsed
9808
9809 \begin_layout Standard
9810
9811
9812 \backslash
9813 /
9814 \end_layout
9815
9816 \end_inset
9817
9818
9819 \series bold
9820 -c1mode
9821 \begin_inset LatexCommand \index{-\/-c1mode}
9822
9823 \end_inset
9824
9825
9826 \series default
9827  reads the preprocessed source from standard input and compiles it.
9828  The file name for the assembler output must be specified using the -o option.
9829 \end_layout
9830
9831 \begin_layout List
9832 \labelwidthstring 00.00.0000
9833
9834 \series bold
9835 -E
9836 \begin_inset LatexCommand \index{-E}
9837
9838 \end_inset
9839
9840
9841 \series default
9842  Run only the C preprocessor.
9843  Preprocess all the C source files specified and output the results to standard
9844  output.
9845 \end_layout
9846
9847 \begin_layout List
9848 \labelwidthstring 00.00.0000
9849
9850 \series bold
9851 -o\InsetSpace ~
9852 <path/file>
9853 \begin_inset LatexCommand \index{-o <path/file>}
9854
9855 \end_inset
9856
9857  
9858 \series default
9859 The output path where everything will be placed or the file name used for
9860  all generated output files.
9861  If the parameter is a path, it must have a trailing slash (or backslash
9862  for the Windows binaries) to be recognized as a path.
9863
9864 \emph on
9865  
9866 \emph default
9867 Note for Windows users: if the path contains spaces, it should be surrounded
9868  by quotes.
9869  The trailing backslash should be doubled in order to prevent escaping the
9870  final quote, for example: 
9871 \emph on
9872 -o 
9873 \begin_inset Quotes sld
9874 \end_inset
9875
9876 F:
9877 \backslash
9878 Projects
9879 \backslash
9880 test3
9881 \backslash
9882 output 1
9883 \backslash
9884
9885 \backslash
9886
9887 \begin_inset Quotes srd
9888 \end_inset
9889
9890
9891 \emph default
9892  or put after the final quote, for example: 
9893 \emph on
9894 -o 
9895 \begin_inset Quotes sld
9896 \end_inset
9897
9898 F:
9899 \backslash
9900 Projects
9901 \backslash
9902 test3
9903 \backslash
9904 output 1
9905 \begin_inset Quotes srd
9906 \end_inset
9907
9908
9909 \backslash
9910
9911 \emph default
9912 .
9913  The path using slashes for directory delimiters can be used too, for example:
9914  
9915 \emph on
9916 -o 
9917 \begin_inset Quotes sld
9918 \end_inset
9919
9920 F:/Projects/test3/output 1/
9921 \begin_inset Quotes srd
9922 \end_inset
9923
9924
9925 \emph default
9926 .
9927 \end_layout
9928
9929 \begin_layout List
9930 \labelwidthstring 00.00.0000
9931
9932 \series bold
9933 -
9934 \begin_inset ERT
9935 status collapsed
9936
9937 \begin_layout Standard
9938
9939
9940 \backslash
9941 /
9942 \end_layout
9943
9944 \end_inset
9945
9946 -stack-auto
9947 \begin_inset LatexCommand \index{-\/-stack-auto}
9948
9949 \end_inset
9950
9951
9952 \series default
9953 \size large
9954 \emph on
9955  
9956 \size default
9957 \emph default
9958 All functions in the source file will be compiled as 
9959 \emph on
9960 reentrant
9961 \emph default
9962
9963 \begin_inset LatexCommand \index{reentrant}
9964
9965 \end_inset
9966
9967 , i.e.
9968  the parameters and local variables will be allocated on the stack
9969 \begin_inset LatexCommand \index{stack}
9970
9971 \end_inset
9972
9973 .
9974  See section 
9975 \begin_inset LatexCommand \ref{sec:Parameters-and-Local-Variables}
9976
9977 \end_inset
9978
9979  Parameters and Local Variables for more details.
9980  If this option is used all source files in the project should be compiled
9981  with this option.
9982  It automatically implies -
9983 \series bold
9984
9985 \begin_inset ERT
9986 status open
9987
9988 \begin_layout Standard
9989
9990
9991 \backslash
9992 /
9993 \end_layout
9994
9995 \end_inset
9996
9997
9998 \series default
9999 -int-long-reent and -
10000 \series bold
10001
10002 \begin_inset ERT
10003 status open
10004
10005 \begin_layout Standard
10006
10007
10008 \backslash
10009 /
10010 \end_layout
10011
10012 \end_inset
10013
10014
10015 \series default
10016 -float-reent.
10017  
10018 \end_layout
10019
10020 \begin_layout List
10021 \labelwidthstring 00.00.0000
10022
10023 \series bold
10024 -
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
10038 \begin_inset LatexCommand \index{-\/-callee-saves}
10039
10040 \end_inset
10041
10042  
10043 \begin_inset LatexCommand \label{lyx:--callee-saves-function1[,function2][,function3]...}
10044
10045 \end_inset
10046
10047 function1[,function2][,function3]....
10048
10049 \series default
10050  The compiler by default uses a caller saves convention for register saving
10051  across function calls, however this can cause unnecessary register pushing
10052  and popping when calling small functions from larger functions.
10053  This option can be used to switch the register saving convention for the
10054  function names specified.
10055  The compiler will not save registers when calling these functions, no extra
10056  code will be generated at the entry and exit (function prologue
10057 \series bold
10058
10059 \begin_inset LatexCommand \index{function prologue}
10060
10061 \end_inset
10062
10063
10064 \series default
10065  and epilogue
10066 \series bold
10067
10068 \begin_inset LatexCommand \index{function epilogue}
10069
10070 \end_inset
10071
10072
10073 \series default
10074 ) for these functions to save and restore the registers used by these functions,
10075  this can SUBSTANTIALLY reduce code and improve run time performance of
10076  the generated code.
10077  In the future the compiler (with inter procedural analysis) will be able
10078  to determine the appropriate scheme to use for each function call.
10079  DO NOT use this option for built-in functions such as _mulint..., if this
10080  option is used for a library function the appropriate library function
10081  needs to be recompiled with the same option.
10082  If the project consists of multiple source files then all the source file
10083  should be compiled with the same -
10084 \begin_inset ERT
10085 status collapsed
10086
10087 \begin_layout Standard
10088
10089
10090 \backslash
10091 /
10092 \end_layout
10093
10094 \end_inset
10095
10096 -callee-saves option string.
10097  Also see #pragma\InsetSpace ~
10098 callee_saves 
10099 \begin_inset LatexCommand \index{\#pragma callee\_saves}
10100
10101 \end_inset
10102
10103  
10104 \begin_inset LatexCommand \vpageref{ite:callee_saves-function1[,function2[,function3...]]--}
10105
10106 \end_inset
10107
10108 .
10109 \end_layout
10110
10111 \begin_layout List
10112 \labelwidthstring 00.00.0000
10113
10114 \series bold
10115 -
10116 \begin_inset ERT
10117 status collapsed
10118
10119 \begin_layout Standard
10120
10121
10122 \backslash
10123 /
10124 \end_layout
10125
10126 \end_inset
10127
10128 -all-callee-saves
10129 \begin_inset LatexCommand \index{-\/-all-callee-saves}
10130
10131 \end_inset
10132
10133  
10134 \series default
10135 Function of
10136 \series bold
10137  
10138 \series default
10139 -
10140 \begin_inset ERT
10141 status collapsed
10142
10143 \begin_layout Standard
10144
10145
10146 \backslash
10147 /
10148 \end_layout
10149
10150 \end_inset
10151
10152 -callee-saves will be applied to all functions by default.
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 -debug
10173 \begin_inset LatexCommand \index{-\/-debug}
10174
10175 \end_inset
10176
10177
10178 \bar under
10179  
10180 \series default
10181 \bar default
10182 When this option is used the compiler will generate debug information.
10183  The debug information collected in a file with .cdb extension can be used
10184  with the SDCDB.
10185  For more information see documentation for SDCDB.
10186  Another file with no extension contains debug information in AOMF or AOMF51
10187 \begin_inset LatexCommand \index{AOMF, AOMF51}
10188
10189 \end_inset
10190
10191  format which is commonly used by third party tools.
10192 \end_layout
10193
10194 \begin_layout List
10195 \labelwidthstring 00.00.0000
10196
10197 \series bold
10198 -S
10199 \begin_inset LatexCommand \index{-S}
10200
10201 \end_inset
10202
10203
10204 \size large
10205 \bar under
10206  
10207 \series default
10208 \size default
10209 \bar default
10210 Stop after the stage of compilation proper; do not assemble.
10211  The output is an assembler code file for the input file specified.
10212 \end_layout
10213
10214 \begin_layout List
10215 \labelwidthstring 00.00.0000
10216
10217 \series bold
10218 -
10219 \begin_inset ERT
10220 status collapsed
10221
10222 \begin_layout Standard
10223
10224
10225 \backslash
10226 /
10227 \end_layout
10228
10229 \end_inset
10230
10231 -int-long-reent
10232 \begin_inset LatexCommand \index{-\/-int-long-reent}
10233
10234 \end_inset
10235
10236
10237 \series default
10238  Integer (16 bit) and long (32 bit) libraries have been compiled as reentrant.
10239  Note by default these libraries are compiled as non-reentrant.
10240  See section Installation for more details.
10241 \end_layout
10242
10243 \begin_layout List
10244 \labelwidthstring 00.00.0000
10245
10246 \series bold
10247 -
10248 \begin_inset ERT
10249 status collapsed
10250
10251 \begin_layout Standard
10252
10253
10254 \backslash
10255 /
10256 \end_layout
10257
10258 \end_inset
10259
10260 -cyclomatic
10261 \begin_inset LatexCommand \index{-\/-cyclomatic}
10262
10263 \end_inset
10264
10265
10266 \bar under
10267  
10268 \series default
10269 \bar default
10270 This option will cause the compiler to generate an information message for
10271  each function in the source file.
10272  The message contains some 
10273 \emph on
10274 important
10275 \emph default
10276  information about the function.
10277  The number of edges and nodes the compiler detected in the control flow
10278  graph of the function, and most importantly the 
10279 \emph on
10280 cyclomatic complexity
10281 \begin_inset LatexCommand \index{Cyclomatic complexity}
10282
10283 \end_inset
10284
10285
10286 \emph default
10287  see section on Cyclomatic Complexity for more details.
10288 \end_layout
10289
10290 \begin_layout List
10291 \labelwidthstring 00.00.0000
10292
10293 \series bold
10294 -
10295 \begin_inset ERT
10296 status collapsed
10297
10298 \begin_layout Standard
10299
10300
10301 \backslash
10302 /
10303 \end_layout
10304
10305 \end_inset
10306
10307 -float-reent
10308 \begin_inset LatexCommand \index{-\/-float-reent}
10309
10310 \end_inset
10311
10312
10313 \series default
10314  Floating point library is compiled as reentrant
10315 \begin_inset LatexCommand \index{reentrant}
10316
10317 \end_inset
10318
10319 .
10320  See section Installation for more details.
10321 \end_layout
10322
10323 \begin_layout List
10324 \labelwidthstring 00.00.0000
10325
10326 \series bold
10327 -
10328 \begin_inset ERT
10329 status collapsed
10330
10331 \begin_layout Standard
10332
10333
10334 \backslash
10335 /
10336 \end_layout
10337
10338 \end_inset
10339
10340 -funsigned-char
10341 \begin_inset LatexCommand \index{-\/-funsigned-char}
10342
10343 \end_inset
10344
10345
10346 \series default
10347  The default signedness for every type is
10348 \family typewriter
10349  signed
10350 \family default
10351 .
10352  In some embedded environments the default signedness of
10353 \family typewriter
10354  char
10355 \family default
10356  is
10357 \family typewriter
10358  unsigned
10359 \family default
10360 .
10361  To set the signess for characters to unsigned, use the option -
10362 \series bold
10363
10364 \begin_inset ERT
10365 status open
10366
10367 \begin_layout Standard
10368
10369
10370 \backslash
10371 /
10372 \end_layout
10373
10374 \end_inset
10375
10376
10377 \series default
10378 -funsigned-char.
10379  If this option is set and no signedness keyword (unsigned/signed) is given,
10380  a char will be signed.
10381  All other types are unaffected.
10382 \end_layout
10383
10384 \begin_layout List
10385 \labelwidthstring 00.00.0000
10386
10387 \series bold
10388 -
10389 \begin_inset ERT
10390 status collapsed
10391
10392 \begin_layout Standard
10393
10394
10395 \backslash
10396 /
10397 \end_layout
10398
10399 \end_inset
10400
10401 -main-return
10402 \begin_inset LatexCommand \index{-\/-main-return}
10403
10404 \end_inset
10405
10406
10407 \series default
10408  This option can be used if the code generated is called by a monitor program
10409  or if the main routine includes an endless loop.
10410  This option results in slightly smaller code and saves two bytes of stack
10411  space.
10412  The return from the 'main'
10413 \begin_inset LatexCommand \index{main return}
10414
10415 \end_inset
10416
10417  function will return to the function calling main.
10418  The default setting is to lock up i.e.
10419  generate a '
10420 \family typewriter
10421 sjmp .
10422 \family default
10423 '.
10424 \end_layout
10425
10426 \begin_layout List
10427 \labelwidthstring 00.00.0000
10428
10429 \series bold
10430 -
10431 \begin_inset ERT
10432 status collapsed
10433
10434 \begin_layout Standard
10435
10436
10437 \backslash
10438 /
10439 \end_layout
10440
10441 \end_inset
10442
10443 -nostdinc
10444 \begin_inset LatexCommand \index{-\/-nostdinc}
10445
10446 \end_inset
10447
10448
10449 \series default
10450  This will prevent the compiler from passing on the default include path
10451  to the preprocessor.
10452 \end_layout
10453
10454 \begin_layout List
10455 \labelwidthstring 00.00.0000
10456
10457 \series bold
10458 -
10459 \begin_inset ERT
10460 status collapsed
10461
10462 \begin_layout Standard
10463
10464
10465 \backslash
10466 /
10467 \end_layout
10468
10469 \end_inset
10470
10471 -nostdlib
10472 \begin_inset LatexCommand \index{-\/-nostdlib}
10473
10474 \end_inset
10475
10476
10477 \series default
10478  This will prevent the compiler from passing on the default library
10479 \begin_inset LatexCommand \index{Libraries}
10480
10481 \end_inset
10482
10483  path to the linker.
10484 \end_layout
10485
10486 \begin_layout List
10487 \labelwidthstring 00.00.0000
10488
10489 \series bold
10490 -
10491 \begin_inset ERT
10492 status collapsed
10493
10494 \begin_layout Standard
10495
10496
10497 \backslash
10498 /
10499 \end_layout
10500
10501 \end_inset
10502
10503 -verbose
10504 \begin_inset LatexCommand \index{-\/-verbose}
10505
10506 \end_inset
10507
10508
10509 \series default
10510  Shows the various actions the compiler is performing.
10511 \end_layout
10512
10513 \begin_layout List
10514 \labelwidthstring 00.00.0000
10515
10516 \series bold
10517 -V
10518 \begin_inset LatexCommand \index{-V}
10519
10520 \end_inset
10521
10522
10523 \series default
10524  Shows the actual commands the compiler is executing.
10525 \end_layout
10526
10527 \begin_layout List
10528 \labelwidthstring 00.00.0000
10529
10530 \series bold
10531 -
10532 \begin_inset ERT
10533 status collapsed
10534
10535 \begin_layout Standard
10536
10537
10538 \backslash
10539 /
10540 \end_layout
10541
10542 \end_inset
10543
10544 -no-c-code-in-asm
10545 \begin_inset LatexCommand \index{-\/-no-c-code-in-asm}
10546
10547 \end_inset
10548
10549
10550 \series default
10551  Hides your ugly and inefficient c-code from the asm file, so you can always
10552  blame the compiler :)
10553 \end_layout
10554
10555 \begin_layout List
10556 \labelwidthstring 00.00.0000
10557
10558 \series bold
10559 -
10560 \begin_inset ERT
10561 status collapsed
10562
10563 \begin_layout Standard
10564
10565
10566 \backslash
10567 /
10568 \end_layout
10569
10570 \end_inset
10571
10572 -fverbose-asm
10573 \begin_inset LatexCommand \index{-\/-no-gen-comments}
10574
10575 \end_inset
10576
10577
10578 \series default
10579  Include code generator and peep-hole comments in the generated asm files.
10580 \end_layout
10581
10582 \begin_layout List
10583 \labelwidthstring 00.00.0000
10584
10585 \series bold
10586 -
10587 \begin_inset ERT
10588 status collapsed
10589
10590 \begin_layout Standard
10591
10592
10593 \backslash
10594 /
10595 \end_layout
10596
10597 \end_inset
10598
10599 -no-peep-comments
10600 \begin_inset LatexCommand \index{-\/-no-peep-comments}
10601
10602 \end_inset
10603
10604
10605 \series default
10606  Don't include peep-hole comments in the generated asm files even if -
10607 \series bold
10608
10609 \begin_inset ERT
10610 status open
10611
10612 \begin_layout Standard
10613
10614
10615 \backslash
10616 /
10617 \end_layout
10618
10619 \end_inset
10620
10621
10622 \series default
10623 -fverbose-asm option is specified.
10624 \end_layout
10625
10626 \begin_layout List
10627 \labelwidthstring 00.00.0000
10628
10629 \series bold
10630 -
10631 \begin_inset ERT
10632 status collapsed
10633
10634 \begin_layout Standard
10635
10636
10637 \backslash
10638 /
10639 \end_layout
10640
10641 \end_inset
10642
10643 -i-code-in-asm
10644 \begin_inset LatexCommand \index{-\/-i-code-in-asm}
10645
10646 \end_inset
10647
10648
10649 \series default
10650  Include i-codes in the asm file.
10651  Sounds like noise but is most helpful for debugging the compiler itself.
10652 \end_layout
10653
10654 \begin_layout List
10655 \labelwidthstring 00.00.0000
10656
10657 \series bold
10658 -
10659 \begin_inset ERT
10660 status collapsed
10661
10662 \begin_layout Standard
10663
10664
10665 \backslash
10666 /
10667 \end_layout
10668
10669 \end_inset
10670
10671 -less-pedantic
10672 \begin_inset LatexCommand \index{pedantic}
10673
10674 \end_inset
10675
10676
10677 \begin_inset LatexCommand \index{-\/-less-pedantic}
10678
10679 \end_inset
10680
10681
10682 \series default
10683
10684 \begin_inset LatexCommand \label{lyx:--less-pedantic}
10685
10686 \end_inset
10687
10688  Disable some of the more pedantic warnings
10689 \begin_inset LatexCommand \index{Warnings}
10690
10691 \end_inset
10692
10693 .
10694  For more details, see the less_pedantic pragma 
10695 \begin_inset LatexCommand \vpageref{ite:less_pedantic}
10696
10697 \end_inset
10698
10699 .
10700 \end_layout
10701
10702 \begin_layout List
10703 \labelwidthstring 00.00.0000
10704
10705 \series bold
10706 -
10707 \begin_inset ERT
10708 status collapsed
10709
10710 \begin_layout Standard
10711
10712
10713 \backslash
10714 /
10715 \end_layout
10716
10717 \end_inset
10718
10719 -disable-warning\InsetSpace ~
10720 <nnnn>
10721 \begin_inset LatexCommand \index{-\/-disable-warning}
10722
10723 \end_inset
10724
10725
10726 \series default
10727  Disable specific warning with number <nnnn>.
10728 \end_layout
10729
10730 \begin_layout List
10731 \labelwidthstring 00.00.0000
10732
10733 \series bold
10734 -
10735 \begin_inset ERT
10736 status collapsed
10737
10738 \begin_layout Standard
10739
10740
10741 \backslash
10742 /
10743 \end_layout
10744
10745 \end_inset
10746
10747 -Werror
10748 \begin_inset LatexCommand \index{-\/-Werror}
10749
10750 \end_inset
10751
10752
10753 \series default
10754  Treat all warnings as errors.
10755 \end_layout
10756
10757 \begin_layout List
10758 \labelwidthstring 00.00.0000
10759
10760 \series bold
10761 -
10762 \begin_inset ERT
10763 status collapsed
10764
10765 \begin_layout Standard
10766
10767
10768 \backslash
10769 /
10770 \end_layout
10771
10772 \end_inset
10773
10774 -print-search-dirs
10775 \begin_inset LatexCommand \index{-\/-print-search-dirs}
10776
10777 \end_inset
10778
10779
10780 \series default
10781  Display the directories in the compiler's search path
10782 \end_layout
10783
10784 \begin_layout List
10785 \labelwidthstring 00.00.0000
10786
10787 \series bold
10788 -
10789 \begin_inset ERT
10790 status collapsed
10791
10792 \begin_layout Standard
10793
10794
10795 \backslash
10796 /
10797 \end_layout
10798
10799 \end_inset
10800
10801 -vc
10802 \begin_inset LatexCommand \index{-\/-vc}
10803
10804 \end_inset
10805
10806
10807 \series default
10808  Display errors and warnings using MSVC style, so you can use SDCC with
10809  the visual studio IDE
10810 \begin_inset LatexCommand \index{IDE}
10811
10812 \end_inset
10813
10814 .
10815  With SDCC both offering a GCC-like (the default) and a MSVC-like
10816 \begin_inset LatexCommand \index{MSVC output style}
10817
10818 \end_inset
10819
10820  output style, integration into most programming editors should be straightforwa
10821 rd.
10822 \end_layout
10823
10824 \begin_layout List
10825 \labelwidthstring 00.00.0000
10826
10827 \series bold
10828 -
10829 \begin_inset ERT
10830 status collapsed
10831
10832 \begin_layout Standard
10833
10834
10835 \backslash
10836 /
10837 \end_layout
10838
10839 \end_inset
10840
10841 -use-stdout
10842 \begin_inset LatexCommand \index{-\/-use-stdout}
10843
10844 \end_inset
10845
10846
10847 \series default
10848  Send errors and warnings to stdout instead of stderr.
10849 \end_layout
10850
10851 \begin_layout List
10852 \labelwidthstring 00.00.0000
10853
10854 \series bold
10855 -Wa\InsetSpace ~
10856 asmOption[,asmOption]
10857 \series default
10858
10859 \begin_inset LatexCommand \index{-Wa asmOption[,asmOption]}
10860
10861 \end_inset
10862
10863 ...
10864  Pass the asmOption to the assembler
10865 \begin_inset LatexCommand \index{Options assembler}
10866
10867 \end_inset
10868
10869
10870 \begin_inset LatexCommand \index{Assembler options}
10871
10872 \end_inset
10873
10874 .
10875  See file sdcc/as/doc/asxhtm.html for assembler options.cd
10876 \end_layout
10877
10878 \begin_layout List
10879 \labelwidthstring 00.00.0000
10880
10881 \series bold
10882 -
10883 \begin_inset ERT
10884 status collapsed
10885
10886 \begin_layout Standard
10887
10888
10889 \backslash
10890 /
10891 \end_layout
10892
10893 \end_inset
10894
10895 -std-sdcc89
10896 \begin_inset LatexCommand \index{-\/-std-sdcc89}
10897
10898 \end_inset
10899
10900
10901 \series default
10902  Generally follow the C89 standard, but allow SDCC features that conflict
10903  with the standard (default).
10904 \end_layout
10905
10906 \begin_layout List
10907 \labelwidthstring 00.00.0000
10908
10909 \series bold
10910 -
10911 \begin_inset ERT
10912 status collapsed
10913
10914 \begin_layout Standard
10915
10916
10917 \backslash
10918 /
10919 \end_layout
10920
10921 \end_inset
10922
10923 -std-c89
10924 \begin_inset LatexCommand \index{-\/-std-c89}
10925
10926 \end_inset
10927
10928
10929 \series default
10930  Follow the C89 standard and disable SDCC features that conflict with the
10931  standard.
10932 \end_layout
10933
10934 \begin_layout List
10935 \labelwidthstring 00.00.0000
10936
10937 \series bold
10938 -
10939 \begin_inset ERT
10940 status collapsed
10941
10942 \begin_layout Standard
10943
10944
10945 \backslash
10946 /
10947 \end_layout
10948
10949 \end_inset
10950
10951 -std-sdcc99
10952 \begin_inset LatexCommand \index{-\/-std-sdcc99}
10953
10954 \end_inset
10955
10956
10957 \series default
10958  Generally follow the C99 standard, but allow SDCC features that conflict
10959  with the standard (incomplete support).
10960 \end_layout
10961
10962 \begin_layout List
10963 \labelwidthstring 00.00.0000
10964
10965 \series bold
10966 -
10967 \begin_inset ERT
10968 status collapsed
10969
10970 \begin_layout Standard
10971
10972
10973 \backslash
10974 /
10975 \end_layout
10976
10977 \end_inset
10978
10979 -std-c99
10980 \begin_inset LatexCommand \index{-\/-std-sdcc99}
10981
10982 \end_inset
10983
10984
10985 \series default
10986  Follow the C99 standard and disable SDCC features that conflict with the
10987  standard (incomplete support).
10988 \end_layout
10989
10990 \begin_layout List
10991 \labelwidthstring 00.00.0000
10992
10993 \series bold
10994 -
10995 \begin_inset ERT
10996 status collapsed
10997
10998 \begin_layout Standard
10999
11000
11001 \backslash
11002 /
11003 \end_layout
11004
11005 \end_inset
11006
11007 -codeseg
11008 \series default
11009
11010 \begin_inset LatexCommand \index{-\/-codeseg <Value>}
11011
11012 \end_inset
11013
11014
11015 \begin_inset LatexCommand \label{lyx:-codeseg}
11016
11017 \end_inset
11018
11019 \InsetSpace ~
11020 <Name> The name to be used for the code
11021 \begin_inset LatexCommand \index{code}
11022
11023 \end_inset
11024
11025  segment, default CSEG.
11026  This is useful if you need to tell the compiler to put the code in a special
11027  segment so you can later on tell the linker to put this segment in a special
11028  place in memory.
11029  Can be used for instance when using bank switching to put the code in a
11030  bank.
11031 \end_layout
11032
11033 \begin_layout List
11034 \labelwidthstring 00.00.0000
11035
11036 \series bold
11037 -
11038 \begin_inset ERT
11039 status collapsed
11040
11041 \begin_layout Standard
11042
11043
11044 \backslash
11045 /
11046 \end_layout
11047
11048 \end_inset
11049
11050 -constseg
11051 \series default
11052
11053 \begin_inset LatexCommand \index{-\/-constseg <Value>}
11054
11055 \end_inset
11056
11057 \InsetSpace ~
11058 <Name> The name to be used for the const
11059 \begin_inset LatexCommand \index{const}
11060
11061 \end_inset
11062
11063  segment, default CONST.
11064  This is useful if you need to tell the compiler to put the const data in
11065  a special segment so you can later on tell the linker to put this segment
11066  in a special place in memory.
11067  Can be used for instance when using bank switching to put the const data
11068  in a bank.
11069 \end_layout
11070
11071 \begin_layout List
11072 \labelwidthstring 00.00.0000
11073
11074 \series bold
11075 -
11076 \begin_inset ERT
11077 status collapsed
11078
11079 \begin_layout Standard
11080
11081
11082 \backslash
11083 /
11084 \end_layout
11085
11086 \end_inset
11087
11088 -fdollars-in-identifiers
11089 \begin_inset LatexCommand \index{-\/-fdollars-in-identifiers}
11090
11091 \end_inset
11092
11093
11094 \series default
11095  Permit '$' as an identifier character.
11096 \end_layout
11097
11098 \begin_layout List
11099 \labelwidthstring 00.00.0000
11100
11101 \series bold
11102 -
11103 \begin_inset ERT
11104 status collapsed
11105
11106 \begin_layout Standard
11107
11108
11109 \backslash
11110 /
11111 \end_layout
11112
11113 \end_inset
11114
11115 -more-pedantic
11116 \series default
11117
11118 \begin_inset LatexCommand \index{-\/-more-pedantic}
11119
11120 \end_inset
11121
11122
11123 \begin_inset LatexCommand \index{pedantic}
11124
11125 \end_inset
11126
11127  Actually this is 
11128 \series bold
11129 \emph on
11130 not
11131 \series default
11132 \emph default
11133  a SDCC compiler option but if you want 
11134 \emph on
11135 more
11136 \emph default
11137  warnings you can use a separate tool dedicated to syntax checking like
11138  splint
11139 \begin_inset LatexCommand \label{lyx:more-pedantic-SPLINT}
11140
11141 \end_inset
11142
11143
11144 \begin_inset LatexCommand \index{lint (syntax checking tool)}
11145
11146 \end_inset
11147
11148  
11149 \begin_inset LatexCommand \url{http://www.splint.org}
11150
11151 \end_inset
11152
11153 .
11154  To make your source files parseable by splint you will have to include
11155  
11156 \family sans
11157 lint.h
11158 \family default
11159
11160 \begin_inset LatexCommand \index{splint (syntax checking tool)}
11161
11162 \end_inset
11163
11164  in your source file and add brackets around extended keywords (like 
11165 \family sans
11166
11167 \begin_inset Quotes sld
11168 \end_inset
11169
11170 __at\InsetSpace ~
11171
11172 \series bold
11173 (
11174 \series default
11175 0xab
11176 \series bold
11177 )
11178 \series default
11179
11180 \begin_inset Quotes srd
11181 \end_inset
11182
11183
11184 \family default
11185  and 
11186 \family sans
11187
11188 \begin_inset Quotes sld
11189 \end_inset
11190
11191 __interrupt\InsetSpace ~
11192 (2)
11193 \begin_inset Quotes srd
11194 \end_inset
11195
11196
11197 \family default
11198 ).
11199  
11200 \newline
11201 Splint has an excellent on line manual at 
11202 \begin_inset LatexCommand \url{http://www.splint.org/manual/}
11203
11204 \end_inset
11205
11206  and it's capabilities go beyond pure syntax checking.
11207  You'll need to tell splint the location of SDCC's include files so a typical
11208  command line could look like this: 
11209 \newline
11210
11211 \family sans
11212 splint\InsetSpace ~
11213 -I\InsetSpace ~
11214 /usr/local/share/sdcc/include/mcs51/\InsetSpace ~
11215 \InsetSpace ~
11216 myprogram.c
11217 \end_layout
11218
11219 \begin_layout List
11220 \labelwidthstring 00.00.0000
11221
11222 \series bold
11223 -
11224 \begin_inset ERT
11225 status collapsed
11226
11227 \begin_layout Standard
11228
11229
11230 \backslash
11231 /
11232 \end_layout
11233
11234 \end_inset
11235
11236 -short-is-8bits
11237 \series default
11238
11239 \begin_inset LatexCommand \index{-\/-short-is-8bits}
11240
11241 \end_inset
11242
11243
11244 \begin_inset LatexCommand \label{lyx:--short-is-8bits}
11245
11246 \end_inset
11247
11248  Treat short as 8-bit (for backward compatibility with older versions of
11249  compiler - see section 
11250 \begin_inset LatexCommand \ref{sec:Compatibility-with-previous}
11251
11252 \end_inset
11253
11254 )
11255 \end_layout
11256
11257 \begin_layout Standard
11258 \begin_inset VSpace bigskip
11259 \end_inset
11260
11261
11262 \end_layout
11263
11264 \begin_layout Subsection
11265 Intermediate Dump Options
11266 \begin_inset LatexCommand \label{sub:Intermediate-Dump-Options}
11267
11268 \end_inset
11269
11270
11271 \begin_inset LatexCommand \index{Options intermediate dump}
11272
11273 \end_inset
11274
11275
11276 \begin_inset LatexCommand \index{Intermediate dump options}
11277
11278 \end_inset
11279
11280
11281 \end_layout
11282
11283 \begin_layout Standard
11284 The following options are provided for the purpose of retargetting and debugging
11285  the compiler.
11286  They provide a means to dump the intermediate code (iCode
11287 \begin_inset LatexCommand \index{iCode}
11288
11289 \end_inset
11290
11291 ) generated by the compiler in human readable form at various stages of
11292  the compilation process.
11293  More on iCodes see chapter 
11294 \begin_inset LatexCommand \ref{sub:The-anatomy-of}
11295
11296 \end_inset
11297
11298  
11299 \begin_inset Quotes srd
11300 \end_inset
11301
11302 The anatomy of the compiler
11303 \begin_inset Quotes srd
11304 \end_inset
11305
11306 .
11307 \end_layout
11308
11309 \begin_layout List
11310 \labelwidthstring 00.00.0000
11311
11312 \series bold
11313 -
11314 \begin_inset ERT
11315 status collapsed
11316
11317 \begin_layout Standard
11318
11319
11320 \backslash
11321 /
11322 \end_layout
11323
11324 \end_inset
11325
11326 -dumpraw
11327 \begin_inset LatexCommand \index{-\/-dumpraw}
11328
11329 \end_inset
11330
11331
11332 \series default
11333  This option will cause the compiler to dump the intermediate code into
11334  a file of named 
11335 \emph on
11336 <source filename>.dumpraw
11337 \emph default
11338  just after the intermediate code has been generated for a function, i.e.
11339  before any optimizations are done.
11340  The basic blocks
11341 \begin_inset LatexCommand \index{Basic blocks}
11342
11343 \end_inset
11344
11345  at this stage ordered in the depth first number, so they may not be in
11346  sequence of execution.
11347 \end_layout
11348
11349 \begin_layout List
11350 \labelwidthstring 00.00.0000
11351
11352 \series bold
11353 -
11354 \begin_inset ERT
11355 status collapsed
11356
11357 \begin_layout Standard
11358
11359
11360 \backslash
11361 /
11362 \end_layout
11363
11364 \end_inset
11365
11366 -dumpgcse
11367 \begin_inset LatexCommand \index{-\/-dumpgcse}
11368
11369 \end_inset
11370
11371
11372 \series default
11373  Will create a dump of iCodes, after global subexpression elimination
11374 \begin_inset LatexCommand \index{Global subexpression elimination}
11375
11376 \end_inset
11377
11378 , into a file named 
11379 \emph on
11380 <source filename>.dumpgcse.
11381 \end_layout
11382
11383 \begin_layout List
11384 \labelwidthstring 00.00.0000
11385
11386 \series bold
11387 -
11388 \begin_inset ERT
11389 status collapsed
11390
11391 \begin_layout Standard
11392
11393
11394 \backslash
11395 /
11396 \end_layout
11397
11398 \end_inset
11399
11400 -dumpdeadcode
11401 \begin_inset LatexCommand \index{-\/-dumpdeadcode}
11402
11403 \end_inset
11404
11405
11406 \series default
11407  Will create a dump of iCodes, after deadcode elimination
11408 \begin_inset LatexCommand \index{Dead-code elimination}
11409
11410 \end_inset
11411
11412 , into a file named 
11413 \emph on
11414 <source filename>.dumpdeadcode.
11415 \end_layout
11416
11417 \begin_layout List
11418 \labelwidthstring 00.00.0000
11419
11420 \series bold
11421 -
11422 \begin_inset ERT
11423 status collapsed
11424
11425 \begin_layout Standard
11426
11427
11428 \backslash
11429 /
11430 \end_layout
11431
11432 \end_inset
11433
11434 -dumploop
11435 \begin_inset LatexCommand \index{-\/-dumploop}
11436
11437 \end_inset
11438
11439
11440 \series default
11441 \size large
11442  
11443 \size default
11444 Will create a dump of iCodes, after loop optimizations
11445 \begin_inset LatexCommand \index{Loop optimization}
11446
11447 \end_inset
11448
11449 , into a file named 
11450 \emph on
11451 <source filename>.dumploop.
11452 \end_layout
11453
11454 \begin_layout List
11455 \labelwidthstring 00.00.0000
11456
11457 \series bold
11458 -
11459 \begin_inset ERT
11460 status collapsed
11461
11462 \begin_layout Standard
11463
11464
11465 \backslash
11466 /
11467 \end_layout
11468
11469 \end_inset
11470
11471 -dumprange
11472 \begin_inset LatexCommand \index{-\/-dumprange}
11473
11474 \end_inset
11475
11476
11477 \series default
11478 \size large
11479  
11480 \size default
11481 Will create a dump of iCodes, after live range analysis
11482 \begin_inset LatexCommand \index{Live range analysis}
11483
11484 \end_inset
11485
11486 , into a file named 
11487 \emph on
11488 <source filename>.dumprange.
11489 \end_layout
11490
11491 \begin_layout List
11492 \labelwidthstring 00.00.0000
11493
11494 \series bold
11495 -
11496 \begin_inset ERT
11497 status collapsed
11498
11499 \begin_layout Standard
11500
11501
11502 \backslash
11503 /
11504 \end_layout
11505
11506 \end_inset
11507
11508 -dumlrange
11509 \begin_inset LatexCommand \index{-\/-dumlrange}
11510
11511 \end_inset
11512
11513
11514 \series default
11515  Will dump the life ranges
11516 \begin_inset LatexCommand \index{Live range analysis}
11517
11518 \end_inset
11519
11520  for all symbols.
11521 \end_layout
11522
11523 \begin_layout List
11524 \labelwidthstring 00.00.0000
11525
11526 \series bold
11527 -
11528 \begin_inset ERT
11529 status collapsed
11530
11531 \begin_layout Standard
11532
11533
11534 \backslash
11535 /
11536 \end_layout
11537
11538 \end_inset
11539
11540 -dumpregassign
11541 \begin_inset LatexCommand \index{-\/-dumpregassign}
11542
11543 \end_inset
11544
11545
11546 \bar under
11547  
11548 \series default
11549 \bar default
11550 Will create a dump of iCodes, after register assignment
11551 \begin_inset LatexCommand \index{Register assignment}
11552
11553 \end_inset
11554
11555 , into a file named 
11556 \emph on
11557 <source filename>.dumprassgn.
11558 \end_layout
11559
11560 \begin_layout List
11561 \labelwidthstring 00.00.0000
11562
11563 \series bold
11564 -
11565 \begin_inset ERT
11566 status collapsed
11567
11568 \begin_layout Standard
11569
11570
11571 \backslash
11572 /
11573 \end_layout
11574
11575 \end_inset
11576
11577 -dumplrange
11578 \begin_inset LatexCommand \index{-\/-dumplrange}
11579
11580 \end_inset
11581
11582
11583 \series default
11584  Will create a dump of the live ranges of iTemp's
11585 \end_layout
11586
11587 \begin_layout List
11588 \labelwidthstring 00.00.0000
11589
11590 \series bold
11591 -
11592 \begin_inset ERT
11593 status collapsed
11594
11595 \begin_layout Standard
11596
11597
11598 \backslash
11599 /
11600 \end_layout
11601
11602 \end_inset
11603
11604 -dumpall
11605 \begin_inset LatexCommand \index{-\/-dumpall}
11606
11607 \end_inset
11608
11609
11610 \size large
11611 \bar under
11612  
11613 \series default
11614 \size default
11615 \bar default
11616 Will cause all the above mentioned dumps to be created.
11617 \end_layout
11618
11619 \begin_layout Standard
11620 \begin_inset VSpace bigskip
11621 \end_inset
11622
11623
11624 \end_layout
11625
11626 \begin_layout Subsection
11627 Redirecting output on Windows Shells
11628 \end_layout
11629
11630 \begin_layout Standard
11631 By default SDCC writes its error messages to 
11632 \begin_inset Quotes sld
11633 \end_inset
11634
11635 standard error
11636 \begin_inset Quotes srd
11637 \end_inset
11638
11639 .
11640  To force all messages to 
11641 \begin_inset Quotes sld
11642 \end_inset
11643
11644 standard output
11645 \begin_inset Quotes srd
11646 \end_inset
11647
11648  use 
11649 \series bold
11650 -
11651 \series default
11652 \emph on
11653
11654 \begin_inset ERT
11655 status collapsed
11656
11657 \begin_layout Standard
11658
11659
11660 \backslash
11661 /
11662 \end_layout
11663
11664 \end_inset
11665
11666
11667 \series bold
11668 \emph default
11669 -
11670 \series default
11671 use-stdout
11672 \begin_inset LatexCommand \index{-\/-use-stdout}
11673
11674 \end_inset
11675
11676 .
11677  Additionally, if you happen to have visual studio installed in your windows
11678  machine, you can use it to compile your sources using a custom build and
11679  the SDCC -
11680 \emph on
11681
11682 \begin_inset ERT
11683 status collapsed
11684
11685 \begin_layout Standard
11686
11687
11688 \backslash
11689 /
11690 \end_layout
11691
11692 \end_inset
11693
11694
11695 \emph default
11696 -vc
11697 \begin_inset LatexCommand \index{-\/-vc}
11698
11699 \end_inset
11700
11701  option.
11702  Something like this should work:
11703 \newline
11704
11705 \newline
11706
11707 \series bold
11708 c:
11709 \backslash
11710 sdcc
11711 \backslash
11712 bin
11713 \backslash
11714 sdcc.exe -
11715 \series default
11716 \emph on
11717
11718 \begin_inset ERT
11719 status collapsed
11720
11721 \begin_layout Standard
11722
11723
11724 \backslash
11725 /
11726 \end_layout
11727
11728 \end_inset
11729
11730
11731 \series bold
11732 \emph default
11733 -vc -
11734 \series default
11735 \emph on
11736
11737 \begin_inset ERT
11738 status collapsed
11739
11740 \begin_layout Standard
11741
11742
11743 \backslash
11744 /
11745 \end_layout
11746
11747 \end_inset
11748
11749
11750 \series bold
11751 \emph default
11752 -model-large -c $(InputPath)
11753 \series default
11754
11755 \begin_inset VSpace bigskip
11756 \end_inset
11757
11758
11759 \end_layout
11760
11761 \begin_layout Section
11762 Environment variables
11763 \begin_inset LatexCommand \index{Environment variables}
11764
11765 \end_inset
11766
11767
11768 \end_layout
11769
11770 \begin_layout Standard
11771 SDCC recognizes the following environment variables:
11772 \end_layout
11773
11774 \begin_layout List
11775 \labelwidthstring 00.00.0000
11776
11777 \series bold
11778 SDCC_LEAVE_SIGNALS
11779 \begin_inset LatexCommand \index{SDCC\_LEAVE\_SIGNALS}
11780
11781 \end_inset
11782
11783
11784 \series default
11785  SDCC installs a signal handler
11786 \begin_inset LatexCommand \index{signal handler}
11787
11788 \end_inset
11789
11790  to be able to delete temporary files after an user break (^C) or an exception.
11791  If this environment variable is set, SDCC won't install the signal handler
11792  in order to be able to debug SDCC.
11793 \end_layout
11794
11795 \begin_layout List
11796 \labelwidthstring 00.00.0000
11797
11798 \series bold
11799 TMP,\InsetSpace ~
11800 TEMP,\InsetSpace ~
11801 TMPDIR
11802 \begin_inset LatexCommand \index{TMP, TEMP, TMPDIR}
11803
11804 \end_inset
11805
11806
11807 \series default
11808  Path, where temporary files will be created.
11809  The order of the variables is the search order.
11810  In a standard *nix environment these variables are not set, and there's
11811  no need to set them.
11812  On Windows it's recommended to set one of them.
11813 \end_layout
11814
11815 \begin_layout List
11816 \labelwidthstring 00.00.0000
11817
11818 \series bold
11819 SDCC_HOME
11820 \begin_inset LatexCommand \index{SDCC\_HOME}
11821
11822 \end_inset
11823
11824
11825 \series default
11826  Path, see section 
11827 \begin_inset LatexCommand \ref{sub:Install-paths}
11828
11829 \end_inset
11830
11831 \InsetSpace ~
11832
11833 \begin_inset Quotes sld
11834 \end_inset
11835
11836  Install Paths
11837 \begin_inset Quotes srd
11838 \end_inset
11839
11840 .
11841 \end_layout
11842
11843 \begin_layout List
11844 \labelwidthstring 00.00.0000
11845
11846 \series bold
11847 SDCC_INCLUDE
11848 \begin_inset LatexCommand \index{SDCC\_INCLUDE}
11849
11850 \end_inset
11851
11852
11853 \series default
11854  Path, see section 
11855 \begin_inset LatexCommand \ref{sub:Search-Paths}
11856
11857 \end_inset
11858
11859 \InsetSpace ~
11860
11861 \begin_inset Quotes sld
11862 \end_inset
11863
11864 Search Paths
11865 \begin_inset Quotes srd
11866 \end_inset
11867
11868 .
11869 \end_layout
11870
11871 \begin_layout List
11872 \labelwidthstring 00.00.0000
11873
11874 \series bold
11875 SDCC_LIB
11876 \begin_inset LatexCommand \index{SDCC\_LIB}
11877
11878 \end_inset
11879
11880
11881 \series default
11882  Path, see section 
11883 \begin_inset LatexCommand \ref{sub:Search-Paths}
11884
11885 \end_inset
11886
11887 \InsetSpace ~
11888
11889 \begin_inset Quotes sld
11890 \end_inset
11891
11892 Search Paths
11893 \begin_inset Quotes srd
11894 \end_inset
11895
11896 ..
11897 \end_layout
11898
11899 \begin_layout Standard
11900 There are some more environment variables recognized by SDCC, but these
11901  are solely used for debugging purposes.
11902  They can change or disappear very quickly, and will never be documented.
11903 \begin_inset VSpace bigskip
11904 \end_inset
11905
11906
11907 \end_layout
11908
11909 \begin_layout Section
11910 Storage Class Language Extensions
11911 \end_layout
11912
11913 \begin_layout Subsection
11914 MCS51/DS390 Storage Class
11915 \begin_inset LatexCommand \index{Storage class}
11916
11917 \end_inset
11918
11919  Language Extensions
11920 \end_layout
11921
11922 \begin_layout Standard
11923 In addition to the ANSI storage classes SDCC allows the following MCS51
11924  specific storage classes:
11925 \end_layout
11926
11927 \begin_layout Subsubsection
11928 data
11929 \begin_inset LatexCommand \index{data (mcs51, ds390 storage class)}
11930
11931 \end_inset
11932
11933
11934 \begin_inset LatexCommand \index{\_\_data (mcs51, ds390 storage class)}
11935
11936 \end_inset
11937
11938  / near
11939 \begin_inset LatexCommand \index{near (storage class)}
11940
11941 \end_inset
11942
11943
11944 \begin_inset LatexCommand \index{\_\_near (storage class)}
11945
11946 \end_inset
11947
11948
11949 \end_layout
11950
11951 \begin_layout Standard
11952 This is the 
11953 \series bold
11954 default
11955 \series default
11956  storage class for the Small Memory model (
11957 \emph on
11958 data
11959 \emph default
11960  and 
11961 \emph on
11962 near
11963 \emph default
11964  or the more ANSI-C compliant forms 
11965 \emph on
11966 __data
11967 \emph default
11968  and 
11969 \emph on
11970 __near
11971 \emph default
11972  can be used synonymously).
11973  Variables declared with this storage class will be allocated in the directly
11974  addressable portion of the internal RAM of a 8051, e.g.:
11975 \end_layout
11976
11977 \begin_layout Verse
11978
11979 \family typewriter
11980 __data unsigned char test_data;
11981 \end_layout
11982
11983 \begin_layout Standard
11984 Writing 0x01 to this variable generates the assembly code:
11985 \end_layout
11986
11987 \begin_layout Verse
11988
11989 \family typewriter
11990 75*00 01\InsetSpace ~
11991 \InsetSpace ~
11992 \InsetSpace ~
11993 mov\InsetSpace ~
11994 \InsetSpace ~
11995 _test_data,#0x01
11996 \end_layout
11997
11998 \begin_layout Subsubsection
11999 xdata
12000 \begin_inset LatexCommand \index{xdata (mcs51, ds390 storage class)}
12001
12002 \end_inset
12003
12004
12005 \begin_inset LatexCommand \index{\_\_xdata (mcs51, ds390 storage class)}
12006
12007 \end_inset
12008
12009  / far
12010 \begin_inset LatexCommand \index{far (storage class)}
12011
12012 \end_inset
12013
12014
12015 \begin_inset LatexCommand \index{\_\_far (storage class)}
12016
12017 \end_inset
12018
12019
12020 \end_layout
12021
12022 \begin_layout Standard
12023 Variables declared with this storage class will be placed in the external
12024  RAM.
12025  This is the 
12026 \series bold
12027 default
12028 \series default
12029  storage class for the Large Memory model, e.g.:
12030 \end_layout
12031
12032 \begin_layout Verse
12033
12034 \family typewriter
12035 __xdata unsigned char test_xdata;
12036 \end_layout
12037
12038 \begin_layout Standard
12039 Writing 0x01 to this variable generates the assembly code:
12040 \end_layout
12041
12042 \begin_layout Verse
12043
12044 \family typewriter
12045 90s00r00\InsetSpace ~
12046 \InsetSpace ~
12047 \InsetSpace ~
12048 mov\InsetSpace ~
12049 \InsetSpace ~
12050 dptr,#_test_xdata 
12051 \newline
12052 74\InsetSpace ~
12053 01\InsetSpace ~
12054 \InsetSpace ~
12055 \InsetSpace ~
12056 \InsetSpace ~
12057 \InsetSpace ~
12058 \InsetSpace ~
12059 mov\InsetSpace ~
12060 \InsetSpace ~
12061 a,#0x01 
12062 \newline
12063 F0\InsetSpace ~
12064 \InsetSpace ~
12065 \InsetSpace ~
12066 \InsetSpace ~
12067 \InsetSpace ~
12068 \InsetSpace ~
12069 \InsetSpace ~
12070 \InsetSpace ~
12071 \InsetSpace ~
12072 movx\InsetSpace ~
12073 @dptr,a 
12074 \end_layout
12075
12076 \begin_layout Subsubsection
12077 idata
12078 \begin_inset LatexCommand \index{idata (mcs51, ds390 storage class)}
12079
12080 \end_inset
12081
12082
12083 \begin_inset LatexCommand \index{\_\_idata (mcs51, ds390 storage class)}
12084
12085 \end_inset
12086
12087
12088 \end_layout
12089
12090 \begin_layout Standard
12091 Variables declared with this storage class will be allocated into the indirectly
12092  addressable portion of the internal ram of a 8051, e.g.:
12093 \end_layout
12094
12095 \begin_layout Verse
12096
12097 \family typewriter
12098 __idata unsigned char test_idata;
12099 \end_layout
12100
12101 \begin_layout Standard
12102 Writing 0x01 to this variable generates the assembly code:
12103 \end_layout
12104
12105 \begin_layout Verse
12106
12107 \family typewriter
12108 78r00\InsetSpace ~
12109 \InsetSpace ~
12110 \InsetSpace ~
12111 \InsetSpace ~
12112 \InsetSpace ~
12113 \InsetSpace ~
12114 \InsetSpace ~
12115 mov\InsetSpace ~
12116 \InsetSpace ~
12117 r0,#_test_idata
12118 \newline
12119 76\InsetSpace ~
12120 01\InsetSpace ~
12121 \InsetSpace ~
12122 \InsetSpace ~
12123 \InsetSpace ~
12124 \InsetSpace ~
12125 \InsetSpace ~
12126 \InsetSpace ~
12127 mov\InsetSpace ~
12128 \InsetSpace ~
12129 @r0,#0x01
12130 \end_layout
12131
12132 \begin_layout Standard
12133 Please note, the first 128 byte of idata physically access the same RAM
12134  as the data memory.
12135  The original 8051 had 128 byte idata memory, nowadays most devices have
12136  256 byte idata memory.
12137  The stack
12138 \begin_inset LatexCommand \index{stack}
12139
12140 \end_inset
12141
12142  is located in idata memory.
12143 \end_layout
12144
12145 \begin_layout Subsubsection
12146 pdata
12147 \begin_inset LatexCommand \index{pdata (mcs51, ds390 storage class)}
12148
12149 \end_inset
12150
12151
12152 \begin_inset LatexCommand \index{\_\_pdata (mcs51, ds390 storage class)}
12153
12154 \end_inset
12155
12156
12157 \end_layout
12158
12159 \begin_layout Standard
12160 Paged xdata access is just as straightforward as using the other addressing
12161  modes of a 8051.
12162  It is typically located at the start of xdata and has a maximum size of
12163  256 bytes.
12164  The following example writes 0x01 to the pdata variable.
12165  Please note, pdata access physically accesses xdata memory.
12166  The high byte of the address is determined by port P2 
12167 \begin_inset LatexCommand \index{P2 (mcs51 sfr)}
12168
12169 \end_inset
12170
12171 (or in case of some 8051 variants by a separate Special Function Register,
12172  see section 
12173 \begin_inset LatexCommand \ref{sub:MCS51-variants}
12174
12175 \end_inset
12176
12177 ).
12178  This is the 
12179 \series bold
12180 default
12181 \series default
12182  storage class for the Medium Memory model, e.g.:
12183 \end_layout
12184
12185 \begin_layout Verse
12186
12187 \family typewriter
12188 __pdata unsigned char test_pdata;
12189 \end_layout
12190
12191 \begin_layout Standard
12192 Writing 0x01 to this variable generates the assembly code:
12193 \end_layout
12194
12195 \begin_layout Verse
12196
12197 \family typewriter
12198 78r00\InsetSpace ~
12199 \InsetSpace ~
12200 \InsetSpace ~
12201 \InsetSpace ~
12202 \InsetSpace ~
12203 \InsetSpace ~
12204 mov r0,#_test_pdata
12205 \newline
12206 74 01\InsetSpace ~
12207 \InsetSpace ~
12208 \InsetSpace ~
12209 \InsetSpace ~
12210 \InsetSpace ~
12211 \InsetSpace ~
12212 mov a,#0x01 
12213 \newline
12214 F2\InsetSpace ~
12215 \InsetSpace ~
12216 \InsetSpace ~
12217 \InsetSpace ~
12218 \InsetSpace ~
12219 \InsetSpace ~
12220 \InsetSpace ~
12221 \InsetSpace ~
12222 \InsetSpace ~
12223 movx @r0,a
12224 \end_layout
12225
12226 \begin_layout Standard
12227 If the -
12228 \begin_inset ERT
12229 status collapsed
12230
12231 \begin_layout Standard
12232
12233
12234 \backslash
12235 /
12236 \end_layout
12237
12238 \end_inset
12239
12240 -xstack
12241 \begin_inset LatexCommand \index{-\/-xstack}
12242
12243 \end_inset
12244
12245  option is used the pdata memory area is followed by the xstack memory area
12246  and the sum of their sizes is limited to 256 bytes.
12247 \end_layout
12248
12249 \begin_layout Subsubsection
12250 code
12251 \begin_inset LatexCommand \index{code}
12252
12253 \end_inset
12254
12255
12256 \begin_inset LatexCommand \index{\_\_code}
12257
12258 \end_inset
12259
12260
12261 \end_layout
12262
12263 \begin_layout Standard
12264 'Variables' declared with this storage class will be placed in the code
12265  memory:
12266 \end_layout
12267
12268 \begin_layout Verse
12269
12270 \family typewriter
12271 __code unsigned char test_code;
12272 \end_layout
12273
12274 \begin_layout Standard
12275 Read access to this variable generates the assembly code:
12276 \end_layout
12277
12278 \begin_layout Verse
12279
12280 \family typewriter
12281 90s00r6F\InsetSpace ~
12282 \InsetSpace ~
12283 \InsetSpace ~
12284 mov dptr,#_test_code
12285 \newline
12286 E4\InsetSpace ~
12287 \InsetSpace ~
12288 \InsetSpace ~
12289 \InsetSpace ~
12290 \InsetSpace ~
12291 \InsetSpace ~
12292 \InsetSpace ~
12293 \InsetSpace ~
12294 \InsetSpace ~
12295 clr a
12296 \newline
12297 93\InsetSpace ~
12298 \InsetSpace ~
12299 \InsetSpace ~
12300 \InsetSpace ~
12301 \InsetSpace ~
12302 \InsetSpace ~
12303 \InsetSpace ~
12304 \InsetSpace ~
12305 \InsetSpace ~
12306 movc a,@a+dptr 
12307 \end_layout
12308
12309 \begin_layout Standard
12310
12311 \family typewriter
12312 char
12313 \family default
12314  indexed arrays of characters in code memory can be accessed efficiently:
12315 \end_layout
12316
12317 \begin_layout Verse
12318
12319 \family typewriter
12320 __code char test_array[] = {'c','h','e','a','p'}; 
12321 \end_layout
12322
12323 \begin_layout Standard
12324 Read access to this array using an 8-bit unsigned index generates the assembly
12325  code:
12326 \end_layout
12327
12328 \begin_layout Verse
12329
12330 \family typewriter
12331 E5*00\InsetSpace ~
12332 \InsetSpace ~
12333 \InsetSpace ~
12334 \InsetSpace ~
12335 \InsetSpace ~
12336 \InsetSpace ~
12337 mov a,_index 
12338 \end_layout
12339
12340 \begin_layout Verse
12341
12342 \family typewriter
12343 90s00r41\InsetSpace ~
12344 \InsetSpace ~
12345 \InsetSpace ~
12346 mov dptr,#_test_array
12347 \end_layout
12348
12349 \begin_layout Verse
12350
12351 \family typewriter
12352 93\InsetSpace ~
12353 \InsetSpace ~
12354 \InsetSpace ~
12355 \InsetSpace ~
12356 \InsetSpace ~
12357 \InsetSpace ~
12358 \InsetSpace ~
12359 \InsetSpace ~
12360 \InsetSpace ~
12361 movc a,@a+dptr 
12362 \end_layout
12363
12364 \begin_layout Subsubsection
12365 bit
12366 \begin_inset LatexCommand \index{bit}
12367
12368 \end_inset
12369
12370
12371 \begin_inset LatexCommand \index{\_\_bit}
12372
12373 \end_inset
12374
12375
12376 \end_layout
12377
12378 \begin_layout Standard
12379 This is a data-type and a storage class specifier.
12380  When a variable is declared as a bit, it is allocated into the bit addressable
12381  memory of 8051, e.g.:
12382 \end_layout
12383
12384 \begin_layout Verse
12385
12386 \family typewriter
12387 __bit test_bit;
12388 \end_layout
12389
12390 \begin_layout Standard
12391 Writing 1 to this variable generates the assembly code:
12392 \end_layout
12393
12394 \begin_layout Verse
12395
12396 \family typewriter
12397 D2*00\InsetSpace ~
12398 \InsetSpace ~
12399 \InsetSpace ~
12400 \InsetSpace ~
12401 \InsetSpace ~
12402 \InsetSpace ~
12403 \InsetSpace ~
12404 setb\InsetSpace ~
12405 _test_bit
12406 \end_layout
12407
12408 \begin_layout Standard
12409 The bit addressable memory consists of 128 bits which are located from 0x20
12410  to 0x2f in data memory.
12411  
12412 \newline
12413 Apart from this 8051 specific storage class most architectures support
12414  ANSI-C bitfields
12415 \begin_inset LatexCommand \index{bitfields}
12416
12417 \end_inset
12418
12419
12420 \begin_inset Foot
12421 status open
12422
12423 \begin_layout Standard
12424 Not really meant as examples, but nevertheless showing what bitfields are
12425  about: device/include/mc68hc908qy.h and support/regression/tests/bitfields.c
12426 \end_layout
12427
12428 \end_inset
12429
12430 .
12431  In accordance with ISO/IEC 9899 bits and bitfields without an explicit
12432  signed modifier are implemented as unsigned.
12433 \end_layout
12434
12435 \begin_layout Subsubsection
12436 sfr
12437 \begin_inset LatexCommand \index{sfr}
12438
12439 \end_inset
12440
12441
12442 \begin_inset LatexCommand \index{\_\_sfr}
12443
12444 \end_inset
12445
12446  / sfr16
12447 \begin_inset LatexCommand \index{sfr16}
12448
12449 \end_inset
12450
12451
12452 \begin_inset LatexCommand \index{\_\_sfr16}
12453
12454 \end_inset
12455
12456  / sfr32
12457 \begin_inset LatexCommand \index{sfr32}
12458
12459 \end_inset
12460
12461
12462 \begin_inset LatexCommand \index{\_\_sfr32}
12463
12464 \end_inset
12465
12466  / sbit
12467 \begin_inset LatexCommand \index{\_\_sbit}
12468
12469 \end_inset
12470
12471
12472 \begin_inset LatexCommand \index{sbit}
12473
12474 \end_inset
12475
12476
12477 \end_layout
12478
12479 \begin_layout Standard
12480 Like the bit keyword, 
12481 \emph on
12482 sfr / sfr16 / sfr32 / sbit 
12483 \emph default
12484 signify both a data-type and storage class, they are used to describe the
12485  
12486 \emph on
12487 s
12488 \emph default
12489 pecial 
12490 \emph on
12491 f
12492 \emph default
12493 unction 
12494 \emph on
12495 r
12496 \emph default
12497 egisters and 
12498 \emph on
12499 s
12500 \emph default
12501 pecial 
12502 \emph on
12503 bit
12504 \emph default
12505  variables of a 8051, eg:
12506 \end_layout
12507
12508 \begin_layout Verse
12509
12510 \family typewriter
12511 __sfr __at
12512 \begin_inset LatexCommand \index{at}
12513
12514 \end_inset
12515
12516
12517 \begin_inset LatexCommand \index{\_\_at}
12518
12519 \end_inset
12520
12521  (0x80) P0;\InsetSpace ~
12522  /* special function register P0 at location 0x80 */
12523 \newline
12524
12525 \newline
12526 /* 16 bit
12527  special function register combination for timer 0
12528 \newline
12529 \InsetSpace ~
12530 \InsetSpace ~
12531  with the high byte at
12532  location 0x8C and the low byte at location 0x8A */
12533 \newline
12534 __sfr16 __at (0x8C8A)
12535  TMR0;
12536 \newline
12537
12538 \newline
12539 __sbit __at
12540 \begin_inset LatexCommand \index{at}
12541
12542 \end_inset
12543
12544
12545 \begin_inset LatexCommand \index{\_\_at}
12546
12547 \end_inset
12548
12549  (0xd7) CY;\InsetSpace ~
12550  /* CY (Carry Flag
12551 \begin_inset LatexCommand \index{Flags}
12552
12553 \end_inset
12554
12555
12556 \begin_inset LatexCommand \index{Carry flag}
12557
12558 \end_inset
12559
12560 ) */
12561 \end_layout
12562
12563 \begin_layout Standard
12564 Special function registers which are located on an address dividable by
12565  8 are bit-addressable, an
12566 \emph on
12567  sbit
12568 \emph default
12569  addresses a specific bit within these sfr.
12570 \newline
12571 16 Bit and 32 bit special function
12572  register combinations which require a certain access order are better not
12573  declared using 
12574 \emph on
12575 sfr16
12576 \emph default
12577  or 
12578 \emph on
12579 sfr32.
12580
12581 \emph default
12582  Allthough SDCC usually accesses them Least Significant Byte (LSB) first,
12583  this is not guaranteed.
12584 \newline
12585
12586 \end_layout
12587
12588 \begin_layout Standard
12589 Please note, if you use a header file which was written for another compiler
12590  then the sfr / sfr16 / sfr32 / sbit Storage Class extensions will most
12591  likely be 
12592 \emph on
12593 not 
12594 \emph default
12595 compatible.
12596  Specifically the syntax 
12597 \family typewriter
12598 \InsetSpace ~
12599 sfr P0 = 0x80;\InsetSpace ~
12600
12601 \family default
12602  is compiled 
12603 \emph on
12604 without warning
12605 \emph default
12606  by SDCC to an assignment of 0x80 to a variable called P0 
12607 \family typewriter
12608
12609 \begin_inset Marginal
12610 status collapsed
12611
12612 \begin_layout Standard
12613
12614 \series bold
12615 \InsetSpace ~
12616 !
12617 \end_layout
12618
12619 \end_inset
12620
12621 .
12622  
12623 \family default
12624 Nevertheless it is possible to write header files
12625 \begin_inset LatexCommand \index{Header files}
12626
12627 \end_inset
12628
12629
12630 \begin_inset LatexCommand \index{Include files}
12631
12632 \end_inset
12633
12634  which can be shared among different compilers (see section 
12635 \begin_inset LatexCommand \ref{sec:Porting-code-to-other-compilers}
12636
12637 \end_inset
12638
12639 ).
12640  
12641 \end_layout
12642
12643 \begin_layout Subsubsection
12644 Pointers
12645 \begin_inset LatexCommand \index{Pointer}
12646
12647 \end_inset
12648
12649  to MCS51/DS390 specific memory spaces
12650 \end_layout
12651
12652 \begin_layout Standard
12653 SDCC allows (via language extensions) pointers to explicitly point to any
12654  of the memory spaces
12655 \begin_inset LatexCommand \index{Memory model}
12656
12657 \end_inset
12658
12659  of the 8051.
12660  In addition to the explicit pointers, the compiler uses (by default) generic
12661  pointers which can be used to point to any of the memory spaces.
12662 \newline
12663
12664 \newline
12665 Pointer
12666  declaration examples:
12667 \end_layout
12668
12669 \begin_layout Verse
12670
12671 \family typewriter
12672 /* pointer physically in internal ram pointing to object in external ram
12673  */ 
12674 \newline
12675 __xdata unsigned char * __data p;
12676 \newline
12677
12678 \newline
12679 /* pointer physically in external ram
12680  pointing to object in internal ram */ 
12681 \newline
12682 __data unsigned char * __xdata p;
12683 \newline
12684
12685 \newline
12686 /*
12687  pointer physically in code rom pointing to data in xdata space */ 
12688 \newline
12689 __xdata
12690  unsigned char * __code p;
12691 \newline
12692
12693 \newline
12694 /* pointer physically in code space pointing to
12695  data in code space */ 
12696 \newline
12697 __code unsigned char * __code p;
12698 \newline
12699
12700 \newline
12701 /* generic pointer
12702  physically located in xdata space */
12703 \newline
12704 unsigned char * __xdata p;
12705 \newline
12706
12707 \newline
12708 /* generic
12709  pointer physically located in default memory space */
12710 \newline
12711 unsigned char * p;
12712 \newline
12713
12714 \newline
12715 /*
12716  the following is a function pointer
12717 \begin_inset LatexCommand \index{function pointer}
12718
12719 \end_inset
12720
12721  physically located in data space */
12722 \newline
12723 char (* __data fp)(void);
12724 \end_layout
12725
12726 \begin_layout Standard
12727 Well you get the idea.
12728  
12729 \newline
12730
12731 \newline
12732 All unqualified pointers are treated as 3-byte (4-byte for the ds390) 
12733 \emph on
12734 generic
12735 \emph default
12736  pointers.
12737  
12738 \size small
12739
12740 \newline
12741
12742 \newline
12743
12744 \size default
12745 The highest order byte of the 
12746 \emph on
12747 generic
12748 \emph default
12749  pointers contains the data space information.
12750  Assembler support routines are called whenever data is stored or retrieved
12751  using 
12752 \emph on
12753 generic
12754 \emph default
12755  pointers.
12756  These are useful for developing reusable library
12757 \begin_inset LatexCommand \index{Libraries}
12758
12759 \end_inset
12760
12761  routines.
12762  Explicitly specifying the pointer
12763 \begin_inset LatexCommand \index{pointer}
12764
12765 \end_inset
12766
12767  type will generate the most efficient code.
12768 \end_layout
12769
12770 \begin_layout Subsubsection
12771 Notes on MCS51 memory
12772 \begin_inset LatexCommand \index{MCS51 memory}
12773
12774 \end_inset
12775
12776  layout
12777 \end_layout
12778
12779 \begin_layout Standard
12780 The 8051 family of microcontrollers have a minimum of 128 bytes of internal
12781  RAM memory which is structured as follows:
12782 \newline
12783
12784 \newline
12785 - Bytes 00-1F - 32 bytes to hold
12786  up to 4 banks of the registers R0 to R7, 
12787 \newline
12788 - Bytes 20-2F - 16 bytes to hold
12789  128 bit
12790 \begin_inset LatexCommand \index{bit}
12791
12792 \end_inset
12793
12794  variables and, 
12795 \newline
12796 - Bytes 30-7F - 80 bytes for general purpose use.
12797 \newline
12798
12799 \end_layout
12800
12801 \begin_layout Standard
12802 Additionally some members of the MCS51 family may have up to 128 bytes of
12803  additional, indirectly addressable, internal RAM memory (
12804 \emph on
12805 idata
12806 \emph default
12807
12808 \begin_inset LatexCommand \index{idata (mcs51, ds390 storage class)}
12809
12810 \end_inset
12811
12812
12813 \begin_inset LatexCommand \index{\_\_idata (mcs51, ds390 storage class)}
12814
12815 \end_inset
12816
12817 ).
12818  Furthermore, some chips may have some built in external memory (
12819 \emph on
12820 xdata
12821 \emph default
12822
12823 \begin_inset LatexCommand \index{xdata (mcs51, ds390 storage class)}
12824
12825 \end_inset
12826
12827
12828 \begin_inset LatexCommand \index{\_\_xdata (mcs51, ds390 storage class)}
12829
12830 \end_inset
12831
12832 ) which should not be confused with the internal, directly addressable RAM
12833  memory (
12834 \emph on
12835 data
12836 \emph default
12837
12838 \begin_inset LatexCommand \index{data (mcs51, ds390 storage class)}
12839
12840 \end_inset
12841
12842
12843 \begin_inset LatexCommand \index{\_\_data (mcs51, ds390 storage class)}
12844
12845 \end_inset
12846
12847 ).
12848  Sometimes this built in 
12849 \emph on
12850 xdata
12851 \emph default
12852  memory has to be activated before using it (you can probably find this
12853  information on the datasheet of the microcontroller your are using, see
12854  also section 
12855 \begin_inset LatexCommand \ref{sub:Startup-Code}
12856
12857 \end_inset
12858
12859 \InsetSpace ~
12860 Startup-Code).
12861 \end_layout
12862
12863 \begin_layout Standard
12864 Normally SDCC will only use the first bank
12865 \begin_inset LatexCommand \index{register bank (mcs51, ds390)}
12866
12867 \end_inset
12868
12869  of registers (register bank 0), but it is possible to specify that other
12870  banks of registers (keyword 
12871 \emph on
12872 using
12873 \emph default
12874  
12875 \emph on
12876
12877 \begin_inset LatexCommand \index{using (mcs51, ds390 register bank)}
12878
12879 \end_inset
12880
12881
12882 \begin_inset LatexCommand \index{\_\_using (mcs51, ds390 register bank)}
12883
12884 \end_inset
12885
12886
12887 \emph default
12888 ) should be used for example in interrupt
12889 \begin_inset LatexCommand \index{interrupt}
12890
12891 \end_inset
12892
12893
12894 \begin_inset LatexCommand \index{\_\_interrupt}
12895
12896 \end_inset
12897
12898  routines.
12899  By default, the compiler will place the stack after the last byte of allocated
12900  memory for variables.
12901  For example, if the first 2 banks of registers are used, and only four
12902  bytes are used for 
12903 \emph on
12904 data
12905 \emph default
12906  variables, it will position the base of the internal stack at address 20
12907  (0x14).
12908  This implies that as the stack
12909 \begin_inset LatexCommand \index{stack}
12910
12911 \end_inset
12912
12913  grows, it will use up the remaining register banks, and the 16 bytes used
12914  by the 128 bit variables, and 80 bytes for general purpose use.
12915  If any bit variables are used, the data variables will be placed in unused
12916  register banks and after the byte holding the last bit variable.
12917  For example, if register banks 0 and 1 are used, and there are 9 bit variables
12918  (two bytes used), 
12919 \emph on
12920 data
12921 \emph default
12922  variables will be placed starting from address 0x10 to 0x20 and continue
12923  at address 0x22.
12924  You can also use -
12925 \begin_inset ERT
12926 status collapsed
12927
12928 \begin_layout Standard
12929
12930
12931 \backslash
12932 /
12933 \end_layout
12934
12935 \end_inset
12936
12937 -data-loc
12938 \begin_inset LatexCommand \index{-\/-data-loc <Value>}
12939
12940 \end_inset
12941
12942  to specify the start address of the 
12943 \emph on
12944 data
12945 \emph default
12946  and -
12947 \begin_inset ERT
12948 status collapsed
12949
12950 \begin_layout Standard
12951
12952
12953 \backslash
12954 /
12955 \end_layout
12956
12957 \end_inset
12958
12959 -iram-size
12960 \begin_inset LatexCommand \index{-\/-iram-size <Value>}
12961
12962 \end_inset
12963
12964  to specify the size of the total internal RAM (
12965 \emph on
12966 data
12967 \emph default
12968 +
12969 \emph on
12970 idata
12971 \emph default
12972 ).
12973  
12974 \newline
12975
12976 \end_layout
12977
12978 \begin_layout Standard
12979 By default the 8051 linker will place the stack after the last byte of (i)data
12980  variables.
12981  Option -
12982 \begin_inset ERT
12983 status collapsed
12984
12985 \begin_layout Standard
12986
12987
12988 \backslash
12989 /
12990 \end_layout
12991
12992 \end_inset
12993
12994 -stack-loc
12995 \begin_inset LatexCommand \index{-\/-stack-loc <Value>}
12996
12997 \end_inset
12998
12999  allows you to specify the start of the stack, i.e.
13000  you could start it after any data in the general purpose area.
13001  If your microcontroller has additional indirectly addressable internal
13002  RAM (
13003 \emph on
13004 idata
13005 \emph default
13006 ) you can place the stack on it.
13007  You may also need to use -
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 -xdata-loc
13021 \begin_inset LatexCommand \index{-\/-xdata-loc<Value>}
13022
13023 \end_inset
13024
13025  to set the start address of the external RAM (
13026 \emph on
13027 xdata
13028 \emph default
13029 ) and -
13030 \begin_inset ERT
13031 status collapsed
13032
13033 \begin_layout Standard
13034
13035
13036 \backslash
13037 /
13038 \end_layout
13039
13040 \end_inset
13041
13042 -xram-size
13043 \begin_inset LatexCommand \index{-\/-xram-size <Value>}
13044
13045 \end_inset
13046
13047  to specify its size.
13048  Same goes for the code memory, using -
13049 \begin_inset ERT
13050 status collapsed
13051
13052 \begin_layout Standard
13053
13054
13055 \backslash
13056 /
13057 \end_layout
13058
13059 \end_inset
13060
13061 -code-loc
13062 \begin_inset LatexCommand \index{-\/-code-loc <Value>}
13063
13064 \end_inset
13065
13066  and -
13067 \begin_inset ERT
13068 status collapsed
13069
13070 \begin_layout Standard
13071
13072
13073 \backslash
13074 /
13075 \end_layout
13076
13077 \end_inset
13078
13079 -code-size
13080 \begin_inset LatexCommand \index{-\/-code-size <Value>}
13081
13082 \end_inset
13083
13084 .
13085  If in doubt, don't specify any options and see if the resulting memory
13086  layout is appropriate, then you can adjust it.
13087 \end_layout
13088
13089 \begin_layout Standard
13090 The linker generates two files with memory allocation information.
13091  The first, with extension .map
13092 \begin_inset LatexCommand \index{<file>.map}
13093
13094 \end_inset
13095
13096  shows all the variables and segments.
13097  The second with extension .mem
13098 \begin_inset LatexCommand \index{<file>.mem}
13099
13100 \end_inset
13101
13102  shows the final memory layout.
13103  The linker will complain either if memory segments overlap, there is not
13104  enough memory, or there is not enough space for stack.
13105  If you get any linking warnings and/or errors related to stack or segments
13106  allocation, take a look at either the .map or .mem files to find out what
13107  the problem is.
13108  The .mem file may even suggest a solution to the problem.
13109 \begin_inset VSpace bigskip
13110 \end_inset
13111
13112
13113 \end_layout
13114
13115 \begin_layout Subsection
13116 Z80/Z180 Storage Class
13117 \begin_inset LatexCommand \index{Z80!Storage class}
13118
13119 \end_inset
13120
13121  Language Extensions
13122 \end_layout
13123
13124 \begin_layout Subsubsection
13125 sfr
13126 \begin_inset LatexCommand \index{sfr}
13127
13128 \end_inset
13129
13130
13131 \begin_inset LatexCommand \index{\_\_sfr}
13132
13133 \end_inset
13134
13135  (in/out to 8-bit addresses)
13136 \end_layout
13137
13138 \begin_layout Standard
13139 The Z80
13140 \begin_inset LatexCommand \index{Z80}
13141
13142 \end_inset
13143
13144  family has separate address spaces for memory and 
13145 \emph on
13146 i
13147 \emph default
13148 nput/
13149 \emph on
13150 o
13151 \emph default
13152 utput memory.
13153  I/O memory
13154 \begin_inset LatexCommand \index{I/O memory (Z80, Z180)}
13155
13156 \end_inset
13157
13158
13159 \begin_inset LatexCommand \index{Z80!I/O memory}
13160
13161 \end_inset
13162
13163
13164 \begin_inset LatexCommand \index{Z180!I/O memory}
13165
13166 \end_inset
13167
13168  is accessed with special instructions, e.g.:
13169 \end_layout
13170
13171 \begin_layout Verse
13172
13173 \family typewriter
13174 sfr at 0x78 IoPort;\InsetSpace ~
13175 \InsetSpace ~
13176 /* define a var in I/O space at 78h called IoPort */
13177  
13178 \end_layout
13179
13180 \begin_layout Standard
13181 Writing 0x01 to this variable generates the assembly code:
13182 \end_layout
13183
13184 \begin_layout Verse
13185
13186 \family typewriter
13187 3E 01\InsetSpace ~
13188 \InsetSpace ~
13189 \InsetSpace ~
13190 \InsetSpace ~
13191 \InsetSpace ~
13192 \InsetSpace ~
13193 ld a,#0x01
13194 \newline
13195 D3 78\InsetSpace ~
13196 \InsetSpace ~
13197 \InsetSpace ~
13198 \InsetSpace ~
13199 \InsetSpace ~
13200 \InsetSpace ~
13201 out (_IoPort),a 
13202 \end_layout
13203
13204 \begin_layout Subsubsection
13205 banked sfr
13206 \begin_inset LatexCommand \index{sfr}
13207
13208 \end_inset
13209
13210
13211 \begin_inset LatexCommand \index{\_\_sfr}
13212
13213 \end_inset
13214
13215  (in/out to 16-bit addresses)
13216 \end_layout
13217
13218 \begin_layout Standard
13219 The keyword 
13220 \emph on
13221 banked
13222 \emph default
13223  is used to support 16 bit addresses in I/O memory e.g.:
13224 \end_layout
13225
13226 \begin_layout Verse
13227
13228 \family typewriter
13229 sfr banked at
13230 \begin_inset LatexCommand \index{at}
13231
13232 \end_inset
13233
13234
13235 \begin_inset LatexCommand \index{\_\_at}
13236
13237 \end_inset
13238
13239  0x123 IoPort; 
13240 \end_layout
13241
13242 \begin_layout Standard
13243 Writing 0x01 to this variable generates the assembly code:
13244 \end_layout
13245
13246 \begin_layout Verse
13247
13248 \family typewriter
13249 01 23 01\InsetSpace ~
13250 \InsetSpace ~
13251 \InsetSpace ~
13252 ld bc,#_IoPort
13253 \newline
13254 3E 01\InsetSpace ~
13255 \InsetSpace ~
13256 \InsetSpace ~
13257 \InsetSpace ~
13258 \InsetSpace ~
13259 \InsetSpace ~
13260 ld a,#0x01 
13261 \newline
13262 ED 79\InsetSpace ~
13263 \InsetSpace ~
13264 \InsetSpace ~
13265 \InsetSpace ~
13266 \InsetSpace ~
13267 \InsetSpace ~
13268 out (c),a 
13269 \end_layout
13270
13271 \begin_layout Subsubsection
13272 sfr
13273 \begin_inset LatexCommand \index{sfr}
13274
13275 \end_inset
13276
13277
13278 \begin_inset LatexCommand \index{\_\_sfr}
13279
13280 \end_inset
13281
13282  (in0/out0 to 8 bit addresses on Z180
13283 \begin_inset LatexCommand \index{Z180}
13284
13285 \end_inset
13286
13287 /HD64180
13288 \begin_inset LatexCommand \index{HD64180 (see Z180)}
13289
13290 \end_inset
13291
13292 )
13293 \end_layout
13294
13295 \begin_layout Standard
13296 The compiler option -
13297 \begin_inset ERT
13298 status collapsed
13299
13300 \begin_layout Standard
13301
13302
13303 \backslash
13304 /
13305 \end_layout
13306
13307 \end_inset
13308
13309 -portmode
13310 \begin_inset LatexCommand \index{Z180!Options!-\/-portmode}
13311
13312 \end_inset
13313
13314 =180 (80) and a compiler #pragma\InsetSpace ~
13315 portmode
13316 \begin_inset LatexCommand \index{Z180!Pragmas!\#pragma portmode}
13317
13318 \end_inset
13319
13320  z180 (z80) is used to turn on (off) the Z180/HD64180 port addressing instructio
13321 ns 
13322 \family typewriter
13323 in0/out0
13324 \family default
13325  instead of 
13326 \family typewriter
13327 in/out
13328 \family default
13329 .
13330  If you include the file z180.h this will be set automatically.
13331 \begin_inset VSpace bigskip
13332 \end_inset
13333
13334
13335 \end_layout
13336
13337 \begin_layout Subsection
13338 HC08 Storage Class
13339 \begin_inset LatexCommand \index{HC08!Storage class}
13340
13341 \end_inset
13342
13343  Language Extensions
13344 \end_layout
13345
13346 \begin_layout Subsubsection
13347 data
13348 \begin_inset LatexCommand \index{data (hc08 storage class)}
13349
13350 \end_inset
13351
13352
13353 \begin_inset LatexCommand \index{\_\_data (hc08 storage class)}
13354
13355 \end_inset
13356
13357  
13358 \end_layout
13359
13360 \begin_layout Standard
13361 The data storage class declares a variable that resides in the first 256
13362  bytes of memory (the direct page).
13363  The HC08
13364 \begin_inset LatexCommand \index{HC08}
13365
13366 \end_inset
13367
13368  is most efficient at accessing variables (especially pointers) stored here.
13369 \end_layout
13370
13371 \begin_layout Subsubsection
13372 xdata
13373 \begin_inset LatexCommand \index{xdata (hc08 storage class)}
13374
13375 \end_inset
13376
13377
13378 \begin_inset LatexCommand \index{\_\_xdata (hc08 storage class)}
13379
13380 \end_inset
13381
13382  
13383 \end_layout
13384
13385 \begin_layout Standard
13386 The xdata storage class declares a variable that can reside anywhere in
13387  memory.
13388  This is the default if no storage class is specified.
13389  
13390 \begin_inset VSpace bigskip
13391 \end_inset
13392
13393
13394 \end_layout
13395
13396 \begin_layout Section
13397 Other SDCC language extensions
13398 \begin_inset LatexCommand \index{Other SDCC language extensions}
13399
13400 \end_inset
13401
13402
13403 \end_layout
13404
13405 \begin_layout Subsection
13406 Binary constants
13407 \end_layout
13408
13409 \begin_layout Standard
13410 SDCC supports the use of binary constants, such as 0b01100010.
13411  This feature is only enabled when the compiler is invoked using --std-sdccxx.
13412 \end_layout
13413
13414 \begin_layout Standard
13415 \begin_inset VSpace bigskip
13416 \end_inset
13417
13418
13419 \end_layout
13420
13421 \begin_layout Section
13422 Absolute Addressing
13423 \begin_inset LatexCommand \index{Absolute addressing}
13424
13425 \end_inset
13426
13427
13428 \end_layout
13429
13430 \begin_layout Standard
13431 Data items can be assigned an absolute address with the 
13432 \emph on
13433 at
13434 \begin_inset LatexCommand \index{at}
13435
13436 \end_inset
13437
13438
13439 \begin_inset LatexCommand \index{\_\_at}
13440
13441 \end_inset
13442
13443  <address>
13444 \emph default
13445  keyword, in addition to a storage class, e.g.:
13446 \end_layout
13447
13448 \begin_layout Verse
13449
13450 \family typewriter
13451 xdata
13452 \begin_inset LatexCommand \index{xdata (mcs51, ds390 storage class)}
13453
13454 \end_inset
13455
13456
13457 \begin_inset LatexCommand \index{\_\_xdata (mcs51, ds390 storage class)}
13458
13459 \end_inset
13460
13461  at
13462 \begin_inset LatexCommand \index{at}
13463
13464 \end_inset
13465
13466
13467 \begin_inset LatexCommand \index{\_\_at}
13468
13469 \end_inset
13470
13471  0x7ffe unsigned int chksum;
13472 \end_layout
13473
13474 \begin_layout Standard
13475 or, better conforming to ISO/IEC 9899 C:
13476 \end_layout
13477
13478 \begin_layout Verse
13479
13480 \family typewriter
13481 __xdata __at (0x7ffe) unsigned int chksum;
13482 \end_layout
13483
13484 \begin_layout Standard
13485 In the above example the variable chksum will be located at 0x7ffe and 0x7fff
13486  of the external ram.
13487  The compiler does 
13488 \emph on
13489 not
13490 \emph default
13491  reserve any space for variables declared in this way
13492 \begin_inset Marginal
13493 status collapsed
13494
13495 \begin_layout Standard
13496
13497 \series bold
13498 \InsetSpace ~
13499 !
13500 \end_layout
13501
13502 \end_inset
13503
13504  (they are implemented with an equate in the assembler).
13505  Thus it is left to the programmer to make sure there are no overlaps with
13506  other variables that are declared without the absolute address.
13507  The assembler listing file (.lst
13508 \begin_inset LatexCommand \index{<file>.lst}
13509
13510 \end_inset
13511
13512 ) and the linker output files (.rst
13513 \begin_inset LatexCommand \index{<file>.rst}
13514
13515 \end_inset
13516
13517 ) and (.map
13518 \begin_inset LatexCommand \index{<file>.map}
13519
13520 \end_inset
13521
13522 ) are good places to look for such overlaps.
13523 \end_layout
13524
13525 \begin_layout Standard
13526 If however you provide an initializer
13527 \begin_inset LatexCommand \index{Variable initialization}
13528
13529 \end_inset
13530
13531  actual memory allocation will take place and overlaps will be detected
13532  by the linker.
13533  E.g.:
13534 \end_layout
13535
13536 \begin_layout Verse
13537
13538 \family typewriter
13539 __code __at (0x7ff0) char Id[5] = 
13540 \begin_inset Quotes sld
13541 \end_inset
13542
13543 SDCC
13544 \begin_inset Quotes srd
13545 \end_inset
13546
13547 ;
13548 \end_layout
13549
13550 \begin_layout Standard
13551 In the above example the variable Id will be located from 0x7ff0 to 0x7ff4
13552  in code memory.
13553 \end_layout
13554
13555 \begin_layout Standard
13556 In case of memory mapped I/O devices the keyword 
13557 \emph on
13558 volatile
13559 \emph default
13560  has to be used to tell the compiler that accesses might not be removed:
13561 \end_layout
13562
13563 \begin_layout Verse
13564
13565 \family typewriter
13566 volatile
13567 \begin_inset LatexCommand \index{volatile}
13568
13569 \end_inset
13570
13571  __xdata
13572 \begin_inset LatexCommand \index{xdata (mcs51, ds390 storage class)}
13573
13574 \end_inset
13575
13576  __at
13577 \begin_inset LatexCommand \index{at}
13578
13579 \end_inset
13580
13581  (0x8000) unsigned char PORTA_8255;
13582 \end_layout
13583
13584 \begin_layout Standard
13585 For some architectures (mcs51) array accesses are more efficient if an (xdata/fa
13586 r) array
13587 \family typewriter
13588 \size footnotesize
13589
13590 \begin_inset LatexCommand \index{Aligned array}
13591
13592 \end_inset
13593
13594
13595 \family default
13596 \size default
13597  starts at a block (256 byte) boundary
13598 \begin_inset LatexCommand \index{block boundary}
13599
13600 \end_inset
13601
13602  (section 
13603 \begin_inset LatexCommand \ref{sub:A-Step-by Assembler Introduction}
13604
13605 \end_inset
13606
13607  has an example).
13608 \newline
13609 Absolute addresses can be specified for variables in all
13610  storage classes, e.g.:
13611 \end_layout
13612
13613 \begin_layout Verse
13614
13615 \family typewriter
13616 __bit
13617 \begin_inset LatexCommand \index{bit}
13618
13619 \end_inset
13620
13621  __at
13622 \begin_inset LatexCommand \index{at}
13623
13624 \end_inset
13625
13626  (0x02) bvar;
13627 \end_layout
13628
13629 \begin_layout Standard
13630 The above example will allocate the variable at offset 0x02 in the bit-addressab
13631 le space.
13632  There is no real advantage to assigning absolute addresses to variables
13633  in this manner, unless you want strict control over all the variables allocated.
13634  One possible use would be to write hardware portable code.
13635  For example, if you have a routine that uses one or more of the microcontroller
13636  I/O pins, and such pins are different for two different hardwares, you
13637  can declare the I/O pins in your routine using:
13638 \end_layout
13639
13640 \begin_layout Verse
13641
13642 \family typewriter
13643 extern volatile
13644 \begin_inset LatexCommand \index{volatile}
13645
13646 \end_inset
13647
13648  __bit MOSI;\InsetSpace ~
13649 \InsetSpace ~
13650 \InsetSpace ~
13651 \InsetSpace ~
13652 /* master out, slave in */
13653 \newline
13654 extern volatile __bit MISO;\InsetSpace ~
13655 \InsetSpace ~
13656 \InsetSpace ~
13657 \InsetSpace ~
13658 /* master
13659  in, slave out */
13660 \newline
13661 extern volatile __bit MCLK;\InsetSpace ~
13662 \InsetSpace ~
13663 \InsetSpace ~
13664 \InsetSpace ~
13665 /* master clock */
13666 \newline
13667
13668 \newline
13669 /* Input and
13670  Output of a byte on a 3-wire serial bus.
13671 \newline
13672 \InsetSpace ~
13673 \InsetSpace ~
13674 \InsetSpace ~
13675 If needed adapt polarity of clock,
13676  polarity of data and bit order
13677 \newline
13678 \InsetSpace ~
13679 */
13680 \newline
13681 unsigned char spi_io(unsigned char out_byte)
13682  
13683 \newline
13684
13685 \newline
13686 \InsetSpace ~
13687 \InsetSpace ~
13688 \InsetSpace ~
13689 \InsetSpace ~
13690 unsigned char i=8;
13691 \newline
13692 \InsetSpace ~
13693 \InsetSpace ~
13694 \InsetSpace ~
13695 \InsetSpace ~
13696 do { 
13697 \newline
13698 \InsetSpace ~
13699 \InsetSpace ~
13700 \InsetSpace ~
13701 \InsetSpace ~
13702 \InsetSpace ~
13703 \InsetSpace ~
13704 \InsetSpace ~
13705 \InsetSpace ~
13706 MOSI = out_byte & 0x80; 
13707 \newline
13708 \InsetSpace ~
13709 \InsetSpace ~
13710 \InsetSpace ~
13711 \InsetSpace ~
13712 \InsetSpace ~
13713 \InsetSpace ~
13714 \InsetSpace ~
13715 \InsetSpace ~
13716 out_byte <<= 1;
13717 \newline
13718 \InsetSpace ~
13719 \InsetSpace ~
13720 \InsetSpace ~
13721 \InsetSpace ~
13722 \InsetSpace ~
13723 \InsetSpace ~
13724 \InsetSpace ~
13725 \InsetSpace ~
13726 MCLK =
13727  1; 
13728 \newline
13729 \InsetSpace ~
13730 \InsetSpace ~
13731 \InsetSpace ~
13732 \InsetSpace ~
13733 \InsetSpace ~
13734 \InsetSpace ~
13735 \InsetSpace ~
13736 \InsetSpace ~
13737 /* _asm nop _endasm; */\InsetSpace ~
13738 \InsetSpace ~
13739 \InsetSpace ~
13740 \InsetSpace ~
13741 \InsetSpace ~
13742 \InsetSpace ~
13743 \InsetSpace ~
13744 \InsetSpace ~
13745 /* for slow peripherals */
13746 \newline
13747 \InsetSpace ~
13748 \InsetSpace ~
13749 \InsetSpace ~
13750 \InsetSpace ~
13751 \InsetSpace ~
13752 \InsetSpace ~
13753 \InsetSpace ~
13754 \InsetSpace ~
13755 if(MISO) 
13756 \newline
13757 \InsetSpace ~
13758 \InsetSpace ~
13759 \InsetSpace ~
13760 \InsetSpace ~
13761 \InsetSpace ~
13762 \InsetSpace ~
13763 \InsetSpace ~
13764 \InsetSpace ~
13765 \InsetSpace ~
13766 \InsetSpace ~
13767 \InsetSpace ~
13768 \InsetSpace ~
13769 out_byte +=
13770  1; 
13771 \newline
13772 \InsetSpace ~
13773 \InsetSpace ~
13774 \InsetSpace ~
13775 \InsetSpace ~
13776 \InsetSpace ~
13777 \InsetSpace ~
13778 \InsetSpace ~
13779 \InsetSpace ~
13780 MCLK = 0; 
13781 \newline
13782 \InsetSpace ~
13783 \InsetSpace ~
13784 \InsetSpace ~
13785 \InsetSpace ~
13786 } while(--i);
13787 \newline
13788 \InsetSpace ~
13789 \InsetSpace ~
13790 \InsetSpace ~
13791 \InsetSpace ~
13792 return out_byte; 
13793 \newline
13794 }
13795 \end_layout
13796
13797 \begin_layout Standard
13798 Then, someplace in the code for the first hardware you would use
13799 \end_layout
13800
13801 \begin_layout Verse
13802
13803 \family typewriter
13804 __bit __at
13805 \begin_inset LatexCommand \index{at}
13806
13807 \end_inset
13808
13809
13810 \begin_inset LatexCommand \index{\_\_at}
13811
13812 \end_inset
13813
13814  (0x80) MOSI;\InsetSpace ~
13815 \InsetSpace ~
13816 \InsetSpace ~
13817 \InsetSpace ~
13818 /* I/O port 0, bit 0 */
13819 \newline
13820 __bit __at (0x81) MISO;\InsetSpace ~
13821 \InsetSpace ~
13822 \InsetSpace ~
13823 \InsetSpace ~
13824 /* I/O port 0,
13825  bit 1 */
13826 \newline
13827 __bit __at (0x82) MCLK;\InsetSpace ~
13828 \InsetSpace ~
13829 \InsetSpace ~
13830 \InsetSpace ~
13831 /* I/O port 0, bit 2 */
13832 \end_layout
13833
13834 \begin_layout Standard
13835 Similarly, for the second hardware you would use
13836 \end_layout
13837
13838 \begin_layout Verse
13839
13840 \family typewriter
13841 __bit __at (0x83) MOSI;\InsetSpace ~
13842 \InsetSpace ~
13843 \InsetSpace ~
13844 \InsetSpace ~
13845 /* I/O port 0, bit 3 */
13846 \newline
13847 __bit __at (0x91) MISO;\InsetSpace ~
13848 \InsetSpace ~
13849 \InsetSpace ~
13850 \InsetSpace ~
13851 /*
13852  I/O port 1, bit 1 */
13853 \newline
13854 __bit
13855 \begin_inset LatexCommand \index{bit}
13856
13857 \end_inset
13858
13859  __at (0x92) MCLK;\InsetSpace ~
13860 \InsetSpace ~
13861 \InsetSpace ~
13862 \InsetSpace ~
13863 /* I/O port 1, bit 2 */
13864 \end_layout
13865
13866 \begin_layout Standard
13867 and you can use the same hardware dependent routine without changes, as
13868  for example in a library.
13869  This is somehow similar to sbit, but only one absolute address has to be
13870  specified in the whole project.
13871 \begin_inset VSpace bigskip
13872 \end_inset
13873
13874
13875 \end_layout
13876
13877 \begin_layout Section
13878 Parameters
13879 \begin_inset LatexCommand \index{Parameters}
13880
13881 \end_inset
13882
13883
13884 \begin_inset LatexCommand \index{function parameter}
13885
13886 \end_inset
13887
13888  & Local Variables
13889 \begin_inset LatexCommand \index{local variables}
13890
13891 \end_inset
13892
13893
13894 \begin_inset LatexCommand \label{sec:Parameters-and-Local-Variables}
13895
13896 \end_inset
13897
13898
13899 \end_layout
13900
13901 \begin_layout Standard
13902 Automatic (local) variables and parameters to functions can either be placed
13903  on the stack or in data-space.
13904  The default action of the compiler is to place these variables in the internal
13905  RAM (for small model) or external RAM (for medium or large model).
13906  This in fact makes them similar to 
13907 \emph on
13908 static
13909 \begin_inset LatexCommand \index{static}
13910
13911 \end_inset
13912
13913
13914 \emph default
13915  so by default functions are non-reentrant
13916 \begin_inset LatexCommand \index{reentrant}
13917
13918 \end_inset
13919
13920 .
13921  
13922 \newline
13923
13924 \newline
13925 They can be placed on the stack
13926 \begin_inset LatexCommand \index{stack}
13927
13928 \end_inset
13929
13930  by using the
13931 \emph on
13932  -
13933 \begin_inset ERT
13934 status collapsed
13935
13936 \begin_layout Standard
13937
13938
13939 \backslash
13940 /
13941 \end_layout
13942
13943 \end_inset
13944
13945 -stack-auto
13946 \begin_inset LatexCommand \index{-\/-stack-auto}
13947
13948 \end_inset
13949
13950
13951 \emph default
13952  option, by using 
13953 \emph on
13954 #pragma\InsetSpace ~
13955 stackauto
13956 \emph default
13957
13958 \begin_inset LatexCommand \index{\#pragma stackauto}
13959
13960 \end_inset
13961
13962  or by using the 
13963 \emph on
13964 reentrant
13965 \begin_inset LatexCommand \index{reentrant}
13966
13967 \end_inset
13968
13969
13970 \emph default
13971  keyword in the function declaration, e.g.:
13972 \end_layout
13973
13974 \begin_layout Verse
13975
13976 \family typewriter
13977 unsigned char foo(char i) __reentrant 
13978 \newline
13979
13980 \newline
13981 \InsetSpace ~
13982 \InsetSpace ~
13983 \InsetSpace ~
13984 \InsetSpace ~
13985 ...
13986  
13987 \newline
13988 }
13989 \end_layout
13990
13991 \begin_layout Standard
13992 Since stack space on 8051 is limited, the 
13993 \emph on
13994 reentrant 
13995 \emph default
13996 keyword or the
13997 \emph on
13998  -
13999 \begin_inset ERT
14000 status collapsed
14001
14002 \begin_layout Standard
14003
14004
14005 \backslash
14006 /
14007 \end_layout
14008
14009 \end_inset
14010
14011 -stack-auto
14012 \emph default
14013  option should be used sparingly.
14014  Note that the reentrant keyword just means that the parameters & local
14015  variables will be allocated to the stack, it 
14016 \emph on
14017 does not
14018 \emph default
14019  mean that the function is register bank
14020 \begin_inset LatexCommand \index{register bank (mcs51, ds390)}
14021
14022 \end_inset
14023
14024  independent.
14025 \newline
14026
14027 \newline
14028 Local variables
14029 \begin_inset LatexCommand \index{local variables}
14030
14031 \end_inset
14032
14033  can be assigned storage classes and absolute
14034 \begin_inset LatexCommand \index{Absolute addressing}
14035
14036 \end_inset
14037
14038  addresses, e.g.: 
14039 \end_layout
14040
14041 \begin_layout Verse
14042
14043 \family typewriter
14044 unsigned char foo() 
14045 \newline
14046 {
14047 \newline
14048 \InsetSpace ~
14049 \InsetSpace ~
14050 \InsetSpace ~
14051 \InsetSpace ~
14052 __xdata unsigned char i;
14053 \newline
14054 \InsetSpace ~
14055 \InsetSpace ~
14056 \InsetSpace ~
14057 \InsetSpace ~
14058 __bit bvar;
14059 \newline
14060 \InsetSpace ~
14061 \InsetSpace ~
14062 \InsetSpace ~
14063 \InsetSpace ~
14064 __data __at
14065 \begin_inset LatexCommand \index{at}
14066
14067 \end_inset
14068
14069  (0x31) unsigned char j;
14070 \newline
14071 \InsetSpace ~
14072 \InsetSpace ~
14073 \InsetSpace ~
14074 \InsetSpace ~
14075 ...
14076  
14077 \newline
14078 }
14079 \end_layout
14080
14081 \begin_layout Standard
14082 In the above example the variable 
14083 \emph on
14084 i
14085 \emph default
14086  will be allocated in the external ram, 
14087 \emph on
14088 bvar
14089 \emph default
14090  in bit addressable space and
14091 \emph on
14092  j
14093 \emph default
14094  in internal ram.
14095  When compiled with 
14096 \emph on
14097 -
14098 \begin_inset ERT
14099 status collapsed
14100
14101 \begin_layout Standard
14102
14103
14104 \backslash
14105 /
14106 \end_layout
14107
14108 \end_inset
14109
14110 -stack-auto
14111 \emph default
14112  or when a function is declared as 
14113 \emph on
14114 reentrant
14115 \emph default
14116  this should only be done for static variables.
14117 \end_layout
14118
14119 \begin_layout Standard
14120 Parameters
14121 \begin_inset LatexCommand \index{function parameter}
14122
14123 \end_inset
14124
14125  however are not allowed any storage class
14126 \begin_inset LatexCommand \index{Storage class}
14127
14128 \end_inset
14129
14130 , (storage classes for parameters will be ignored), their allocation is
14131  governed by the memory model in use, and the reentrancy options.
14132 \end_layout
14133
14134 \begin_layout Standard
14135 It is however allowed to use bit parameters in reentrant functions and also
14136  non-static local bit variables are supported.
14137  Efficient use is limited to 8 semi-bitregisters in bit space.
14138  They are pushed and popped to stack
14139 \begin_inset LatexCommand \index{stack}
14140
14141 \end_inset
14142
14143  as a single byte just like the normal registers.
14144 \end_layout
14145
14146 \begin_layout Section
14147 Overlaying
14148 \begin_inset LatexCommand \label{sub:Overlaying}
14149
14150 \end_inset
14151
14152
14153 \begin_inset LatexCommand \index{Overlaying}
14154
14155 \end_inset
14156
14157
14158 \end_layout
14159
14160 \begin_layout Standard
14161 For non-reentrant
14162 \begin_inset LatexCommand \index{reentrant}
14163
14164 \end_inset
14165
14166  functions SDCC will try to reduce internal ram space usage by overlaying
14167  parameters and local variables of a function (if possible).
14168  Parameters and local variables
14169 \begin_inset LatexCommand \index{local variables}
14170
14171 \end_inset
14172
14173  of a function will be allocated to an overlayable segment if the function
14174  has 
14175 \emph on
14176 no other function calls and the function is non-reentrant and the memory
14177  model
14178 \begin_inset LatexCommand \index{Memory model}
14179
14180 \end_inset
14181
14182  is small.
14183
14184 \emph default
14185  If an explicit storage class
14186 \begin_inset LatexCommand \index{Storage class}
14187
14188 \end_inset
14189
14190  is specified for a local variable, it will NOT be overlayed.
14191 \end_layout
14192
14193 \begin_layout Standard
14194 Note that the compiler (not the linkage editor) makes the decision for overlayin
14195 g the data items.
14196  Functions that are called from an interrupt service routine
14197 \begin_inset Marginal
14198 status collapsed
14199
14200 \begin_layout Standard
14201
14202 \series bold
14203 !
14204 \end_layout
14205
14206 \end_inset
14207
14208  should be preceded by a #pragma\InsetSpace ~
14209 nooverlay
14210 \begin_inset LatexCommand \index{\#pragma nooverlay}
14211
14212 \end_inset
14213
14214  if they are not reentrant.
14215 \end_layout
14216
14217 \begin_layout Standard
14218 Also note that the compiler does not do any processing of inline assembler
14219  code, so the compiler might incorrectly assign local variables and parameters
14220  of a function into the overlay segment if the inline assembler code calls
14221  other c-functions that might use the overlay.
14222  In that case the #pragma\InsetSpace ~
14223 nooverlay should be used.
14224 \end_layout
14225
14226 \begin_layout Standard
14227 Parameters and local variables of functions that contain 16 or 32 bit multiplica
14228 tion
14229 \begin_inset LatexCommand \index{Multiplication}
14230
14231 \end_inset
14232
14233  or division
14234 \begin_inset LatexCommand \index{Division}
14235
14236 \end_inset
14237
14238  will NOT be overlayed since these are implemented using external functions,
14239  e.g.:
14240 \end_layout
14241
14242 \begin_layout Verse
14243
14244 \family typewriter
14245 #pragma save 
14246 \newline
14247 #pragma nooverlay
14248 \begin_inset LatexCommand \index{\#pragma nooverlay}
14249
14250 \end_inset
14251
14252  
14253 \newline
14254 void set_error(unsigned char errcd) 
14255 \newline
14256 {
14257 \newline
14258 \InsetSpace ~
14259 \InsetSpace ~
14260 \InsetSpace ~
14261 \InsetSpace ~
14262 P3 = errcd;
14263 \newline
14264
14265 \newline
14266 #pragma restore 
14267 \newline
14268
14269 \newline
14270 void
14271  some_isr () __interrupt
14272 \begin_inset LatexCommand \index{interrupt}
14273
14274 \end_inset
14275
14276  (2)
14277 \newline
14278 {
14279 \newline
14280 \InsetSpace ~
14281 \InsetSpace ~
14282 \InsetSpace ~
14283 \InsetSpace ~
14284 ...
14285 \newline
14286 \InsetSpace ~
14287 \InsetSpace ~
14288 \InsetSpace ~
14289 \InsetSpace ~
14290 set_error(10);
14291 \newline
14292 \InsetSpace ~
14293 \InsetSpace ~
14294 \InsetSpace ~
14295 \InsetSpace ~
14296 ...
14297  
14298 \newline
14299 }
14300 \end_layout
14301
14302 \begin_layout Standard
14303 In the above example the parameter 
14304 \emph on
14305 errcd
14306 \emph default
14307  for the function 
14308 \emph on
14309 set_error
14310 \emph default
14311  would be assigned to the overlayable segment if the #pragma\InsetSpace ~
14312 nooverlay was
14313  not present, this could cause unpredictable runtime behavior when called
14314  from an interrupt service routine.
14315  The #pragma\InsetSpace ~
14316 nooverlay ensures that the parameters and local variables for
14317  the function are NOT overlayed.
14318 \begin_inset VSpace bigskip
14319 \end_inset
14320
14321
14322 \end_layout
14323
14324 \begin_layout Section
14325 Interrupt Service Routines
14326 \begin_inset LatexCommand \label{sub:Interrupt-Service-Routines}
14327
14328 \end_inset
14329
14330
14331 \end_layout
14332
14333 \begin_layout Subsection
14334 General Information
14335 \end_layout
14336
14337 \begin_layout Standard
14338 SDCC allows 
14339 \emph on
14340 i
14341 \emph default
14342 nterrupt 
14343 \emph on
14344 s
14345 \emph default
14346 ervice 
14347 \emph on
14348 r
14349 \emph default
14350 outines to be coded in C, with some extended keywords.
14351 \end_layout
14352
14353 \begin_layout Verse
14354
14355 \family typewriter
14356 void timer_isr (void) __interrupt (1) __using (1) 
14357 \newline
14358
14359 \newline
14360 \InsetSpace ~
14361 \InsetSpace ~
14362 \InsetSpace ~
14363 \InsetSpace ~
14364 ...
14365  
14366 \newline
14367 }
14368 \end_layout
14369
14370 \begin_layout Standard
14371 The optional number following the 
14372 \emph on
14373 interrupt
14374 \begin_inset LatexCommand \index{interrupt}
14375
14376 \end_inset
14377
14378
14379 \begin_inset LatexCommand \index{\_\_interrupt}
14380
14381 \end_inset
14382
14383
14384 \emph default
14385  keyword is the interrupt number this routine will service.
14386  When present, the compiler will insert a call to this routine in the interrupt
14387  vector table
14388 \begin_inset LatexCommand \index{interrupt vector table}
14389
14390 \end_inset
14391
14392  for the interrupt number specified.
14393  If you have multiple source files in your project, interrupt service routines
14394  can be present in any of them, but a prototype of the isr MUST be present
14395  or included in the file that contains the function 
14396 \emph on
14397 main
14398 \emph default
14399 .
14400  The optional (8051 specific) keyword 
14401 \emph on
14402 using
14403 \begin_inset LatexCommand \index{using (mcs51, ds390 register bank)}
14404
14405 \end_inset
14406
14407
14408 \begin_inset LatexCommand \index{\_\_using (mcs51, ds390 register bank)}
14409
14410 \end_inset
14411
14412
14413 \emph default
14414  can be used to tell the compiler to use the specified register bank when
14415  generating code for this function.
14416  
14417 \newline
14418 Interrupt service routines open the door for some very interesting bugs:
14419 \end_layout
14420
14421 \begin_layout Subsubsection
14422 \begin_inset LatexCommand \label{sub:Common-interrupt-pitfall-volatile}
14423
14424 \end_inset
14425
14426 Common interrupt pitfall: variable not declared 
14427 \emph on
14428 volatile
14429 \end_layout
14430
14431 \begin_layout Standard
14432 If an interrupt service routine changes variables which are accessed by
14433  other functions these variables have to be declared 
14434 \emph on
14435 volatile
14436 \emph default
14437
14438 \begin_inset LatexCommand \index{volatile}
14439
14440 \end_inset
14441
14442 .
14443  See 
14444 \begin_inset LatexCommand \url{http://en.wikipedia.org/wiki/Volatile_variable}
14445
14446 \end_inset
14447
14448  .
14449 \end_layout
14450
14451 \begin_layout Subsubsection
14452 \begin_inset LatexCommand \label{sub:Common-interrupt-pitfall-non-atomic}
14453
14454 \end_inset
14455
14456 Common interrupt pitfall: 
14457 \emph on
14458 non-atomic access
14459 \end_layout
14460
14461 \begin_layout Standard
14462 If the access to these variables is not 
14463 \emph on
14464 atomic
14465 \begin_inset LatexCommand \index{atomic}
14466
14467 \end_inset
14468
14469
14470 \emph default
14471  (i.e.
14472  the processor needs more than one instruction for the access and could
14473  be interrupted while accessing the variable) the interrupt must be disabled
14474  during the access to avoid inconsistent data.
14475  
14476 \newline
14477 Access to 16 or 32 bit variables is obviously not atomic on 8 bit CPUs
14478  and should be protected by disabling interrupts.
14479  You're not automatically on the safe side if you use 8 bit variables though.
14480  We need an example here: f.e.
14481  on the 8051 the harmless looking 
14482 \begin_inset Quotes srd
14483 \end_inset
14484
14485
14486 \family typewriter
14487 flags\InsetSpace ~
14488 |=\InsetSpace ~
14489 0x80;
14490 \family default
14491
14492 \begin_inset Quotes sld
14493 \end_inset
14494
14495  is not atomic if 
14496 \family typewriter
14497 flags
14498 \family default
14499  resides in xdata.
14500  Setting 
14501 \begin_inset Quotes srd
14502 \end_inset
14503
14504
14505 \family typewriter
14506 flags\InsetSpace ~
14507 |=\InsetSpace ~
14508 0x40;
14509 \family default
14510
14511 \begin_inset Quotes sld
14512 \end_inset
14513
14514  from within an interrupt routine might get lost if the interrupt occurs
14515  at the wrong time.
14516  
14517 \begin_inset Quotes sld
14518 \end_inset
14519
14520
14521 \family typewriter
14522 counter\InsetSpace ~
14523 +=\InsetSpace ~
14524 8;
14525 \family default
14526
14527 \begin_inset Quotes srd
14528 \end_inset
14529
14530  is not atomic on the 8051 even if 
14531 \family typewriter
14532 counter
14533 \family default
14534  is located in data memory.
14535 \newline
14536 Bugs like these are hard to reproduce and can
14537  cause a lot of trouble.
14538  
14539 \end_layout
14540
14541 \begin_layout Subsubsection
14542 \begin_inset LatexCommand \label{sub:Common-interrupt-pitfall-stack-overflow}
14543
14544 \end_inset
14545
14546 Common interrupt pitfall: 
14547 \emph on
14548 stack overflow
14549 \end_layout
14550
14551 \begin_layout Standard
14552 The return address and the registers used in the interrupt service routine
14553  are saved on the stack
14554 \begin_inset LatexCommand \index{stack}
14555
14556 \end_inset
14557
14558  so there must be sufficient stack space.
14559  If there isn't variables or registers (or even the return address itself)
14560  will be corrupted.
14561  This 
14562 \emph on
14563 stack overflow
14564 \emph default
14565
14566 \begin_inset LatexCommand \index{stack overflow}
14567
14568 \end_inset
14569
14570  is most likely to happen if the interrupt occurs during the 
14571 \begin_inset Quotes sld
14572 \end_inset
14573
14574 deepest
14575 \begin_inset Quotes srd
14576 \end_inset
14577
14578  subroutine when the stack is already in use for f.e.
14579  many return addresses.
14580 \end_layout
14581
14582 \begin_layout Subsubsection
14583 \begin_inset LatexCommand \label{sub:Common-interrupt-pitfall-non-reentrant}
14584
14585 \end_inset
14586
14587 Common interrupt pitfall: 
14588 \emph on
14589 use of non-reentrant functions
14590 \end_layout
14591
14592 \begin_layout Standard
14593 A special note here, int (16 bit) and long (32 bit) integer division
14594 \begin_inset LatexCommand \index{Division}
14595
14596 \end_inset
14597
14598 , multiplication
14599 \begin_inset LatexCommand \index{Multiplication}
14600
14601 \end_inset
14602
14603  & modulus
14604 \begin_inset LatexCommand \index{Modulus}
14605
14606 \end_inset
14607
14608  and floating-point
14609 \begin_inset LatexCommand \index{Floating point support}
14610
14611 \end_inset
14612
14613  operations are implemented using external support routines.
14614  If an interrupt service routine needs to do any of these operations then
14615  the support routines (as mentioned in a following section) will have to
14616  be recompiled using the
14617 \emph on
14618  -
14619 \begin_inset ERT
14620 status collapsed
14621
14622 \begin_layout Standard
14623
14624
14625 \backslash
14626 /
14627 \end_layout
14628
14629 \end_inset
14630
14631 -stack-auto
14632 \begin_inset LatexCommand \index{-\/-stack-auto}
14633
14634 \end_inset
14635
14636
14637 \emph default
14638  option and the source file will need to be compiled using the 
14639 \emph on
14640 -
14641 \begin_inset ERT
14642 status collapsed
14643
14644 \begin_layout Standard
14645
14646
14647 \backslash
14648 /
14649 \end_layout
14650
14651 \end_inset
14652
14653 -int-long-reent
14654 \emph default
14655
14656 \begin_inset LatexCommand \index{-\/-int-long-reent}
14657
14658 \end_inset
14659
14660  compiler option.
14661  
14662 \newline
14663 Note, the type promotion
14664 \begin_inset LatexCommand \index{type promotion}
14665
14666 \end_inset
14667
14668  required by ANSI C can cause 16 bit routines to be used
14669 \begin_inset Marginal
14670 status collapsed
14671
14672 \begin_layout Standard
14673
14674 \series bold
14675 \InsetSpace ~
14676 !
14677 \end_layout
14678
14679 \end_inset
14680
14681  without the programmer being aware of it.
14682  See f.e.
14683  the cast 
14684 \family typewriter
14685 (unsigned char)(tail-1)
14686 \family default
14687  within the if clause in section 
14688 \begin_inset LatexCommand \ref{sub:A-Step-by Assembler Introduction}
14689
14690 \end_inset
14691
14692 .
14693 \end_layout
14694
14695 \begin_layout Standard
14696 Calling other functions from an interrupt service routine is not recommended,
14697  avoid it if possible.
14698  Note that when some function is called from an interrupt service routine
14699  it should be preceded by a #pragma\InsetSpace ~
14700 nooverlay
14701 \begin_inset LatexCommand \index{\#pragma nooverlay}
14702
14703 \end_inset
14704
14705  if it is not reentrant.
14706  Furthermore nonreentrant functions should not be called from the main program
14707  while the interrupt service routine might be active.
14708  They also must not be called from low priority interrupt service routines
14709  while a high priority interrupt service routine might be active.
14710  You could use semaphores or make the function
14711 \emph on
14712  critical
14713 \emph default
14714  if all parameters are passed in registers.
14715 \newline
14716  Also see section 
14717 \begin_inset LatexCommand \ref{sub:Overlaying}
14718
14719 \end_inset
14720
14721 \InsetSpace ~
14722 about Overlaying and section 
14723 \begin_inset LatexCommand \ref{sub:Functions-using-private-banks}
14724
14725 \end_inset
14726
14727 \InsetSpace ~
14728 about Functions using private register banks.
14729 \begin_inset VSpace bigskip
14730 \end_inset
14731
14732
14733 \end_layout
14734
14735 \begin_layout Subsection
14736 MCS51/DS390 Interrupt Service Routines
14737 \end_layout
14738
14739 \begin_layout Standard
14740 Interrupt
14741 \begin_inset LatexCommand \index{interrupt}
14742
14743 \end_inset
14744
14745  numbers and the corresponding address & descriptions for the Standard 8051/8052
14746  are listed below.
14747  SDCC will automatically adjust the 
14748 \begin_inset LatexCommand \index{interrupt vector table}
14749
14750 \end_inset
14751
14752  to the maximum interrupt number specified.
14753 \newline
14754
14755 \end_layout
14756
14757 \begin_layout Standard
14758 \align center
14759 \begin_inset Tabular
14760 <lyxtabular version="3" rows="9" columns="3">
14761 <features>
14762 <column alignment="center" valignment="top" leftline="true" width="0in">
14763 <column alignment="left" valignment="top" leftline="true" width="0in">
14764 <column alignment="left" valignment="top" leftline="true" rightline="true" width="0in">
14765 <row topline="true" bottomline="true">
14766 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14767 \begin_inset Text
14768
14769 \begin_layout Standard
14770 Interrupt #
14771 \end_layout
14772
14773 \end_inset
14774 </cell>
14775 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14776 \begin_inset Text
14777
14778 \begin_layout Standard
14779 Description
14780 \end_layout
14781
14782 \end_inset
14783 </cell>
14784 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
14785 \begin_inset Text
14786
14787 \begin_layout Standard
14788 Vector Address
14789 \end_layout
14790
14791 \end_inset
14792 </cell>
14793 </row>
14794 <row topline="true">
14795 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14796 \begin_inset Text
14797
14798 \begin_layout Standard
14799 0
14800 \end_layout
14801
14802 \end_inset
14803 </cell>
14804 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14805 \begin_inset Text
14806
14807 \begin_layout Standard
14808 External 0
14809 \end_layout
14810
14811 \end_inset
14812 </cell>
14813 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
14814 \begin_inset Text
14815
14816 \begin_layout Standard
14817 0x0003
14818 \end_layout
14819
14820 \end_inset
14821 </cell>
14822 </row>
14823 <row topline="true">
14824 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14825 \begin_inset Text
14826
14827 \begin_layout Standard
14828 1
14829 \end_layout
14830
14831 \end_inset
14832 </cell>
14833 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14834 \begin_inset Text
14835
14836 \begin_layout Standard
14837 Timer 0
14838 \end_layout
14839
14840 \end_inset
14841 </cell>
14842 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
14843 \begin_inset Text
14844
14845 \begin_layout Standard
14846 0x000b
14847 \end_layout
14848
14849 \end_inset
14850 </cell>
14851 </row>
14852 <row topline="true">
14853 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14854 \begin_inset Text
14855
14856 \begin_layout Standard
14857 2
14858 \end_layout
14859
14860 \end_inset
14861 </cell>
14862 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14863 \begin_inset Text
14864
14865 \begin_layout Standard
14866 External 1
14867 \end_layout
14868
14869 \end_inset
14870 </cell>
14871 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
14872 \begin_inset Text
14873
14874 \begin_layout Standard
14875 0x0013
14876 \end_layout
14877
14878 \end_inset
14879 </cell>
14880 </row>
14881 <row topline="true">
14882 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14883 \begin_inset Text
14884
14885 \begin_layout Standard
14886 3
14887 \end_layout
14888
14889 \end_inset
14890 </cell>
14891 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14892 \begin_inset Text
14893
14894 \begin_layout Standard
14895 Timer 1
14896 \end_layout
14897
14898 \end_inset
14899 </cell>
14900 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
14901 \begin_inset Text
14902
14903 \begin_layout Standard
14904 0x001b
14905 \end_layout
14906
14907 \end_inset
14908 </cell>
14909 </row>
14910 <row topline="true">
14911 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14912 \begin_inset Text
14913
14914 \begin_layout Standard
14915 4
14916 \end_layout
14917
14918 \end_inset
14919 </cell>
14920 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14921 \begin_inset Text
14922
14923 \begin_layout Standard
14924 Serial
14925 \end_layout
14926
14927 \end_inset
14928 </cell>
14929 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
14930 \begin_inset Text
14931
14932 \begin_layout Standard
14933 0x0023
14934 \end_layout
14935
14936 \end_inset
14937 </cell>
14938 </row>
14939 <row topline="true">
14940 <cell multicolumn="1" alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14941 \begin_inset Text
14942
14943 \begin_layout Standard
14944 5
14945 \end_layout
14946
14947 \end_inset
14948 </cell>
14949 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14950 \begin_inset Text
14951
14952 \begin_layout Standard
14953 Timer 2 (8052)
14954 \end_layout
14955
14956 \end_inset
14957 </cell>
14958 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
14959 \begin_inset Text
14960
14961 \begin_layout Standard
14962 0x002b
14963 \end_layout
14964
14965 \end_inset
14966 </cell>
14967 </row>
14968 <row topline="true">
14969 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14970 \begin_inset Text
14971
14972 \begin_layout Standard
14973 ...
14974 \end_layout
14975
14976 \end_inset
14977 </cell>
14978 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14979 \begin_inset Text
14980
14981 \begin_layout Standard
14982
14983 \end_layout
14984
14985 \end_inset
14986 </cell>
14987 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
14988 \begin_inset Text
14989
14990 \begin_layout Standard
14991 ...
14992 \end_layout
14993
14994 \end_inset
14995 </cell>
14996 </row>
14997 <row topline="true" bottomline="true">
14998 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14999 \begin_inset Text
15000
15001 \begin_layout Standard
15002 n
15003 \end_layout
15004
15005 \end_inset
15006 </cell>
15007 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
15008 \begin_inset Text
15009
15010 \begin_layout Standard
15011
15012 \end_layout
15013
15014 \end_inset
15015 </cell>
15016 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
15017 \begin_inset Text
15018
15019 \begin_layout Standard
15020 0x0003 + 8*n
15021 \end_layout
15022
15023 \end_inset
15024 </cell>
15025 </row>
15026 </lyxtabular>
15027
15028 \end_inset
15029
15030
15031 \newline
15032
15033 \end_layout
15034
15035 \begin_layout Standard
15036 If the interrupt service routine is defined without 
15037 \emph on
15038 using
15039 \begin_inset LatexCommand \index{using (mcs51, ds390 register bank)}
15040
15041 \end_inset
15042
15043
15044 \begin_inset LatexCommand \index{\_\_using (mcs51, ds390 register bank)}
15045
15046 \end_inset
15047
15048
15049 \emph default
15050  a register bank or with register bank 0 (
15051 \emph on
15052 using
15053 \emph default
15054  0), the compiler will save the registers used by itself on the stack upon
15055  entry and restore them at exit, however if such an interrupt service routine
15056  calls another function then the entire register bank will be saved on the
15057  stack.
15058  This scheme may be advantageous for small interrupt service routines which
15059  have low register usage.
15060 \end_layout
15061
15062 \begin_layout Standard
15063 If the interrupt service routine is defined to be using a specific register
15064  bank then only 
15065 \emph on
15066 a, b, dptr
15067 \emph default
15068  & psw are saved and restored, if such an interrupt service routine calls
15069  another function (using another register bank) then the entire register
15070  bank of the called function will be saved on the stack
15071 \begin_inset LatexCommand \index{stack}
15072
15073 \end_inset
15074
15075 .
15076  This scheme is recommended for larger interrupt service routines.
15077 \begin_inset VSpace bigskip
15078 \end_inset
15079
15080
15081 \end_layout
15082
15083 \begin_layout Subsection
15084 HC08
15085 \begin_inset LatexCommand \index{HC08}
15086
15087 \end_inset
15088
15089  Interrupt Service Routines
15090 \end_layout
15091
15092 \begin_layout Standard
15093 Since the number of interrupts
15094 \begin_inset LatexCommand \index{HC08!interrupt}
15095
15096 \end_inset
15097
15098  available is chip specific and the interrupt vector table always ends at
15099  the last byte of memory, the interrupt numbers corresponds to the interrupt
15100  vectors in reverse order of address.
15101  For example, interrupt 1 will use the interrupt vector at 0xfffc, interrupt
15102  2 will use the interrupt vector at 0xfffa, and so on.
15103  However, interrupt 0 (the reset vector at 0xfffe) is not redefinable in
15104  this way; instead see section 
15105 \begin_inset LatexCommand \ref{sub:Startup-Code}
15106
15107 \end_inset
15108
15109  for details on customizing startup.
15110 \begin_inset VSpace bigskip
15111 \end_inset
15112
15113
15114 \end_layout
15115
15116 \begin_layout Subsection
15117 Z80 Interrupt Service Routines
15118 \end_layout
15119
15120 \begin_layout Standard
15121 The Z80
15122 \begin_inset LatexCommand \index{Z80}
15123
15124 \end_inset
15125
15126  uses several different methods for determining the correct interrupt
15127 \begin_inset LatexCommand \index{Z80!interrupt}
15128
15129 \end_inset
15130
15131  vector depending on the hardware implementation.
15132  Therefore, SDCC ignores the optional interrupt number and does not attempt
15133  to generate an interrupt vector table.
15134 \end_layout
15135
15136 \begin_layout Standard
15137 By default, SDCC generates code for a maskable interrupt, which uses a RETI
15138  instruction to return from the interrupt.
15139  To write an interrupt handler for the non-maskable interrupt, which needs
15140  a RETN instruction instead, add the 
15141 \emph on
15142 critical
15143 \emph default
15144  keyword:
15145 \end_layout
15146
15147 \begin_layout Verse
15148
15149 \family typewriter
15150 void nmi_isr (void) critical interrupt
15151 \newline
15152
15153 \newline
15154 \InsetSpace ~
15155 \InsetSpace ~
15156 \InsetSpace ~
15157 \InsetSpace ~
15158 ...
15159  
15160 \newline
15161 }
15162 \end_layout
15163
15164 \begin_layout Standard
15165 However if you need to create a non-interruptable interrupt service routine
15166  you would also require the 
15167 \emph on
15168 critical
15169 \emph default
15170  keyword.
15171  To distinguish between this and an nmi_isr you must provide an interrupt
15172  number.
15173 \begin_inset VSpace bigskip
15174 \end_inset
15175
15176
15177 \end_layout
15178
15179 \begin_layout Section
15180 Enabling and Disabling Interrupts
15181 \end_layout
15182
15183 \begin_layout Subsection
15184 Critical Functions and Critical Statements
15185 \end_layout
15186
15187 \begin_layout Standard
15188 A special keyword may be associated with a block or a function declaring
15189  it as 
15190 \emph on
15191 critical
15192 \emph default
15193 .
15194  SDCC will generate code to disable all interrupts
15195 \begin_inset LatexCommand \index{interrupt}
15196
15197 \end_inset
15198
15199  upon entry to a critical function and restore the interrupt enable to the
15200  previous state before returning.
15201  Nesting critical functions will need one additional byte on the stack
15202 \begin_inset LatexCommand \index{stack}
15203
15204 \end_inset
15205
15206  for each call.
15207 \end_layout
15208
15209 \begin_layout Verse
15210
15211 \family typewriter
15212 int foo () __critical
15213 \begin_inset LatexCommand \index{critical}
15214
15215 \end_inset
15216
15217
15218 \begin_inset LatexCommand \index{\_\_critical}
15219
15220 \end_inset
15221
15222  
15223 \newline
15224
15225 \newline
15226 \InsetSpace ~
15227 \InsetSpace ~
15228 \InsetSpace ~
15229 \InsetSpace ~
15230 ...
15231  
15232 \newline
15233 \InsetSpace ~
15234 \InsetSpace ~
15235 \InsetSpace ~
15236 \InsetSpace ~
15237 ...
15238  
15239 \newline
15240 }
15241 \end_layout
15242
15243 \begin_layout Standard
15244 The critical attribute maybe used with other attributes like 
15245 \emph on
15246 reentrant.
15247 \emph default
15248
15249 \newline
15250 The keyword 
15251 \emph on
15252 critical
15253 \emph default
15254  may also be used to disable interrupts more locally:
15255 \end_layout
15256
15257 \begin_layout Verse
15258
15259 \family typewriter
15260 __critical{ i++; }
15261 \end_layout
15262
15263 \begin_layout Standard
15264 More than one statement could have been included in the block.
15265 \end_layout
15266
15267 \begin_layout Subsection
15268 Enabling and Disabling Interrupts directly
15269 \end_layout
15270
15271 \begin_layout Standard
15272 Interrupts
15273 \begin_inset LatexCommand \index{interrupt}
15274
15275 \end_inset
15276
15277  can also be disabled and enabled directly (8051):
15278 \end_layout
15279
15280 \begin_layout Verse
15281
15282 \family typewriter
15283 EA = 0;\InsetSpace ~
15284 \InsetSpace ~
15285 \InsetSpace ~
15286 \InsetSpace ~
15287 \InsetSpace ~
15288 \InsetSpace ~
15289 \InsetSpace ~
15290 \InsetSpace ~
15291 \InsetSpace ~
15292 \InsetSpace ~
15293 \InsetSpace ~
15294 \InsetSpace ~
15295 or:\InsetSpace ~
15296 \InsetSpace ~
15297 \InsetSpace ~
15298 \InsetSpace ~
15299 \InsetSpace ~
15300 \InsetSpace ~
15301 \InsetSpace ~
15302 \InsetSpace ~
15303 \InsetSpace ~
15304 \InsetSpace ~
15305 \InsetSpace ~
15306 EA_SAVE = EA;
15307 \end_layout
15308
15309 \begin_layout Verse
15310
15311 \family typewriter
15312 ...\InsetSpace ~
15313 \InsetSpace ~
15314 \InsetSpace ~
15315 \InsetSpace ~
15316 \InsetSpace ~
15317 \InsetSpace ~
15318 \InsetSpace ~
15319 \InsetSpace ~
15320 \InsetSpace ~
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 EA = 0;
15343 \end_layout
15344
15345 \begin_layout Verse
15346
15347 \family typewriter
15348 EA = 1;\InsetSpace ~
15349 \InsetSpace ~
15350 \InsetSpace ~
15351 \InsetSpace ~
15352 \InsetSpace ~
15353 \InsetSpace ~
15354 \InsetSpace ~
15355 \InsetSpace ~
15356 \InsetSpace ~
15357 \InsetSpace ~
15358 \InsetSpace ~
15359 \InsetSpace ~
15360 \InsetSpace ~
15361 \InsetSpace ~
15362 \InsetSpace ~
15363 \InsetSpace ~
15364 \InsetSpace ~
15365 \InsetSpace ~
15366 \InsetSpace ~
15367 \InsetSpace ~
15368 \InsetSpace ~
15369 \InsetSpace ~
15370 \InsetSpace ~
15371 \InsetSpace ~
15372 \InsetSpace ~
15373 \InsetSpace ~
15374 ...
15375 \end_layout
15376
15377 \begin_layout Verse
15378
15379 \family typewriter
15380 \InsetSpace ~
15381 \InsetSpace ~
15382 \InsetSpace ~
15383 \InsetSpace ~
15384 \InsetSpace ~
15385 \InsetSpace ~
15386 \InsetSpace ~
15387 \InsetSpace ~
15388 \InsetSpace ~
15389 \InsetSpace ~
15390 \InsetSpace ~
15391 \InsetSpace ~
15392 \InsetSpace ~
15393 \InsetSpace ~
15394 \InsetSpace ~
15395 \InsetSpace ~
15396 \InsetSpace ~
15397 \InsetSpace ~
15398 \InsetSpace ~
15399 \InsetSpace ~
15400 \InsetSpace ~
15401 \InsetSpace ~
15402 \InsetSpace ~
15403 \InsetSpace ~
15404 \InsetSpace ~
15405 \InsetSpace ~
15406 \InsetSpace ~
15407 \InsetSpace ~
15408 \InsetSpace ~
15409 \InsetSpace ~
15410 \InsetSpace ~
15411 \InsetSpace ~
15412 \InsetSpace ~
15413 EA = EA_SAVE;
15414 \end_layout
15415
15416 \begin_layout Standard
15417 On other architectures which have seperate opcodes for enabling and disabling
15418  interrupts you might want to make use of defines with inline assembly
15419 \begin_inset LatexCommand \index{Assembler routines}
15420
15421 \end_inset
15422
15423  (HC08
15424 \begin_inset LatexCommand \index{HC08!interrupt}
15425
15426 \end_inset
15427
15428 ):
15429 \end_layout
15430
15431 \begin_layout Verse
15432
15433 \family typewriter
15434 #define CLI _asm
15435 \begin_inset LatexCommand \index{\_asm}
15436
15437 \end_inset
15438
15439 \InsetSpace ~
15440 \InsetSpace ~
15441 cli\InsetSpace ~
15442 \InsetSpace ~
15443 _endasm
15444 \begin_inset LatexCommand \index{\_endasm}
15445
15446 \end_inset
15447
15448
15449 \end_layout
15450
15451 \begin_layout Verse
15452
15453 \family typewriter
15454 #define SEI _asm\InsetSpace ~
15455 \InsetSpace ~
15456 sei\InsetSpace ~
15457 \InsetSpace ~
15458 _endasm; 
15459 \end_layout
15460
15461 \begin_layout Verse
15462
15463 \family typewriter
15464 ...
15465 \end_layout
15466
15467 \begin_layout Standard
15468 Note: it is sometimes sufficient to disable only a specific interrupt source
15469  like f.e.
15470  a timer or serial interrupt by manipulating an 
15471 \emph on
15472 interrupt mask
15473 \begin_inset LatexCommand \index{interrupt mask}
15474
15475 \end_inset
15476
15477
15478 \emph default
15479  register.
15480  
15481 \end_layout
15482
15483 \begin_layout Standard
15484 Usually the time during which interrupts are disabled should be kept as
15485  short as possible.
15486  This minimizes both 
15487 \emph on
15488 interrupt latency
15489 \emph default
15490
15491 \begin_inset LatexCommand \index{interrupt latency}
15492
15493 \end_inset
15494
15495  (the time between the occurrence of the interrupt and the execution of
15496  the first code in the interrupt routine) and 
15497 \emph on
15498 interrupt jitter
15499 \emph default
15500
15501 \begin_inset LatexCommand \index{interrupt jitter}
15502
15503 \end_inset
15504
15505  (the difference between the shortest and the longest interrupt latency).
15506  These really are something different, f.e.
15507  a serial interrupt has to be served before its buffer overruns so it cares
15508  for the maximum interrupt latency, whereas it does not care about jitter.
15509  On a loudspeaker driven via a digital to analog converter which is fed
15510  by an interrupt a latency of a few milliseconds might be tolerable, whereas
15511  a much smaller jitter will be very audible.
15512 \end_layout
15513
15514 \begin_layout Standard
15515 You can reenable interrupts within an interrupt routine and on some architecture
15516 s you can make use of two (or more) levels of 
15517 \emph on
15518 interrupt priorities
15519 \emph default
15520
15521 \begin_inset LatexCommand \index{interrupt priority}
15522
15523 \end_inset
15524
15525 .
15526  On some architectures which don't support interrupt priorities these can
15527  be implemented by manipulating the interrupt mask and reenabling interrupts
15528  within the interrupt routine.
15529  Check there is sufficient space on the stack
15530 \begin_inset LatexCommand \index{stack}
15531
15532 \end_inset
15533
15534  and don't add complexity unless you have to.
15535  
15536 \end_layout
15537
15538 \begin_layout Subsection
15539 Semaphore
15540 \begin_inset LatexCommand \index{semaphore}
15541
15542 \end_inset
15543
15544  locking (mcs51/ds390)
15545 \end_layout
15546
15547 \begin_layout Standard
15548 Some architectures (mcs51/ds390) have an atomic
15549 \begin_inset LatexCommand \index{atomic}
15550
15551 \end_inset
15552
15553  bit test and
15554 \emph on
15555  
15556 \emph default
15557 clear
15558 \emph on
15559  
15560 \emph default
15561 instruction.
15562  These type of instructions are typically used in preemptive multitasking
15563  systems, where a routine f.e.
15564  claims the use of a data structure ('acquires a lock
15565 \begin_inset LatexCommand \index{lock}
15566
15567 \end_inset
15568
15569  on it'), makes some modifications and then releases the lock when the data
15570  structure is consistent again.
15571  The instruction may also be used if interrupt and non-interrupt code have
15572  to compete for a resource.
15573  With the atomic bit test and clear instruction interrupts
15574 \begin_inset LatexCommand \index{interrupt}
15575
15576 \end_inset
15577
15578  don't have to be disabled for the locking operation.
15579  
15580 \end_layout
15581
15582 \begin_layout Standard
15583 SDCC generates this instruction if the source follows this pattern:
15584 \end_layout
15585
15586 \begin_layout Verse
15587
15588 \family typewriter
15589 volatile
15590 \begin_inset LatexCommand \index{volatile}
15591
15592 \end_inset
15593
15594  bit resource_is_free; 
15595 \newline
15596
15597 \newline
15598 if (resource_is_free) 
15599 \newline
15600 \InsetSpace ~
15601 \InsetSpace ~
15602
15603 \newline
15604 \InsetSpace ~
15605 \InsetSpace ~
15606 \InsetSpace ~
15607 \InsetSpace ~
15608 resource_is_free=0; 
15609 \newline
15610 \InsetSpace ~
15611 \InsetSpace ~
15612 \InsetSpace ~
15613 \InsetSpace ~
15614 ...
15615  
15616 \newline
15617 \InsetSpace ~
15618 \InsetSpace ~
15619 \InsetSpace ~
15620 \InsetSpace ~
15621 resource_is_free=1;
15622 \newline
15623 \InsetSpace ~
15624 \InsetSpace ~
15625
15626 \end_layout
15627
15628 \begin_layout Standard
15629 Note, mcs51 and ds390 support only an atomic
15630 \begin_inset LatexCommand \index{atomic}
15631
15632 \end_inset
15633
15634  bit test and 
15635 \emph on
15636 clear
15637 \emph default
15638  instruction (as opposed to atomic bit test and 
15639 \emph on
15640 set).
15641 \end_layout
15642
15643 \begin_layout Section
15644 Functions using private register banks
15645 \begin_inset LatexCommand \label{sub:Functions-using-private-banks}
15646
15647 \end_inset
15648
15649  (mcs51/ds390)
15650 \end_layout
15651
15652 \begin_layout Standard
15653 Some architectures have support for quickly changing register sets.
15654  SDCC supports this feature with the 
15655 \emph on
15656 using
15657 \begin_inset LatexCommand \index{using (mcs51, ds390 register bank)}
15658
15659 \end_inset
15660
15661
15662 \begin_inset LatexCommand \index{\_\_using (mcs51, ds390 register bank)}
15663
15664 \end_inset
15665
15666
15667 \emph default
15668  attribute (which tells the compiler to use a register bank
15669 \begin_inset LatexCommand \index{register bank (mcs51, ds390)}
15670
15671 \end_inset
15672
15673  other than the default bank zero).
15674  It should only be applied to 
15675 \emph on
15676 interrupt
15677 \begin_inset LatexCommand \index{interrupt}
15678
15679 \end_inset
15680
15681
15682 \emph default
15683  functions (see footnote below).
15684  This will in most circumstances make the generated ISR code more efficient
15685  since it will not have to save registers on the stack.
15686 \end_layout
15687
15688 \begin_layout Standard
15689 The 
15690 \emph on
15691 using
15692 \emph default
15693  attribute will have no effect on the generated code for a 
15694 \emph on
15695 non-interrupt
15696 \emph default
15697  function (but may occasionally be useful anyway
15698 \begin_inset Foot
15699 status open
15700
15701 \begin_layout Standard
15702 possible exception: if a function is called ONLY from 'interrupt' functions
15703  using a particular bank, it can be declared with the same 'using' attribute
15704  as the calling 'interrupt' functions.
15705  For instance, if you have several ISRs using bank one, and all of them
15706  call memcpy(), it might make sense to create a specialized version of memcpy()
15707  'using 1', since this would prevent the ISR from having to save bank zero
15708  to the stack on entry and switch to bank zero before calling the function
15709 \end_layout
15710
15711 \end_inset
15712
15713 ).
15714 \newline
15715
15716 \emph on
15717 (pending: Note, nowadays the 
15718 \emph default
15719 using
15720 \emph on
15721  attribute has an effect on
15722 \emph default
15723  
15724 \emph on
15725 the generated code for a 
15726 \emph default
15727 non-interrupt
15728 \emph on
15729  function
15730 \emph default
15731 .
15732 \emph on
15733 )
15734 \end_layout
15735
15736 \begin_layout Standard
15737 An 
15738 \emph on
15739 interrupt
15740 \emph default
15741  function using a non-zero bank will assume that it can trash that register
15742  bank, and will not save it.
15743  Since high-priority interrupts
15744 \begin_inset LatexCommand \index{interrupts}
15745
15746 \end_inset
15747
15748
15749 \begin_inset LatexCommand \index{interrupt priority}
15750
15751 \end_inset
15752
15753  can interrupt low-priority ones on the 8051 and friends, this means that
15754  if a high-priority ISR 
15755 \emph on
15756 using
15757 \emph default
15758  a particular bank occurs while processing a low-priority ISR 
15759 \emph on
15760 using
15761 \emph default
15762  the same bank, terrible and bad things can happen.
15763  To prevent this, no single register bank should be 
15764 \emph on
15765 used
15766 \emph default
15767  by both a high priority and a low priority ISR.
15768  This is probably most easily done by having all high priority ISRs use
15769  one bank and all low priority ISRs use another.
15770  If you have an ISR which can change priority at runtime, you're on your
15771  own: I suggest using the default bank zero and taking the small performance
15772  hit.
15773 \end_layout
15774
15775 \begin_layout Standard
15776 It is most efficient if your ISR calls no other functions.
15777  If your ISR must call other functions, it is most efficient if those functions
15778  use the same bank as the ISR (see note 1 below); the next best is if the
15779  called functions use bank zero.
15780  It is very inefficient to call a function using a different, non-zero bank
15781  from an ISR.
15782  
15783 \begin_inset VSpace bigskip
15784 \end_inset
15785
15786
15787 \end_layout
15788
15789 \begin_layout Section
15790 Startup Code
15791 \begin_inset LatexCommand \label{sub:Startup-Code}
15792
15793 \end_inset
15794
15795
15796 \begin_inset LatexCommand \index{Startup code}
15797
15798 \end_inset
15799
15800
15801 \end_layout
15802
15803 \begin_layout Subsection
15804 MCS51/DS390 Startup Code
15805 \end_layout
15806
15807 \begin_layout Standard
15808 The compiler triggers the linker to link certain initialization modules
15809  from the runtime library
15810 \begin_inset LatexCommand \index{Runtime library}
15811
15812 \end_inset
15813
15814  called crt<something>.
15815  Only the necessary ones are linked, for instance crtxstack.asm (GSINIT1,
15816  GSINIT5) is not linked unless the -
15817 \series bold
15818
15819 \begin_inset ERT
15820 status open
15821
15822 \begin_layout Standard
15823
15824
15825 \backslash
15826 /
15827 \end_layout
15828
15829 \end_inset
15830
15831
15832 \series default
15833 -xstack option is used.
15834  These modules are highly entangled by the use of special segments/areas,
15835  but a common layout is shown below:
15836 \end_layout
15837
15838 \begin_layout Verse
15839
15840 \family typewriter
15841 \series bold
15842 \size footnotesize
15843 (main.asm)
15844 \end_layout
15845
15846 \begin_layout Verse
15847
15848 \family typewriter
15849 \size footnotesize
15850 \InsetSpace ~
15851 \InsetSpace ~
15852 \InsetSpace ~
15853 \InsetSpace ~
15854 \InsetSpace ~
15855 \InsetSpace ~
15856 \InsetSpace ~
15857 \InsetSpace ~
15858 .area HOME (CODE)
15859 \newline
15860 __interrupt_vect:
15861 \newline
15862 \InsetSpace ~
15863 \InsetSpace ~
15864 \InsetSpace ~
15865 \InsetSpace ~
15866 \InsetSpace ~
15867 \InsetSpace ~
15868 \InsetSpace ~
15869 \InsetSpace ~
15870 ljmp __sdcc_gsinit_startup
15871 \end_layout
15872
15873 \begin_layout Verse
15874
15875 \family typewriter
15876 \series bold
15877 \size footnotesize
15878 (crtstart.asm)
15879 \end_layout
15880
15881 \begin_layout Verse
15882
15883 \family typewriter
15884 \size footnotesize
15885 \InsetSpace ~
15886 \InsetSpace ~
15887 \InsetSpace ~
15888 \InsetSpace ~
15889 \InsetSpace ~
15890 \InsetSpace ~
15891 \InsetSpace ~
15892 \InsetSpace ~
15893 .area GSINIT0 (CODE)
15894 \newline
15895 __sdcc_gsinit_startup::
15896 \newline
15897 \InsetSpace ~
15898 \InsetSpace ~
15899 \InsetSpace ~
15900 \InsetSpace ~
15901 \InsetSpace ~
15902 \InsetSpace ~
15903 \InsetSpace ~
15904 \InsetSpace ~
15905 mov sp,#__start__stack - 1
15906 \end_layout
15907
15908 \begin_layout Verse
15909
15910 \family typewriter
15911 \series bold
15912 \size footnotesize
15913 (crtxstack.asm)
15914 \end_layout
15915
15916 \begin_layout Verse
15917
15918 \family typewriter
15919 \size footnotesize
15920 \InsetSpace ~
15921 \InsetSpace ~
15922 \InsetSpace ~
15923 \InsetSpace ~
15924 \InsetSpace ~
15925 \InsetSpace ~
15926 \InsetSpace ~
15927 \InsetSpace ~
15928 .area GSINIT1 (CODE)
15929 \newline
15930 __sdcc_init_xstack::
15931 \newline
15932 ; Need to initialize in GSINIT1 in
15933  case the user's __sdcc_external_startup uses the xstack.
15934 \newline
15935 \InsetSpace ~
15936 \InsetSpace ~
15937 \InsetSpace ~
15938 \InsetSpace ~
15939 \InsetSpace ~
15940 \InsetSpace ~
15941 \InsetSpace ~
15942 \InsetSpace ~
15943 mov __XPAGE,#(__start__x
15944 stack >> 8)
15945 \newline
15946 \InsetSpace ~
15947 \InsetSpace ~
15948 \InsetSpace ~
15949 \InsetSpace ~
15950 \InsetSpace ~
15951 \InsetSpace ~
15952 \InsetSpace ~
15953 \InsetSpace ~
15954 mov _spx,#__start__xstack
15955 \end_layout
15956
15957 \begin_layout Verse
15958
15959 \family typewriter
15960 \series bold
15961 \size footnotesize
15962 (crtstart.asm)
15963 \end_layout
15964
15965 \begin_layout Verse
15966
15967 \family typewriter
15968 \size footnotesize
15969 \InsetSpace ~
15970 \InsetSpace ~
15971 \InsetSpace ~
15972 \InsetSpace ~
15973 \InsetSpace ~
15974 \InsetSpace ~
15975 \InsetSpace ~
15976 \InsetSpace ~
15977 .area GSINIT2 (CODE)
15978 \newline
15979 \InsetSpace ~
15980 \InsetSpace ~
15981 \InsetSpace ~
15982 \InsetSpace ~
15983 \InsetSpace ~
15984 \InsetSpace ~
15985 \InsetSpace ~
15986 \InsetSpace ~
15987 lcall __sdcc_external_startup
15988 \newline
15989 \InsetSpace ~
15990 \InsetSpace ~
15991 \InsetSpace ~
15992 \InsetSpace ~
15993 \InsetSpace ~
15994 \InsetSpace ~
15995 \InsetSpace ~
15996 \InsetSpace ~
15997 mov a,dpl
15998 \newline
15999 \InsetSpace ~
16000 \InsetSpace ~
16001 \InsetSpace ~
16002 \InsetSpace ~
16003 \InsetSpace ~
16004 \InsetSpace ~
16005 \InsetSpace ~
16006 \InsetSpace ~
16007 jz __sdcc_init_data
16008 \newline
16009 \InsetSpace ~
16010 \InsetSpace ~
16011 \InsetSpace ~
16012 \InsetSpace ~
16013 \InsetSpace ~
16014 \InsetSpace ~
16015 \InsetSpace ~
16016 \InsetSpace ~
16017 ljmp
16018  __sdcc_program_startup
16019 \newline
16020 __sdcc_init_data:
16021 \end_layout
16022
16023 \begin_layout Verse
16024
16025 \family typewriter
16026 \series bold
16027 \size footnotesize
16028 (crtxinit.asm)
16029 \end_layout
16030
16031 \begin_layout Verse
16032
16033 \family typewriter
16034 \size footnotesize
16035 \InsetSpace ~
16036 \InsetSpace ~
16037 \InsetSpace ~
16038 \InsetSpace ~
16039 \InsetSpace ~
16040 \InsetSpace ~
16041 \InsetSpace ~
16042 \InsetSpace ~
16043 .area GSINIT3 (CODE)
16044 \newline
16045 __mcs51_genXINIT::
16046 \newline
16047 \InsetSpace ~
16048 \InsetSpace ~
16049 \InsetSpace ~
16050 \InsetSpace ~
16051 \InsetSpace ~
16052 \InsetSpace ~
16053 \InsetSpace ~
16054 \InsetSpace ~
16055 mov r1,#l_XINIT
16056 \newline
16057 \InsetSpace ~
16058 \InsetSpace ~
16059 \InsetSpace ~
16060 \InsetSpace ~
16061 \InsetSpace ~
16062 \InsetSpace ~
16063 \InsetSpace ~
16064 \InsetSpace ~
16065 mov a,r1
16066 \newline
16067 \InsetSpace ~
16068 \InsetSpace ~
16069 \InsetSpace ~
16070 \InsetSpace ~
16071 \InsetSpace ~
16072 \InsetSpace ~
16073 \InsetSpace ~
16074 \InsetSpace ~
16075 orl a,#(l_XINIT
16076  >> 8)
16077 \newline
16078 \InsetSpace ~
16079 \InsetSpace ~
16080 \InsetSpace ~
16081 \InsetSpace ~
16082 \InsetSpace ~
16083 \InsetSpace ~
16084 \InsetSpace ~
16085 \InsetSpace ~
16086 jz 00003$
16087 \newline
16088 \InsetSpace ~
16089 \InsetSpace ~
16090 \InsetSpace ~
16091 \InsetSpace ~
16092 \InsetSpace ~
16093 \InsetSpace ~
16094 \InsetSpace ~
16095 \InsetSpace ~
16096 mov r2,#((l_XINIT+255) >> 8)
16097 \newline
16098 \InsetSpace ~
16099 \InsetSpace ~
16100 \InsetSpace ~
16101 \InsetSpace ~
16102 \InsetSpace ~
16103 \InsetSpace ~
16104 \InsetSpace ~
16105 \InsetSpace ~
16106 mov dptr,#s_XINIT
16107 \newline
16108 \InsetSpace ~
16109 \InsetSpace ~
16110 \InsetSpace ~
16111 \InsetSpace ~
16112 \InsetSpace ~
16113 \InsetSpace ~
16114 \InsetSpace ~
16115 \InsetSpace ~
16116 mov r0,#s_XISEG
16117 \newline
16118 \InsetSpace ~
16119 \InsetSpace ~
16120 \InsetSpace ~
16121 \InsetSpace ~
16122 \InsetSpace ~
16123 \InsetSpace ~
16124 \InsetSpace ~
16125 \InsetSpace ~
16126 mov
16127  __XPAGE,#(s_XISEG >> 8)
16128 \newline
16129 00001$:\InsetSpace ~
16130 clr a
16131 \newline
16132 \InsetSpace ~
16133 \InsetSpace ~
16134 \InsetSpace ~
16135 \InsetSpace ~
16136 \InsetSpace ~
16137 \InsetSpace ~
16138 \InsetSpace ~
16139 \InsetSpace ~
16140 movc a,@a+dptr
16141 \newline
16142 \InsetSpace ~
16143 \InsetSpace ~
16144 \InsetSpace ~
16145 \InsetSpace ~
16146 \InsetSpace ~
16147 \InsetSpace ~
16148 \InsetSpace ~
16149 \InsetSpace ~
16150 movx @r0,a
16151 \newline
16152 \InsetSpace ~
16153 \InsetSpace ~
16154 \InsetSpace ~
16155 \InsetSpace ~
16156 \InsetSpace ~
16157 \InsetSpace ~
16158 \InsetSpace ~
16159 \InsetSpace ~
16160 inc dptr
16161 \newline
16162 \InsetSpace ~
16163 \InsetSpace ~
16164 \InsetSpace ~
16165 \InsetSpace ~
16166 \InsetSpace ~
16167 \InsetSpace ~
16168 \InsetSpace ~
16169 \InsetSpace ~
16170 inc
16171  r0
16172 \newline
16173 \InsetSpace ~
16174 \InsetSpace ~
16175 \InsetSpace ~
16176 \InsetSpace ~
16177 \InsetSpace ~
16178 \InsetSpace ~
16179 \InsetSpace ~
16180 \InsetSpace ~
16181 cjne r0,#0,00002$
16182 \newline
16183 \InsetSpace ~
16184 \InsetSpace ~
16185 \InsetSpace ~
16186 \InsetSpace ~
16187 \InsetSpace ~
16188 \InsetSpace ~
16189 \InsetSpace ~
16190 \InsetSpace ~
16191 inc __XPAGE
16192 \newline
16193 00002$:\InsetSpace ~
16194 djnz r1,00001$
16195 \newline
16196 \InsetSpace ~
16197 \InsetSpace ~
16198 \InsetSpace ~
16199 \InsetSpace ~
16200 \InsetSpace ~
16201 \InsetSpace ~
16202 \InsetSpace ~
16203 \InsetSpace ~
16204 djnz r2,00001$
16205 \newline
16206 \InsetSpace ~
16207 \InsetSpace ~
16208 \InsetSpace ~
16209 \InsetSpace ~
16210 \InsetSpace ~
16211 \InsetSpace ~
16212 \InsetSpace ~
16213 \InsetSpace ~
16214 mov __XPAGE,#0
16215 xFF
16216 \newline
16217 00003$:
16218 \end_layout
16219
16220 \begin_layout Verse
16221
16222 \family typewriter
16223 \series bold
16224 \size footnotesize
16225 (crtclear.asm)
16226 \end_layout
16227
16228 \begin_layout Verse
16229
16230 \family typewriter
16231 \size footnotesize
16232 \InsetSpace ~
16233 \InsetSpace ~
16234 \InsetSpace ~
16235 \InsetSpace ~
16236 \InsetSpace ~
16237 \InsetSpace ~
16238 \InsetSpace ~
16239 \InsetSpace ~
16240 .area GSINIT4 (CODE)
16241 \newline
16242 __mcs51_genRAMCLEAR::
16243 \newline
16244 \InsetSpace ~
16245 \InsetSpace ~
16246 \InsetSpace ~
16247 \InsetSpace ~
16248 \InsetSpace ~
16249 \InsetSpace ~
16250 \InsetSpace ~
16251 \InsetSpace ~
16252 clr a
16253 \newline
16254 \InsetSpace ~
16255 \InsetSpace ~
16256 \InsetSpace ~
16257 \InsetSpace ~
16258 \InsetSpace ~
16259 \InsetSpace ~
16260 \InsetSpace ~
16261 \InsetSpace ~
16262 mov r0,#(l_IRAM-1)
16263 \newline
16264 00004$:\InsetSpace ~
16265 mov
16266  @r0,a
16267 \newline
16268 \InsetSpace ~
16269 \InsetSpace ~
16270 \InsetSpace ~
16271 \InsetSpace ~
16272 \InsetSpace ~
16273 \InsetSpace ~
16274 \InsetSpace ~
16275 \InsetSpace ~
16276 djnz r0,00004$
16277 \newline
16278 ; _mcs51_genRAMCLEAR() end
16279 \end_layout
16280
16281 \begin_layout Verse
16282
16283 \family typewriter
16284 \series bold
16285 \size footnotesize
16286 (crtxclear.asm)
16287 \end_layout
16288
16289 \begin_layout Verse
16290
16291 \family typewriter
16292 \size footnotesize
16293 \InsetSpace ~
16294 \InsetSpace ~
16295 \InsetSpace ~
16296 \InsetSpace ~
16297 \InsetSpace ~
16298 \InsetSpace ~
16299 \InsetSpace ~
16300 \InsetSpace ~
16301 .area GSINIT4 (CODE)
16302 \newline
16303 __mcs51_genXRAMCLEAR::
16304 \newline
16305 \InsetSpace ~
16306 \InsetSpace ~
16307 \InsetSpace ~
16308 \InsetSpace ~
16309 \InsetSpace ~
16310 \InsetSpace ~
16311 \InsetSpace ~
16312 \InsetSpace ~
16313 mov r0,#l_PSEG
16314 \newline
16315 \InsetSpace ~
16316 \InsetSpace ~
16317 \InsetSpace ~
16318 \InsetSpace ~
16319 \InsetSpace ~
16320 \InsetSpace ~
16321 \InsetSpace ~
16322 \InsetSpace ~
16323 mov a,r0
16324 \newline
16325 \InsetSpace ~
16326 \InsetSpace ~
16327 \InsetSpace ~
16328 \InsetSpace ~
16329 \InsetSpace ~
16330 \InsetSpace ~
16331 \InsetSpace ~
16332 \InsetSpace ~
16333 orl a,#(l_PSEG
16334  >> 8)
16335 \newline
16336 \InsetSpace ~
16337 \InsetSpace ~
16338 \InsetSpace ~
16339 \InsetSpace ~
16340 \InsetSpace ~
16341 \InsetSpace ~
16342 \InsetSpace ~
16343 \InsetSpace ~
16344 jz 00006$
16345 \newline
16346 \InsetSpace ~
16347 \InsetSpace ~
16348 \InsetSpace ~
16349 \InsetSpace ~
16350 \InsetSpace ~
16351 \InsetSpace ~
16352 \InsetSpace ~
16353 \InsetSpace ~
16354 mov r1,#s_PSEG
16355 \newline
16356 \InsetSpace ~
16357 \InsetSpace ~
16358 \InsetSpace ~
16359 \InsetSpace ~
16360 \InsetSpace ~
16361 \InsetSpace ~
16362 \InsetSpace ~
16363 \InsetSpace ~
16364 mov __XPAGE,#(s_PSEG >> 8)
16365 \newline
16366 \InsetSpace ~
16367 \InsetSpace ~
16368 \InsetSpace ~
16369 \InsetSpace ~
16370 \InsetSpace ~
16371 \InsetSpace ~
16372 \InsetSpace ~
16373 \InsetSpace ~
16374 clr a
16375 \newline
16376 00005$:\InsetSpace ~
16377 movx
16378  @r1,a
16379 \newline
16380 \InsetSpace ~
16381 \InsetSpace ~
16382 \InsetSpace ~
16383 \InsetSpace ~
16384 \InsetSpace ~
16385 \InsetSpace ~
16386 \InsetSpace ~
16387 \InsetSpace ~
16388 inc r1
16389 \newline
16390 \InsetSpace ~
16391 \InsetSpace ~
16392 \InsetSpace ~
16393 \InsetSpace ~
16394 \InsetSpace ~
16395 \InsetSpace ~
16396 \InsetSpace ~
16397 \InsetSpace ~
16398 djnz r0,00005$
16399 \newline
16400 00006$:
16401 \newline
16402 \InsetSpace ~
16403 \InsetSpace ~
16404 \InsetSpace ~
16405 \InsetSpace ~
16406 \InsetSpace ~
16407 \InsetSpace ~
16408 \InsetSpace ~
16409 \InsetSpace ~
16410 mov r0,#l_XSEG
16411 \newline
16412 \InsetSpace ~
16413 \InsetSpace ~
16414 \InsetSpace ~
16415 \InsetSpace ~
16416 \InsetSpace ~
16417 \InsetSpace ~
16418 \InsetSpace ~
16419 \InsetSpace ~
16420 mov a,r0
16421 \newline
16422 \InsetSpace ~
16423 \InsetSpace ~
16424 \InsetSpace ~
16425 \InsetSpace ~
16426 \InsetSpace ~
16427 \InsetSpace ~
16428 \InsetSpace ~
16429 \InsetSpace ~
16430 orl a,#(l_XSEG >>
16431  8)
16432 \newline
16433 \InsetSpace ~
16434 \InsetSpace ~
16435 \InsetSpace ~
16436 \InsetSpace ~
16437 \InsetSpace ~
16438 \InsetSpace ~
16439 \InsetSpace ~
16440 \InsetSpace ~
16441 jz 00008$
16442 \newline
16443 \InsetSpace ~
16444 \InsetSpace ~
16445 \InsetSpace ~
16446 \InsetSpace ~
16447 \InsetSpace ~
16448 \InsetSpace ~
16449 \InsetSpace ~
16450 \InsetSpace ~
16451 mov r1,#((l_XSEG + 255) >> 8)
16452 \newline
16453 \InsetSpace ~
16454 \InsetSpace ~
16455 \InsetSpace ~
16456 \InsetSpace ~
16457 \InsetSpace ~
16458 \InsetSpace ~
16459 \InsetSpace ~
16460 \InsetSpace ~
16461 mov dptr,#s_XSEG
16462 \newline
16463 \InsetSpace ~
16464 \InsetSpace ~
16465 \InsetSpace ~
16466 \InsetSpace ~
16467 \InsetSpace ~
16468 \InsetSpace ~
16469 \InsetSpace ~
16470 \InsetSpace ~
16471 clr a
16472 \newline
16473 00007$:\InsetSpace ~
16474 movx
16475  @dptr,a
16476 \newline
16477 \InsetSpace ~
16478 \InsetSpace ~
16479 \InsetSpace ~
16480 \InsetSpace ~
16481 \InsetSpace ~
16482 \InsetSpace ~
16483 \InsetSpace ~
16484 \InsetSpace ~
16485 inc dptr
16486 \newline
16487 \InsetSpace ~
16488 \InsetSpace ~
16489 \InsetSpace ~
16490 \InsetSpace ~
16491 \InsetSpace ~
16492 \InsetSpace ~
16493 \InsetSpace ~
16494 \InsetSpace ~
16495 djnz r0,00007$
16496 \newline
16497 \InsetSpace ~
16498 \InsetSpace ~
16499 \InsetSpace ~
16500 \InsetSpace ~
16501 \InsetSpace ~
16502 \InsetSpace ~
16503 \InsetSpace ~
16504 \InsetSpace ~
16505 djnz r1,00007$
16506 \newline
16507 00008$:
16508 \end_layout
16509
16510 \begin_layout Verse
16511
16512 \family typewriter
16513 \series bold
16514 \size footnotesize
16515 (crtxstack.asm)
16516 \end_layout
16517
16518 \begin_layout Verse
16519
16520 \family typewriter
16521 \size footnotesize
16522 \InsetSpace ~
16523 \InsetSpace ~
16524 \InsetSpace ~
16525 \InsetSpace ~
16526 \InsetSpace ~
16527 \InsetSpace ~
16528 \InsetSpace ~
16529 \InsetSpace ~
16530 .area GSINIT5 (CODE)
16531 \newline
16532 ; Need to initialize in GSINIT5 because __mcs51_genXINIT
16533  modifies __XPAGE
16534 \newline
16535 ; and __mcs51_genRAMCLEAR modifies _spx.
16536 \newline
16537 \InsetSpace ~
16538 \InsetSpace ~
16539 \InsetSpace ~
16540 \InsetSpace ~
16541 \InsetSpace ~
16542 \InsetSpace ~
16543 \InsetSpace ~
16544 \InsetSpace ~
16545 mov __XPAGE,#(__start__x
16546 stack >> 8)
16547 \newline
16548 \InsetSpace ~
16549 \InsetSpace ~
16550 \InsetSpace ~
16551 \InsetSpace ~
16552 \InsetSpace ~
16553 \InsetSpace ~
16554 \InsetSpace ~
16555 \InsetSpace ~
16556 mov _spx,#__start__xstack
16557 \end_layout
16558
16559 \begin_layout Verse
16560
16561 \family typewriter
16562 \series bold
16563 \size footnotesize
16564 (application modules)
16565 \end_layout
16566
16567 \begin_layout Verse
16568
16569 \family typewriter
16570 \size footnotesize
16571 \InsetSpace ~
16572 \InsetSpace ~
16573 \InsetSpace ~
16574 \InsetSpace ~
16575 \InsetSpace ~
16576 \InsetSpace ~
16577 \InsetSpace ~
16578 \InsetSpace ~
16579 .area GSINIT (CODE)
16580 \end_layout
16581
16582 \begin_layout Verse
16583
16584 \family typewriter
16585 \series bold
16586 \size footnotesize
16587 (main.asm)
16588 \end_layout
16589
16590 \begin_layout Verse
16591
16592 \family typewriter
16593 \size footnotesize
16594 \InsetSpace ~
16595 \InsetSpace ~
16596 \InsetSpace ~
16597 \InsetSpace ~
16598 \InsetSpace ~
16599 \InsetSpace ~
16600 \InsetSpace ~
16601 \InsetSpace ~
16602 .area GSFINAL (CODE)
16603 \newline
16604 \InsetSpace ~
16605 \InsetSpace ~
16606 \InsetSpace ~
16607 \InsetSpace ~
16608 \InsetSpace ~
16609 \InsetSpace ~
16610 \InsetSpace ~
16611 \InsetSpace ~
16612 ljmp __sdcc_program_startup
16613 \newline
16614 ;---------------------------------
16615 -----------------------
16616 \newline
16617 ; Home
16618 \newline
16619 ;--------------------------------------------------
16620 ------
16621 \newline
16622 \InsetSpace ~
16623 \InsetSpace ~
16624 \InsetSpace ~
16625 \InsetSpace ~
16626 \InsetSpace ~
16627 \InsetSpace ~
16628 \InsetSpace ~
16629 \InsetSpace ~
16630 .area HOME (CODE)
16631 \newline
16632 \InsetSpace ~
16633 \InsetSpace ~
16634 \InsetSpace ~
16635 \InsetSpace ~
16636 \InsetSpace ~
16637 \InsetSpace ~
16638 \InsetSpace ~
16639 \InsetSpace ~
16640 .area CSEG (CODE)
16641 \newline
16642 __sdcc_program_startup:
16643 \newline
16644 \InsetSpace ~
16645 \InsetSpace ~
16646 \InsetSpace ~
16647 \InsetSpace ~
16648 \InsetSpace ~
16649 \InsetSpace ~
16650 \InsetSpace ~
16651 \InsetSpace ~
16652 lcall _main
16653 \newline
16654 ;
16655  return from main will lock up
16656 \newline
16657 \InsetSpace ~
16658 \InsetSpace ~
16659 \InsetSpace ~
16660 \InsetSpace ~
16661 \InsetSpace ~
16662 \InsetSpace ~
16663 \InsetSpace ~
16664 \InsetSpace ~
16665 sjmp .
16666 \end_layout
16667
16668 \begin_layout Standard
16669 One of these modules (crtstart.asm) contains a call to the C routine 
16670 \emph on
16671 _sdcc_external_startup()
16672 \begin_inset LatexCommand \index{\_sdcc\_external\_startup()}
16673
16674 \end_inset
16675
16676
16677 \series bold
16678 \emph default
16679  
16680 \series default
16681 at the start of the CODE area.
16682  This routine is also in the runtime library
16683 \begin_inset LatexCommand \index{Runtime library}
16684
16685 \end_inset
16686
16687  and returns 0 by default.
16688  If this routine returns a non-zero value, the static & global variable
16689  initialization will be skipped and the function main will be invoked.
16690  Otherwise static & global variables will be initialized before the function
16691  main is invoked.
16692  You could add an 
16693 \emph on
16694 _sdcc_external_startup()
16695 \emph default
16696  routine to your program to override the default if you need to setup hardware
16697  or perform some other critical operation prior to static & global variable
16698  initialization
16699 \begin_inset LatexCommand \index{Variable initialization}
16700
16701 \end_inset
16702
16703 .
16704  On some mcs51 variants xdata
16705 \begin_inset LatexCommand \index{xdata (mcs51, ds390 storage class)}
16706
16707 \end_inset
16708
16709  memory has to be explicitly enabled before it can be accessed or if the
16710  watchdog
16711 \begin_inset LatexCommand \index{watchdog}
16712
16713 \end_inset
16714
16715  needs to be disabled, this is the place to do it.
16716  The startup code clears all internal data memory, 256 bytes by default,
16717  but from 0 to n-1 if 
16718 \emph on
16719 -
16720 \begin_inset ERT
16721 status collapsed
16722
16723 \begin_layout Standard
16724
16725
16726 \backslash
16727 /
16728 \end_layout
16729
16730 \end_inset
16731
16732 -iram-size
16733 \begin_inset LatexCommand \index{-\/-iram-size <Value>}
16734
16735 \end_inset
16736
16737 n
16738 \emph default
16739  is used.
16740  (recommended for Chipcon CC1010).
16741 \end_layout
16742
16743 \begin_layout Standard
16744 See also the compiler options 
16745 \emph on
16746 -
16747 \begin_inset ERT
16748 status collapsed
16749
16750 \begin_layout Standard
16751
16752
16753 \backslash
16754 /
16755 \end_layout
16756
16757 \end_inset
16758
16759 -no-xinit
16760 \emph default
16761 -
16762 \emph on
16763 opt
16764 \emph default
16765
16766 \begin_inset LatexCommand \index{-\/-no-xinit-opt}
16767
16768 \end_inset
16769
16770
16771 \emph on
16772 -
16773 \begin_inset ERT
16774 status collapsed
16775
16776 \begin_layout Standard
16777
16778
16779 \backslash
16780 /
16781 \end_layout
16782
16783 \end_inset
16784
16785 -main-return
16786 \emph default
16787
16788 \begin_inset LatexCommand \index{-\/-main-return}
16789
16790 \end_inset
16791
16792  and section 
16793 \begin_inset LatexCommand \ref{sub:MCS51-variants}
16794
16795 \end_inset
16796
16797  about MCS51-variants.
16798 \newline
16799
16800 \end_layout
16801
16802 \begin_layout Standard
16803 While these initialization modules are meant as generic startup code there
16804  might be the need for customization.
16805  Let's assume the return value of 
16806 \emph on
16807 _sdcc_external_startup()
16808 \emph default
16809  in 
16810 \emph on
16811 crtstart.asm
16812 \emph default
16813  should not be checked (or 
16814 \emph on
16815 _sdcc_external_startup()
16816 \emph default
16817  should not be called at all).
16818  The recommended way would be to copy 
16819 \emph on
16820 crtstart.asm
16821 \emph default
16822  (f.e.
16823  from 
16824 \begin_inset LatexCommand \url{http://sdcc.svn.sourceforge.net/viewvc/*checkout*/sdcc/trunk/sdcc/device/lib/mcs51/crtstart.asm}
16825
16826 \end_inset
16827
16828 ) into the source directory, adapt it there, then assemble it with 
16829 \emph on
16830 asx8051 -plosgff
16831 \begin_inset Foot
16832 status open
16833
16834 \begin_layout Standard
16835 \begin_inset Quotes sld
16836 \end_inset
16837
16838 -plosgff
16839 \begin_inset Quotes srd
16840 \end_inset
16841
16842  are the assembler options used in 
16843 \begin_inset LatexCommand \url{http://sdcc.svn.sourceforge.net/viewvc/sdcc/trunk/sdcc/device/lib/mcs51/Makefile.in?view=markup }
16844
16845 \end_inset
16846
16847
16848 \end_layout
16849
16850 \end_inset
16851
16852  crtstart.asm
16853 \emph default
16854  and when linking your project explicitely specify 
16855 \emph on
16856 crtstart.rel
16857 \emph default
16858 .
16859  As a bonus a listing of the relocated object file 
16860 \emph on
16861 crtstart.rst
16862 \emph default
16863  is generated.
16864 \end_layout
16865
16866 \begin_layout Standard
16867 \begin_inset VSpace bigskip
16868 \end_inset
16869
16870
16871 \end_layout
16872
16873 \begin_layout Subsection
16874 HC08 Startup Code
16875 \end_layout
16876
16877 \begin_layout Standard
16878 The HC08
16879 \begin_inset LatexCommand \index{HC08}
16880
16881 \end_inset
16882
16883  startup code follows the same scheme as the MCS51 startup code.
16884 \begin_inset VSpace bigskip
16885 \end_inset
16886
16887
16888 \end_layout
16889
16890 \begin_layout Subsection
16891 Z80 Startup Code
16892 \end_layout
16893
16894 \begin_layout Standard
16895 On the Z80
16896 \begin_inset LatexCommand \index{Z80}
16897
16898 \end_inset
16899
16900  the startup code is inserted by linking with crt0.o which is generated from
16901  sdcc/device/lib/z80/crt0.s.
16902  If you need a different startup code you can use the compiler option 
16903 \emph on
16904 -
16905 \series bold
16906 \emph default
16907
16908 \begin_inset ERT
16909 status collapsed
16910
16911 \begin_layout Standard
16912
16913
16914 \backslash
16915 /
16916 \end_layout
16917
16918 \end_inset
16919
16920
16921 \series default
16922 \emph on
16923 -no-std-crt0
16924 \emph default
16925
16926 \begin_inset LatexCommand \index{-\/-no-std-crt0}
16927
16928 \end_inset
16929
16930  and provide your own crt0.o.
16931  
16932 \begin_inset VSpace bigskip
16933 \end_inset
16934
16935
16936 \end_layout
16937
16938 \begin_layout Section
16939 Inline Assembler Code
16940 \begin_inset LatexCommand \index{Assembler routines}
16941
16942 \end_inset
16943
16944
16945 \end_layout
16946
16947 \begin_layout Subsection
16948 A Step by Step Introduction
16949 \begin_inset LatexCommand \label{sub:A-Step-by Assembler Introduction}
16950
16951 \end_inset
16952
16953
16954 \end_layout
16955
16956 \begin_layout Standard
16957 Starting from a small snippet of c-code this example shows for the MCS51
16958  how to use inline assembly, access variables, a function parameter and
16959  an array in xdata memory.
16960  The example uses an MCS51 here but is easily adapted for other architectures.
16961  This is a buffer routine which should be optimized:
16962 \end_layout
16963
16964 \begin_layout Verse
16965
16966 \family typewriter
16967 \size footnotesize
16968 unsigned char __far
16969 \begin_inset LatexCommand \index{far (storage class)}
16970
16971 \end_inset
16972
16973
16974 \begin_inset LatexCommand \index{\_\_far (storage class)}
16975
16976 \end_inset
16977
16978  __at
16979 \begin_inset LatexCommand \index{at}
16980
16981 \end_inset
16982
16983
16984 \begin_inset LatexCommand \index{\_\_at}
16985
16986 \end_inset
16987
16988 (0x7f00) buf[0x100];
16989 \begin_inset LatexCommand \index{Aligned array}
16990
16991 \end_inset
16992
16993
16994 \newline
16995 unsigned char head, tail;\InsetSpace ~
16996 \InsetSpace ~
16997 \InsetSpace ~
16998 \InsetSpace ~
16999 \InsetSpace ~
17000 \InsetSpace ~
17001 \InsetSpace ~
17002 \InsetSpace ~
17003 \InsetSpace ~
17004 \InsetSpace ~
17005 \InsetSpace ~
17006 \InsetSpace ~
17007 \InsetSpace ~
17008 \InsetSpace ~
17009 \InsetSpace ~
17010 \InsetSpace ~
17011 \InsetSpace ~
17012 /* if interrupts
17013 \begin_inset LatexCommand \index{interrupt}
17014
17015 \end_inset
17016
17017  are involved see
17018 \newline
17019 \InsetSpace ~
17020 \InsetSpace ~
17021 \InsetSpace ~
17022 \InsetSpace ~
17023 \InsetSpace ~
17024 \InsetSpace ~
17025 \InsetSpace ~
17026 \InsetSpace ~
17027 \InsetSpace ~
17028 \InsetSpace ~
17029 \InsetSpace ~
17030 \InsetSpace ~
17031 \InsetSpace ~
17032 \InsetSpace ~
17033 \InsetSpace ~
17034 \InsetSpace ~
17035 \InsetSpace ~
17036 \InsetSpace ~
17037 \InsetSpace ~
17038 \InsetSpace ~
17039 \InsetSpace ~
17040 \InsetSpace ~
17041 \InsetSpace ~
17042 \InsetSpace ~
17043 \InsetSpace ~
17044 \InsetSpace ~
17045 \InsetSpace ~
17046 \InsetSpace ~
17047 \InsetSpace ~
17048 \InsetSpace ~
17049 \InsetSpace ~
17050 \InsetSpace ~
17051 \InsetSpace ~
17052 \InsetSpace ~
17053 \InsetSpace ~
17054 \InsetSpace ~
17055 \InsetSpace ~
17056 \InsetSpace ~
17057 \InsetSpace ~
17058 \InsetSpace ~
17059 \InsetSpace ~
17060 \InsetSpace ~
17061 \InsetSpace ~
17062 \InsetSpace ~
17063 \InsetSpace ~
17064 section 
17065 \begin_inset LatexCommand \ref{sub:Common-interrupt-pitfall-volatile}
17066
17067 \end_inset
17068
17069  about
17070 \series bold
17071  volatile
17072 \series default
17073  */
17074 \newline
17075
17076 \newline
17077 void to_buffer( unsigned char c ) 
17078 \newline
17079 {
17080 \newline
17081 \InsetSpace ~
17082 \InsetSpace ~
17083 \InsetSpace ~
17084 \InsetSpace ~
17085 if( head != (unsigned char)(tail-1)
17086  )\InsetSpace ~
17087 /* cast 
17088 \series bold
17089 needed
17090 \series default
17091  to avoid promotion
17092 \begin_inset LatexCommand \index{promotion to signed int}
17093
17094 \end_inset
17095
17096
17097 \begin_inset LatexCommand \index{type promotion}
17098
17099 \end_inset
17100
17101  to integer */
17102 \begin_inset Marginal
17103 status collapsed
17104
17105 \begin_layout Standard
17106
17107 \series bold
17108 \InsetSpace ~
17109 !
17110 \end_layout
17111
17112 \end_inset
17113
17114
17115 \newline
17116 \InsetSpace ~
17117 \InsetSpace ~
17118 \InsetSpace ~
17119 \InsetSpace ~
17120 \InsetSpace ~
17121 \InsetSpace ~
17122 \InsetSpace ~
17123 \InsetSpace ~
17124 buf[ head++ ] = c;\InsetSpace ~
17125 \InsetSpace ~
17126 \InsetSpace ~
17127 \InsetSpace ~
17128 \InsetSpace ~
17129 \InsetSpace ~
17130 \InsetSpace ~
17131 \InsetSpace ~
17132 \InsetSpace ~
17133 \InsetSpace ~
17134 \InsetSpace ~
17135 \InsetSpace ~
17136 \InsetSpace ~
17137 \InsetSpace ~
17138 \InsetSpace ~
17139 \InsetSpace ~
17140 /* access to a 256 byte aligned array */
17141 \newline
17142
17143 \end_layout
17144
17145 \begin_layout Standard
17146 If the code snippet (assume it is saved in buffer.c) is compiled with SDCC
17147  then a corresponding buffer.asm file is generated.
17148  We define a new function 
17149 \family typewriter
17150 to_buffer_asm()
17151 \family default
17152  in file buffer.c in which we cut and paste the generated code, removing
17153  unwanted comments and some ':'.
17154  Then add 
17155 \begin_inset Quotes sld
17156 \end_inset
17157
17158
17159 \series bold
17160 _asm
17161 \series default
17162
17163 \begin_inset Quotes srd
17164 \end_inset
17165
17166  and 
17167 \begin_inset Quotes sld
17168 \end_inset
17169
17170
17171 \series bold
17172 _endasm;
17173 \series default
17174
17175 \begin_inset Quotes srd
17176 \end_inset
17177
17178
17179 \begin_inset Foot
17180 status open
17181
17182 \begin_layout Standard
17183 Note, that the single underscore form (_asm and _endasm) are not C99-compatible,
17184  and for C-99 compatibility, the double-underscore form (__asm and __endasm)
17185  has to be used.
17186  The latter is also used in the library functions.
17187 \end_layout
17188
17189 \end_inset
17190
17191  to the beginning and the end of the function body:
17192 \end_layout
17193
17194 \begin_layout Verse
17195
17196 \family typewriter
17197 \size footnotesize
17198 /* With a cut and paste from the .asm file, we have something to start with.
17199 \newline
17200 \InsetSpace ~
17201 \InsetSpace ~
17202 \InsetSpace ~
17203 The
17204  function is not yet OK! (registers aren't saved) */ 
17205 \newline
17206 void to_buffer_asm(
17207  unsigned char c ) 
17208 \newline
17209
17210 \newline
17211 \InsetSpace ~
17212 \InsetSpace ~
17213 \InsetSpace ~
17214 \InsetSpace ~
17215 _asm
17216 \begin_inset LatexCommand \index{\_asm}
17217
17218 \end_inset
17219
17220
17221 \begin_inset LatexCommand \index{\_\_asm}
17222
17223 \end_inset
17224
17225
17226 \newline
17227 \InsetSpace ~
17228 \InsetSpace ~
17229 \InsetSpace ~
17230 \InsetSpace ~
17231 mov\InsetSpace ~
17232 \InsetSpace ~
17233 r2,dpl 
17234 \newline
17235 ;buffer.c if( head != (unsigned char)(tail-1) ) \InsetSpace ~
17236 /* cast 
17237 \series bold
17238 needed
17239 \series default
17240  to avoid promotion
17241 \begin_inset LatexCommand \index{promotion to signed int}
17242
17243 \end_inset
17244
17245
17246 \begin_inset LatexCommand \index{type promotion}
17247
17248 \end_inset
17249
17250  to integer */
17251 \newline
17252 \InsetSpace ~
17253 \InsetSpace ~
17254 \InsetSpace ~
17255 \InsetSpace ~
17256 mov\InsetSpace ~
17257 \InsetSpace ~
17258 a,_tail 
17259 \newline
17260 \InsetSpace ~
17261 \InsetSpace ~
17262 \InsetSpace ~
17263 \InsetSpace ~
17264 dec\InsetSpace ~
17265 \InsetSpace ~
17266
17267 \newline
17268 \InsetSpace ~
17269 \InsetSpace ~
17270 \InsetSpace ~
17271 \InsetSpace ~
17272 mov\InsetSpace ~
17273 \InsetSpace ~
17274 r3,a 
17275 \newline
17276 \InsetSpace ~
17277 \InsetSpace ~
17278 \InsetSpace ~
17279 \InsetSpace ~
17280 mov\InsetSpace ~
17281 \InsetSpace ~
17282 a,_head 
17283 \newline
17284 \InsetSpace ~
17285 \InsetSpace ~
17286 \InsetSpace ~
17287 \InsetSpace ~
17288 cjne a,ar3,00106$ 
17289 \newline
17290 \InsetSpace ~
17291 \InsetSpace ~
17292 \InsetSpace ~
17293 \InsetSpace ~
17294 ret
17295 \newline
17296 00106$:
17297  
17298 \newline
17299 ;buffer.c buf[ head++ ] = c; /* access to a 256 byte aligned array */
17300 \begin_inset LatexCommand \index{Aligned array}
17301
17302 \end_inset
17303
17304
17305 \newline
17306 \InsetSpace ~
17307 \InsetSpace ~
17308 \InsetSpace ~
17309 \InsetSpace ~
17310 mov\InsetSpace ~
17311 \InsetSpace ~
17312 r3,_head 
17313 \newline
17314 \InsetSpace ~
17315 \InsetSpace ~
17316 \InsetSpace ~
17317 \InsetSpace ~
17318 inc\InsetSpace ~
17319 \InsetSpace ~
17320 _head 
17321 \newline
17322 \InsetSpace ~
17323 \InsetSpace ~
17324 \InsetSpace ~
17325 \InsetSpace ~
17326 mov\InsetSpace ~
17327 \InsetSpace ~
17328 dpl,r3 
17329 \newline
17330 \InsetSpace ~
17331 \InsetSpace ~
17332 \InsetSpace ~
17333 \InsetSpace ~
17334 mov\InsetSpace ~
17335 \InsetSpace ~
17336 dph,#(_buf >> 8) 
17337 \newline
17338 \InsetSpace ~
17339 \InsetSpace ~
17340 \InsetSpace ~
17341 \InsetSpace ~
17342 mov\InsetSpace ~
17343 \InsetSpace ~
17344 a,r2 
17345 \newline
17346 \InsetSpace ~
17347 \InsetSpace ~
17348 \InsetSpace ~
17349 \InsetSpace ~
17350 movx @dptr,a
17351  
17352 \newline
17353 00103$: 
17354 \newline
17355 \InsetSpace ~
17356 \InsetSpace ~
17357 \InsetSpace ~
17358 \InsetSpace ~
17359 ret
17360 \newline
17361 \InsetSpace ~
17362 \InsetSpace ~
17363 \InsetSpace ~
17364 \InsetSpace ~
17365 _endasm
17366 \begin_inset LatexCommand \index{\_endasm}
17367
17368 \end_inset
17369
17370
17371 \begin_inset LatexCommand \index{\_\_endasm}
17372
17373 \end_inset
17374
17375 ;
17376 \newline
17377
17378 \end_layout
17379
17380 \begin_layout Standard
17381 The new file buffer.c should compile with only one warning about the unreferenced
17382  function argument 'c'.
17383  Now we hand-optimize the assembly code and insert an #define USE_ASSEMBLY
17384  (1) and finally have:
17385 \end_layout
17386
17387 \begin_layout Verse
17388
17389 \family typewriter
17390 \size footnotesize
17391 unsigned char __far __at(0x7f00) buf[0x100];
17392 \newline
17393 unsigned char head, tail;
17394 \newline
17395 #define
17396  USE_ASSEMBLY (1)
17397 \newline
17398
17399 \newline
17400 #if !USE_ASSEMBLY
17401 \newline
17402
17403 \newline
17404 void to_buffer( unsigned char c )
17405 \newline
17406 {
17407 \newline
17408 \InsetSpace ~
17409 \InsetSpace ~
17410 \InsetSpace ~
17411 \InsetSpace ~
17412 if(
17413  head != (unsigned char)(tail-1) )
17414 \newline
17415 \InsetSpace ~
17416 \InsetSpace ~
17417 \InsetSpace ~
17418 \InsetSpace ~
17419 \InsetSpace ~
17420 \InsetSpace ~
17421 \InsetSpace ~
17422 \InsetSpace ~
17423 buf[ head++ ] = c;
17424 \newline
17425 }
17426 \newline
17427
17428 \newline
17429 #else
17430 \newline
17431
17432 \newline
17433 void to_buffer(
17434  unsigned char c )
17435 \newline
17436 {
17437 \newline
17438 \InsetSpace ~
17439 \InsetSpace ~
17440 \InsetSpace ~
17441 \InsetSpace ~
17442 c; // to avoid warning: unreferenced function argument
17443 \newline
17444 \InsetSpace ~
17445 \InsetSpace ~
17446 \InsetSpace ~
17447 \InsetSpace ~
17448 _asm
17449 \begin_inset LatexCommand \index{\_asm}
17450
17451 \end_inset
17452
17453
17454 \begin_inset LatexCommand \index{\_\_asm}
17455
17456 \end_inset
17457
17458
17459 \newline
17460 \InsetSpace ~
17461 \InsetSpace ~
17462 \InsetSpace ~
17463 \InsetSpace ~
17464 \InsetSpace ~
17465 \InsetSpace ~
17466 \InsetSpace ~
17467 \InsetSpace ~
17468 ; save used registers here.
17469  
17470 \newline
17471 \InsetSpace ~
17472 \InsetSpace ~
17473 \InsetSpace ~
17474 \InsetSpace ~
17475 \InsetSpace ~
17476 \InsetSpace ~
17477 \InsetSpace ~
17478 \InsetSpace ~
17479 ; If we were still using r2,r3 we would have to push them here.
17480  
17481 \newline
17482 ; if( head != (unsigned char)(tail-1) )
17483 \newline
17484 \InsetSpace ~
17485 \InsetSpace ~
17486 \InsetSpace ~
17487 \InsetSpace ~
17488 \InsetSpace ~
17489 \InsetSpace ~
17490 \InsetSpace ~
17491 \InsetSpace ~
17492 mov\InsetSpace ~
17493  a,_tail
17494 \newline
17495 \InsetSpace ~
17496 \InsetSpace ~
17497 \InsetSpace ~
17498 \InsetSpace ~
17499 \InsetSpace ~
17500 \InsetSpace ~
17501 \InsetSpace ~
17502 \InsetSpace ~
17503 dec\InsetSpace ~
17504  a
17505 \newline
17506 \InsetSpace ~
17507 \InsetSpace ~
17508 \InsetSpace ~
17509 \InsetSpace ~
17510 \InsetSpace ~
17511 \InsetSpace ~
17512 \InsetSpace ~
17513 \InsetSpace ~
17514 xrl\InsetSpace ~
17515  a,_head
17516 \newline
17517 \InsetSpace ~
17518 \InsetSpace ~
17519 \InsetSpace ~
17520 \InsetSpace ~
17521 \InsetSpace ~
17522 \InsetSpace ~
17523 \InsetSpace ~
17524 \InsetSpace ~
17525 ; we
17526  could do an ANL a,#0x0f here to use a smaller buffer (see below)
17527 \newline
17528 \InsetSpace ~
17529 \InsetSpace ~
17530 \InsetSpace ~
17531 \InsetSpace ~
17532 \InsetSpace ~
17533 \InsetSpace ~
17534 \InsetSpace ~
17535 \InsetSpace ~
17536 jz\InsetSpace ~
17537 \InsetSpace ~
17538  t_b_end$
17539 \newline
17540 \InsetSpace ~
17541 \InsetSpace ~
17542 \InsetSpace ~
17543 \InsetSpace ~
17544 \InsetSpace ~
17545 \InsetSpace ~
17546 \InsetSpace ~
17547 \InsetSpace ~
17548 ;
17549 \newline
17550 ;
17551  buf[ head++ ] = c;
17552 \newline
17553 \InsetSpace ~
17554 \InsetSpace ~
17555 \InsetSpace ~
17556 \InsetSpace ~
17557 \InsetSpace ~
17558 \InsetSpace ~
17559 \InsetSpace ~
17560 \InsetSpace ~
17561 mov\InsetSpace ~
17562  a,dpl \InsetSpace ~
17563 \InsetSpace ~
17564 \InsetSpace ~
17565 \InsetSpace ~
17566 \InsetSpace ~
17567 \InsetSpace ~
17568 \InsetSpace ~
17569 ; dpl holds lower byte of function argument
17570 \newline
17571 \InsetSpace ~
17572 \InsetSpace ~
17573 \InsetSpace ~
17574 \InsetSpace ~
17575 \InsetSpace ~
17576 \InsetSpace ~
17577 \InsetSpace ~
17578 \InsetSpace ~
17579 mov\InsetSpace ~
17580
17581  dpl,_head \InsetSpace ~
17582 \InsetSpace ~
17583 \InsetSpace ~
17584 ; buf is 0x100 byte aligned so head can be used directly
17585 \newline
17586 \InsetSpace ~
17587 \InsetSpace ~
17588 \InsetSpace ~
17589 \InsetSpace ~
17590 \InsetSpace ~
17591 \InsetSpace ~
17592 \InsetSpace ~
17593 \InsetSpace ~
17594 mov\InsetSpace ~
17595  dph,#(_bu
17596 f>>8)
17597 \newline
17598 \InsetSpace ~
17599 \InsetSpace ~
17600 \InsetSpace ~
17601 \InsetSpace ~
17602 \InsetSpace ~
17603 \InsetSpace ~
17604 \InsetSpace ~
17605 \InsetSpace ~
17606 movx @dptr,a
17607 \newline
17608 \InsetSpace ~
17609 \InsetSpace ~
17610 \InsetSpace ~
17611 \InsetSpace ~
17612 \InsetSpace ~
17613 \InsetSpace ~
17614 \InsetSpace ~
17615 \InsetSpace ~
17616 inc \InsetSpace ~
17617 _head
17618 \newline
17619 \InsetSpace ~
17620 \InsetSpace ~
17621 \InsetSpace ~
17622 \InsetSpace ~
17623 \InsetSpace ~
17624 \InsetSpace ~
17625 \InsetSpace ~
17626 \InsetSpace ~
17627 ; we could do an ANL _head,#0x0f here to use a
17628  smaller buffer (see above)
17629 \newline
17630 t_b_end$:
17631 \newline
17632 \InsetSpace ~
17633 \InsetSpace ~
17634 \InsetSpace ~
17635 \InsetSpace ~
17636 \InsetSpace ~
17637 \InsetSpace ~
17638 \InsetSpace ~
17639 \InsetSpace ~
17640 ; restore used registers here 
17641 \newline
17642 \InsetSpace ~
17643 \InsetSpace ~
17644 \InsetSpace ~
17645 \InsetSpace ~
17646 _endasm
17647 \begin_inset LatexCommand \index{\_endasm}
17648
17649 \end_inset
17650
17651
17652 \begin_inset LatexCommand \index{\_\_endasm}
17653
17654 \end_inset
17655
17656 ;
17657 \newline
17658 }
17659 \newline
17660 #endif
17661 \end_layout
17662
17663 \begin_layout Standard
17664 The inline assembler code can contain any valid code understood by the assembler
17665 , this includes any assembler directives and comment lines.
17666  The assembler does not like some characters like ':' or ''' in comments.
17667  You'll find an 100+ pages assembler manual in sdcc/as/doc/asxhtm.html
17668 \begin_inset LatexCommand \index{asXXXX (as-gbz80, as-hc08, asx8051, as-z80)}
17669
17670 \end_inset
17671
17672
17673 \begin_inset LatexCommand \index{Assembler documentation}
17674
17675 \end_inset
17676
17677  or online at 
17678 \begin_inset LatexCommand \url{http://sdcc.svn.sourceforge.net/viewvc/*checkout*/sdcc/trunk/sdcc/as/doc/asxhtm.html}
17679
17680 \end_inset
17681
17682 \InsetSpace ~
17683 .
17684 \end_layout
17685
17686 \begin_layout Standard
17687 The compiler does not do any validation of the code within the 
17688 \family typewriter
17689 _asm
17690 \begin_inset LatexCommand \index{\_asm}
17691
17692 \end_inset
17693
17694
17695 \begin_inset LatexCommand \index{\_\_asm}
17696
17697 \end_inset
17698
17699  ...
17700  _endasm
17701 \size footnotesize
17702
17703 \begin_inset LatexCommand \index{\_endasm}
17704
17705 \end_inset
17706
17707
17708 \begin_inset LatexCommand \index{\_\_endasm}
17709
17710 \end_inset
17711
17712
17713 \size default
17714 ;
17715 \family default
17716  keyword pair.
17717  Specifically it will not know which registers are used and thus register
17718  pushing/popping
17719 \begin_inset LatexCommand \index{push/pop}
17720
17721 \end_inset
17722
17723  has to be done manually.
17724  
17725 \end_layout
17726
17727 \begin_layout Standard
17728 It is recommended that each assembly instruction (including labels) be placed
17729  in a separate line (as the example shows).
17730  When the -
17731 \begin_inset ERT
17732 status collapsed
17733
17734 \begin_layout Standard
17735
17736
17737 \backslash
17738 /
17739 \end_layout
17740
17741 \end_inset
17742
17743 -
17744 \emph on
17745 peep-asm
17746 \begin_inset LatexCommand \index{-\/-peep-asm}
17747
17748 \end_inset
17749
17750
17751 \emph default
17752  command line option is used, the inline assembler code will be passed through
17753  the peephole optimizer
17754 \begin_inset LatexCommand \index{Peephole optimizer}
17755
17756 \end_inset
17757
17758 .
17759  There are only a few (if any) cases where this option makes sense, it might
17760  cause some unexpected changes in the inline assembler code.
17761  Please go through the peephole optimizer rules defined in file 
17762 \emph on
17763 SDCCpeeph.def
17764 \emph default
17765  before using this option.
17766 \end_layout
17767
17768 \begin_layout Subsection
17769 Naked Functions
17770 \begin_inset LatexCommand \label{sub:Naked-Functions}
17771
17772 \end_inset
17773
17774
17775 \begin_inset LatexCommand \index{Naked functions}
17776
17777 \end_inset
17778
17779
17780 \end_layout
17781
17782 \begin_layout Standard
17783 A special keyword may be associated with a function declaring it as 
17784 \emph on
17785 _naked
17786 \begin_inset LatexCommand \index{\_naked}
17787
17788 \end_inset
17789
17790
17791 \begin_inset LatexCommand \index{\_\_naked}
17792
17793 \end_inset
17794
17795 .
17796  
17797 \emph default
17798 The 
17799 \emph on
17800 _naked
17801 \emph default
17802  function modifier attribute prevents the compiler from generating prologue
17803 \begin_inset LatexCommand \index{function prologue}
17804
17805 \end_inset
17806
17807  and epilogue
17808 \begin_inset LatexCommand \index{function epilogue}
17809
17810 \end_inset
17811
17812  code for that function.
17813  This means that the user is entirely responsible for such things as saving
17814  any registers that may need to be preserved, selecting the proper register
17815  bank, generating the 
17816 \emph on
17817 return
17818 \emph default
17819  instruction at the end, etc.
17820  Practically, this means that the contents of the function must be written
17821  in inline assembler.
17822  This is particularly useful for interrupt functions, which can have a large
17823  (and often unnecessary) prologue/epilogue.
17824  For example, compare the code generated by these two functions:
17825 \end_layout
17826
17827 \begin_layout Verse
17828
17829 \family typewriter
17830 volatile
17831 \begin_inset LatexCommand \index{volatile}
17832
17833 \end_inset
17834
17835  data unsigned char counter;
17836 \newline
17837
17838 \newline
17839 void simpleInterrupt(void) __interrupt
17840 \begin_inset LatexCommand \index{interrupt}
17841
17842 \end_inset
17843
17844
17845 \begin_inset LatexCommand \index{\_\_interrupt}
17846
17847 \end_inset
17848
17849  (1)
17850 \newline
17851 {
17852 \newline
17853 \InsetSpace ~
17854 \InsetSpace ~
17855 \InsetSpace ~
17856 \InsetSpace ~
17857 counter++;
17858 \newline
17859 }
17860 \newline
17861
17862 \newline
17863 void nakedInterrupt(void) __interrupt (2) __naked
17864 \newline
17865 {
17866 \newline
17867 \InsetSpace ~
17868 \InsetSpace ~
17869 \InsetSpace ~
17870 \InsetSpace ~
17871 _asm
17872 \begin_inset LatexCommand \index{\_asm}
17873
17874 \end_inset
17875
17876
17877 \begin_inset LatexCommand \index{\_\_asm}
17878
17879 \end_inset
17880
17881
17882 \newline
17883 \InsetSpace ~
17884 \InsetSpace ~
17885 \InsetSpace ~
17886 \InsetSpace ~
17887 \InsetSpace ~
17888 \InsetSpace ~
17889 inc\InsetSpace ~
17890 \InsetSpace ~
17891 \InsetSpace ~
17892 \InsetSpace ~
17893 \InsetSpace ~
17894 _counter ; does not change flags, no need to save psw
17895 \newline
17896 \InsetSpace ~
17897 \InsetSpace ~
17898 \InsetSpace ~
17899 \InsetSpace ~
17900 \InsetSpace ~
17901 \InsetSpace ~
17902 reti\InsetSpace ~
17903 \InsetSpace ~
17904 \InsetSpace ~
17905 \InsetSpace ~
17906 ; MUST explicitly
17907  include ret or reti in _naked function.
17908 \newline
17909 \InsetSpace ~
17910 \InsetSpace ~
17911 \InsetSpace ~
17912 \InsetSpace ~
17913 _endasm
17914 \begin_inset LatexCommand \index{\_endasm}
17915
17916 \end_inset
17917
17918
17919 \begin_inset LatexCommand \index{\_\_endasm}
17920
17921 \end_inset
17922
17923 ;
17924 \newline
17925 }
17926 \end_layout
17927
17928 \begin_layout Standard
17929 For an 8051 target, the generated simpleInterrupt looks like:
17930 \end_layout
17931
17932 \begin_layout Verse
17933
17934 \family typewriter
17935 Note, this is an 
17936 \emph on
17937 outdated
17938 \emph default
17939  example, recent versions of SDCC generate
17940 \newline
17941 the 
17942 \emph on
17943 same
17944 \emph default
17945  code for simpleInterrupt() and nakedInterrupt()!
17946 \newline
17947
17948 \newline
17949 _simpleInterrupt:
17950 \newline
17951 \InsetSpace ~
17952 \InsetSpace ~
17953 \InsetSpace ~
17954 \InsetSpace ~
17955 push\InsetSpace ~
17956 \InsetSpace ~
17957 \InsetSpace ~
17958 \InsetSpace ~
17959 acc
17960 \newline
17961 \InsetSpace ~
17962 \InsetSpace ~
17963 \InsetSpace ~
17964 \InsetSpace ~
17965 push\InsetSpace ~
17966 \InsetSpace ~
17967 \InsetSpace ~
17968 \InsetSpace ~
17969 b
17970 \newline
17971 \InsetSpace ~
17972 \InsetSpace ~
17973 \InsetSpace ~
17974 \InsetSpace ~
17975 pu
17976 sh\InsetSpace ~
17977 \InsetSpace ~
17978 \InsetSpace ~
17979 \InsetSpace ~
17980 dpl
17981 \newline
17982 \InsetSpace ~
17983 \InsetSpace ~
17984 \InsetSpace ~
17985 \InsetSpace ~
17986 push\InsetSpace ~
17987 \InsetSpace ~
17988 \InsetSpace ~
17989 \InsetSpace ~
17990 dph
17991 \newline
17992 \InsetSpace ~
17993 \InsetSpace ~
17994 \InsetSpace ~
17995 \InsetSpace ~
17996 push\InsetSpace ~
17997 \InsetSpace ~
17998 \InsetSpace ~
17999 \InsetSpace ~
18000 psw
18001 \newline
18002 \InsetSpace ~
18003 \InsetSpace ~
18004 \InsetSpace ~
18005 \InsetSpace ~
18006 mov\InsetSpace ~
18007 \InsetSpace ~
18008 \InsetSpace ~
18009 \InsetSpace ~
18010 \InsetSpace ~
18011 psw,#0x00
18012 \newline
18013 \InsetSpace ~
18014 \InsetSpace ~
18015 \InsetSpace ~
18016 \InsetSpace ~
18017 inc\InsetSpace ~
18018 \InsetSpace ~
18019 \InsetSpace ~
18020 \InsetSpace ~
18021 \InsetSpace ~
18022 _counter
18023 \newline
18024 \InsetSpace ~
18025 \InsetSpace ~
18026 \InsetSpace ~
18027 \InsetSpace ~
18028 pop\InsetSpace ~
18029 \InsetSpace ~
18030 \InsetSpace ~
18031 \InsetSpace ~
18032 \InsetSpace ~
18033 psw
18034 \newline
18035 \InsetSpace ~
18036 \InsetSpace ~
18037 \InsetSpace ~
18038 \InsetSpace ~
18039 pop\InsetSpace ~
18040 \InsetSpace ~
18041 \InsetSpace ~
18042 \InsetSpace ~
18043 \InsetSpace ~
18044 dph
18045 \newline
18046 \InsetSpace ~
18047 \InsetSpace ~
18048 \InsetSpace ~
18049 \InsetSpace ~
18050 pop\InsetSpace ~
18051 \InsetSpace ~
18052 \InsetSpace ~
18053 \InsetSpace ~
18054 \InsetSpace ~
18055 dpl
18056 \newline
18057 \InsetSpace ~
18058 \InsetSpace ~
18059 \InsetSpace ~
18060 \InsetSpace ~
18061 pop\InsetSpace ~
18062 \InsetSpace ~
18063 \InsetSpace ~
18064 \InsetSpace ~
18065 \InsetSpace ~
18066 b
18067 \newline
18068 \InsetSpace ~
18069 \InsetSpace ~
18070 \InsetSpace ~
18071 \InsetSpace ~
18072 pop\InsetSpace ~
18073 \InsetSpace ~
18074 \InsetSpace ~
18075 \InsetSpace ~
18076 \InsetSpace ~
18077 acc
18078 \newline
18079 \InsetSpace ~
18080 \InsetSpace ~
18081 \InsetSpace ~
18082 \InsetSpace ~
18083 reti
18084 \end_layout
18085
18086 \begin_layout Standard
18087 whereas nakedInterrupt looks like:
18088 \end_layout
18089
18090 \begin_layout Verse
18091
18092 \family typewriter
18093 _nakedInterrupt:
18094 \newline
18095 \InsetSpace ~
18096 \InsetSpace ~
18097 \InsetSpace ~
18098 \InsetSpace ~
18099 inc\InsetSpace ~
18100 \InsetSpace ~
18101 \InsetSpace ~
18102 \InsetSpace ~
18103 _counter ; does not change flags, no need to save psw
18104 \newline
18105 \InsetSpace ~
18106 \InsetSpace ~
18107 \InsetSpace ~
18108 \InsetSpace ~
18109 reti\InsetSpace ~
18110 \InsetSpace ~
18111 \InsetSpace ~
18112 \InsetSpace ~
18113 \InsetSpace ~
18114 \InsetSpace ~
18115 \InsetSpace ~
18116 \InsetSpace ~
18117 \InsetSpace ~
18118 \InsetSpace ~
18119 \InsetSpace ~
18120 \InsetSpace ~
18121 ;
18122  MUST explicitly include ret or reti in _naked function
18123 \end_layout
18124
18125 \begin_layout Standard
18126 The related directive #pragma exclude
18127 \begin_inset LatexCommand \index{\#pragma exclude}
18128
18129 \end_inset
18130
18131  allows a more fine grained control over pushing & popping
18132 \begin_inset LatexCommand \index{push/pop}
18133
18134 \end_inset
18135
18136  the registers.
18137 \end_layout
18138
18139 \begin_layout Standard
18140 While there is nothing preventing you from writing C code inside a 
18141 \family typewriter
18142 _naked
18143 \family default
18144  function, there are many ways to shoot yourself in the foot doing this,
18145  and it is recommended that you stick to inline assembler.
18146 \end_layout
18147
18148 \begin_layout Subsection
18149 Use of Labels within Inline Assembler
18150 \end_layout
18151
18152 \begin_layout Standard
18153 SDCC allows the use of in-line assembler with a few restrictions regarding
18154  labels.
18155  All labels defined within inline assembler code have to be of the form
18156  
18157 \emph on
18158 nnnnn$
18159 \emph default
18160  where nnnnn is a number less than 100 (which implies a limit of utmost
18161  100 inline assembler labels 
18162 \emph on
18163 per function
18164 \emph default
18165 \noun on
18166 )
18167 \noun default
18168 .
18169 \begin_inset Foot
18170 status open
18171
18172 \begin_layout Standard
18173 This is a slightly more stringent rule than absolutely necessary, but stays
18174  always on the safe side.
18175  Labels in the form of nnnnn$ are local labels in the assembler, locality
18176  of which is confined within two labels of the standard form.
18177  The compiler uses the same form for labels within a function (but starting
18178  from nnnnn=00100); and places always a standard label at the beginning
18179  of a function, thus limiting the locality of labels within the scope of
18180  the function.
18181  So, if the inline assembler part would be embedded into C-code, an improperly
18182  placed non-local label in the assembler would break up the reference space
18183  for labels created by the compiler for the C-code, leading to an assembling
18184  error.
18185 \end_layout
18186
18187 \begin_layout Standard
18188 The numeric part of local labels does not need to have 5 digits (although
18189  this is the form of labels output by the compiler), any valid integer will
18190  do.
18191  Please refer to the assemblers documentation for further details.
18192 \end_layout
18193
18194 \end_inset
18195
18196  
18197 \end_layout
18198
18199 \begin_layout Verse
18200
18201 \family typewriter
18202 _asm
18203 \begin_inset LatexCommand \index{\_asm}
18204
18205 \end_inset
18206
18207
18208 \begin_inset LatexCommand \index{\_\_asm}
18209
18210 \end_inset
18211
18212  
18213 \newline
18214 \InsetSpace ~
18215 \InsetSpace ~
18216 \InsetSpace ~
18217 \InsetSpace ~
18218 mov\InsetSpace ~
18219 \InsetSpace ~
18220 \InsetSpace ~
18221 \InsetSpace ~
18222 \InsetSpace ~
18223 b,#10 
18224 \newline
18225 00001$: 
18226 \newline
18227 \InsetSpace ~
18228 \InsetSpace ~
18229 \InsetSpace ~
18230 \InsetSpace ~
18231 djnz\InsetSpace ~
18232 \InsetSpace ~
18233 \InsetSpace ~
18234 \InsetSpace ~
18235 b,00001$ 
18236 \newline
18237 _endasm
18238 \begin_inset LatexCommand \index{\_endasm}
18239
18240 \end_inset
18241
18242
18243 \begin_inset LatexCommand \index{\_\_endasm}
18244
18245 \end_inset
18246
18247  ;
18248 \end_layout
18249
18250 \begin_layout Standard
18251 Inline assembler code cannot reference any C-labels, however it can reference
18252  labels
18253 \begin_inset LatexCommand \index{Labels}
18254
18255 \end_inset
18256
18257  defined by the inline assembler, e.g.:
18258 \end_layout
18259
18260 \begin_layout Verse
18261
18262 \family typewriter
18263 foo() { 
18264 \newline
18265 \InsetSpace ~
18266 \InsetSpace ~
18267 \InsetSpace ~
18268 \InsetSpace ~
18269 /* some c code */ 
18270 \newline
18271 \InsetSpace ~
18272 \InsetSpace ~
18273 \InsetSpace ~
18274 \InsetSpace ~
18275 _asm 
18276 \newline
18277 \InsetSpace ~
18278 \InsetSpace ~
18279 \InsetSpace ~
18280 \InsetSpace ~
18281 \InsetSpace ~
18282 \InsetSpace ~
18283 ; some assembler code 
18284 \newline
18285 \InsetSpace ~
18286 \InsetSpace ~
18287 \InsetSpace ~
18288 \InsetSpace ~
18289 \InsetSpace ~
18290 \InsetSpace ~
18291 ljmp 0003$ 
18292 \newline
18293 \InsetSpace ~
18294 \InsetSpace ~
18295 \InsetSpace ~
18296 \InsetSpace ~
18297 _endasm;
18298  
18299 \newline
18300 \InsetSpace ~
18301 \InsetSpace ~
18302 \InsetSpace ~
18303 \InsetSpace ~
18304 /* some more c code */ 
18305 \newline
18306 clabel:\InsetSpace ~
18307 \InsetSpace ~
18308 /* inline assembler cannot reference this
18309  label */ 
18310 \begin_inset Foot
18311 status open
18312
18313 \begin_layout Standard
18314 Here, the C-label 
18315 \family typewriter
18316 clabel
18317 \family default
18318  is translated by the compiler into a local label, so the locality of labels
18319  within the function is not broken.
18320 \end_layout
18321
18322 \end_inset
18323
18324
18325 \newline
18326 \InsetSpace ~
18327 \InsetSpace ~
18328 \InsetSpace ~
18329 \InsetSpace ~
18330 _asm
18331 \newline
18332 \InsetSpace ~
18333 \InsetSpace ~
18334 \InsetSpace ~
18335 \InsetSpace ~
18336 0003$: ;label (can be referenced by inline assembler only) 
18337 \newline
18338 \InsetSpace ~
18339 \InsetSpace ~
18340 \InsetSpace ~
18341 \InsetSpace ~
18342 _endasm
18343 \begin_inset LatexCommand \index{\_endasm}
18344
18345 \end_inset
18346
18347
18348 \begin_inset LatexCommand \index{\_\_endasm}
18349
18350 \end_inset
18351
18352  ; 
18353 \newline
18354 \InsetSpace ~
18355 \InsetSpace ~
18356 \InsetSpace ~
18357 \InsetSpace ~
18358 /* some more c code */
18359 \newline
18360 }
18361 \end_layout
18362
18363 \begin_layout Standard
18364 In other words inline assembly code can access labels defined in inline
18365  assembly within the scope of the function.
18366  The same goes the other way, i.e.
18367  labels defines in inline assembly can not be accessed by C statements.
18368 \end_layout
18369
18370 \begin_layout Section
18371 Interfacing with Assembler Code
18372 \begin_inset LatexCommand \index{Assembler routines}
18373
18374 \end_inset
18375
18376
18377 \end_layout
18378
18379 \begin_layout Subsection
18380 Global Registers used for Parameter Passing
18381 \begin_inset LatexCommand \index{Parameter passing}
18382
18383 \end_inset
18384
18385
18386 \end_layout
18387
18388 \begin_layout Standard
18389 The compiler always uses the global registers 
18390 \emph on
18391 DPL, DPH
18392 \begin_inset LatexCommand \index{DPTR, DPH, DPL}
18393
18394 \end_inset
18395
18396
18397 \begin_inset LatexCommand \index{DPTR}
18398
18399 \end_inset
18400
18401 , B
18402 \begin_inset LatexCommand \index{B (mcs51, ds390 register)}
18403
18404 \end_inset
18405
18406  
18407 \emph default
18408 and
18409 \emph on
18410  ACC
18411 \begin_inset LatexCommand \index{ACC (mcs51, ds390 register)}
18412
18413 \end_inset
18414
18415
18416 \emph default
18417  to pass the first (non-bit) parameter to a function, and also to pass the
18418  return value 
18419 \begin_inset LatexCommand \index{return value}
18420
18421 \end_inset
18422
18423 of function; according to the following scheme: one byte return value in
18424  
18425 \emph on
18426 DPL
18427 \emph default
18428 , two byte value in 
18429 \emph on
18430 DPL
18431 \emph default
18432  (LSB) and 
18433 \emph on
18434 DPH
18435 \emph default
18436  (MSB).
18437  three byte values (generic pointers) in 
18438 \emph on
18439 DPH
18440 \emph default
18441
18442 \emph on
18443 DPL
18444 \emph default
18445  and 
18446 \emph on
18447 B
18448 \emph default
18449 , and four byte values in 
18450 \emph on
18451 DPH
18452 \emph default
18453
18454 \emph on
18455 DPL
18456 \emph default
18457 ,
18458 \emph on
18459  B
18460 \emph default
18461  and 
18462 \emph on
18463 ACC
18464 \emph default
18465 .
18466  Generic pointers
18467 \begin_inset LatexCommand \index{generic pointer}
18468
18469 \end_inset
18470
18471  contain type of accessed memory in 
18472 \emph on
18473 B
18474 \emph default
18475
18476 \series bold
18477 0x00
18478 \series default
18479  -- xdata/far, 
18480 \series bold
18481 0x40
18482 \series default
18483  -- idata/near -- , 
18484 \series bold
18485 0x60
18486 \series default
18487  -- pdata, 
18488 \series bold
18489 0x80
18490 \series default
18491  -- code
18492 \begin_inset Note Note
18493 status collapsed
18494
18495 \begin_layout Standard
18496 This might not be the case of certain memory models (medium???)
18497 \end_layout
18498
18499 \end_inset
18500
18501 .
18502 \end_layout
18503
18504 \begin_layout Standard
18505 The second parameter onwards is either allocated on the stack (for reentrant
18506  routines or if -
18507 \begin_inset ERT
18508 status collapsed
18509
18510 \begin_layout Standard
18511
18512
18513 \backslash
18514 /
18515 \end_layout
18516
18517 \end_inset
18518
18519 -stack-auto is used) or in data/xdata memory (depending on the memory model).
18520 \end_layout
18521
18522 \begin_layout Standard
18523 Bit parameters are passed in a virtual register called 'bits' in bit-addressable
18524  space for reentrant functions or allocated directly in bit memory otherwise.
18525 \end_layout
18526
18527 \begin_layout Standard
18528 Functions (with two or more parameters or bit parameters) that are called
18529  through function pointers
18530 \begin_inset LatexCommand \index{function pointers}
18531
18532 \end_inset
18533
18534  must therefor be reentrant so the compiler knows how to pass the parameters.
18535 \end_layout
18536
18537 \begin_layout Subsection
18538 Registers usage
18539 \end_layout
18540
18541 \begin_layout Standard
18542 Unless the called function is declared as 
18543 \family typewriter
18544 _naked
18545 \family default
18546
18547 \begin_inset LatexCommand \index{naked}
18548
18549 \end_inset
18550
18551 , or the -
18552 \begin_inset ERT
18553 status collapsed
18554
18555 \begin_layout Standard
18556
18557
18558 \backslash
18559 /
18560 \end_layout
18561
18562 \end_inset
18563
18564 -callee-saves
18565 \begin_inset LatexCommand \index{-\/-callee-saves}
18566
18567 \end_inset
18568
18569 /-
18570 \begin_inset ERT
18571 status collapsed
18572
18573 \begin_layout Standard
18574
18575
18576 \backslash
18577 /
18578 \end_layout
18579
18580 \end_inset
18581
18582 -all-callee-saves command line option or the corresponding callee_saves
18583  pragma are used, the caller will save the registers (
18584 \emph on
18585 R0-R7
18586 \emph default
18587 ) around the call, so the called function can destroy they content freely.
18588 \end_layout
18589
18590 \begin_layout Standard
18591 If the called function is not declared as 
18592 \family typewriter
18593 _naked
18594 \family default
18595 , the caller will swap register banks around the call, if caller and callee
18596  use different register banks (having them defined by the 
18597 \family typewriter
18598 _using
18599 \family default
18600  modifier).
18601  
18602 \end_layout
18603
18604 \begin_layout Standard
18605 The called function can also use 
18606 \emph on
18607 DPL
18608 \emph default
18609
18610 \emph on
18611 DPH
18612 \emph default
18613
18614 \emph on
18615 B
18616 \emph default
18617  and 
18618 \emph on
18619 ACC
18620 \emph default
18621  observing that they are used for parameter/return value passing.
18622 \end_layout
18623
18624 \begin_layout Subsection
18625 Assembler Routine (non-reentrant)
18626 \end_layout
18627
18628 \begin_layout Standard
18629 In the following example
18630 \begin_inset LatexCommand \index{reentrant}
18631
18632 \end_inset
18633
18634
18635 \begin_inset LatexCommand \index{Assembler routines (non-reentrant)}
18636
18637 \end_inset
18638
18639  the function c_func calls an assembler routine asm_func, which takes two
18640  parameters
18641 \begin_inset LatexCommand \index{function parameter}
18642
18643 \end_inset
18644
18645 .
18646 \end_layout
18647
18648 \begin_layout Verse
18649
18650 \family typewriter
18651 extern int asm_func(unsigned char, unsigned char);
18652 \newline
18653
18654 \newline
18655 int c_func (unsigned char
18656  i, unsigned char j)
18657 \newline
18658 {
18659 \newline
18660 \InsetSpace ~
18661 \InsetSpace ~
18662 \InsetSpace ~
18663 \InsetSpace ~
18664 return asm_func(i,j);
18665 \newline
18666 }
18667 \newline
18668
18669 \newline
18670 int main()
18671 \newline
18672 {
18673 \newline
18674 \InsetSpace ~
18675 \InsetSpace ~
18676 \InsetSpace ~
18677 \InsetSpace ~
18678 return c_func(10,9);
18679 \newline
18680 }
18681 \end_layout
18682
18683 \begin_layout Standard
18684 The corresponding assembler function is:
18685 \end_layout
18686
18687 \begin_layout Verse
18688
18689 \family typewriter
18690 .globl _asm_func_PARM_2 
18691 \newline
18692 \InsetSpace ~
18693 \InsetSpace ~
18694 \InsetSpace ~
18695 \InsetSpace ~
18696 \InsetSpace ~
18697 \InsetSpace ~
18698 \InsetSpace ~
18699 \InsetSpace ~
18700 .globl _asm_func 
18701 \newline
18702 \InsetSpace ~
18703 \InsetSpace ~
18704 \InsetSpace ~
18705 \InsetSpace ~
18706 \InsetSpace ~
18707 \InsetSpace ~
18708 \InsetSpace ~
18709 \InsetSpace ~
18710 .area OSEG 
18711 \newline
18712 _asm_func_PARM_2:
18713 \newline
18714 \InsetSpace ~
18715 \InsetSpace ~
18716 \InsetSpace ~
18717 \InsetSpace ~
18718 \InsetSpace ~
18719 \InsetSpace ~
18720 \InsetSpace ~
18721 \InsetSpace ~
18722 .ds   
18723  1 
18724 \newline
18725 \InsetSpace ~
18726 \InsetSpace ~
18727 \InsetSpace ~
18728 \InsetSpace ~
18729 \InsetSpace ~
18730 \InsetSpace ~
18731 \InsetSpace ~
18732 \InsetSpace ~
18733 .area CSEG 
18734 \newline
18735 _asm_func: 
18736 \newline
18737 \InsetSpace ~
18738 \InsetSpace ~
18739 \InsetSpace ~
18740 \InsetSpace ~
18741 \InsetSpace ~
18742 \InsetSpace ~
18743 \InsetSpace ~
18744 \InsetSpace ~
18745 mov\InsetSpace ~
18746 \InsetSpace ~
18747 \InsetSpace ~
18748 \InsetSpace ~
18749 a,dpl 
18750 \newline
18751 \InsetSpace ~
18752 \InsetSpace ~
18753 \InsetSpace ~
18754 \InsetSpace ~
18755 \InsetSpace ~
18756 \InsetSpace ~
18757 \InsetSpace ~
18758 \InsetSpace ~
18759 add\InsetSpace ~
18760 \InsetSpace ~
18761 \InsetSpace ~
18762 \InsetSpace ~
18763 a,_asm_func_PARM_2 
18764 \newline
18765 \InsetSpace ~
18766 \InsetSpace ~
18767 \InsetSpace ~
18768 \InsetSpace ~
18769 \InsetSpace ~
18770 \InsetSpace ~
18771 \InsetSpace ~
18772 \InsetSpace ~
18773 mov\InsetSpace ~
18774 \InsetSpace ~
18775 \InsetSpace ~
18776 \InsetSpace ~
18777 dpl,a 
18778 \newline
18779 \InsetSpace ~
18780 \InsetSpace ~
18781 \InsetSpace ~
18782 \InsetSpace ~
18783 \InsetSpace ~
18784 \InsetSpace ~
18785 \InsetSpace ~
18786 \InsetSpace ~
18787 mov\InsetSpace ~
18788 \InsetSpace ~
18789 \InsetSpace ~
18790 \InsetSpace ~
18791 dph
18792 \begin_inset LatexCommand \index{DPTR, DPH, DPL}
18793
18794 \end_inset
18795
18796 ,#0x00 
18797 \newline
18798 \InsetSpace ~
18799 \InsetSpace ~
18800 \InsetSpace ~
18801 \InsetSpace ~
18802 \InsetSpace ~
18803 \InsetSpace ~
18804 \InsetSpace ~
18805 \InsetSpace ~
18806 ret
18807 \end_layout
18808
18809 \begin_layout Standard
18810 The parameter naming convention is _<function_name>_PARM_<n>, where n is
18811  the parameter number starting from 1, and counting from the left.
18812  The first parameter is passed in 
18813 \emph on
18814 DPH
18815 \emph default
18816
18817 \emph on
18818 DPL
18819 \emph default
18820
18821 \emph on
18822 B
18823 \emph default
18824  and 
18825 \emph on
18826 ACC
18827 \emph default
18828  according to the description above.
18829  The variable name for the second parameter will be _<function_name>_PARM_2.
18830 \newline
18831
18832 \newline
18833 Assem
18834 ble the assembler routine with the following command:
18835 \newline
18836
18837 \newline
18838
18839 \family sans
18840 \series bold
18841 asx8051 -losg asmfunc.asm
18842 \newline
18843
18844 \newline
18845
18846 \family default
18847 \series default
18848 Then compile and link the assembler routine to the C source file with the
18849  following command:
18850 \newline
18851
18852 \newline
18853
18854 \family sans
18855 \series bold
18856 sdcc cfunc.c asmfunc.rel
18857 \end_layout
18858
18859 \begin_layout Subsection
18860 Assembler Routine (reentrant)
18861 \end_layout
18862
18863 \begin_layout Standard
18864 In this case
18865 \begin_inset LatexCommand \index{reentrant}
18866
18867 \end_inset
18868
18869
18870 \begin_inset LatexCommand \index{Assembler routines (reentrant)}
18871
18872 \end_inset
18873
18874  the second parameter
18875 \begin_inset LatexCommand \index{function parameter}
18876
18877 \end_inset
18878
18879  onwards will be passed on the stack, the parameters are pushed from right
18880  to left i.e.
18881  before the call the second leftmost parameter will be on the top of the
18882  stack (the leftmost parameter is passed in registers).
18883  Here is an example:
18884 \end_layout
18885
18886 \begin_layout Verse
18887
18888 \family typewriter
18889 extern int asm_func(unsigned char, unsigned char, unsigned char) reentrant;
18890 \newline
18891
18892 \newline
18893 int
18894  c_func (unsigned char i, unsigned char j, unsigned char k) reentrant 
18895 \newline
18896 {
18897  
18898 \newline
18899 \InsetSpace ~
18900 \InsetSpace ~
18901 \InsetSpace ~
18902 \InsetSpace ~
18903 return asm_func(i,j,k); 
18904 \newline
18905
18906 \newline
18907
18908 \newline
18909 int main() 
18910 \newline
18911
18912 \newline
18913 \InsetSpace ~
18914 \InsetSpace ~
18915 \InsetSpace ~
18916 \InsetSpace ~
18917 return c_func(10,9,8); 
18918 \newline
18919 }
18920 \end_layout
18921
18922 \begin_layout Standard
18923 The corresponding (unoptimized) assembler routine is:
18924 \end_layout
18925
18926 \begin_layout Verse
18927
18928 \family typewriter
18929 .globl _asm_func 
18930 \newline
18931 _asm_func: 
18932 \newline
18933 \InsetSpace ~
18934 \InsetSpace ~
18935 \InsetSpace ~
18936 \InsetSpace ~
18937 push\InsetSpace ~
18938 _bp 
18939 \newline
18940 \InsetSpace ~
18941 \InsetSpace ~
18942 \InsetSpace ~
18943 \InsetSpace ~
18944 mov\InsetSpace ~
18945 \InsetSpace ~
18946 _bp,sp\InsetSpace ~
18947 \InsetSpace ~
18948 \InsetSpace ~
18949 \InsetSpace ~
18950 \InsetSpace ~
18951 \InsetSpace ~
18952 ;stack contains: _bp, return
18953  address, second parameter, third parameter
18954 \newline
18955 \InsetSpace ~
18956 \InsetSpace ~
18957 \InsetSpace ~
18958 \InsetSpace ~
18959 mov\InsetSpace ~
18960 \InsetSpace ~
18961 r2,dpl
18962 \newline
18963 \InsetSpace ~
18964 \InsetSpace ~
18965 \InsetSpace ~
18966 \InsetSpace ~
18967 mov\InsetSpace ~
18968 \InsetSpace ~
18969 a,_bp
18970 \newline
18971 \InsetSpace ~
18972 \InsetSpace ~
18973 \InsetSpace ~
18974 \InsetSpace ~
18975 add\InsetSpace ~
18976 \InsetSpace ~
18977 a,#0xfd\InsetSpace ~
18978 \InsetSpace ~
18979 \InsetSpace ~
18980 \InsetSpace ~
18981 \InsetSpace ~
18982 ;calculate
18983  pointer to the second parameter
18984 \newline
18985 \InsetSpace ~
18986 \InsetSpace ~
18987 \InsetSpace ~
18988 \InsetSpace ~
18989 mov\InsetSpace ~
18990 \InsetSpace ~
18991 r0,a 
18992 \newline
18993 \InsetSpace ~
18994 \InsetSpace ~
18995 \InsetSpace ~
18996 \InsetSpace ~
18997 mov\InsetSpace ~
18998 \InsetSpace ~
18999 a,_bp 
19000 \newline
19001 \InsetSpace ~
19002 \InsetSpace ~
19003 \InsetSpace ~
19004 \InsetSpace ~
19005 add\InsetSpace ~
19006 \InsetSpace ~
19007 a,#0xfc\InsetSpace ~
19008 \InsetSpace ~
19009 \InsetSpace ~
19010 \InsetSpace ~
19011 \InsetSpace ~
19012 ;calculate pointer
19013  to the rightmost parameter
19014 \newline
19015 \InsetSpace ~
19016 \InsetSpace ~
19017 \InsetSpace ~
19018 \InsetSpace ~
19019 mov\InsetSpace ~
19020 \InsetSpace ~
19021 r1,a 
19022 \newline
19023 \InsetSpace ~
19024 \InsetSpace ~
19025 \InsetSpace ~
19026 \InsetSpace ~
19027 mov\InsetSpace ~
19028 \InsetSpace ~
19029 a,@r0
19030 \newline
19031 \InsetSpace ~
19032 \InsetSpace ~
19033 \InsetSpace ~
19034 \InsetSpace ~
19035 add\InsetSpace ~
19036 \InsetSpace ~
19037 a,@r1
19038 \newline
19039 \InsetSpace ~
19040 \InsetSpace ~
19041 \InsetSpace ~
19042 \InsetSpace ~
19043 add\InsetSpace ~
19044 \InsetSpace ~
19045 a,r2\InsetSpace ~
19046 \InsetSpace ~
19047 \InsetSpace ~
19048 \InsetSpace ~
19049 \InsetSpace ~
19050 \InsetSpace ~
19051 \InsetSpace ~
19052 \InsetSpace ~
19053 ;calculate the
19054  result (= sum of all three parameters)
19055 \newline
19056 \InsetSpace ~
19057 \InsetSpace ~
19058 \InsetSpace ~
19059 \InsetSpace ~
19060 mov\InsetSpace ~
19061 \InsetSpace ~
19062 dpl,a\InsetSpace ~
19063 \InsetSpace ~
19064 \InsetSpace ~
19065 \InsetSpace ~
19066 \InsetSpace ~
19067 \InsetSpace ~
19068 \InsetSpace ~
19069 ;return value goes into dptr
19070  (cast into int)
19071 \newline
19072 \InsetSpace ~
19073 \InsetSpace ~
19074 \InsetSpace ~
19075 \InsetSpace ~
19076 mov\InsetSpace ~
19077 \InsetSpace ~
19078 dph,#0x00 
19079 \newline
19080 \InsetSpace ~
19081 \InsetSpace ~
19082 \InsetSpace ~
19083 \InsetSpace ~
19084 mov\InsetSpace ~
19085 \InsetSpace ~
19086 sp,_bp 
19087 \newline
19088 \InsetSpace ~
19089 \InsetSpace ~
19090 \InsetSpace ~
19091 \InsetSpace ~
19092 pop\InsetSpace ~
19093 \InsetSpace ~
19094 _bp 
19095 \newline
19096 \InsetSpace ~
19097 \InsetSpace ~
19098 \InsetSpace ~
19099 \InsetSpace ~
19100 ret
19101 \end_layout
19102
19103 \begin_layout Standard
19104 The compiling and linking procedure remains the same, however note the extra
19105  entry & exit linkage required for the assembler code, _bp is the stack
19106  frame pointer and is used to compute the offset into the stack for parameters
19107  and local variables.
19108 \begin_inset VSpace bigskip
19109 \end_inset
19110
19111
19112 \end_layout
19113
19114 \begin_layout Section
19115 int (16 bit)
19116 \begin_inset LatexCommand \index{int (16 bit)}
19117
19118 \end_inset
19119
19120  and long (32 bit)
19121 \begin_inset LatexCommand \index{long (32 bit)}
19122
19123 \end_inset
19124
19125  Support
19126 \end_layout
19127
19128 \begin_layout Standard
19129 For signed & unsigned int (16 bit) and long (32 bit) variables, division,
19130  multiplication and modulus operations are implemented by support routines.
19131  These support routines are all developed in ANSI-C to facilitate porting
19132  to other MCUs, although some model specific assembler optimizations are
19133  used.
19134  The following files contain the described routines, all of them can be
19135  found in <installdir>/share/sdcc/lib.
19136 \newline
19137
19138 \end_layout
19139
19140 \begin_layout Standard
19141 \align center
19142 \begin_inset Tabular
19143 <lyxtabular version="3" rows="11" columns="2">
19144 <features>
19145 <column alignment="left" valignment="top" leftline="true" width="0">
19146 <column alignment="left" valignment="top" leftline="true" rightline="true" width="0">
19147 <row topline="true" bottomline="true">
19148 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19149 \begin_inset Text
19150
19151 \begin_layout Standard
19152
19153 \series bold
19154 Function
19155 \end_layout
19156
19157 \end_inset
19158 </cell>
19159 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19160 \begin_inset Text
19161
19162 \begin_layout Standard
19163
19164 \series bold
19165 Description
19166 \end_layout
19167
19168 \end_inset
19169 </cell>
19170 </row>
19171 <row topline="true">
19172 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19173 \begin_inset Text
19174
19175 \begin_layout Standard
19176 _mulint.c 
19177 \end_layout
19178
19179 \end_inset
19180 </cell>
19181 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19182 \begin_inset Text
19183
19184 \begin_layout Standard
19185 16 bit multiplication
19186 \end_layout
19187
19188 \end_inset
19189 </cell>
19190 </row>
19191 <row topline="true">
19192 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19193 \begin_inset Text
19194
19195 \begin_layout Standard
19196 _divsint.c 
19197 \end_layout
19198
19199 \end_inset
19200 </cell>
19201 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19202 \begin_inset Text
19203
19204 \begin_layout Standard
19205  signed 16 bit division (calls _divuint)
19206 \end_layout
19207
19208 \end_inset
19209 </cell>
19210 </row>
19211 <row topline="true">
19212 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19213 \begin_inset Text
19214
19215 \begin_layout Standard
19216 _divuint.c 
19217 \end_layout
19218
19219 \end_inset
19220 </cell>
19221 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19222 \begin_inset Text
19223
19224 \begin_layout Standard
19225  unsigned 16 bit division
19226 \end_layout
19227
19228 \end_inset
19229 </cell>
19230 </row>
19231 <row topline="true">
19232 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19233 \begin_inset Text
19234
19235 \begin_layout Standard
19236 _modsint.c
19237 \end_layout
19238
19239 \end_inset
19240 </cell>
19241 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19242 \begin_inset Text
19243
19244 \begin_layout Standard
19245 signed 16 bit modulus (calls _moduint)
19246 \end_layout
19247
19248 \end_inset
19249 </cell>
19250 </row>
19251 <row topline="true">
19252 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19253 \begin_inset Text
19254
19255 \begin_layout Standard
19256 _moduint.c
19257 \end_layout
19258
19259 \end_inset
19260 </cell>
19261 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19262 \begin_inset Text
19263
19264 \begin_layout Standard
19265 unsigned 16 bit modulus
19266 \end_layout
19267
19268 \end_inset
19269 </cell>
19270 </row>
19271 <row topline="true">
19272 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19273 \begin_inset Text
19274
19275 \begin_layout Standard
19276 _mullong.c
19277 \end_layout
19278
19279 \end_inset
19280 </cell>
19281 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19282 \begin_inset Text
19283
19284 \begin_layout Standard
19285 32 bit multiplication
19286 \end_layout
19287
19288 \end_inset
19289 </cell>
19290 </row>
19291 <row topline="true">
19292 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19293 \begin_inset Text
19294
19295 \begin_layout Standard
19296 _divslong.c 
19297 \end_layout
19298
19299 \end_inset
19300 </cell>
19301 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19302 \begin_inset Text
19303
19304 \begin_layout Standard
19305  signed 32 division (calls _divulong)
19306 \end_layout
19307
19308 \end_inset
19309 </cell>
19310 </row>
19311 <row topline="true">
19312 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19313 \begin_inset Text
19314
19315 \begin_layout Standard
19316 _divulong.c 
19317 \end_layout
19318
19319 \end_inset
19320 </cell>
19321 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19322 \begin_inset Text
19323
19324 \begin_layout Standard
19325 unsigned 32 division
19326 \end_layout
19327
19328 \end_inset
19329 </cell>
19330 </row>
19331 <row topline="true">
19332 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19333 \begin_inset Text
19334
19335 \begin_layout Standard
19336 _modslong.c
19337 \end_layout
19338
19339 \end_inset
19340 </cell>
19341 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19342 \begin_inset Text
19343
19344 \begin_layout Standard
19345  signed 32 bit modulus (calls _modulong)
19346 \end_layout
19347
19348 \end_inset
19349 </cell>
19350 </row>
19351 <row topline="true" bottomline="true">
19352 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19353 \begin_inset Text
19354
19355 \begin_layout Standard
19356 _modulong.c
19357 \end_layout
19358
19359 \end_inset
19360 </cell>
19361 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19362 \begin_inset Text
19363
19364 \begin_layout Standard
19365 unsigned 32 bit modulus
19366 \end_layout
19367
19368 \end_inset
19369 </cell>
19370 </row>
19371 </lyxtabular>
19372
19373 \end_inset
19374
19375
19376 \newline
19377
19378 \end_layout
19379
19380 \begin_layout Standard
19381 Since they are compiled as 
19382 \emph on
19383 non-reentrant
19384 \emph default
19385
19386 \begin_inset LatexCommand \index{reentrant}
19387
19388 \end_inset
19389
19390 , interrupt
19391 \begin_inset LatexCommand \index{interrupt}
19392
19393 \end_inset
19394
19395  service routines should not do any of the above operations.
19396  If this is unavoidable then the above routines will need to be compiled
19397  with the 
19398 \emph on
19399 -
19400 \begin_inset ERT
19401 status collapsed
19402
19403 \begin_layout Standard
19404
19405
19406 \backslash
19407 /
19408 \end_layout
19409
19410 \end_inset
19411
19412 -stack-auto
19413 \begin_inset LatexCommand \index{-\/-stack-auto}
19414
19415 \end_inset
19416
19417
19418 \emph default
19419  option, after which the source program will have to be compiled with 
19420 \emph on
19421 -
19422 \begin_inset ERT
19423 status collapsed
19424
19425 \begin_layout Standard
19426
19427
19428 \backslash
19429 /
19430 \end_layout
19431
19432 \end_inset
19433
19434 -int-long-reent
19435 \begin_inset LatexCommand \index{-\/-int-long-reent}
19436
19437 \end_inset
19438
19439
19440 \emph default
19441  option.
19442  Notice that you don't have to call these routines directly.
19443  The compiler will use them automatically every time an integer operation
19444  is required.
19445 \end_layout
19446
19447 \begin_layout Section
19448 Floating Point Support
19449 \begin_inset LatexCommand \index{Floating point support}
19450
19451 \end_inset
19452
19453
19454 \end_layout
19455
19456 \begin_layout Standard
19457 SDCC supports IEEE (single precision 4 bytes) floating point numbers.
19458  The floating point support routines are derived from gcc's floatlib.c and
19459  consist of the following routines:
19460 \newline
19461
19462 \end_layout
19463
19464 \begin_layout Standard
19465 \align center
19466
19467 \size footnotesize
19468 \begin_inset Tabular
19469 <lyxtabular version="3" rows="17" columns="2">
19470 <features>
19471 <column alignment="left" valignment="top" leftline="true" width="0">
19472 <column alignment="left" valignment="top" leftline="true" rightline="true" width="0">
19473 <row topline="true" bottomline="true">
19474 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19475 \begin_inset Text
19476
19477 \begin_layout Standard
19478
19479 \family roman
19480 \series medium
19481 \shape up
19482 \size normal
19483 \emph off
19484 \bar no
19485 \noun off
19486 \color none
19487 Function 
19488 \end_layout
19489
19490 \end_inset
19491 </cell>
19492 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19493 \begin_inset Text
19494
19495 \begin_layout Standard
19496 Description
19497 \end_layout
19498
19499 \end_inset
19500 </cell>
19501 </row>
19502 <row topline="true">
19503 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19504 \begin_inset Text
19505
19506 \begin_layout Standard
19507
19508 \family roman
19509 \series medium
19510 \shape up
19511 \size normal
19512 \emph off
19513 \bar no
19514 \noun off
19515 \color none
19516 _fsadd.c
19517 \end_layout
19518
19519 \end_inset
19520 </cell>
19521 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19522 \begin_inset Text
19523
19524 \begin_layout Standard
19525
19526 \family roman
19527 \series medium
19528 \shape up
19529 \size normal
19530 \emph off
19531 \bar no
19532 \noun off
19533 \color none
19534 add floating point numbers
19535 \end_layout
19536
19537 \end_inset
19538 </cell>
19539 </row>
19540 <row topline="true">
19541 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19542 \begin_inset Text
19543
19544 \begin_layout Standard
19545
19546 \family roman
19547 \series medium
19548 \shape up
19549 \size normal
19550 \emph off
19551 \bar no
19552 \noun off
19553 \color none
19554 _fssub.c 
19555 \end_layout
19556
19557 \end_inset
19558 </cell>
19559 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19560 \begin_inset Text
19561
19562 \begin_layout Standard
19563
19564 \family roman
19565 \series medium
19566 \shape up
19567 \size normal
19568 \emph off
19569 \bar no
19570 \noun off
19571 \color none
19572 subtract floating point numbers 
19573 \end_layout
19574
19575 \end_inset
19576 </cell>
19577 </row>
19578 <row topline="true">
19579 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19580 \begin_inset Text
19581
19582 \begin_layout Standard
19583
19584 \family roman
19585 \series medium
19586 \shape up
19587 \size normal
19588 \emph off
19589 \bar no
19590 \noun off
19591 \color none
19592 _fsdiv.c 
19593 \end_layout
19594
19595 \end_inset
19596 </cell>
19597 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19598 \begin_inset Text
19599
19600 \begin_layout Standard
19601
19602 \family roman
19603 \series medium
19604 \shape up
19605 \size normal
19606 \emph off
19607 \bar no
19608 \noun off
19609 \color none
19610 divide floating point numbers 
19611 \end_layout
19612
19613 \end_inset
19614 </cell>
19615 </row>
19616 <row topline="true">
19617 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19618 \begin_inset Text
19619
19620 \begin_layout Standard
19621
19622 \family roman
19623 \series medium
19624 \shape up
19625 \size normal
19626 \emph off
19627 \bar no
19628 \noun off
19629 \color none
19630 _fsmul.c 
19631 \end_layout
19632
19633 \end_inset
19634 </cell>
19635 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19636 \begin_inset Text
19637
19638 \begin_layout Standard
19639
19640 \family roman
19641 \series medium
19642 \shape up
19643 \size normal
19644 \emph off
19645 \bar no
19646 \noun off
19647 \color none
19648 multiply floating point numbers 
19649 \end_layout
19650
19651 \end_inset
19652 </cell>
19653 </row>
19654 <row topline="true">
19655 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19656 \begin_inset Text
19657
19658 \begin_layout Standard
19659
19660 \family roman
19661 \series medium
19662 \shape up
19663 \size normal
19664 \emph off
19665 \bar no
19666 \noun off
19667 \color none
19668 _fs2uchar.c
19669 \end_layout
19670
19671 \end_inset
19672 </cell>
19673 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19674 \begin_inset Text
19675
19676 \begin_layout Standard
19677
19678 \family roman
19679 \series medium
19680 \shape up
19681 \size normal
19682 \emph off
19683 \bar no
19684 \noun off
19685 \color none
19686 convert floating point to unsigned char
19687 \end_layout
19688
19689 \end_inset
19690 </cell>
19691 </row>
19692 <row topline="true">
19693 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19694 \begin_inset Text
19695
19696 \begin_layout Standard
19697
19698 \family roman
19699 \series medium
19700 \shape up
19701 \size normal
19702 \emph off
19703 \bar no
19704 \noun off
19705 \color none
19706 _fs2char.c
19707 \end_layout
19708
19709 \end_inset
19710 </cell>
19711 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19712 \begin_inset Text
19713
19714 \begin_layout Standard
19715
19716 \family roman
19717 \series medium
19718 \shape up
19719 \size normal
19720 \emph off
19721 \bar no
19722 \noun off
19723 \color none
19724 convert floating point to signed char
19725 \end_layout
19726
19727 \end_inset
19728 </cell>
19729 </row>
19730 <row topline="true">
19731 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19732 \begin_inset Text
19733
19734 \begin_layout Standard
19735
19736 \family roman
19737 \series medium
19738 \shape up
19739 \size normal
19740 \emph off
19741 \bar no
19742 \noun off
19743 \color none
19744 _fs2uint.c
19745 \end_layout
19746
19747 \end_inset
19748 </cell>
19749 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19750 \begin_inset Text
19751
19752 \begin_layout Standard
19753
19754 \family roman
19755 \series medium
19756 \shape up
19757 \size normal
19758 \emph off
19759 \bar no
19760 \noun off
19761 \color none
19762 convert floating point to unsigned int
19763 \end_layout
19764
19765 \end_inset
19766 </cell>
19767 </row>
19768 <row topline="true">
19769 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19770 \begin_inset Text
19771
19772 \begin_layout Standard
19773
19774 \family roman
19775 \series medium
19776 \shape up
19777 \size normal
19778 \emph off
19779 \bar no
19780 \noun off
19781 \color none
19782 _fs2int.c
19783 \end_layout
19784
19785 \end_inset
19786 </cell>
19787 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19788 \begin_inset Text
19789
19790 \begin_layout Standard
19791
19792 \family roman
19793 \series medium
19794 \shape up
19795 \size normal
19796 \emph off
19797 \bar no
19798 \noun off
19799 \color none
19800 convert floating point to signed int
19801 \end_layout
19802
19803 \end_inset
19804 </cell>
19805 </row>
19806 <row topline="true">
19807 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19808 \begin_inset Text
19809
19810 \begin_layout Standard
19811
19812 \family roman
19813 \series medium
19814 \shape up
19815 \size normal
19816 \emph off
19817 \bar no
19818 \noun off
19819 \color none
19820 _fs2ulong.
19821 \family default
19822 \series default
19823 \shape default
19824 \size default
19825 \emph default
19826 \bar default
19827 \noun default
19828 c
19829 \end_layout
19830
19831 \end_inset
19832 </cell>
19833 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19834 \begin_inset Text
19835
19836 \begin_layout Standard
19837
19838 \family roman
19839 \series medium
19840 \shape up
19841 \size normal
19842 \emph off
19843 \bar no
19844 \noun off
19845 \color none
19846 convert floating point to unsigned long
19847 \end_layout
19848
19849 \end_inset
19850 </cell>
19851 </row>
19852 <row topline="true">
19853 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19854 \begin_inset Text
19855
19856 \begin_layout Standard
19857
19858 \family roman
19859 \series medium
19860 \shape up
19861 \size normal
19862 \emph off
19863 \bar no
19864 \noun off
19865 \color none
19866 _fs2long.c
19867 \end_layout
19868
19869 \end_inset
19870 </cell>
19871 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19872 \begin_inset Text
19873
19874 \begin_layout Standard
19875
19876 \family roman
19877 \series medium
19878 \shape up
19879 \size normal
19880 \emph off
19881 \bar no
19882 \noun off
19883 \color none
19884 convert floating point to signed long
19885 \end_layout
19886
19887 \end_inset
19888 </cell>
19889 </row>
19890 <row topline="true">
19891 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19892 \begin_inset Text
19893
19894 \begin_layout Standard
19895
19896 \family roman
19897 \series medium
19898 \shape up
19899 \size normal
19900 \emph off
19901 \bar no
19902 \noun off
19903 \color none
19904 _uchar2fs.c
19905 \end_layout
19906
19907 \end_inset
19908 </cell>
19909 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19910 \begin_inset Text
19911
19912 \begin_layout Standard
19913
19914 \family roman
19915 \series medium
19916 \shape up
19917 \size normal
19918 \emph off
19919 \bar no
19920 \noun off
19921 \color none
19922 convert unsigned char to floating point
19923 \end_layout
19924
19925 \end_inset
19926 </cell>
19927 </row>
19928 <row topline="true">
19929 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19930 \begin_inset Text
19931
19932 \begin_layout Standard
19933
19934 \family roman
19935 \series medium
19936 \shape up
19937 \size normal
19938 \emph off
19939 \bar no
19940 \noun off
19941 \color none
19942 _char2fs.c
19943 \end_layout
19944
19945 \end_inset
19946 </cell>
19947 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19948 \begin_inset Text
19949
19950 \begin_layout Standard
19951
19952 \family roman
19953 \series medium
19954 \shape up
19955 \size normal
19956 \emph off
19957 \bar no
19958 \noun off
19959 \color none
19960 convert char to floating point number
19961 \end_layout
19962
19963 \end_inset
19964 </cell>
19965 </row>
19966 <row topline="true">
19967 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19968 \begin_inset Text
19969
19970 \begin_layout Standard
19971
19972 \family roman
19973 \series medium
19974 \shape up
19975 \size normal
19976 \emph off
19977 \bar no
19978 \noun off
19979 \color none
19980 _uint2fs.c
19981 \end_layout
19982
19983 \end_inset
19984 </cell>
19985 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19986 \begin_inset Text
19987
19988 \begin_layout Standard
19989
19990 \family roman
19991 \series medium
19992 \shape up
19993 \size normal
19994 \emph off
19995 \bar no
19996 \noun off
19997 \color none
19998 convert unsigned int to floating point
19999 \end_layout
20000
20001 \end_inset
20002 </cell>
20003 </row>
20004 <row topline="true">
20005 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20006 \begin_inset Text
20007
20008 \begin_layout Standard
20009
20010 \family roman
20011 \series medium
20012 \shape up
20013 \size normal
20014 \emph off
20015 \bar no
20016 \noun off
20017 \color none
20018 _int2fs.c
20019 \end_layout
20020
20021 \end_inset
20022 </cell>
20023 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20024 \begin_inset Text
20025
20026 \begin_layout Standard
20027
20028 \family roman
20029 \series medium
20030 \shape up
20031 \size normal
20032 \emph off
20033 \bar no
20034 \noun off
20035 \color none
20036 convert int to floating point numbers
20037 \end_layout
20038
20039 \end_inset
20040 </cell>
20041 </row>
20042 <row topline="true">
20043 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20044 \begin_inset Text
20045
20046 \begin_layout Standard
20047
20048 \family roman
20049 \series medium
20050 \shape up
20051 \size normal
20052 \emph off
20053 \bar no
20054 \noun off
20055 \color none
20056 _ulong2fs.c
20057 \end_layout
20058
20059 \end_inset
20060 </cell>
20061 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20062 \begin_inset Text
20063
20064 \begin_layout Standard
20065
20066 \family roman
20067 \series medium
20068 \shape up
20069 \size normal
20070 \emph off
20071 \bar no
20072 \noun off
20073 \color none
20074 convert unsigned long to floating point number
20075 \end_layout
20076
20077 \end_inset
20078 </cell>
20079 </row>
20080 <row topline="true" bottomline="true">
20081 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20082 \begin_inset Text
20083
20084 \begin_layout Standard
20085
20086 \family roman
20087 \series medium
20088 \shape up
20089 \size normal
20090 \emph off
20091 \bar no
20092 \noun off
20093 \color none
20094 _long2fs.c
20095 \end_layout
20096
20097 \end_inset
20098 </cell>
20099 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20100 \begin_inset Text
20101
20102 \begin_layout Standard
20103
20104 \family roman
20105 \series medium
20106 \shape up
20107 \size normal
20108 \emph off
20109 \bar no
20110 \noun off
20111 \color none
20112 convert long to floating point number
20113 \end_layout
20114
20115 \end_inset
20116 </cell>
20117 </row>
20118 </lyxtabular>
20119
20120 \end_inset
20121
20122
20123 \newline
20124
20125 \end_layout
20126
20127 \begin_layout Standard
20128 These support routines are developed in ANSI-C so there is room for space
20129  and speed improvement
20130 \begin_inset Foot
20131 status open
20132
20133 \begin_layout Standard
20134 These floating point routines (
20135 \emph on
20136 not
20137 \emph default
20138  sinf(), cosf(), ...) for the mcs51 are implemented in assembler.
20139  
20140 \end_layout
20141
20142 \end_inset
20143
20144 .
20145  Note if all these routines are used simultaneously the data space might
20146  overflow.
20147  For serious floating point usage the large model might be needed.
20148  Also notice that you don't have to call this routines directly.
20149  The compiler will use them automatically every time a floating point operation
20150  is required.
20151 \begin_inset VSpace bigskip
20152 \end_inset
20153
20154
20155 \end_layout
20156
20157 \begin_layout Section
20158 Library Routines
20159 \begin_inset LatexCommand \index{Libraries}
20160
20161 \end_inset
20162
20163
20164 \end_layout
20165
20166 \begin_layout Standard
20167
20168 \emph on
20169 <pending: this is messy and incomplete - a little more information is in
20170  sdcc/doc/libdoc.txt
20171 \emph default
20172  >
20173 \end_layout
20174
20175 \begin_layout Subsection
20176 Compiler support routines (_gptrget, _mulint etc.)
20177 \end_layout
20178
20179 \begin_layout Subsection
20180 Stdclib functions (puts, printf, strcat etc.)
20181 \end_layout
20182
20183 \begin_layout Subsubsection
20184 <stdio.h>
20185 \end_layout
20186
20187 \begin_layout Paragraph
20188 getchar(), putchar()
20189 \end_layout
20190
20191 \begin_layout Standard
20192 \begin_inset LatexCommand \index{<stdio.h>}
20193
20194 \end_inset
20195
20196 As usual on embedded systems you have to provide your own 
20197 \family typewriter
20198 getchar()
20199 \begin_inset LatexCommand \index{getchar()}
20200
20201 \end_inset
20202
20203  
20204 \family default
20205 and 
20206 \family typewriter
20207 putchar()
20208 \begin_inset LatexCommand \index{putchar()}
20209
20210 \end_inset
20211
20212
20213 \family default
20214  routines.
20215  SDCC does not know whether the system connects to a serial line with or
20216  without handshake, LCD, keyboard or other device.
20217  And whether a 
20218 \family typewriter
20219 lf
20220 \family default
20221  to 
20222 \family typewriter
20223 crlf
20224 \family default
20225  conversion within 
20226 \family typewriter
20227 putchar()
20228 \family default
20229  is intended.
20230  You'll find examples for serial routines f.e.
20231  in sdcc/device/lib.
20232  For the mcs51 this minimalistic polling 
20233 \family typewriter
20234 putchar()
20235 \family default
20236  routine might be a start:
20237 \end_layout
20238
20239 \begin_layout Verse
20240
20241 \family typewriter
20242 void putchar (char c) { 
20243 \newline
20244 \InsetSpace ~
20245 \InsetSpace ~
20246 \InsetSpace ~
20247 \InsetSpace ~
20248 while (!TI)\InsetSpace ~
20249 \InsetSpace ~
20250 \InsetSpace ~
20251  /* assumes UART is initialized */
20252 \newline
20253 \InsetSpace ~
20254 \InsetSpace ~
20255 \InsetSpace ~
20256 \InsetSpace ~
20257 \InsetSpace ~
20258 \InsetSpace ~
20259 \InsetSpace ~
20260 \InsetSpace ~
20261 ;
20262 \newline
20263 \InsetSpace ~
20264 \InsetSpace ~
20265 \InsetSpace ~
20266 \InsetSpace ~
20267 TI
20268  = 0;
20269 \newline
20270 \InsetSpace ~
20271 \InsetSpace ~
20272 \InsetSpace ~
20273 \InsetSpace ~
20274 SBUF = c;
20275 \newline
20276 }
20277 \end_layout
20278
20279 \begin_layout Paragraph
20280 printf()
20281 \end_layout
20282
20283 \begin_layout Standard
20284 The default
20285 \family typewriter
20286  printf()
20287 \begin_inset LatexCommand \index{printf()}
20288
20289 \end_inset
20290
20291
20292 \family default
20293  implementation in
20294 \family typewriter
20295  printf_large.c
20296 \family default
20297  does not support float (except on ds390).
20298  To enable this recompile it with the option 
20299 \emph on
20300 -
20301 \begin_inset ERT
20302 status collapsed
20303
20304 \begin_layout Standard
20305
20306
20307 \backslash
20308 /
20309 \end_layout
20310
20311 \end_inset
20312
20313 DUSE_FLOATS=1
20314 \begin_inset LatexCommand \index{USE\_FLOATS}
20315
20316 \end_inset
20317
20318
20319 \emph default
20320  on the command line.
20321  Use
20322 \emph on
20323  -
20324 \begin_inset ERT
20325 status collapsed
20326
20327 \begin_layout Standard
20328
20329
20330 \backslash
20331 /
20332 \end_layout
20333
20334 \end_inset
20335
20336 -model-large
20337 \begin_inset LatexCommand \index{-\/-model-large}
20338
20339 \end_inset
20340
20341
20342 \emph default
20343  for the mcs51 port, since this uses a lot of memory.
20344 \end_layout
20345
20346 \begin_layout Standard
20347 If you're short on code memory you might want to use 
20348 \family typewriter
20349 printf_small()
20350 \begin_inset LatexCommand \index{printf\_small()}
20351
20352 \end_inset
20353
20354
20355 \family default
20356  
20357 \emph on
20358 instead
20359 \emph default
20360  of
20361 \family typewriter
20362  printf().
20363
20364 \family default
20365  For the mcs51 there additionally are assembly versions 
20366 \family typewriter
20367 printf_tiny()
20368 \begin_inset LatexCommand \index{printf\_tiny() (mcs51)}
20369
20370 \end_inset
20371
20372
20373 \family default
20374  (subset of printf using less than 270 bytes) and 
20375 \family typewriter
20376 printf_fast()
20377 \begin_inset LatexCommand \index{printf\_fast() (mcs51)}
20378
20379 \end_inset
20380
20381  
20382 \family default
20383 and
20384 \family typewriter
20385  printf_fast_f()
20386 \begin_inset LatexCommand \index{printf\_fast\_f() (mcs51)}
20387
20388 \end_inset
20389
20390
20391 \family default
20392  (floating-point aware version of printf_fast) which should fit the requirements
20393  of many embedded systems (printf_fast() can be customized by unsetting
20394  #defines to 
20395 \emph on
20396 not
20397 \emph default
20398  support long variables and field widths).
20399  Be sure to use only one of these printf options within a project.
20400 \newline
20401
20402 \end_layout
20403
20404 \begin_layout Standard
20405 Feature matrix of different 
20406 \emph on
20407 printf
20408 \emph default
20409  options on mcs51.
20410 \end_layout
20411
20412 \begin_layout Standard
20413 \begin_inset Tabular
20414 <lyxtabular version="3" rows="14" columns="7">
20415 <features islongtable="true">
20416 <column alignment="left" valignment="middle" leftline="true" width="14col%">
20417 <column alignment="center" valignment="top" leftline="true" width="0">
20418 <column alignment="center" valignment="top" leftline="true" width="12col%">
20419 <column alignment="center" valignment="top" leftline="true" width="10col%">
20420 <column alignment="center" valignment="top" leftline="true" width="0">
20421 <column alignment="center" valignment="top" leftline="true" rightline="true" width="12col%">
20422 <column alignment="center" valignment="top" rightline="true" width="0">
20423 <row topline="true" bottomline="true" endhead="true">
20424 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20425 \begin_inset Text
20426
20427 \begin_layout Standard
20428
20429 \series bold
20430 \size large
20431 mcs51
20432 \end_layout
20433
20434 \end_inset
20435 </cell>
20436 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20437 \begin_inset Text
20438
20439 \begin_layout Standard
20440 printf
20441 \begin_inset LatexCommand \index{printf}
20442
20443 \end_inset
20444
20445
20446 \end_layout
20447
20448 \end_inset
20449 </cell>
20450 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20451 \begin_inset Text
20452
20453 \begin_layout Standard
20454 printf 
20455 \size scriptsize
20456 USE_FLOATS=1
20457 \end_layout
20458
20459 \end_inset
20460 </cell>
20461 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20462 \begin_inset Text
20463
20464 \begin_layout Standard
20465 printf_small
20466 \end_layout
20467
20468 \end_inset
20469 </cell>
20470 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20471 \begin_inset Text
20472
20473 \begin_layout Standard
20474 printf_fast
20475 \end_layout
20476
20477 \end_inset
20478 </cell>
20479 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20480 \begin_inset Text
20481
20482 \begin_layout Standard
20483 printf_fast_f
20484 \end_layout
20485
20486 \end_inset
20487 </cell>
20488 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20489 \begin_inset Text
20490
20491 \begin_layout Standard
20492 printf_tiny
20493 \end_layout
20494
20495 \end_inset
20496 </cell>
20497 </row>
20498 <row topline="true" endhead="true">
20499 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20500 \begin_inset Text
20501
20502 \begin_layout Standard
20503 filename
20504 \end_layout
20505
20506 \end_inset
20507 </cell>
20508 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20509 \begin_inset Text
20510
20511 \begin_layout Standard
20512
20513 \size scriptsize
20514 printf_large.c
20515 \end_layout
20516
20517 \end_inset
20518 </cell>
20519 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20520 \begin_inset Text
20521
20522 \begin_layout Standard
20523
20524 \size scriptsize
20525 printf_large.c
20526 \end_layout
20527
20528 \end_inset
20529 </cell>
20530 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20531 \begin_inset Text
20532
20533 \begin_layout Standard
20534
20535 \size scriptsize
20536 printfl.c
20537 \end_layout
20538
20539 \end_inset
20540 </cell>
20541 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20542 \begin_inset Text
20543
20544 \begin_layout Standard
20545
20546 \size scriptsize
20547 printf_fast.c
20548 \end_layout
20549
20550 \end_inset
20551 </cell>
20552 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20553 \begin_inset Text
20554
20555 \begin_layout Standard
20556
20557 \size scriptsize
20558 printf_fast_f.c
20559 \end_layout
20560
20561 \end_inset
20562 </cell>
20563 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20564 \begin_inset Text
20565
20566 \begin_layout Standard
20567
20568 \size scriptsize
20569 printf_tiny.c
20570 \end_layout
20571
20572 \end_inset
20573 </cell>
20574 </row>
20575 <row topline="true" endhead="true">
20576 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20577 \begin_inset Text
20578
20579 \begin_layout Standard
20580 \begin_inset Quotes sld
20581 \end_inset
20582
20583 Hello World
20584 \begin_inset Quotes srd
20585 \end_inset
20586
20587  size
20588 \end_layout
20589
20590 \begin_layout Standard
20591 small / large
20592 \end_layout
20593
20594 \end_inset
20595 </cell>
20596 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20597 \begin_inset Text
20598
20599 \begin_layout Standard
20600 1.7k / 2.4k
20601 \end_layout
20602
20603 \end_inset
20604 </cell>
20605 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20606 \begin_inset Text
20607
20608 \begin_layout Standard
20609 4.3k / 5.6k
20610 \end_layout
20611
20612 \end_inset
20613 </cell>
20614 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20615 \begin_inset Text
20616
20617 \begin_layout Standard
20618 1.2k / 1.8k
20619 \end_layout
20620
20621 \end_inset
20622 </cell>
20623 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20624 \begin_inset Text
20625
20626 \begin_layout Standard
20627 1.3k / 1.3k
20628 \end_layout
20629
20630 \end_inset
20631 </cell>
20632 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20633 \begin_inset Text
20634
20635 \begin_layout Standard
20636 1.9k / 1.9k
20637 \end_layout
20638
20639 \end_inset
20640 </cell>
20641 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20642 \begin_inset Text
20643
20644 \begin_layout Standard
20645 0.44k / 0.44k
20646 \end_layout
20647
20648 \end_inset
20649 </cell>
20650 </row>
20651 <row topline="true" endhead="true">
20652 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20653 \begin_inset Text
20654
20655 \begin_layout Standard
20656 code size
20657 \end_layout
20658
20659 \begin_layout Standard
20660 small / large
20661 \end_layout
20662
20663 \end_inset
20664 </cell>
20665 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20666 \begin_inset Text
20667
20668 \begin_layout Standard
20669 1.4k / 2.0k
20670 \end_layout
20671
20672 \end_inset
20673 </cell>
20674 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20675 \begin_inset Text
20676
20677 \begin_layout Standard
20678 2.8k / 3.7k
20679 \end_layout
20680
20681 \end_inset
20682 </cell>
20683 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20684 \begin_inset Text
20685
20686 \begin_layout Standard
20687 0.45k / 0.47k (+ _ltoa)
20688 \end_layout
20689
20690 \end_inset
20691 </cell>
20692 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20693 \begin_inset Text
20694
20695 \begin_layout Standard
20696 1.2k / 1.2k
20697 \end_layout
20698
20699 \end_inset
20700 </cell>
20701 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20702 \begin_inset Text
20703
20704 \begin_layout Standard
20705 1.6k / 1.6k
20706 \end_layout
20707
20708 \end_inset
20709 </cell>
20710 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20711 \begin_inset Text
20712
20713 \begin_layout Standard
20714 0.26k / 0.26k
20715 \end_layout
20716
20717 \end_inset
20718 </cell>
20719 </row>
20720 <row topline="true">
20721 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20722 \begin_inset Text
20723
20724 \begin_layout Standard
20725 formats
20726 \end_layout
20727
20728 \end_inset
20729 </cell>
20730 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20731 \begin_inset Text
20732
20733 \begin_layout Standard
20734 cdi
20735 \emph on
20736 o
20737 \emph default
20738 psux
20739 \end_layout
20740
20741 \end_inset
20742 </cell>
20743 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20744 \begin_inset Text
20745
20746 \begin_layout Standard
20747
20748 \family roman
20749 \series medium
20750 \shape up
20751 \size normal
20752 \emph off
20753 \bar no
20754 \noun off
20755 \color none
20756 cd
20757 \family default
20758 \series default
20759 \shape default
20760 \size default
20761 \emph default
20762 \bar default
20763 \noun default
20764 f
20765 \family roman
20766 \series medium
20767 \shape up
20768 \size normal
20769 \emph off
20770 \bar no
20771 \noun off
20772 i
20773 \family default
20774 \series default
20775 \shape default
20776 \size default
20777 \emph on
20778 \bar default
20779 \noun default
20780 o
20781 \family roman
20782 \series medium
20783 \shape up
20784 \size normal
20785 \emph off
20786 \bar no
20787 \noun off
20788 psux
20789 \end_layout
20790
20791 \end_inset
20792 </cell>
20793 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20794 \begin_inset Text
20795
20796 \begin_layout Standard
20797 c
20798 \family roman
20799 \series medium
20800 \shape up
20801 \size normal
20802 \emph off
20803 \bar no
20804 \noun off
20805 \color none
20806 d
20807 \family default
20808 \series default
20809 \shape default
20810 \size default
20811 \emph on
20812 \bar default
20813 \noun default
20814 o
20815 \family roman
20816 \series medium
20817 \shape up
20818 \size normal
20819 \emph off
20820 \bar no
20821 \noun off
20822 s
20823 \family default
20824 \series default
20825 \shape default
20826 \size default
20827 \emph default
20828 \bar default
20829 \noun default
20830 x
20831 \end_layout
20832
20833 \end_inset
20834 </cell>
20835 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20836 \begin_inset Text
20837
20838 \begin_layout Standard
20839 cdsux
20840 \end_layout
20841
20842 \end_inset
20843 </cell>
20844 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20845 \begin_inset Text
20846
20847 \begin_layout Standard
20848 cdfsux
20849 \end_layout
20850
20851 \end_inset
20852 </cell>
20853 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20854 \begin_inset Text
20855
20856 \begin_layout Standard
20857 cdsux
20858 \end_layout
20859
20860 \end_inset
20861 </cell>
20862 </row>
20863 <row topline="true">
20864 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20865 \begin_inset Text
20866
20867 \begin_layout Standard
20868 long (32 bit) support
20869 \end_layout
20870
20871 \end_inset
20872 </cell>
20873 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20874 \begin_inset Text
20875
20876 \begin_layout Standard
20877 x
20878 \end_layout
20879
20880 \end_inset
20881 </cell>
20882 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20883 \begin_inset Text
20884
20885 \begin_layout Standard
20886 x
20887 \end_layout
20888
20889 \end_inset
20890 </cell>
20891 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20892 \begin_inset Text
20893
20894 \begin_layout Standard
20895 x
20896 \end_layout
20897
20898 \end_inset
20899 </cell>
20900 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20901 \begin_inset Text
20902
20903 \begin_layout Standard
20904 x
20905 \end_layout
20906
20907 \end_inset
20908 </cell>
20909 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20910 \begin_inset Text
20911
20912 \begin_layout Standard
20913
20914 \family roman
20915 \series medium
20916 \shape up
20917 \size normal
20918 \emph off
20919 \bar no
20920 \noun off
20921 \color none
20922 x
20923 \end_layout
20924
20925 \end_inset
20926 </cell>
20927 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20928 \begin_inset Text
20929
20930 \begin_layout Standard
20931 -
20932 \end_layout
20933
20934 \end_inset
20935 </cell>
20936 </row>
20937 <row topline="true">
20938 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20939 \begin_inset Text
20940
20941 \begin_layout Standard
20942 byte arguments on stack
20943 \end_layout
20944
20945 \end_inset
20946 </cell>
20947 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20948 \begin_inset Text
20949
20950 \begin_layout Standard
20951 b
20952 \end_layout
20953
20954 \end_inset
20955 </cell>
20956 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20957 \begin_inset Text
20958
20959 \begin_layout Standard
20960 b
20961 \end_layout
20962
20963 \end_inset
20964 </cell>
20965 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20966 \begin_inset Text
20967
20968 \begin_layout Standard
20969 -
20970 \end_layout
20971
20972 \end_inset
20973 </cell>
20974 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20975 \begin_inset Text
20976
20977 \begin_layout Standard
20978 -
20979 \end_layout
20980
20981 \end_inset
20982 </cell>
20983 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20984 \begin_inset Text
20985
20986 \begin_layout Standard
20987 -
20988 \end_layout
20989
20990 \end_inset
20991 </cell>
20992 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20993 \begin_inset Text
20994
20995 \begin_layout Standard
20996 -
20997 \end_layout
20998
20999 \end_inset
21000 </cell>
21001 </row>
21002 <row topline="true">
21003 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21004 \begin_inset Text
21005
21006 \begin_layout Standard
21007 float format
21008 \begin_inset LatexCommand \index{Floating point support}
21009
21010 \end_inset
21011
21012
21013 \end_layout
21014
21015 \end_inset
21016 </cell>
21017 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21018 \begin_inset Text
21019
21020 \begin_layout Standard
21021 -
21022 \end_layout
21023
21024 \end_inset
21025 </cell>
21026 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21027 \begin_inset Text
21028
21029 \begin_layout Standard
21030 %f
21031 \end_layout
21032
21033 \end_inset
21034 </cell>
21035 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21036 \begin_inset Text
21037
21038 \begin_layout Standard
21039 -
21040 \end_layout
21041
21042 \end_inset
21043 </cell>
21044 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21045 \begin_inset Text
21046
21047 \begin_layout Standard
21048 -
21049 \end_layout
21050
21051 \end_inset
21052 </cell>
21053 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
21054 \begin_inset Text
21055
21056 \begin_layout Standard
21057 %f
21058 \begin_inset Foot
21059 status collapsed
21060
21061 \begin_layout Standard
21062 Range limited to +/- 4294967040, precision limited to 8 digits past decimal
21063 \end_layout
21064
21065 \end_inset
21066
21067
21068 \end_layout
21069
21070 \end_inset
21071 </cell>
21072 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
21073 \begin_inset Text
21074
21075 \begin_layout Standard
21076 -
21077 \end_layout
21078
21079 \end_inset
21080 </cell>
21081 </row>
21082 <row topline="true">
21083 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21084 \begin_inset Text
21085
21086 \begin_layout Standard
21087 float formats %e %g
21088 \end_layout
21089
21090 \end_inset
21091 </cell>
21092 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21093 \begin_inset Text
21094
21095 \begin_layout Standard
21096 -
21097 \end_layout
21098
21099 \end_inset
21100 </cell>
21101 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21102 \begin_inset Text
21103
21104 \begin_layout Standard
21105 -
21106 \end_layout
21107
21108 \end_inset
21109 </cell>
21110 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21111 \begin_inset Text
21112
21113 \begin_layout Standard
21114 -
21115 \end_layout
21116
21117 \end_inset
21118 </cell>
21119 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21120 \begin_inset Text
21121
21122 \begin_layout Standard
21123 -
21124 \end_layout
21125
21126 \end_inset
21127 </cell>
21128 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
21129 \begin_inset Text
21130
21131 \begin_layout Standard
21132 -
21133 \end_layout
21134
21135 \end_inset
21136 </cell>
21137 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
21138 \begin_inset Text
21139
21140 \begin_layout Standard
21141 -
21142 \end_layout
21143
21144 \end_inset
21145 </cell>
21146 </row>
21147 <row topline="true" bottomline="true">
21148 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21149 \begin_inset Text
21150
21151 \begin_layout Standard
21152 field width
21153 \end_layout
21154
21155 \end_inset
21156 </cell>
21157 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21158 \begin_inset Text
21159
21160 \begin_layout Standard
21161 x
21162 \end_layout
21163
21164 \end_inset
21165 </cell>
21166 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21167 \begin_inset Text
21168
21169 \begin_layout Standard
21170 x
21171 \end_layout
21172
21173 \end_inset
21174 </cell>
21175 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21176 \begin_inset Text
21177
21178 \begin_layout Standard
21179 -
21180 \end_layout
21181
21182 \end_inset
21183 </cell>
21184 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21185 \begin_inset Text
21186
21187 \begin_layout Standard
21188 x
21189 \end_layout
21190
21191 \end_inset
21192 </cell>
21193 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
21194 \begin_inset Text
21195
21196 \begin_layout Standard
21197 x
21198 \end_layout
21199
21200 \end_inset
21201 </cell>
21202 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
21203 \begin_inset Text
21204
21205 \begin_layout Standard
21206 -
21207 \end_layout
21208
21209 \end_inset
21210 </cell>
21211 </row>
21212 <row bottomline="true">
21213 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21214 \begin_inset Text
21215
21216 \begin_layout Standard
21217 string speed
21218 \begin_inset Foot
21219 status collapsed
21220
21221 \begin_layout Standard
21222 Execution time of printf("%s%c%s%c%c%c", "Hello", ' ', "World", '!', '
21223 \backslash
21224 r', '
21225 \backslash
21226 n'); standard 8051 @ 22.1184 MHz, empty putchar()
21227 \end_layout
21228
21229 \end_inset
21230
21231 ,
21232 \end_layout
21233
21234 \begin_layout Standard
21235 small / large
21236 \end_layout
21237
21238 \end_inset
21239 </cell>
21240 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21241 \begin_inset Text
21242
21243 \begin_layout Standard
21244 1.52 / 2.59 ms
21245 \end_layout
21246
21247 \end_inset
21248 </cell>
21249 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21250 \begin_inset Text
21251
21252 \begin_layout Standard
21253 1.53 / 2.62 ms
21254 \end_layout
21255
21256 \end_inset
21257 </cell>
21258 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21259 \begin_inset Text
21260
21261 \begin_layout Standard
21262 0.92 / 0.93 ms
21263 \end_layout
21264
21265 \end_inset
21266 </cell>
21267 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21268 \begin_inset Text
21269
21270 \begin_layout Standard
21271 0.45 / 0.45 ms
21272 \end_layout
21273
21274 \end_inset
21275 </cell>
21276 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21277 \begin_inset Text
21278
21279 \begin_layout Standard
21280 0.46 / 0.46 ms
21281 \end_layout
21282
21283 \end_inset
21284 </cell>
21285 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
21286 \begin_inset Text
21287
21288 \begin_layout Standard
21289 0.45 / 0.45 ms
21290 \end_layout
21291
21292 \end_inset
21293 </cell>
21294 </row>
21295 <row bottomline="true">
21296 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21297 \begin_inset Text
21298
21299 \begin_layout Standard
21300 int speed
21301 \begin_inset Foot
21302 status collapsed
21303
21304 \begin_layout Standard
21305 Execution time of printf("%d", -12345); standard 8051 @ 22.1184 MHz, empty
21306  putchar()
21307 \end_layout
21308
21309 \end_inset
21310
21311 ,
21312 \end_layout
21313
21314 \begin_layout Standard
21315 small / large
21316 \end_layout
21317
21318 \end_inset
21319 </cell>
21320 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21321 \begin_inset Text
21322
21323 \begin_layout Standard
21324 3.01 / 3.61 ms
21325 \end_layout
21326
21327 \end_inset
21328 </cell>
21329 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21330 \begin_inset Text
21331
21332 \begin_layout Standard
21333 3.01 / 3.61 ms
21334 \end_layout
21335
21336 \end_inset
21337 </cell>
21338 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21339 \begin_inset Text
21340
21341 \begin_layout Standard
21342 3.51 / 18.13 ms
21343 \end_layout
21344
21345 \end_inset
21346 </cell>
21347 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21348 \begin_inset Text
21349
21350 \begin_layout Standard
21351 0.22 / 0.22 ms
21352 \end_layout
21353
21354 \end_inset
21355 </cell>
21356 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21357 \begin_inset Text
21358
21359 \begin_layout Standard
21360 0.23 / 0.23 ms
21361 \end_layout
21362
21363 \end_inset
21364 </cell>
21365 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
21366 \begin_inset Text
21367
21368 \begin_layout Standard
21369 0.25 / 0.25 ms
21370 \begin_inset Foot
21371 status collapsed
21372
21373 \begin_layout Standard
21374 printf_tiny integer speed is data dependent, worst case is 0.33 ms
21375 \end_layout
21376
21377 \end_inset
21378
21379
21380 \end_layout
21381
21382 \end_inset
21383 </cell>
21384 </row>
21385 <row bottomline="true">
21386 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21387 \begin_inset Text
21388
21389 \begin_layout Standard
21390 long speed
21391 \begin_inset Foot
21392 status collapsed
21393
21394 \begin_layout Standard
21395 Execution time of printf("%ld", -123456789); standard 8051 @ 22.1184 MHz,
21396  empty putchar()
21397 \end_layout
21398
21399 \end_inset
21400
21401 ,
21402 \end_layout
21403
21404 \begin_layout Standard
21405 small / large
21406 \end_layout
21407
21408 \end_inset
21409 </cell>
21410 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21411 \begin_inset Text
21412
21413 \begin_layout Standard
21414 5.37 / 6.31 ms
21415 \end_layout
21416
21417 \end_inset
21418 </cell>
21419 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21420 \begin_inset Text
21421
21422 \begin_layout Standard
21423 5.37 / 6.31 ms
21424 \end_layout
21425
21426 \end_inset
21427 </cell>
21428 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21429 \begin_inset Text
21430
21431 \begin_layout Standard
21432 8.71 / 40.65 ms
21433 \end_layout
21434
21435 \end_inset
21436 </cell>
21437 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21438 \begin_inset Text
21439
21440 \begin_layout Standard
21441 0.40 / 0.40 ms
21442 \end_layout
21443
21444 \end_inset
21445 </cell>
21446 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21447 \begin_inset Text
21448
21449 \begin_layout Standard
21450 0.40 / 0.40 ms
21451 \end_layout
21452
21453 \end_inset
21454 </cell>
21455 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
21456 \begin_inset Text
21457
21458 \begin_layout Standard
21459 -
21460 \end_layout
21461
21462 \end_inset
21463 </cell>
21464 </row>
21465 <row bottomline="true">
21466 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21467 \begin_inset Text
21468
21469 \begin_layout Standard
21470 float speed
21471 \begin_inset Foot
21472 status collapsed
21473
21474 \begin_layout Standard
21475 Execution time of printf("%.3f", -12345.678); standard 8051 @ 22.1184 MHz,
21476  empty putchar()
21477 \end_layout
21478
21479 \end_inset
21480
21481 ,
21482 \end_layout
21483
21484 \begin_layout Standard
21485 small / large
21486 \end_layout
21487
21488 \end_inset
21489 </cell>
21490 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21491 \begin_inset Text
21492
21493 \begin_layout Standard
21494 -
21495 \end_layout
21496
21497 \end_inset
21498 </cell>
21499 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21500 \begin_inset Text
21501
21502 \begin_layout Standard
21503 7.49 / 22.47 ms
21504 \end_layout
21505
21506 \end_inset
21507 </cell>
21508 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21509 \begin_inset Text
21510
21511 \begin_layout Standard
21512 -
21513 \end_layout
21514
21515 \end_inset
21516 </cell>
21517 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21518 \begin_inset Text
21519
21520 \begin_layout Standard
21521 -
21522 \end_layout
21523
21524 \end_inset
21525 </cell>
21526 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21527 \begin_inset Text
21528
21529 \begin_layout Standard
21530 1.04 / 1.04 ms
21531 \end_layout
21532
21533 \end_inset
21534 </cell>
21535 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
21536 \begin_inset Text
21537
21538 \begin_layout Standard
21539 -
21540 \end_layout
21541
21542 \end_inset
21543 </cell>
21544 </row>
21545 </lyxtabular>
21546
21547 \end_inset
21548
21549
21550 \end_layout
21551
21552 \begin_layout Subsubsection
21553 <malloc.h>
21554 \begin_inset LatexCommand \index{malloc.h}
21555
21556 \end_inset
21557
21558
21559 \end_layout
21560
21561 \begin_layout Standard
21562 As of SDCC 2.6.2 you no longer need to call an initialization routine before
21563  using dynamic memory allocation
21564 \begin_inset LatexCommand \index{dynamic memory allocation (malloc)}
21565
21566 \end_inset
21567
21568  and a default heap
21569 \begin_inset LatexCommand \index{heap (malloc)}
21570
21571 \end_inset
21572
21573  space of 1024 bytes is provided for malloc to allocate memory from.
21574  If you need a different heap size you need to recompile _heap.c with the
21575  required size defined in HEAP_SIZE.
21576  It is recommended to make a copy of this file into your project directory
21577  and compile it there with:
21578 \end_layout
21579
21580 \begin_layout Verse
21581
21582 \family typewriter
21583 sdcc -c _heap.c -D HEAD_SIZE=2048
21584 \end_layout
21585
21586 \begin_layout Standard
21587 And then link it with:
21588 \end_layout
21589
21590 \begin_layout Verse
21591
21592 \family typewriter
21593 sdcc main.rel _heap.rel
21594 \end_layout
21595
21596 \begin_layout Subsection
21597 Math functions (sinf, powf, sqrtf etc.)
21598 \end_layout
21599
21600 \begin_layout Subsubsection
21601 <math.h>
21602 \end_layout
21603
21604 \begin_layout Standard
21605 See definitions in file <math.h>.
21606 \end_layout
21607
21608 \begin_layout Subsection
21609 Other libraries
21610 \end_layout
21611
21612 \begin_layout Standard
21613 Libraries
21614 \begin_inset LatexCommand \index{Libraries}
21615
21616 \end_inset
21617
21618  included in SDCC should have a license at least as liberal as the GNU Lesser
21619  General Public License
21620 \begin_inset LatexCommand \index{GNU Lesser General Public License, LGPL}
21621
21622 \end_inset
21623
21624  
21625 \emph on
21626 LGPL
21627 \emph default
21628 .
21629 \end_layout
21630
21631 \begin_layout Standard
21632 \begin_inset Note Note
21633 status collapsed
21634
21635 \begin_layout Standard
21636 license statements for the libraries are missing.
21637  sdcc/device/lib/ser_ir.c
21638 \end_layout
21639
21640 \begin_layout Standard
21641 or _decdptr f.e.
21642  come with a GPL (as opposed to LGPL) License - this will not be liberal
21643  enough for many embedded programmers.
21644 \end_layout
21645
21646 \end_inset
21647
21648
21649 \end_layout
21650
21651 \begin_layout Standard
21652 If you have ported some library or want to share experience about some code
21653  which f.e.
21654  falls into any of these categories Busses (I
21655 \begin_inset Formula $^{\textrm{2}}$
21656 \end_inset
21657
21658 C, CAN, Ethernet, Profibus, Modbus, USB, SPI, JTAG ...), Media (IDE, Memory
21659  cards, eeprom, flash...), En-/Decryption, Remote debugging, Realtime kernel,
21660  Keyboard, LCD, RTC, FPGA, PID then the sdcc-user mailing list 
21661 \begin_inset LatexCommand \url{http://sourceforge.net/mail/?group_id=599}
21662
21663 \end_inset
21664
21665 \InsetSpace ~
21666 would certainly like to hear about it.
21667 \end_layout
21668
21669 \begin_layout Standard
21670 Programmers coding for embedded systems are not especially famous for being
21671  enthusiastic, so don't expect a big hurray but as the mailing list is searchabl
21672 e these references are very valuable.
21673  Let's help to create a climate where information is shared.
21674 \begin_inset VSpace bigskip
21675 \end_inset
21676
21677
21678 \end_layout
21679
21680 \begin_layout Section
21681 Memory Models
21682 \end_layout
21683
21684 \begin_layout Subsection
21685 MCS51 Memory Models
21686 \begin_inset LatexCommand \index{Memory model}
21687
21688 \end_inset
21689
21690
21691 \begin_inset LatexCommand \index{MCS51 memory model}
21692
21693 \end_inset
21694
21695
21696 \end_layout
21697
21698 \begin_layout Subsubsection
21699 Small, Medium and Large
21700 \end_layout
21701
21702 \begin_layout Standard
21703 SDCC allows three memory models for MCS51 code, 
21704 \shape slanted
21705 small, medium
21706 \shape default
21707  and 
21708 \shape slanted
21709 large
21710 \shape default
21711 .
21712  Modules compiled with different memory models should 
21713 \emph on
21714 never
21715 \emph default
21716  be combined together or the results would be unpredictable.
21717  The library routines supplied with the compiler are compiled as small,
21718  medium and large.
21719  The compiled library modules are contained in separate directories as small,
21720  medium and large so that you can link to the appropriate set.
21721 \end_layout
21722
21723 \begin_layout Standard
21724 When the medium or large model is used all variables declared without a
21725  storage class will be allocated into the external ram, this includes all
21726  parameters and local variables (for non-reentrant
21727 \begin_inset LatexCommand \index{reentrant}
21728
21729 \end_inset
21730
21731  functions).
21732  When the small model is used variables without storage class are allocated
21733  in the internal ram.
21734 \end_layout
21735
21736 \begin_layout Standard
21737 Judicious usage of the processor specific storage classes
21738 \begin_inset LatexCommand \index{Storage class}
21739
21740 \end_inset
21741
21742  and the 'reentrant' function type will yield much more efficient code,
21743  than using the large model.
21744  Several optimizations are disabled when the program is compiled using the
21745  large model, it is therefore recommended that the small model be used unless
21746  absolutely required.
21747 \end_layout
21748
21749 \begin_layout Subsubsection
21750 External Stack
21751 \begin_inset LatexCommand \label{sub:External-Stack}
21752
21753 \end_inset
21754
21755
21756 \begin_inset LatexCommand \index{stack}
21757
21758 \end_inset
21759
21760
21761 \begin_inset LatexCommand \index{External stack (mcs51)}
21762
21763 \end_inset
21764
21765
21766 \end_layout
21767
21768 \begin_layout Standard
21769 The external stack (-
21770 \begin_inset ERT
21771 status collapsed
21772
21773 \begin_layout Standard
21774
21775
21776 \backslash
21777 /
21778 \end_layout
21779
21780 \end_inset
21781
21782 -xstack option
21783 \begin_inset LatexCommand \index{-\/-xstack}
21784
21785 \end_inset
21786
21787 ) is located in pdata
21788 \begin_inset LatexCommand \index{pdata (mcs51, ds390 storage class)}
21789
21790 \end_inset
21791
21792  memory (usually at the start of the external ram segment) and uses all
21793  unused space in pdata (max.
21794  256 bytes).
21795  When -
21796 \begin_inset ERT
21797 status collapsed
21798
21799 \begin_layout Standard
21800
21801
21802 \backslash
21803 /
21804 \end_layout
21805
21806 \end_inset
21807
21808 -xstack option is used to compile the program, the parameters and local
21809  variables
21810 \begin_inset LatexCommand \index{local variables}
21811
21812 \end_inset
21813
21814  of all reentrant functions are allocated in this area.
21815  This option is provided for programs with large stack space requirements.
21816  When used with the -
21817 \begin_inset ERT
21818 status collapsed
21819
21820 \begin_layout Standard
21821
21822
21823 \backslash
21824 /
21825 \end_layout
21826
21827 \end_inset
21828
21829 -stack-auto
21830 \begin_inset LatexCommand \index{-\/-stack-auto}
21831
21832 \end_inset
21833
21834  option, all parameters and local variables are allocated on the external
21835  stack (note: support libraries will need to be recompiled with the same
21836  options.
21837  There is a predefined target in the library makefile).
21838 \end_layout
21839
21840 \begin_layout Standard
21841 The compiler outputs the higher order address byte of the external ram segment
21842  into port P2
21843 \begin_inset LatexCommand \index{P2 (mcs51 sfr)}
21844
21845 \end_inset
21846
21847  (see also section 
21848 \begin_inset LatexCommand \ref{sub:MCS51-variants}
21849
21850 \end_inset
21851
21852 ), therefore when using the External Stack option, this port 
21853 \emph on
21854 may not
21855 \emph default
21856  be used by the application program.
21857 \end_layout
21858
21859 \begin_layout Subsection
21860 DS390 Memory Model
21861 \begin_inset LatexCommand \index{Memory model}
21862
21863 \end_inset
21864
21865
21866 \begin_inset LatexCommand \index{DS390 memory model}
21867
21868 \end_inset
21869
21870
21871 \end_layout
21872
21873 \begin_layout Standard
21874 The only model supported is Flat 24
21875 \begin_inset LatexCommand \index{Flat 24 (DS390 memory model)}
21876
21877 \end_inset
21878
21879 .
21880  This generates code for the 24 bit contiguous addressing mode of the Dallas
21881  DS80C390 part.
21882  In this mode, up to four meg of external RAM or code space can be directly
21883  addressed.
21884  See the data sheets at www.dalsemi.com for further information on this part.
21885 \newline
21886
21887 \newline
21888 Note
21889  that the compiler does not generate any code to place the processor into
21890  24 bitmode (although 
21891 \emph on
21892 tinibios
21893 \emph default
21894  in the ds390 libraries will do that for you).
21895  If you don't use 
21896 \emph on
21897 tinibios
21898 \emph default
21899
21900 \begin_inset LatexCommand \index{Tinibios (DS390)}
21901
21902 \end_inset
21903
21904 , the boot loader or similar code must ensure that the processor is in 24
21905  bit contiguous addressing mode before calling the SDCC startup code.
21906 \newline
21907
21908 \newline
21909 Like
21910  the 
21911 \emph on
21912 -
21913 \begin_inset ERT
21914 status collapsed
21915
21916 \begin_layout Standard
21917
21918
21919 \backslash
21920 /
21921 \end_layout
21922
21923 \end_inset
21924
21925 -model-large
21926 \emph default
21927  option, variables will by default be placed into the XDATA segment.
21928  
21929 \newline
21930
21931 \newline
21932 Segments may be placed anywhere in the 4 meg address space using the usual
21933  -
21934 \begin_inset ERT
21935 status collapsed
21936
21937 \begin_layout Standard
21938
21939
21940 \backslash
21941 /
21942 \end_layout
21943
21944 \end_inset
21945
21946 -*-loc options.
21947  Note that if any segments are located above 64K, the -r flag must be passed
21948  to the linker to generate the proper segment relocations, and the Intel
21949  HEX output format must be used.
21950  The -r flag can be passed to the linker by using the option 
21951 \emph on
21952 -Wl-r
21953 \emph default
21954  on the SDCC command line.
21955  However, currently the linker can not handle code segments > 64k.
21956 \end_layout
21957
21958 \begin_layout Section
21959 Pragmas
21960 \begin_inset LatexCommand \label{sec:Pragmas}
21961
21962 \end_inset
21963
21964
21965 \begin_inset LatexCommand \index{Pragmas}
21966
21967 \end_inset
21968
21969
21970 \end_layout
21971
21972 \begin_layout Standard
21973 Pragmas are used to turn on and/or off certain compiler options.
21974  Some of them are closely related to corresponding command-line options
21975  (see section 
21976 \begin_inset LatexCommand \vref{sec:Command-Line-Options}
21977
21978 \end_inset
21979
21980 ).
21981 \newline
21982 Pragmas should be placed before and/or after a function, placing pragmas
21983  inside a function body could have unpredictable results.
21984 \newline
21985
21986 \newline
21987 SDCC supports the
21988  following #pragma directives:
21989 \end_layout
21990
21991 \begin_layout Itemize
21992
21993 \series bold
21994 save
21995 \series default
21996
21997 \begin_inset LatexCommand \index{\#pragma save}
21998
21999 \end_inset
22000
22001  - this will save most current options to the save/restore stack.
22002  See #pragma\InsetSpace ~
22003 restore.
22004 \end_layout
22005
22006 \begin_layout Itemize
22007
22008 \series bold
22009 restore
22010 \series default
22011
22012 \begin_inset LatexCommand \index{\#pragma restore}
22013
22014 \end_inset
22015
22016  - will restore saved options from the last save.
22017  saves & restores can be nested.
22018  SDCC uses a save/restore stack: save pushes current options to the stack,
22019  restore pulls current options from the stack.
22020  See #pragma\InsetSpace ~
22021 save.
22022 \newline
22023
22024 \end_layout
22025
22026 \begin_layout Itemize
22027
22028 \series bold
22029 callee_saves
22030 \series default
22031
22032 \begin_inset LatexCommand \index{\#pragma callee\_saves}
22033
22034 \end_inset
22035
22036
22037 \begin_inset LatexCommand \index{function prologue}
22038
22039 \end_inset
22040
22041  function1[,function2[,function3...]] 
22042 \begin_inset LatexCommand \label{ite:callee_saves-function1[,function2[,function3...]]--}
22043
22044 \end_inset
22045
22046 - The compiler by default uses a caller saves convention for register saving
22047  across function calls, however this can cause unnecessary register pushing
22048  and popping
22049 \begin_inset LatexCommand \index{push/pop}
22050
22051 \end_inset
22052
22053  when calling small functions from larger functions.
22054  This option can be used to switch off the register saving convention for
22055  the function names specified.
22056  The compiler will not save registers when calling these functions, extra
22057  code need to be manually inserted at the entry and exit for these functions
22058  to save and restore the registers used by these functions, this can SUBSTANTIAL
22059 LY reduce code and improve run time performance of the generated code.
22060  In the future the compiler (with inter procedural analysis) may be able
22061  to determine the appropriate scheme to use for each function call.
22062  If -
22063 \begin_inset ERT
22064 status collapsed
22065
22066 \begin_layout Standard
22067
22068
22069 \backslash
22070 /
22071 \end_layout
22072
22073 \end_inset
22074
22075 -callee-saves command line option is used (see page 
22076 \begin_inset LatexCommand \vpageref{lyx:--callee-saves-function1[,function2][,function3]...}
22077
22078 \end_inset
22079
22080 ), the function names specified in #pragma\InsetSpace ~
22081 callee_saves
22082 \begin_inset LatexCommand \index{\#pragma callee\_saves}
22083
22084 \end_inset
22085
22086  is appended to the list of functions specified in the command line.
22087 \end_layout
22088
22089 \begin_layout Itemize
22090
22091 \series bold
22092 exclude
22093 \series default
22094
22095 \begin_inset LatexCommand \index{\#pragma exclude}
22096
22097 \end_inset
22098
22099  none | {acc[,b[,dpl[,dph]]] - The exclude pragma disables the generation
22100  of pairs of push/pop
22101 \begin_inset LatexCommand \index{push/pop}
22102
22103 \end_inset
22104
22105  instructions in 
22106 \emph on
22107 I
22108 \emph default
22109 nterrupt
22110 \begin_inset LatexCommand \index{interrupt}
22111
22112 \end_inset
22113
22114  
22115 \emph on
22116 S
22117 \emph default
22118 ervice 
22119 \emph on
22120 R
22121 \emph default
22122 outines.
22123  The directive should be placed immediately before the ISR function definition
22124  and it affects ALL ISR functions following it.
22125  To enable the normal register saving for ISR functions use #pragma\InsetSpace ~
22126 exclude\InsetSpace ~
22127 none
22128 \begin_inset LatexCommand \index{\#pragma exclude}
22129
22130 \end_inset
22131
22132 .
22133  See also the related keyword _naked
22134 \begin_inset LatexCommand \index{\_naked}
22135
22136 \end_inset
22137
22138
22139 \begin_inset LatexCommand \index{\_\_naked}
22140
22141 \end_inset
22142
22143 .
22144 \end_layout
22145
22146 \begin_layout Itemize
22147
22148 \series bold
22149 less_pedantic
22150 \series default
22151
22152 \begin_inset LatexCommand \index{pedantic}
22153
22154 \end_inset
22155
22156
22157 \begin_inset LatexCommand \index{\#pragma less\_pedantic}
22158
22159 \end_inset
22160
22161  
22162 \begin_inset LatexCommand \label{ite:less_pedantic}
22163
22164 \end_inset
22165
22166 - the compiler will not warn you anymore for obvious mistakes, you're on
22167  your own now ;-( .
22168  See also the command line option -
22169 \begin_inset ERT
22170 status collapsed
22171
22172 \begin_layout Standard
22173
22174
22175 \backslash
22176 /
22177 \end_layout
22178
22179 \end_inset
22180
22181 -less-pedantic 
22182 \begin_inset LatexCommand \vpageref{lyx:--less-pedantic}
22183
22184 \end_inset
22185
22186 .
22187  
22188 \newline
22189 More specifically, the following warnings will be disabled: 
22190 \shape italic
22191 comparison is always [true/false] due to limited range of data type
22192 \shape default
22193  (94); 
22194 \shape italic
22195 overflow in implicit constant conversion
22196 \shape default
22197  (158); [the (in)famous] 
22198 \shape italic
22199 conditional flow changed by optimizer: so said EVELYN the modified DOG
22200 \shape default
22201  (110); 
22202 \shape italic
22203 function '[function name]' must return value
22204 \shape default
22205  (59).
22206  
22207 \newline
22208 Furthermore, warnings of less importance (of PEDANTIC and INFO warning
22209  level) are disabled, too, namely: 
22210 \shape italic
22211 constant value '[
22212 \begin_inset Note Note
22213 status collapsed
22214
22215 \begin_layout Standard
22216 dunno what comes here - this warning appears to be unused altogether
22217 \end_layout
22218
22219 \end_inset
22220
22221 ]', out of range
22222 \shape default
22223  (81); 
22224 \shape italic
22225 [left/right] shifting more than size of object changed to zero
22226 \shape default
22227  (116); 
22228 \shape italic
22229 unreachable code
22230 \shape default
22231  (126); 
22232 \shape italic
22233 integer overflow in expression
22234 \shape default
22235  (165); 
22236 \shape italic
22237 unmatched #pragma save and #pragma restore
22238 \shape default
22239  (170); 
22240 \shape italic
22241 comparison of 'signed char' with 'unsigned char' requires promotion to int
22242 \shape default
22243  (185); 
22244 \shape italic
22245 ISO C90 does not support flexible array members
22246 \shape default
22247  (187); 
22248 \shape italic
22249 extended stack by [number] bytes for compiler temp(s) :in function '[function\InsetSpace ~
22250 nam
22251 e]':\InsetSpace ~
22252 [
22253 \begin_inset Note Note
22254 status collapsed
22255
22256 \begin_layout Standard
22257 appears to be always blank - what was supposed to be here?
22258 \end_layout
22259
22260 \end_inset
22261
22262 ]
22263 \shape default
22264  (114); 
22265 \shape italic
22266 function '[function name]', # edges [number] , # nodes [number] , cyclomatic
22267  complexity [number]
22268 \shape default
22269  (121).
22270 \end_layout
22271
22272 \begin_layout Itemize
22273
22274 \series bold
22275 disable_warning
22276 \series default
22277  <nnnn>
22278 \begin_inset LatexCommand \index{\#pragma disable\_warning}
22279
22280 \end_inset
22281
22282  - the compiler will not warn you anymore about warning number <nnnn>.
22283 \end_layout
22284
22285 \begin_layout Itemize
22286
22287 \series bold
22288 nogcse
22289 \series default
22290
22291 \begin_inset LatexCommand \index{\#pragma nogcse}
22292
22293 \end_inset
22294
22295  - will stop global common subexpression elimination.
22296 \end_layout
22297
22298 \begin_layout Itemize
22299
22300 \series bold
22301 noinduction
22302 \series default
22303
22304 \begin_inset LatexCommand \index{\#pragma noinduction}
22305
22306 \end_inset
22307
22308  - will stop loop induction optimizations.
22309 \end_layout
22310
22311 \begin_layout Itemize
22312
22313 \series bold
22314 noinvariant
22315 \series default
22316
22317 \begin_inset LatexCommand \index{\#pragma noinvariant}
22318
22319 \end_inset
22320
22321  - will not do loop invariant optimizations.
22322  For more details see Loop Invariants in section
22323 \begin_inset LatexCommand \ref{sub:Loop-Optimizations}
22324
22325 \end_inset
22326
22327 .
22328 \end_layout
22329
22330 \begin_layout Itemize
22331
22332 \series bold
22333 noiv
22334 \series default
22335
22336 \begin_inset LatexCommand \index{\#pragma noiv}
22337
22338 \end_inset
22339
22340  - Do not generate interrupt
22341 \begin_inset LatexCommand \index{interrupt}
22342
22343 \end_inset
22344
22345  vector table
22346 \begin_inset LatexCommand \index{interrupt vector table}
22347
22348 \end_inset
22349
22350  entries for all ISR functions defined after the pragma.
22351  This is useful in cases where the interrupt vector table must be defined
22352  manually, or when there is a secondary, manually defined interrupt vector
22353  table (e.g.
22354  for the autovector feature of the Cypress EZ-USB FX2).
22355  More elegantly this can be achieved by obmitting the optional interrupt
22356  number after the interrupt keyword, see section 
22357 \begin_inset LatexCommand \ref{sub:Interrupt-Service-Routines}
22358
22359 \end_inset
22360
22361 \InsetSpace ~
22362 about interrupts.
22363 \end_layout
22364
22365 \begin_layout Itemize
22366
22367 \series bold
22368 nojtbound
22369 \series default
22370
22371 \begin_inset LatexCommand \index{\#pragma nojtbound}
22372
22373 \end_inset
22374
22375  - will not generate code for boundary value checking, when switch statements
22376  are turned into jump-tables (dangerous).
22377  For more details see section 
22378 \begin_inset LatexCommand \ref{sub:'switch'-Statements}
22379
22380 \end_inset
22381
22382 .
22383 \end_layout
22384
22385 \begin_layout Itemize
22386
22387 \series bold
22388 noloopreverse
22389 \series default
22390
22391 \begin_inset LatexCommand \index{\#pragma noloopreverse}
22392
22393 \end_inset
22394
22395  - Will not do loop reversal optimization
22396 \end_layout
22397
22398 \begin_layout Itemize
22399
22400 \series bold
22401 nooverlay
22402 \series default
22403
22404 \begin_inset LatexCommand \index{\#pragma nooverlay}
22405
22406 \end_inset
22407
22408  - the compiler will not overlay the parameters and local variables of a
22409  function.
22410 \end_layout
22411
22412 \begin_layout Itemize
22413
22414 \series bold
22415 stackauto
22416 \series default
22417
22418 \begin_inset LatexCommand \index{\#pragma stackauto}
22419
22420 \end_inset
22421
22422 - See option -
22423 \begin_inset ERT
22424 status collapsed
22425
22426 \begin_layout Standard
22427
22428
22429 \backslash
22430 /
22431 \end_layout
22432
22433 \end_inset
22434
22435 -stack-auto
22436 \begin_inset LatexCommand \index{-\/-stack-auto}
22437
22438 \end_inset
22439
22440  and section 
22441 \begin_inset LatexCommand \ref{sec:Parameters-and-Local-Variables}
22442
22443 \end_inset
22444
22445  Parameters and Local Variables.
22446 \end_layout
22447
22448 \begin_layout Itemize
22449
22450 \series bold
22451 opt_code_speed
22452 \series default
22453  
22454 \begin_inset LatexCommand \index{\#pragma opt\_code\_speed}
22455
22456 \end_inset
22457
22458 - The compiler will optimize code generation towards fast code, possibly
22459  at the expense of code size.
22460  Currently this has little effect.
22461 \end_layout
22462
22463 \begin_layout Itemize
22464
22465 \series bold
22466 opt_code_size
22467 \series default
22468  
22469 \begin_inset LatexCommand \index{\#pragma opt\_code\_size}
22470
22471 \end_inset
22472
22473 - The compiler will optimize code generation towards compact code, possibly
22474  at the expense of code speed.
22475  Currently this has little effect.
22476 \end_layout
22477
22478 \begin_layout Itemize
22479
22480 \series bold
22481 opt_code_balanced
22482 \series default
22483  
22484 \begin_inset LatexCommand \index{\#pragma opt\_code\_balanced}
22485
22486 \end_inset
22487
22488 - The compiler will attempt to generate code that is both compact and fast,
22489  as long as meeting one goal is not a detriment to the other (this is the
22490  default).
22491  
22492 \end_layout
22493
22494 \begin_layout Itemize
22495
22496 \series bold
22497 std_sdcc89
22498 \series default
22499  
22500 \begin_inset LatexCommand \index{\#pragma std\_sdcc89}
22501
22502 \end_inset
22503
22504 - Generally follow the C89 standard, but allow SDCC features that conflict
22505  with the standard (default).
22506 \end_layout
22507
22508 \begin_layout Itemize
22509
22510 \series bold
22511 std_c89
22512 \series default
22513  
22514 \begin_inset LatexCommand \index{\#pragma std\_c89}
22515
22516 \end_inset
22517
22518 - Follow the C89 standard and disable SDCC features that conflict with the
22519  standard.
22520 \end_layout
22521
22522 \begin_layout Itemize
22523
22524 \series bold
22525 std_sdcc99
22526 \series default
22527  
22528 \begin_inset LatexCommand \index{\#pragma std\_sdcc99}
22529
22530 \end_inset
22531
22532 - Generally follow the C99 standard, but allow SDCC features that conflict
22533  with the standard (incomplete support).
22534 \end_layout
22535
22536 \begin_layout Itemize
22537
22538 \series bold
22539 std_c99
22540 \series default
22541  
22542 \begin_inset LatexCommand \index{\#pragma std\_c99}
22543
22544 \end_inset
22545
22546 - Follow the C99 standard and disable SDCC features that conflict with the
22547  standard (incomplete support).
22548 \end_layout
22549
22550 \begin_layout Itemize
22551
22552 \series bold
22553 codeseg
22554 \series default
22555  <name>
22556 \begin_inset LatexCommand \index{\#pragma codeseg}
22557
22558 \end_inset
22559
22560 - Use this name (max.
22561  8 characters) for the code segment.
22562  See option -
22563 \begin_inset ERT
22564 status collapsed
22565
22566 \begin_layout Standard
22567
22568
22569 \backslash
22570 /
22571 \end_layout
22572
22573 \end_inset
22574
22575 -codeseg.
22576 \end_layout
22577
22578 \begin_layout Itemize
22579
22580 \series bold
22581 constseg
22582 \series default
22583  <name>
22584 \begin_inset LatexCommand \index{\#pragma constseg}
22585
22586 \end_inset
22587
22588 - Use this name (max.
22589  8 characters) for the const segment.
22590  See option -
22591 \begin_inset ERT
22592 status collapsed
22593
22594 \begin_layout Standard
22595
22596
22597 \backslash
22598 /
22599 \end_layout
22600
22601 \end_inset
22602
22603 -constseg.
22604 \end_layout
22605
22606 \begin_layout Standard
22607 The preprocessor SDCPP
22608 \begin_inset LatexCommand \index{sdcpp (preprocessor)}
22609
22610 \end_inset
22611
22612  supports the following #pragma directives:
22613 \end_layout
22614
22615 \begin_layout Itemize
22616
22617 \series bold
22618 pedantic_parse_number
22619 \series default
22620
22621 \begin_inset LatexCommand \index{pedantic}
22622
22623 \end_inset
22624
22625
22626 \begin_inset LatexCommand \index{\#pragma pedantic\_parse\_number}
22627
22628 \end_inset
22629
22630  (+ | -) 
22631 \begin_inset LatexCommand \label{ite:pedantic_parse_number}
22632
22633 \end_inset
22634
22635 - Pedantic parse numbers so that situations like 0xfe-LO_B(3) are parsed
22636  properly and the macro LO_B(3) gets expanded.
22637  Default is off.
22638  See also the -
22639 \begin_inset ERT
22640 status collapsed
22641
22642 \begin_layout Standard
22643
22644
22645 \backslash
22646 /
22647 \end_layout
22648
22649 \end_inset
22650
22651 -pedantic-parse-number command line option 
22652 \begin_inset LatexCommand \vpageref{lyx:-pedantic-parse-number}
22653
22654 \end_inset
22655
22656 .
22657  
22658 \newline
22659 Below is an example on how to use this pragma.
22660
22661 \emph on
22662  Note: this functionality is not in conformance with standard!
22663 \end_layout
22664
22665 \begin_layout Verse
22666
22667 \family typewriter
22668 #pragma pedantic_parse_number +
22669 \begin_inset LatexCommand \index{\#pragma pedantic\_parse\_number}
22670
22671 \end_inset
22672
22673
22674 \newline
22675
22676 \newline
22677 #define LO_B(x) ((x) & 0xff)
22678 \newline
22679
22680 \newline
22681 unsigned char foo(void)
22682 \newline
22683 {
22684 \newline
22685 \InsetSpace ~
22686 \InsetSpace ~
22687 \InsetSpace ~
22688 unsigned char c=0xfe-LO_B(3)
22689 ;
22690 \newline
22691
22692 \newline
22693 \InsetSpace ~
22694 \InsetSpace ~
22695 \InsetSpace ~
22696 return c;
22697 \newline
22698 }
22699 \newline
22700
22701 \end_layout
22702
22703 \begin_layout Itemize
22704
22705 \series bold
22706 preproc_asm
22707 \series default
22708
22709 \begin_inset LatexCommand \index{\#pragma preproc\_asm}
22710
22711 \end_inset
22712
22713  (+ | -) - switch _asm _endasm block preprocessing on / off.
22714  Default is on.
22715  You use this prama to define multilines of assembly code.
22716  This will prevent the preprocessor from changing the formating required
22717  by assembly code.
22718  Below is an example on how to use this pragma.
22719 \end_layout
22720
22721 \begin_layout Verse
22722
22723 \family typewriter
22724 #pragma preproc_asm -
22725 \begin_inset LatexCommand \index{\#pragma preproc\_asm}
22726
22727 \end_inset
22728
22729
22730 \newline
22731 #define MYDELAY _asm
22732 \newline
22733 \InsetSpace ~
22734 \InsetSpace ~
22735 \InsetSpace ~
22736 nop ;my assembly comment...
22737 \newline
22738 \InsetSpace ~
22739 \InsetSpace ~
22740 \InsetSpace ~
22741 nop
22742 \newline
22743 \InsetSpace ~
22744 \InsetSpace ~
22745 \InsetSpace ~
22746 nop
22747 \newline
22748 _endasm
22749 \newline
22750 #pragma preproc_asm
22751  +
22752 \newline
22753
22754 \newline
22755 void foo (void) 
22756 \newline
22757
22758 \newline
22759 \InsetSpace ~
22760 \InsetSpace ~
22761 \InsetSpace ~
22762  ...
22763  
22764 \newline
22765 \InsetSpace ~
22766 \InsetSpace ~
22767 \InsetSpace ~
22768  MYDELAY;
22769 \newline
22770 \InsetSpace ~
22771 \InsetSpace ~
22772 \InsetSpace ~
22773  ...
22774  
22775 \newline
22776
22777 \newline
22778
22779 \end_layout
22780
22781 \begin_layout Itemize
22782
22783 \series bold
22784 sdcc_hash
22785 \series default
22786
22787 \begin_inset LatexCommand \index{\#pragma sdcc\_hash}
22788
22789 \end_inset
22790
22791  (+ | -) - Allow "naked" hash in macro definition, for example:
22792 \newline
22793
22794 \family typewriter
22795 #define DIR_LO(x) #(x & 0xff)
22796 \family default
22797
22798 \newline
22799 Default is off.
22800  Below is an example on how to use this pragma.
22801 \end_layout
22802
22803 \begin_layout Verse
22804
22805 \family typewriter
22806 #pragma preproc_asm +
22807 \newline
22808 #pragma sdcc_hash +
22809 \begin_inset LatexCommand \index{\#pragma sdcc\_hash}
22810
22811 \end_inset
22812
22813
22814 \newline
22815
22816 \newline
22817 #define ROMCALL(x) 
22818 \backslash
22819
22820 \newline
22821 \InsetSpace ~
22822 \InsetSpace ~
22823 \InsetSpace ~
22824 mov R6_B3, #(x & 0xff) 
22825 \backslash
22826
22827 \newline
22828 \InsetSpace ~
22829 \InsetSpace ~
22830 \InsetSpace ~
22831 mov R7_B3, #((x >> 8) & 0xff) 
22832 \backslash
22833
22834 \newline
22835 \InsetSpace ~
22836 \InsetSpace ~
22837 \InsetSpace ~
22838 lcall __romcall
22839 \newline
22840
22841 \newline
22842 ...
22843 \newline
22844 _asm
22845 \newline
22846 ROMCALL(72)
22847 \newline
22848 _endasm;
22849 \newline
22850 ...
22851 \newline
22852
22853 \end_layout
22854
22855 \begin_layout Standard
22856 Some of the pragmas are intended to be used to turn-on or off certain optimizati
22857 ons which might cause the compiler to generate extra stack and/or data space
22858  to store compiler generated temporary variables.
22859  This usually happens in large functions.
22860  Pragma directives should be used as shown in the following example, they
22861  are used to control options and optimizations for a given function.
22862  
22863 \end_layout
22864
22865 \begin_layout Verse
22866
22867 \family typewriter
22868 #pragma save
22869 \begin_inset LatexCommand \index{\#pragma save}
22870
22871 \end_inset
22872
22873  \InsetSpace ~
22874 \InsetSpace ~
22875 \InsetSpace ~
22876 \InsetSpace ~
22877 \InsetSpace ~
22878 \InsetSpace ~
22879 \InsetSpace ~
22880 /* save the current settings */ 
22881 \newline
22882 #pragma nogcse
22883 \begin_inset LatexCommand \index{\#pragma nogcse}
22884
22885 \end_inset
22886
22887  \InsetSpace ~
22888 \InsetSpace ~
22889 \InsetSpace ~
22890 \InsetSpace ~
22891 \InsetSpace ~
22892 /* turnoff global subexpression elimination */ 
22893 \newline
22894 #pragma noinduction
22895 \begin_inset LatexCommand \index{\#pragma noinduction}
22896
22897 \end_inset
22898
22899  /* turn off induction optimizations */ 
22900 \newline
22901 int foo () 
22902 \newline
22903
22904 \newline
22905 \InsetSpace ~
22906  \InsetSpace ~
22907  ...
22908  
22909 \newline
22910 \InsetSpace ~
22911  \InsetSpace ~
22912  /* large code */ 
22913 \newline
22914 \InsetSpace ~
22915  \InsetSpace ~
22916  ...
22917  
22918 \newline
22919
22920 \newline
22921 #pragma restore
22922 \begin_inset LatexCommand \index{\#pragma restore}
22923
22924 \end_inset
22925
22926  /* turn the optimizations back on */
22927 \end_layout
22928
22929 \begin_layout Standard
22930 The compiler will generate a warning message when extra space is allocated.
22931  It is strongly recommended that the save and restore pragmas be used when
22932  changing options for a function.
22933 \newline
22934
22935 \newline
22936
22937 \newline
22938
22939 \end_layout
22940
22941 \begin_layout Section
22942 Defines Created by the Compiler
22943 \end_layout
22944
22945 \begin_layout Standard
22946 The compiler creates the following #defines
22947 \begin_inset LatexCommand \index{\#defines}
22948
22949 \end_inset
22950
22951
22952 \begin_inset LatexCommand \index{Defines created by the compiler}
22953
22954 \end_inset
22955
22956 :
22957 \newline
22958
22959 \end_layout
22960
22961 \begin_layout Standard
22962 \begin_inset Tabular
22963 <lyxtabular version="3" rows="15" columns="2">
22964 <features>
22965 <column alignment="left" valignment="top" leftline="true" width="3in">
22966 <column alignment="left" valignment="top" leftline="true" rightline="true" width="3in">
22967 <row topline="true" bottomline="true">
22968 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
22969 \begin_inset Text
22970
22971 \begin_layout Standard
22972
22973 \series bold
22974 #define
22975 \end_layout
22976
22977 \end_inset
22978 </cell>
22979 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
22980 \begin_inset Text
22981
22982 \begin_layout Standard
22983
22984 \series bold
22985 Description
22986 \end_layout
22987
22988 \end_inset
22989 </cell>
22990 </row>
22991 <row topline="true">
22992 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
22993 \begin_inset Text
22994
22995 \begin_layout Standard
22996 SDCC
22997 \begin_inset LatexCommand \index{SDCC}
22998
22999 \end_inset
23000
23001  
23002 \end_layout
23003
23004 \end_inset
23005 </cell>
23006 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
23007 \begin_inset Text
23008
23009 \begin_layout Standard
23010 Always defined.
23011  Since version 2.5.6 the version number as an int (ex.
23012  256)
23013 \end_layout
23014
23015 \end_inset
23016 </cell>
23017 </row>
23018 <row topline="true">
23019 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
23020 \begin_inset Text
23021
23022 \begin_layout Standard
23023 SDCC_mcs51
23024 \begin_inset LatexCommand \index{SDCC\_mcs51}
23025
23026 \end_inset
23027
23028  or SDCC_ds390
23029 \begin_inset LatexCommand \index{SDCC\_ds390}
23030
23031 \end_inset
23032
23033  or SDCC_z80
23034 \begin_inset LatexCommand \index{SDCC\_z80}
23035
23036 \end_inset
23037
23038 , etc.
23039 \end_layout
23040
23041 \end_inset
23042 </cell>
23043 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
23044 \begin_inset Text
23045
23046 \begin_layout Standard
23047 depending on the model used (e.g.: -mds390)
23048 \end_layout
23049
23050 \end_inset
23051 </cell>
23052 </row>
23053 <row topline="true">
23054 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
23055 \begin_inset Text
23056
23057 \begin_layout Standard
23058 __mcs51
23059 \begin_inset LatexCommand \index{\_\_mcs51}
23060
23061 \end_inset
23062
23063 , __ds390
23064 \begin_inset LatexCommand \index{\_\_ds390}
23065
23066 \end_inset
23067
23068 , __hc08
23069 \begin_inset LatexCommand \index{\_\_hc08}
23070
23071 \end_inset
23072
23073 , __z80
23074 \begin_inset LatexCommand \index{\_\_z80}
23075
23076 \end_inset
23077
23078 , etc
23079 \end_layout
23080
23081 \end_inset
23082 </cell>
23083 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
23084 \begin_inset Text
23085
23086 \begin_layout Standard
23087 depending on the model used (e.g.
23088  -mz80)
23089 \end_layout
23090
23091 \end_inset
23092 </cell>
23093 </row>
23094 <row topline="true">
23095 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
23096 \begin_inset Text
23097
23098 \begin_layout Standard
23099 SDCC_STACK_AUTO
23100 \begin_inset LatexCommand \index{SDCC\_STACK\_AUTO}
23101
23102 \end_inset
23103
23104
23105 \end_layout
23106
23107 \end_inset
23108 </cell>
23109 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
23110 \begin_inset Text
23111
23112 \begin_layout Standard
23113 when 
23114 \emph on
23115 -
23116 \begin_inset ERT
23117 status collapsed
23118
23119 \begin_layout Standard
23120
23121
23122 \backslash
23123 /
23124 \end_layout
23125
23126 \end_inset
23127
23128 -stack-auto
23129 \emph default
23130  option is used
23131 \end_layout
23132
23133 \end_inset
23134 </cell>
23135 </row>
23136 <row topline="true">
23137 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
23138 \begin_inset Text
23139
23140 \begin_layout Standard
23141 SDCC_MODEL_SMALL
23142 \begin_inset LatexCommand \index{SDCC\_MODEL\_SMALL}
23143
23144 \end_inset
23145
23146
23147 \end_layout
23148
23149 \end_inset
23150 </cell>
23151 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
23152 \begin_inset Text
23153
23154 \begin_layout Standard
23155 when 
23156 \emph on
23157 -
23158 \begin_inset ERT
23159 status collapsed
23160
23161 \begin_layout Standard
23162
23163
23164 \backslash
23165 /
23166 \end_layout
23167
23168 \end_inset
23169
23170 -model-small
23171 \emph default
23172  is used
23173 \end_layout
23174
23175 \end_inset
23176 </cell>
23177 </row>
23178 <row topline="true">
23179 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
23180 \begin_inset Text
23181
23182 \begin_layout Standard
23183 SDCC_MODEL_MEDIUM
23184 \begin_inset LatexCommand \index{SDCC\_MODEL\_MEDIUM}
23185
23186 \end_inset
23187
23188
23189 \end_layout
23190
23191 \end_inset
23192 </cell>
23193 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
23194 \begin_inset Text
23195
23196 \begin_layout Standard
23197 when 
23198 \emph on
23199 -
23200 \begin_inset ERT
23201 status collapsed
23202
23203 \begin_layout Standard
23204
23205
23206 \backslash
23207 /
23208 \end_layout
23209
23210 \end_inset
23211
23212 -model-medium
23213 \emph default
23214  is used
23215 \end_layout
23216
23217 \end_inset
23218 </cell>
23219 </row>
23220 <row topline="true">
23221 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
23222 \begin_inset Text
23223
23224 \begin_layout Standard
23225 SDCC_MODEL_LARGE
23226 \begin_inset LatexCommand \index{SDCC\_MODEL\_LARGE}
23227
23228 \end_inset
23229
23230
23231 \end_layout
23232
23233 \end_inset
23234 </cell>
23235 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
23236 \begin_inset Text
23237
23238 \begin_layout Standard
23239 when 
23240 \emph on
23241 -
23242 \begin_inset ERT
23243 status collapsed
23244
23245 \begin_layout Standard
23246
23247
23248 \backslash
23249 /
23250 \end_layout
23251
23252 \end_inset
23253
23254 -model-large
23255 \emph default
23256  is used
23257 \end_layout
23258
23259 \end_inset
23260 </cell>
23261 </row>
23262 <row topline="true">
23263 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
23264 \begin_inset Text
23265
23266 \begin_layout Standard
23267 SDCC_USE_XSTACK
23268 \begin_inset LatexCommand \index{SDCC\_USE\_XSTACK}
23269
23270 \end_inset
23271
23272
23273 \end_layout
23274
23275 \end_inset
23276 </cell>
23277 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
23278 \begin_inset Text
23279
23280 \begin_layout Standard
23281 when 
23282 \emph on
23283 -
23284 \begin_inset ERT
23285 status collapsed
23286
23287 \begin_layout Standard
23288
23289
23290 \backslash
23291 /
23292 \end_layout
23293
23294 \end_inset
23295
23296 -xstack
23297 \emph default
23298  option is used
23299 \end_layout
23300
23301 \end_inset
23302 </cell>
23303 </row>
23304 <row topline="true">
23305 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
23306 \begin_inset Text
23307
23308 \begin_layout Standard
23309 SDCC_STACK_TENBIT
23310 \begin_inset LatexCommand \index{SDCC\_STACK\_TENBIT}
23311
23312 \end_inset
23313
23314  
23315 \end_layout
23316
23317 \end_inset
23318 </cell>
23319 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
23320 \begin_inset Text
23321
23322 \begin_layout Standard
23323 when 
23324 \emph on
23325 -mds390
23326 \emph default
23327  is used
23328 \end_layout
23329
23330 \end_inset
23331 </cell>
23332 </row>
23333 <row topline="true">
23334 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
23335 \begin_inset Text
23336
23337 \begin_layout Standard
23338 SDCC_MODEL_FLAT24
23339 \begin_inset LatexCommand \index{SDCC\_MODEL\_FLAT24}
23340
23341 \end_inset
23342
23343
23344 \end_layout
23345
23346 \end_inset
23347 </cell>
23348 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
23349 \begin_inset Text
23350
23351 \begin_layout Standard
23352 when 
23353 \emph on
23354 -mds390
23355 \emph default
23356  is used
23357 \end_layout
23358
23359 \end_inset
23360 </cell>
23361 </row>
23362 <row topline="true">
23363 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
23364 \begin_inset Text
23365
23366 \begin_layout Standard
23367 SDCC_REVISION
23368 \begin_inset LatexCommand \index{SDCC\_REVISION}
23369
23370 \end_inset
23371
23372
23373 \end_layout
23374
23375 \end_inset
23376 </cell>
23377 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
23378 \begin_inset Text
23379
23380 \begin_layout Standard
23381 Always defined.
23382  SDCC svn revision number
23383 \end_layout
23384
23385 \end_inset
23386 </cell>
23387 </row>
23388 <row topline="true">
23389 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
23390 \begin_inset Text
23391
23392 \begin_layout Standard
23393 SDCC_PARMS_IN_BANK1
23394 \begin_inset LatexCommand \index{SDCC\_PARMS\_IN\_BANK1}
23395
23396 \end_inset
23397
23398
23399 \end_layout
23400
23401 \end_inset
23402 </cell>
23403 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
23404 \begin_inset Text
23405
23406 \begin_layout Standard
23407 when 
23408 \emph on
23409 -
23410 \begin_inset ERT
23411 status collapsed
23412
23413 \begin_layout Standard
23414
23415
23416 \backslash
23417 /
23418 \end_layout
23419
23420 \end_inset
23421
23422 -parms-in-bank1
23423 \emph default
23424  is used
23425 \end_layout
23426
23427 \end_inset
23428 </cell>
23429 </row>
23430 <row topline="true">
23431 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
23432 \begin_inset Text
23433
23434 \begin_layout Standard
23435 SDCC_FLOAT_REENT
23436 \begin_inset LatexCommand \index{SDCC\_MODEL\_FLAT24}
23437
23438 \end_inset
23439
23440
23441 \end_layout
23442
23443 \end_inset
23444 </cell>
23445 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
23446 \begin_inset Text
23447
23448 \begin_layout Standard
23449 when 
23450 \emph on
23451 -
23452 \begin_inset ERT
23453 status collapsed
23454
23455 \begin_layout Standard
23456
23457
23458 \backslash
23459 /
23460 \end_layout
23461
23462 \end_inset
23463
23464 -float-reent
23465 \emph default
23466  is used
23467 \end_layout
23468
23469 \end_inset
23470 </cell>
23471 </row>
23472 <row topline="true" bottomline="true">
23473 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
23474 \begin_inset Text
23475
23476 \begin_layout Standard
23477 SDCC_INT_LONG_REENT
23478 \begin_inset LatexCommand \index{SDCC\_INT\_LONG\_REENT}
23479
23480 \end_inset
23481
23482
23483 \end_layout
23484
23485 \end_inset
23486 </cell>
23487 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
23488 \begin_inset Text
23489
23490 \begin_layout Standard
23491 when 
23492 \emph on
23493 -
23494 \begin_inset ERT
23495 status collapsed
23496
23497 \begin_layout Standard
23498
23499
23500 \backslash
23501 /
23502 \end_layout
23503
23504 \end_inset
23505
23506 -int-long-reent
23507 \emph default
23508  is used
23509 \end_layout
23510
23511 \end_inset
23512 </cell>
23513 </row>
23514 </lyxtabular>
23515
23516 \end_inset
23517
23518
23519 \end_layout
23520
23521 \begin_layout Chapter
23522 Notes on supported Processors
23523 \end_layout
23524
23525 \begin_layout Section
23526 MCS51 variants
23527 \begin_inset LatexCommand \label{sub:MCS51-variants}
23528
23529 \end_inset
23530
23531
23532 \begin_inset LatexCommand \index{MCS51 variants}
23533
23534 \end_inset
23535
23536
23537 \end_layout
23538
23539 \begin_layout Standard
23540 MCS51 processors are available from many vendors and come in many different
23541  flavours.
23542  While they might differ considerably in respect to Special Function Registers
23543  the core MCS51 is usually not modified or is kept compatible.
23544  
23545 \end_layout
23546
23547 \begin_layout Subsection
23548 pdata access by SFR 
23549 \end_layout
23550
23551 \begin_layout Standard
23552 With the upcome of devices with internal xdata and flash memory devices
23553  using port P2
23554 \begin_inset LatexCommand \index{P2 (mcs51 sfr)}
23555
23556 \end_inset
23557
23558  as dedicated I/O port is becoming more popular.
23559  Switching the high byte for pdata
23560 \begin_inset LatexCommand \index{pdata (mcs51, ds390 storage class)}
23561
23562 \end_inset
23563
23564  access which was formerly done by port P2 is then achieved by a Special
23565  Function Register
23566 \begin_inset LatexCommand \index{sfr}
23567
23568 \end_inset
23569
23570 .
23571  In well-established MCS51 tradition the address of this 
23572 \emph on
23573 sfr
23574 \emph default
23575  is where the chip designers decided to put it.
23576  Needless to say that they didn't agree on a common name either.
23577  So that the startup code can correctly initialize xdata variables, you
23578  should define an sfr with the name _XPAGE
23579 \family typewriter
23580
23581 \begin_inset LatexCommand \index{\_XPAGE (mcs51)}
23582
23583 \end_inset
23584
23585
23586 \family default
23587  at the appropriate location if the default, port P2, is not used for this.
23588  Some examples are:
23589 \end_layout
23590
23591 \begin_layout Verse
23592
23593 \family typewriter
23594 __sfr __at (0x85) _XPAGE; /* Ramtron VRS51 family a.k.a.
23595  MPAGE */
23596 \end_layout
23597
23598 \begin_layout Verse
23599
23600 \family typewriter
23601 __sfr __at (0x92) _XPAGE; /* Cypress EZ-USB family, Texas Instruments (Chipcon)
23602  a.k.a.
23603  MPAGE */
23604 \end_layout
23605
23606 \begin_layout Verse
23607
23608 \family typewriter
23609 __sfr __at (0x91) _XPAGE; /* Infineon (Siemens) C500 family a.k.a.
23610  XPAGE */
23611 \end_layout
23612
23613 \begin_layout Verse
23614
23615 \family typewriter
23616 __sfr __at (0xaf) _XPAGE; /* some Silicon Labs (Cygnal) chips a.k.a.
23617  EMI0CN */
23618 \end_layout
23619
23620 \begin_layout Verse
23621
23622 \family typewriter
23623 __sfr __at (0xaa) _XPAGE; /* some Silicon Labs (Cygnal) chips a.k.a.
23624  EMI0CN */
23625 \end_layout
23626
23627 \begin_layout Standard
23628 For more exotic implementations further customizations may be needed.
23629  See section 
23630 \begin_inset LatexCommand \ref{sub:Startup-Code}
23631
23632 \end_inset
23633
23634  for other possibilities.
23635 \end_layout
23636
23637 \begin_layout Subsection
23638 Other Features available by SFR
23639 \end_layout
23640
23641 \begin_layout Standard
23642 Some MCS51 variants offer features like Double DPTR
23643 \begin_inset LatexCommand \index{DPTR}
23644
23645 \end_inset
23646
23647 , multiple DPTR, decrementing DPTR, 16x16 Multiply.
23648  These are currently not used for the MCS51 port.
23649  If you absolutely need them you can fall back to inline assembly or submit
23650  a patch to SDCC.
23651 \end_layout
23652
23653 \begin_layout Subsection
23654 Bankswitching
23655 \end_layout
23656
23657 \begin_layout Standard
23658 Bankswitching
23659 \begin_inset LatexCommand \index{Bankswitching}
23660
23661 \end_inset
23662
23663  (a.k.a.
23664  code banking
23665 \begin_inset LatexCommand \index{code banking}
23666
23667 \end_inset
23668
23669 ) is a technique to increase the code space above the 64k limit of the 8051.
23670 \end_layout
23671
23672 \begin_layout Subsubsection
23673 Hardware
23674 \end_layout
23675
23676 \begin_layout Standard
23677 \begin_inset Tabular
23678 <lyxtabular version="3" rows="3" columns="4">
23679 <features>
23680 <column alignment="center" valignment="top" width="0">
23681 <column alignment="center" valignment="top" leftline="true" width="0">
23682 <column alignment="center" valignment="top" leftline="true" width="0">
23683 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
23684 <row topline="true" bottomline="true">
23685 <cell multicolumn="1" alignment="center" valignment="top" usebox="none">
23686 \begin_inset Text
23687
23688 \begin_layout Standard
23689 8000-FFFF
23690 \end_layout
23691
23692 \end_inset
23693 </cell>
23694 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
23695 \begin_inset Text
23696
23697 \begin_layout Standard
23698 bank1
23699 \end_layout
23700
23701 \end_inset
23702 </cell>
23703 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
23704 \begin_inset Text
23705
23706 \begin_layout Standard
23707 bank2
23708 \end_layout
23709
23710 \end_inset
23711 </cell>
23712 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
23713 \begin_inset Text
23714
23715 \begin_layout Standard
23716 bank3
23717 \end_layout
23718
23719 \end_inset
23720 </cell>
23721 </row>
23722 <row topline="true" bottomline="true">
23723 <cell multicolumn="1" alignment="center" valignment="top" usebox="none">
23724 \begin_inset Text
23725
23726 \begin_layout Standard
23727 0000-7FFF
23728 \end_layout
23729
23730 \end_inset
23731 </cell>
23732 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
23733 \begin_inset Text
23734
23735 \begin_layout Standard
23736 common
23737 \end_layout
23738
23739 \end_inset
23740 </cell>
23741 <cell multicolumn="1" alignment="center" valignment="top" usebox="none">
23742 \begin_inset Text
23743
23744 \begin_layout Standard
23745
23746 \end_layout
23747
23748 \end_inset
23749 </cell>
23750 <cell multicolumn="2" alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
23751 \begin_inset Text
23752
23753 \begin_layout Standard
23754
23755 \end_layout
23756
23757 \end_inset
23758 </cell>
23759 </row>
23760 <row>
23761 <cell multicolumn="1" alignment="center" valignment="top" usebox="none">
23762 \begin_inset Text
23763
23764 \begin_layout Standard
23765 SiLabs C8051F120 example
23766 \end_layout
23767
23768 \end_inset
23769 </cell>
23770 <cell multicolumn="2" alignment="center" valignment="top" usebox="none">
23771 \begin_inset Text
23772
23773 \begin_layout Standard
23774
23775 \end_layout
23776
23777 \end_inset
23778 </cell>
23779 <cell multicolumn="2" alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
23780 \begin_inset Text
23781
23782 \begin_layout Standard
23783
23784 \end_layout
23785
23786 \end_inset
23787 </cell>
23788 <cell multicolumn="2" alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
23789 \begin_inset Text
23790
23791 \begin_layout Standard
23792
23793 \end_layout
23794
23795 \end_inset
23796 </cell>
23797 </row>
23798 </lyxtabular>
23799
23800 \end_inset
23801
23802
23803 \newline
23804
23805 \newline
23806 Usually the hardware uses some sfr (an output port or an internal sfr) to
23807  select a bank and put it in the banked area of the memory map.
23808  The selected bank usually becomes active immediately upon assignment to
23809  this sfr and when running inside a bank it will switch out this code it
23810  is currently running.
23811  Therefor you cannot jump or call directly from one bank to another and
23812  need to use a so-called trampoline in the common area.
23813  For SDCC an example trampoline is in crtbank.asm and you may need to change
23814  it to your 8051 derivative or schematic.
23815  The presented code is written for the C8051F120.
23816 \newline
23817
23818 \newline
23819 When calling a banked function
23820  SDCC will put the LSB of the functions address in register R0, the MSB
23821  in R1 and the bank in R2 and then call this trampoline 
23822 \emph on
23823 __sdcc_banked_call
23824 \emph default
23825 .
23826  The current selected bank is saved on the stack, the new bank is selected
23827  and an indirect jump is made.
23828  When the banked function returns it jumps to 
23829 \emph on
23830 __sdcc_banked_ret
23831 \emph default
23832  which restores the previous bank and returns to the caller.
23833 \end_layout
23834
23835 \begin_layout Subsubsection
23836 Software
23837 \end_layout
23838
23839 \begin_layout Standard
23840 When writing banked software using SDCC you need to use some special keywords
23841  and options.
23842  You also need to take over a bit of work from the linker.
23843 \newline
23844
23845 \newline
23846 To create a function
23847  that can be called from another bank it requires the keyword 
23848 \emph on
23849 banked
23850 \emph default
23851
23852 \begin_inset LatexCommand \index{banked}
23853
23854 \end_inset
23855
23856 .
23857  The caller must see this in the prototype of the callee and the callee
23858  needs it for a proper return.
23859  Called functions within the same bank as the caller do not need the 
23860 \emph on
23861 banked
23862 \emph default
23863  keyword nor do functions in the common area.
23864  Beware: SDCC does not know or check if functions are in the same bank.
23865  This is your responsibility!
23866 \newline
23867
23868 \newline
23869 Normally all functions you write end up in
23870  the segment CSEG.
23871  If you want a function explicitly to reside in the common area put it in
23872  segment HOME.
23873  This applies for instance to interrupt service routines as they should
23874  not be banked.
23875 \end_layout
23876
23877 \begin_layout Standard
23878 Functions that need to be in a switched bank must be put in a named segment.
23879  The name can be mostly anything upto eight characters (e.g.
23880  BANK1).
23881  To do this you either use -
23882 \begin_inset ERT
23883 status collapsed
23884
23885 \begin_layout Standard
23886
23887
23888 \backslash
23889 /
23890 \end_layout
23891
23892 \end_inset
23893
23894 -codeseg BANK1 (See 
23895 \begin_inset LatexCommand \ref{lyx:-codeseg}
23896
23897 \end_inset
23898
23899 ) on the command line when compiling or #pragma codeseg BANK1 (See 
23900 \begin_inset LatexCommand \ref{sec:Pragmas}
23901
23902 \end_inset
23903
23904 ) at the top of the C source file.
23905  The segment name always applies to the whole source file and generated
23906  object so functions for different banks need to be defined in different
23907  source files.
23908 \newline
23909
23910 \newline
23911 When linking your objects you need to tell the linker where
23912  to put your segments.
23913  To do this you use the following command line option to SDCC: -Wl-b BANK1=0x180
23914 00 (See 
23915 \begin_inset LatexCommand \ref{lyx:-Wl option}
23916
23917 \end_inset
23918
23919 ).
23920  This sets the virtual start address of this segment.
23921  It sets the banknumber to 0x01 and maps the bank to 0x8000 and up.
23922  The linker will not check for overflows, again this is your responsibility.
23923 \end_layout
23924
23925 \begin_layout Standard
23926 \begin_inset VSpace bigskip
23927 \end_inset
23928
23929
23930 \end_layout
23931
23932 \begin_layout Section
23933 DS400 port
23934 \end_layout
23935
23936 \begin_layout Standard
23937 The DS80C400
23938 \begin_inset LatexCommand \index{DS80C400}
23939
23940 \end_inset
23941
23942
23943 \begin_inset LatexCommand \index{DS400}
23944
23945 \end_inset
23946
23947  microcontroller has a rich set of peripherals.
23948  In its built-in ROM library it includes functions to access some of the
23949  features, among them is a TCP stack with IP4 and IP6 support.
23950  Library headers (currently in beta status) and other files are provided
23951  at 
23952 \size footnotesize
23953
23954 \begin_inset LatexCommand \url{ftp://ftp.dalsemi.com/pub/tini/ds80c400/c_libraries/sdcc/index.html}
23955
23956 \end_inset
23957
23958 .
23959  
23960 \begin_inset VSpace bigskip
23961 \end_inset
23962
23963
23964 \end_layout
23965
23966 \begin_layout Section
23967 The Z80 and gbz80 port
23968 \end_layout
23969
23970 \begin_layout Standard
23971 SDCC can target both the Zilog Z80
23972 \begin_inset LatexCommand \index{Z80}
23973
23974 \end_inset
23975
23976  and the Nintendo Gameboy's Z80-like gbz80
23977 \begin_inset LatexCommand \index{gbz80 (GameBoy Z80)}
23978
23979 \end_inset
23980
23981 .
23982  The Z80 port is passed through the same 
23983 \emph on
23984 regressions tests
23985 \begin_inset LatexCommand \index{Regression test}
23986
23987 \end_inset
23988
23989
23990 \emph default
23991  (see section 
23992 \begin_inset LatexCommand \ref{sec:Quality-control}
23993
23994 \end_inset
23995
23996 ) as the MCS51 and DS390 ports, so floating point support, support for long
23997  variables and bitfield support is fine.
23998  See mailing lists and forums about interrupt routines.
23999 \end_layout
24000
24001 \begin_layout Standard
24002 As always, the code is the authoritative reference - see z80/ralloc.c and
24003  z80/gen.c.
24004  The stack
24005 \begin_inset LatexCommand \index{Z80!stack}
24006
24007 \end_inset
24008
24009  frame is similar to that generated by the IAR Z80 compiler.
24010  IX is used as the base pointer, HL and IY are used as a temporary registers,
24011  and BC and DE are available for holding variables.
24012  Return values
24013 \begin_inset LatexCommand \index{Z80!return value}
24014
24015 \end_inset
24016
24017  for the Z80 port are stored in L (one byte), HL (two bytes), or DEHL (four
24018  bytes).
24019  The gbz80 port use the same set of registers for the return values, but
24020  in a different order of significance: E (one byte), DE (two bytes), or
24021  HLDE (four bytes).
24022 \begin_inset VSpace bigskip
24023 \end_inset
24024
24025
24026 \end_layout
24027
24028 \begin_layout Section
24029 The HC08 port
24030 \end_layout
24031
24032 \begin_layout Standard
24033 The port to the Freescale/Motorola HC08
24034 \begin_inset LatexCommand \index{HC08}
24035
24036 \end_inset
24037
24038  family has been added in October 2003, and is still undergoing some basic
24039  development.
24040  The code generator is complete, but the register allocation is still quite
24041  unoptimized.
24042  Some of the SDCC's standard C library functions have embedded non-HC08
24043  inline assembly and so are not yet usable.
24044 \end_layout
24045
24046 \begin_layout Standard
24047 The HC08 port passes the regression test suite (see section 
24048 \begin_inset LatexCommand \ref{sec:Quality-control}
24049
24050 \end_inset
24051
24052 ).
24053 \begin_inset VSpace bigskip
24054 \end_inset
24055
24056
24057 \end_layout
24058
24059 \begin_layout Section
24060 The PIC14
24061 \begin_inset LatexCommand \index{PIC14}
24062
24063 \end_inset
24064
24065  port
24066 \end_layout
24067
24068 \begin_layout Standard
24069 The PIC14 port adds support for Microchip
24070 \begin_inset LatexCommand \index{Microchip}
24071
24072 \end_inset
24073
24074
24075 \begin_inset Formula $^{\text{TM}}$
24076 \end_inset
24077
24078  PIC
24079 \begin_inset LatexCommand \index{PIC14}
24080
24081 \end_inset
24082
24083
24084 \begin_inset Formula $^{\text{TM}}$
24085 \end_inset
24086
24087  MCUs with 14 bit wide instructions.
24088  This port is not yet mature and still lacks many features.
24089  However, it can work for simple code.
24090 \end_layout
24091
24092 \begin_layout Standard
24093 \noindent
24094 Currently supported devices include:
24095 \end_layout
24096
24097 \begin_layout Standard
24098 12F: 629, 635, 675, 683
24099 \end_layout
24100
24101 \begin_layout Standard
24102 16C: 432, 433
24103 \end_layout
24104
24105 \begin_layout Standard
24106 16C: 554, 557, 558
24107 \end_layout
24108
24109 \begin_layout Standard
24110 16C: 62, 620, 620a, 621, 621a, 622, 622a, 63a, 65b
24111 \end_layout
24112
24113 \begin_layout Standard
24114 16C: 71, 710, 711, 715, 717, 72, 73b, 745, 74b, 765, 770, 771, 773, 774,
24115  781, 782
24116 \end_layout
24117
24118 \begin_layout Standard
24119 16C: 925, 926
24120 \end_layout
24121
24122 \begin_layout Standard
24123 16CR: 620a, 73, 74, 76, 77
24124 \end_layout
24125
24126 \begin_layout Standard
24127 16F: 616, 627, 627a, 628, 628a, 630, 636, 639, 648, 648a, 676, 684, 685,
24128  687, 688, 689, 690
24129 \end_layout
24130
24131 \begin_layout Standard
24132 16F: 716, 72, 73, 737, 74, 747, 76, 767, 77, 777, 785
24133 \end_layout
24134
24135 \begin_layout Standard
24136 16F: 818, 819, 84, 84a, 87, 870, 871, 872, 873, 873a, 874, 874a, 876, 876a,
24137  877, 877a, 88, 886, 887
24138 \end_layout
24139
24140 \begin_layout Standard
24141 16F: 913, 914, 916, 917, 946
24142 \end_layout
24143
24144 \begin_layout Standard
24145 26HV: 626, 785
24146 \end_layout
24147
24148 \begin_layout Standard
24149 \noindent
24150 An up-to-date list of currently supported devices can be obtained via 
24151 \family typewriter
24152 sdcc -mpic14 -phelp foo.c
24153 \family default
24154  (foo.c must exist...).
24155 \end_layout
24156
24157 \begin_layout Subsection
24158 PIC Code Pages
24159 \begin_inset LatexCommand \index{code page (pic14)}
24160
24161 \end_inset
24162
24163  and Memory Banks
24164 \begin_inset LatexCommand \index{Memory bank (pic14)}
24165
24166 \end_inset
24167
24168
24169 \end_layout
24170
24171 \begin_layout Standard
24172 The linker organizes allocation for the code page and RAM banks.
24173  It does not have intimate knowledge of the code flow.
24174  It will put all the code section of a single .asm file into a single code
24175  page.
24176  In order to make use of multiple code pages, separate asm files must be
24177  used.
24178  The compiler assigns all 
24179 \emph on
24180 static
24181 \emph default
24182  functions of a single .c file into the same code page.
24183 \newline
24184
24185 \newline
24186 To get the best results,
24187  follow these guidelines:
24188 \end_layout
24189
24190 \begin_layout Enumerate
24191 Make local functions static, as non static functions require code page selection
24192  overhead.
24193 \newline
24194 Due to the way sdcc handles functions, place called functions prior
24195  to calling functions in the file wherever possible: Otherwise sdcc will
24196  insert unneccessary pagesel directives around the call, believing that
24197  the called function is externally defined.
24198 \end_layout
24199
24200 \begin_layout Enumerate
24201 For devices that have multiple code pages it is more efficient to use the
24202  same number of files as pages: Use up to 4 separate .c files for the 16F877,
24203  but only 2 files for the 16F874.
24204  This way the linker can put the code for each file into different code
24205  pages and there will be less page selection overhead.
24206 \end_layout
24207
24208 \begin_layout Enumerate
24209 And as for any 8 bit micro (especially for PIC14 as they have a very simple
24210  instruction set), use `unsigned char' wherever possible instead of `int'.
24211 \end_layout
24212
24213 \begin_layout Subsection
24214 Adding New Devices to the Port 
24215 \end_layout
24216
24217 \begin_layout Standard
24218 Adding support for a new 14
24219 \begin_inset ERT
24220 status open
24221
24222 \begin_layout Standard
24223
24224
24225 \backslash
24226 ,
24227 \end_layout
24228
24229 \end_inset
24230
24231 bit PIC MCU requires the following steps:
24232 \end_layout
24233
24234 \begin_layout Enumerate
24235 Create a new device description.
24236 \newline
24237 Each device is described in two files: pic16f*.h
24238  and pic16f*.c.
24239  These files primarily define SFRs, structs to access their bits, and symbolic
24240  configuration options.
24241  Both files can be generated from gputils' .inc files using the perl script
24242  
24243 \family typewriter
24244 support/scripts/inc2h.pl
24245 \family default
24246 .
24247  This file also contains further instructions on how to proceed.
24248 \end_layout
24249
24250 \begin_layout Enumerate
24251 Copy the .h file into SDCC's include path and either add the .c file to your
24252  project or copy it to 
24253 \family typewriter
24254 device/lib/pic/libdev
24255 \family default
24256 .
24257  Afterwards, rebuild and install the libraries.
24258 \end_layout
24259
24260 \begin_layout Enumerate
24261 Edit pic14devices.txt in SDCC's include path (
24262 \family typewriter
24263 device/include/pic/
24264 \family default
24265  in the source tree or 
24266 \family typewriter
24267 /usr/local/share/sdcc/include/pic
24268 \family default
24269  after installation).
24270 \newline
24271 You need to add a device specification here to make
24272  the memory layout (code banks, RAM, aliased memory regions, ...) known to
24273  the compiler.
24274  Probably you can copy and modify an existing entry.
24275  The file format is documented at the top of the file.
24276 \end_layout
24277
24278 \begin_layout Subsection
24279 Interrupt Code
24280 \end_layout
24281
24282 \begin_layout Standard
24283 For the interrupt function, use the keyword `__interrupt'
24284 \begin_inset LatexCommand \index{PIC14!interrupt}
24285
24286 \end_inset
24287
24288  with level number of 0 (PIC14 only has 1 interrupt so this number is only
24289  there to avoid a syntax error - it ought to be fixed).
24290  E.g.:
24291 \end_layout
24292
24293 \begin_layout Verse
24294
24295 \family typewriter
24296 void Intr(void) __interrupt 0
24297 \newline
24298 {
24299 \newline
24300 \InsetSpace ~
24301 \InsetSpace ~
24302 T0IF = 0; /* Clear timer interrupt */
24303 \newline
24304 }
24305 \end_layout
24306
24307 \begin_layout Subsection
24308 Linking and Assembling
24309 \end_layout
24310
24311 \begin_layout Standard
24312 For assembling you can use either GPUTILS'
24313 \begin_inset LatexCommand \index{gputils (pic tools)}
24314
24315 \end_inset
24316
24317  gpasm.exe or MPLAB's mpasmwin.exe.
24318  GPUTILS are available from 
24319 \begin_inset LatexCommand \url{http://sourceforge.net/projects/gputils}
24320
24321 \end_inset
24322
24323 .
24324  For linking you can use either GPUTILS' gplink or MPLAB's mplink.exe.
24325  If you use MPLAB and an interrupt function then the linker script file
24326  vectors section will need to be enlarged to link with mplink.
24327 \newline
24328
24329 \newline
24330 Here is a 
24331 \family typewriter
24332 Makefile
24333 \family default
24334  using GPUTILS:
24335 \end_layout
24336
24337 \begin_layout Verse
24338
24339 \family typewriter
24340 .c.o:
24341 \newline
24342 \InsetSpace ~
24343 \InsetSpace ~
24344 \InsetSpace ~
24345 \InsetSpace ~
24346 \InsetSpace ~
24347 \InsetSpace ~
24348 \InsetSpace ~
24349 \InsetSpace ~
24350 sdcc -V -mpic14 -p16f877 -c $< 
24351 \newline
24352
24353 \newline
24354 $(PRJ).hex: $(OBJS) 
24355 \newline
24356 \InsetSpace ~
24357 \InsetSpace ~
24358 \InsetSpace ~
24359 \InsetSpace ~
24360 \InsetSpace ~
24361 \InsetSpace ~
24362 \InsetSpace ~
24363 \InsetSpace ~
24364 gplink -m -s $(PRJ).lkr
24365  -o $(PRJ).hex $(OBJS) libsdcc.lib
24366 \end_layout
24367
24368 \begin_layout Standard
24369 Here is a 
24370 \family typewriter
24371 Makefile
24372 \family default
24373  using MPLAB:
24374 \end_layout
24375
24376 \begin_layout Verse
24377
24378 \family typewriter
24379 .c.o: 
24380 \newline
24381 \InsetSpace ~
24382 \InsetSpace ~
24383 \InsetSpace ~
24384 \InsetSpace ~
24385 \InsetSpace ~
24386 \InsetSpace ~
24387 \InsetSpace ~
24388 \InsetSpace ~
24389 sdcc -S -V -mpic14 -p16f877 $< 
24390 \newline
24391 \InsetSpace ~
24392 \InsetSpace ~
24393 \InsetSpace ~
24394 \InsetSpace ~
24395 \InsetSpace ~
24396 \InsetSpace ~
24397 \InsetSpace ~
24398 \InsetSpace ~
24399 mpasmwin /q /o $*.asm
24400 \newline
24401
24402 \newline
24403 $(PRJ).hex: $(OBJS)
24404  
24405 \newline
24406 \InsetSpace ~
24407 \InsetSpace ~
24408 \InsetSpace ~
24409 \InsetSpace ~
24410 \InsetSpace ~
24411 \InsetSpace ~
24412 \InsetSpace ~
24413 \InsetSpace ~
24414 mplink /v $(PRJ).lkr /m $(PRJ).map /o $(PRJ).hex $(OBJS) libsdcc.lib
24415 \end_layout
24416
24417 \begin_layout Standard
24418 Please note that indentations within a
24419 \family typewriter
24420  Makefile
24421 \family default
24422  have to be done with a tabulator character.
24423 \end_layout
24424
24425 \begin_layout Subsection
24426 Command-Line Options
24427 \end_layout
24428
24429 \begin_layout Standard
24430 Besides the switches common to all SDCC backends, the PIC14 port accepts
24431  the following options (for an updated list see sdcc -
24432 \begin_inset ERT
24433 status collapsed
24434
24435 \begin_layout Standard
24436
24437
24438 \backslash
24439 /
24440 \end_layout
24441
24442 \end_inset
24443
24444 -help):
24445 \end_layout
24446
24447 \begin_layout Description
24448 -
24449 \begin_inset ERT
24450 status collapsed
24451
24452 \begin_layout Standard
24453
24454
24455 \backslash
24456 /
24457 \end_layout
24458
24459 \end_inset
24460
24461 -debug-xtra
24462 \begin_inset LatexCommand \index{PIC14!Options!-\/-debug-extra}
24463
24464 \end_inset
24465
24466  emit debug info in assembly output
24467 \end_layout
24468
24469 \begin_layout Description
24470 -
24471 \begin_inset ERT
24472 status collapsed
24473
24474 \begin_layout Standard
24475
24476
24477 \backslash
24478 /
24479 \end_layout
24480
24481 \end_inset
24482
24483 -no-pcode-opt
24484 \begin_inset LatexCommand \index{PIC14!Options!-\/-no-pcode-opt}
24485
24486 \end_inset
24487
24488  disable (slightly faulty) optimization on pCode
24489 \end_layout
24490
24491 \begin_layout Description
24492 -
24493 \begin_inset ERT
24494 status collapsed
24495
24496 \begin_layout Standard
24497
24498
24499 \backslash
24500 /
24501 \end_layout
24502
24503 \end_inset
24504
24505 -stack-loc
24506 \begin_inset LatexCommand \index{PIC14!Options!-\/-stack-loc}
24507
24508 \end_inset
24509
24510  sets the lowest address of the argument passing stack (defaults to a suitably
24511  large shared databank to reduce BANKSEL overhead)
24512 \end_layout
24513
24514 \begin_layout Description
24515 -
24516 \begin_inset ERT
24517 status collapsed
24518
24519 \begin_layout Standard
24520
24521
24522 \backslash
24523 /
24524 \end_layout
24525
24526 \end_inset
24527
24528 -stack-size
24529 \begin_inset LatexCommand \index{PIC14!Options!-\/-stack-size}
24530
24531 \end_inset
24532
24533  sets the size if the argument passing stack (default: 16, minimum: 4)
24534 \end_layout
24535
24536 \begin_layout Subsection
24537 Environment Variables
24538 \end_layout
24539
24540 \begin_layout Standard
24541 The PIC14 port recognizes the following environment variables:
24542 \end_layout
24543
24544 \begin_layout Description
24545 SDCC_PIC14_SPLIT_LOCALS If set and not empty, sdcc will allocate each temporary
24546  register (the ones called r0xNNNN) in a section of its own.
24547  By default (if this variable is unset), sdcc tries to cluster registers
24548  in sections in order to reduce the BANKSEL overhead when accessing them.
24549 \end_layout
24550
24551 \begin_layout Subsection
24552 The Library
24553 \end_layout
24554
24555 \begin_layout Standard
24556 The PIC14 library currently only contains support routines required by the
24557  compiler to implement multiplication, division, and floating point support.
24558  No libc-like replacement is available at the moment, though many of the
24559  common sdcc library sources (in 
24560 \family typewriter
24561 device/lib
24562 \family default
24563 ) should also compile with the PIC14 port.
24564 \end_layout
24565
24566 \begin_layout Subsubsection
24567 error: missing definition for symbol ``__gptrget1''
24568 \end_layout
24569
24570 \begin_layout Standard
24571 The PIC14 port uses library routines to provide more complex operations
24572  like multiplication, division/modulus and (generic) pointer dereferencing.
24573  In order to add these routines to your project, you must link with PIC14's
24574  
24575 \family typewriter
24576 libsdcc.lib
24577 \family default
24578 .
24579  For single source file projects this is done automatically, more complex
24580  projects must add 
24581 \family typewriter
24582 libsdcc.lib
24583 \family default
24584  to the linker's arguments.
24585  Make sure you also add an include path for the library (using the -I switch
24586  to the linker)!
24587 \end_layout
24588
24589 \begin_layout Subsubsection
24590 Processor mismatch in file ``XXX''.
24591 \end_layout
24592
24593 \begin_layout Standard
24594 This warning can usually be ignored due to the very good compatibility amongst
24595  14
24596 \begin_inset ERT
24597 status open
24598
24599 \begin_layout Standard
24600
24601
24602 \backslash
24603 ,
24604 \end_layout
24605
24606 \end_inset
24607
24608 bit PIC
24609 \begin_inset LatexCommand \index{PIC14}
24610
24611 \end_inset
24612
24613  devices.
24614 \end_layout
24615
24616 \begin_layout Standard
24617 You might also consider recompiling the library for your specific device
24618  by changing the ARCH=p16f877 (default target) entry in 
24619 \family typewriter
24620 device/lib/pic/Makefile.in
24621 \family default
24622  and 
24623 \family typewriter
24624 device/lib/pic/Makefile
24625 \family default
24626  to reflect your device.
24627  This might even improve performance for smaller devices as unneccesary
24628  BANKSELs might be removed.
24629 \end_layout
24630
24631 \begin_layout Subsection
24632 Known Bugs
24633 \end_layout
24634
24635 \begin_layout Subsubsection
24636 Function arguments
24637 \end_layout
24638
24639 \begin_layout Standard
24640 Functions with variable argument lists (like printf) are not yet supported.
24641  Similarly, taking the address of the first argument passed into a function
24642  does not work: It is currently passed in WREG and has no address...
24643 \end_layout
24644
24645 \begin_layout Subsubsection
24646 Regression tests fail
24647 \end_layout
24648
24649 \begin_layout Standard
24650 Though the small subset of regression tests in src/regression passes, SDCC
24651  regression test suite does not, indicating that there are still major bugs
24652  in the port.
24653  However, many smaller projects have successfully used SDCC in the past...
24654 \end_layout
24655
24656 \begin_layout Standard
24657
24658 \size footnotesize
24659
24660 \newpage
24661
24662 \end_layout
24663
24664 \begin_layout Section
24665 The PIC16
24666 \begin_inset LatexCommand \index{PIC16}
24667
24668 \end_inset
24669
24670  port
24671 \end_layout
24672
24673 \begin_layout Standard
24674 The PIC16 port adds support for Microchip
24675 \begin_inset LatexCommand \index{Microchip}
24676
24677 \end_inset
24678
24679
24680 \begin_inset Formula $^{\text{TM}}$
24681 \end_inset
24682
24683  PIC
24684 \begin_inset LatexCommand \index{PIC}
24685
24686 \end_inset
24687
24688
24689 \begin_inset Formula $^{\text{TM}}$
24690 \end_inset
24691
24692  MCUs with 16 bit wide instructions.
24693  Currently this family of microcontrollers contains the PIC18Fxxx and PIC18Fxxxx
24694 ; devices supported by the port include:
24695 \end_layout
24696
24697 \begin_layout Standard
24698 18F: 242, 248, 252, 258, 442, 448, 452, 458
24699 \end_layout
24700
24701 \begin_layout Standard
24702 18F: 1220, 1320
24703 \end_layout
24704
24705 \begin_layout Standard
24706 18F: 2220, 2221, 2320, 2321, 2331, 2410, 2420, 2423, 2431, 2450, 2455, 2480,
24707  24j10
24708 \end_layout
24709
24710 \begin_layout Standard
24711 18F: (2510,) 2515, 2520, 2523, 2525, 2550, 2580, 2585, 25j10, 2610, 2620,
24712  2680, 2682, 2685
24713 \end_layout
24714
24715 \begin_layout Standard
24716 18F: 4220, 4221, 4320, 4321, 4331, 4410, 4420, 4423, 4431, 4450, 4455, 4480,
24717  44j10
24718 \end_layout
24719
24720 \begin_layout Standard
24721 18F: 4510, 4515, 4520, 4523, 4525, 4550, 4580, 4585, 45j10, 4610, 4620,
24722  4680, 4682, 4685
24723 \end_layout
24724
24725 \begin_layout Standard
24726 18F: 6520, 6585, 6620, 6680, 66j60, 66j65, 6720, 67j60
24727 \end_layout
24728
24729 \begin_layout Standard
24730 18F: 8520, 8585, 8620, 8680, 86j60, 86j65, 8720, 87j60
24731 \end_layout
24732
24733 \begin_layout Standard
24734 18F: 96j60, 96j65, 97j60
24735 \end_layout
24736
24737 \begin_layout Standard
24738 \noindent
24739 An up-to-date list of supported devices is also available via '
24740 \family typewriter
24741 sdcc -mpic16 -plist
24742 \family default
24743 '.
24744 \end_layout
24745
24746 \begin_layout Subsection
24747 Global Options
24748 \end_layout
24749
24750 \begin_layout Standard
24751 PIC16 port supports the standard command line arguments as supposed, with
24752  the exception of certain cases that will be mentioned in the following
24753  list:
24754 \end_layout
24755
24756 \begin_layout Description
24757 -
24758 \begin_inset ERT
24759 status collapsed
24760
24761 \begin_layout Standard
24762
24763
24764 \backslash
24765 /
24766 \end_layout
24767
24768 \end_inset
24769
24770 -callee-saves
24771 \begin_inset LatexCommand \index{PIC16!Options!-\/-callee-saves}
24772
24773 \end_inset
24774
24775  See -
24776 \begin_inset ERT
24777 status collapsed
24778
24779 \begin_layout Standard
24780
24781
24782 \backslash
24783 /
24784 \end_layout
24785
24786 \end_inset
24787
24788 -all-callee-saves
24789 \end_layout
24790
24791 \begin_layout Description
24792 -
24793 \begin_inset ERT
24794 status collapsed
24795
24796 \begin_layout Standard
24797
24798
24799 \backslash
24800 /
24801 \end_layout
24802
24803 \end_inset
24804
24805 -fommit-frame-pointer
24806 \begin_inset LatexCommand \index{PIC16!Options!-\/-fommit-frame-pointer}
24807
24808 \end_inset
24809
24810  Frame pointer will be omitted when the function uses no local variables.
24811 \end_layout
24812
24813 \begin_layout Subsection
24814 Port Specific Options
24815 \begin_inset LatexCommand \index{Options PIC16}
24816
24817 \end_inset
24818
24819
24820 \end_layout
24821
24822 \begin_layout Standard
24823 The port specific options appear after the global options in the sdcc -
24824 \begin_inset ERT
24825 status collapsed
24826
24827 \begin_layout Standard
24828
24829
24830 \backslash
24831 /
24832 \end_layout
24833
24834 \end_inset
24835
24836 -help output.
24837 \end_layout
24838
24839 \begin_layout Subsubsection
24840 Code Generation Options
24841 \end_layout
24842
24843 \begin_layout Standard
24844 These options influence the generated assembler code.
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 -pstack-model=[model] Used in conjuction with the command above.
24862  Defines the stack model to be used, valid stack models are:
24863 \end_layout
24864
24865 \begin_deeper
24866 \begin_layout List
24867 \labelwidthstring 00.00.0000
24868
24869 \emph on
24870 small
24871 \emph default
24872  Selects small stack model.
24873  8 bit stack and frame pointers.
24874  Supports 256 bytes stack size.
24875 \end_layout
24876
24877 \begin_layout List
24878 \labelwidthstring 00.00.0000
24879
24880 \emph on
24881 large
24882 \emph default
24883  Selects large stack model.
24884  16 bit stack and frame pointers.
24885  Supports 65536 bytes stack size.
24886 \end_layout
24887
24888 \end_deeper
24889 \begin_layout Description
24890 -
24891 \begin_inset ERT
24892 status collapsed
24893
24894 \begin_layout Standard
24895
24896
24897 \backslash
24898 /
24899 \end_layout
24900
24901 \end_inset
24902
24903 -pno-banksel Do not generate BANKSEL assembler directives.
24904 \end_layout
24905
24906 \begin_layout Description
24907 -
24908 \begin_inset ERT
24909 status collapsed
24910
24911 \begin_layout Standard
24912
24913
24914 \backslash
24915 /
24916 \end_layout
24917
24918 \end_inset
24919
24920 -extended Enable extended instruction set/literal offset addressing mode.
24921  Use with care!
24922 \end_layout
24923
24924 \begin_layout Subsubsection
24925 Optimization Options
24926 \end_layout
24927
24928 \begin_layout Description
24929 -
24930 \begin_inset ERT
24931 status collapsed
24932
24933 \begin_layout Standard
24934
24935
24936 \backslash
24937 /
24938 \end_layout
24939
24940 \end_inset
24941
24942 -obanksel=n Set optimization level for inserting BANKSELs.
24943 \newline
24944
24945 \end_layout
24946
24947 \begin_deeper
24948 \begin_layout List
24949 \labelwidthstring 00.00.0000
24950 0 no optimization
24951 \end_layout
24952
24953 \begin_layout List
24954 \labelwidthstring 00.00.0000
24955 1 checks previous used register and if it is the same then does not emit
24956  BANKSEL, accounts only for labels.
24957 \end_layout
24958
24959 \begin_layout List
24960 \labelwidthstring 00.00.0000
24961 2 tries to check the location of (even different) symbols and removes BANKSELs
24962  if they are in the same bank.
24963  
24964 \newline
24965
24966 \emph on
24967 Important: There might be problems if the linker script has data sections
24968  across bank borders!
24969 \end_layout
24970
24971 \end_deeper
24972 \begin_layout Description
24973 -
24974 \begin_inset ERT
24975 status collapsed
24976
24977 \begin_layout Standard
24978
24979
24980 \backslash
24981 /
24982 \end_layout
24983
24984 \end_inset
24985
24986 -denable-peeps Force the usage of peepholes.
24987  Use with care.
24988 \end_layout
24989
24990 \begin_layout Description
24991 -
24992 \begin_inset ERT
24993 status collapsed
24994
24995 \begin_layout Standard
24996
24997
24998 \backslash
24999 /
25000 \end_layout
25001
25002 \end_inset
25003
25004 -no-optimize-goto Do not use (conditional) BRA instead of GOTO.
25005 \end_layout
25006
25007 \begin_layout Description
25008 -
25009 \begin_inset ERT
25010 status collapsed
25011
25012 \begin_layout Standard
25013
25014
25015 \backslash
25016 /
25017 \end_layout
25018
25019 \end_inset
25020
25021 -optimize-cmp Try to optimize some compares.
25022 \end_layout
25023
25024 \begin_layout Description
25025 -
25026 \begin_inset ERT
25027 status collapsed
25028
25029 \begin_layout Standard
25030
25031
25032 \backslash
25033 /
25034 \end_layout
25035
25036 \end_inset
25037
25038 -optimize-df Analyze the dataflow of the generated code and improve it.
25039 \end_layout
25040
25041 \begin_layout Subsubsection
25042 Assembling Options
25043 \end_layout
25044
25045 \begin_layout Description
25046 -
25047 \begin_inset ERT
25048 status collapsed
25049
25050 \begin_layout Standard
25051
25052
25053 \backslash
25054 /
25055 \end_layout
25056
25057 \end_inset
25058
25059 -asm= Sets the full path and name of an external assembler to call.
25060 \end_layout
25061
25062 \begin_layout Description
25063 -
25064 \begin_inset ERT
25065 status collapsed
25066
25067 \begin_layout Standard
25068
25069
25070 \backslash
25071 /
25072 \end_layout
25073
25074 \end_inset
25075
25076 -mplab-comp MPLAB
25077 \begin_inset LatexCommand \index{PIC16!MPLAB}
25078
25079 \end_inset
25080
25081  compatibility option.
25082  Currently only suppresses special gpasm directives.
25083 \end_layout
25084
25085 \begin_layout Subsubsection
25086 Linking Options
25087 \end_layout
25088
25089 \begin_layout Description
25090 -
25091 \begin_inset ERT
25092 status collapsed
25093
25094 \begin_layout Standard
25095
25096
25097 \backslash
25098 /
25099 \end_layout
25100
25101 \end_inset
25102
25103 -link= Sets the full path and name of an external linker to call.
25104 \end_layout
25105
25106 \begin_layout Description
25107 -
25108 \begin_inset ERT
25109 status collapsed
25110
25111 \begin_layout Standard
25112
25113
25114 \backslash
25115 /
25116 \end_layout
25117
25118 \end_inset
25119
25120 -preplace-udata-with=[kword] Replaces the default udata keyword for allocating
25121  unitialized data variables with [kword].
25122  Valid keywords are: "udata_acs", "udata_shr", "udata_ovr".
25123 \end_layout
25124
25125 \begin_layout Description
25126 -
25127 \begin_inset ERT
25128 status collapsed
25129
25130 \begin_layout Standard
25131
25132
25133 \backslash
25134 /
25135 \end_layout
25136
25137 \end_inset
25138
25139 -ivt-loc=n Place the interrupt vector table at address 
25140 \emph on
25141 n
25142 \emph default
25143 .
25144  Useful for bootloaders.
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 -nodefaultlibs Do not link default libraries when linking.
25162 \end_layout
25163
25164 \begin_layout Description
25165 -
25166 \begin_inset ERT
25167 status collapsed
25168
25169 \begin_layout Standard
25170
25171
25172 \backslash
25173 /
25174 \end_layout
25175
25176 \end_inset
25177
25178 -use-crt= Use a custom run-time module instead of the defaults.
25179 \end_layout
25180
25181 \begin_layout Description
25182 -
25183 \begin_inset ERT
25184 status collapsed
25185
25186 \begin_layout Standard
25187
25188
25189 \backslash
25190 /
25191 \end_layout
25192
25193 \end_inset
25194
25195 -no-crt Don't link the default run-time modules
25196 \end_layout
25197
25198 \begin_layout Subsubsection
25199 Debugging Options
25200 \end_layout
25201
25202 \begin_layout Standard
25203 Debugging options enable extra debugging information in the output files.
25204 \end_layout
25205
25206 \begin_layout Description
25207 -
25208 \begin_inset ERT
25209 status collapsed
25210
25211 \begin_layout Standard
25212
25213
25214 \backslash
25215 /
25216 \end_layout
25217
25218 \end_inset
25219
25220 -debug-xtra Similar to -
25221 \begin_inset ERT
25222 status collapsed
25223
25224 \begin_layout Standard
25225
25226
25227 \backslash
25228 /
25229 \end_layout
25230
25231 \end_inset
25232
25233 -debug
25234 \begin_inset LatexCommand \index{-\/-debug}
25235
25236 \end_inset
25237
25238 , but dumps more information.
25239 \end_layout
25240
25241 \begin_layout Description
25242 -
25243 \begin_inset ERT
25244 status collapsed
25245
25246 \begin_layout Standard
25247
25248
25249 \backslash
25250 /
25251 \end_layout
25252
25253 \end_inset
25254
25255 -debug-ralloc Force register allocator to dump <source>.d file with debugging
25256  information.
25257  <source> is the name of the file being compiled.
25258 \end_layout
25259
25260 \begin_layout Description
25261 -
25262 \begin_inset ERT
25263 status collapsed
25264
25265 \begin_layout Standard
25266
25267
25268 \backslash
25269 /
25270 \end_layout
25271
25272 \end_inset
25273
25274 -pcode-verbose Enable pcode debugging information in translation.
25275 \end_layout
25276
25277 \begin_layout Description
25278 -
25279 \begin_inset ERT
25280 status collapsed
25281
25282 \begin_layout Standard
25283
25284
25285 \backslash
25286 /
25287 \end_layout
25288
25289 \end_inset
25290
25291 -calltree Dump call tree in .calltree file.
25292 \end_layout
25293
25294 \begin_layout Description
25295 -
25296 \begin_inset ERT
25297 status collapsed
25298
25299 \begin_layout Standard
25300
25301
25302 \backslash
25303 /
25304 \end_layout
25305
25306 \end_inset
25307
25308 -gstack Trace push/pops for stack pointer overflow.
25309 \end_layout
25310
25311 \begin_layout Subsection
25312 Enviroment Variables
25313 \end_layout
25314
25315 \begin_layout Standard
25316 There is a number of enviromental variables that can be used when running
25317  SDCC to enable certain optimizations or force a specific program behaviour.
25318  these variables are primarily for debugging purposes so they can be enabled/dis
25319 abled at will.
25320 \end_layout
25321
25322 \begin_layout Standard
25323 Currently there is only two such variables available:
25324 \end_layout
25325
25326 \begin_layout Description
25327 OPTIMIZE_BITFIELD_POINTER_GET When this variable exists, reading of structure
25328  bitfields is optimized by directly loading FSR0 with the address of the
25329  bitfield structure.
25330  Normally SDCC will cast the bitfield structure to a bitfield pointer and
25331  then load FSR0.
25332  This step saves data ram and code space for functions that make heavy use
25333  of bitfields.
25334  (i.e., 80 bytes of code space are saved when compiling malloc.c with this
25335  option).
25336  
25337 \end_layout
25338
25339 \begin_layout Description
25340 NO_REG_OPT Do not perform pCode registers optimization.
25341  This should be used for debugging purposes.
25342  If bugs in the pcode optimizer are found, users can benefit from temporarily
25343  disabling the optimizer until the bug is fixed.
25344 \end_layout
25345
25346 \begin_layout Subsection
25347 Preprocessor Macros
25348 \end_layout
25349
25350 \begin_layout Standard
25351 PIC16
25352 \begin_inset LatexCommand \index{PIC16}
25353
25354 \end_inset
25355
25356  port defines the following preprocessor macros while translating a source.
25357 \end_layout
25358
25359 \begin_layout Standard
25360 \align center
25361 \begin_inset Tabular
25362 <lyxtabular version="3" rows="6" columns="2">
25363 <features>
25364 <column alignment="center" valignment="top" leftline="true" width="0">
25365 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
25366 <row topline="true" bottomline="true">
25367 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25368 \begin_inset Text
25369
25370 \begin_layout Standard
25371 Macro
25372 \end_layout
25373
25374 \end_inset
25375 </cell>
25376 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
25377 \begin_inset Text
25378
25379 \begin_layout Standard
25380 Description
25381 \end_layout
25382
25383 \end_inset
25384 </cell>
25385 </row>
25386 <row topline="true">
25387 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25388 \begin_inset Text
25389
25390 \begin_layout Standard
25391 SDCC_pic16
25392 \end_layout
25393
25394 \end_inset
25395 </cell>
25396 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
25397 \begin_inset Text
25398
25399 \begin_layout Standard
25400 Port identification
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 _pic16
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 Port identification (same as above)
25434 \end_layout
25435
25436 \end_inset
25437 </cell>
25438 </row>
25439 <row topline="true">
25440 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25441 \begin_inset Text
25442
25443 \begin_layout Standard
25444 pic18fxxxx
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 MCU Identification.
25454  
25455 \emph on
25456 xxxx
25457 \emph default
25458  is the microcontrol identification number, i.e.
25459  452, 6620, etc
25460 \end_layout
25461
25462 \end_inset
25463 </cell>
25464 </row>
25465 <row topline="true">
25466 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25467 \begin_inset Text
25468
25469 \begin_layout Standard
25470 _
25471 \begin_inset ERT
25472 status collapsed
25473
25474 \begin_layout Standard
25475
25476
25477 \backslash
25478 /
25479 \end_layout
25480
25481 \end_inset
25482
25483 _18Fxxxx
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 MCU Identification (same as above)
25493 \end_layout
25494
25495 \end_inset
25496 </cell>
25497 </row>
25498 <row topline="true" bottomline="true">
25499 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25500 \begin_inset Text
25501
25502 \begin_layout Standard
25503 STACK_MODEL_nnn
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 nnn = SMALL or LARGE respectively according to the stack model used
25513 \end_layout
25514
25515 \end_inset
25516 </cell>
25517 </row>
25518 </lyxtabular>
25519
25520 \end_inset
25521
25522
25523 \end_layout
25524
25525 \begin_layout Standard
25526 \noindent
25527 In addition the following macros are defined when calling assembler:
25528 \end_layout
25529
25530 \begin_layout Standard
25531 \align center
25532 \begin_inset Tabular
25533 <lyxtabular version="3" rows="4" columns="2">
25534 <features>
25535 <column alignment="center" valignment="top" leftline="true" width="0">
25536 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
25537 <row topline="true" bottomline="true">
25538 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25539 \begin_inset Text
25540
25541 \begin_layout Standard
25542 Macro
25543 \end_layout
25544
25545 \end_inset
25546 </cell>
25547 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
25548 \begin_inset Text
25549
25550 \begin_layout Standard
25551 Description
25552 \end_layout
25553
25554 \end_inset
25555 </cell>
25556 </row>
25557 <row topline="true">
25558 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25559 \begin_inset Text
25560
25561 \begin_layout Standard
25562 __18Fxxxx
25563 \end_layout
25564
25565 \end_inset
25566 </cell>
25567 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
25568 \begin_inset Text
25569
25570 \begin_layout Standard
25571 MCU Identification.
25572  
25573 \emph on
25574 xxxx
25575 \emph default
25576  is the microcontrol identification number, i.e.
25577  452, 6620, etc
25578 \end_layout
25579
25580 \end_inset
25581 </cell>
25582 </row>
25583 <row topline="true">
25584 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25585 \begin_inset Text
25586
25587 \begin_layout Standard
25588 SDCC_MODEL_nnn
25589 \end_layout
25590
25591 \end_inset
25592 </cell>
25593 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
25594 \begin_inset Text
25595
25596 \begin_layout Standard
25597 nnn = SMALL or LARGE respectively according to the memory model used for
25598  SDCC
25599 \end_layout
25600
25601 \end_inset
25602 </cell>
25603 </row>
25604 <row topline="true" bottomline="true">
25605 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25606 \begin_inset Text
25607
25608 \begin_layout Standard
25609 STACK_MODEL_nnn
25610 \end_layout
25611
25612 \end_inset
25613 </cell>
25614 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
25615 \begin_inset Text
25616
25617 \begin_layout Standard
25618 nnn = SMALL or LARGE respectively according to the stack model used
25619 \end_layout
25620
25621 \end_inset
25622 </cell>
25623 </row>
25624 </lyxtabular>
25625
25626 \end_inset
25627
25628
25629 \end_layout
25630
25631 \begin_layout Subsection
25632 Directories
25633 \end_layout
25634
25635 \begin_layout Standard
25636 PIC16
25637 \begin_inset LatexCommand \index{PIC16}
25638
25639 \end_inset
25640
25641  port uses the following directories for searching header files and libraries.
25642 \end_layout
25643
25644 \begin_layout Standard
25645 \align center
25646 \begin_inset Tabular
25647 <lyxtabular version="3" rows="3" columns="4">
25648 <features>
25649 <column alignment="center" valignment="top" leftline="true" width="0">
25650 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
25651 <column alignment="center" valignment="top" width="0">
25652 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
25653 <row topline="true" bottomline="true">
25654 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25655 \begin_inset Text
25656
25657 \begin_layout Standard
25658 Directory
25659 \end_layout
25660
25661 \end_inset
25662 </cell>
25663 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
25664 \begin_inset Text
25665
25666 \begin_layout Standard
25667 Description
25668 \end_layout
25669
25670 \end_inset
25671 </cell>
25672 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
25673 \begin_inset Text
25674
25675 \begin_layout Standard
25676 Target
25677 \end_layout
25678
25679 \end_inset
25680 </cell>
25681 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
25682 \begin_inset Text
25683
25684 \begin_layout Standard
25685 Command prefix
25686 \end_layout
25687
25688 \end_inset
25689 </cell>
25690 </row>
25691 <row topline="true">
25692 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25693 \begin_inset Text
25694
25695 \begin_layout Standard
25696 PREFIX/sdcc/include/pic16
25697 \end_layout
25698
25699 \end_inset
25700 </cell>
25701 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
25702 \begin_inset Text
25703
25704 \begin_layout Standard
25705 PIC16 specific headers
25706 \end_layout
25707
25708 \end_inset
25709 </cell>
25710 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
25711 \begin_inset Text
25712
25713 \begin_layout Standard
25714 Compiler
25715 \end_layout
25716
25717 \end_inset
25718 </cell>
25719 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
25720 \begin_inset Text
25721
25722 \begin_layout Standard
25723 -I
25724 \end_layout
25725
25726 \end_inset
25727 </cell>
25728 </row>
25729 <row topline="true" bottomline="true">
25730 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25731 \begin_inset Text
25732
25733 \begin_layout Standard
25734 PREFIX/sdcc/lib/pic16
25735 \end_layout
25736
25737 \end_inset
25738 </cell>
25739 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
25740 \begin_inset Text
25741
25742 \begin_layout Standard
25743 PIC16 specific libraries
25744 \end_layout
25745
25746 \end_inset
25747 </cell>
25748 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
25749 \begin_inset Text
25750
25751 \begin_layout Standard
25752 Linker
25753 \end_layout
25754
25755 \end_inset
25756 </cell>
25757 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
25758 \begin_inset Text
25759
25760 \begin_layout Standard
25761 -L
25762 \end_layout
25763
25764 \end_inset
25765 </cell>
25766 </row>
25767 </lyxtabular>
25768
25769 \end_inset
25770
25771
25772 \end_layout
25773
25774 \begin_layout Subsection
25775 Pragmas
25776 \begin_inset LatexCommand \label{sub:PIC16_Pragmas}
25777
25778 \end_inset
25779
25780
25781 \end_layout
25782
25783 \begin_layout Standard
25784 The PIC16
25785 \begin_inset LatexCommand \index{PIC16}
25786
25787 \end_inset
25788
25789  port currently supports the following pragmas:
25790 \end_layout
25791
25792 \begin_layout Description
25793 stack
25794 \begin_inset LatexCommand \index{PIC16!Pragmas!\#pragma stack}
25795
25796 \end_inset
25797
25798  This forces the code generator to initialize the stack & frame pointers
25799  at a specific address.
25800  This is an ad hoc solution for cases where no STACK directive is available
25801  in the linker script or gplink is not instructed to create a stack section.
25802 \newline
25803 The
25804  stack pragma should be used only once in a project.
25805  Multiple pragmas may result in indeterminate behaviour of the program.
25806 \begin_inset Foot
25807 status open
25808
25809 \begin_layout Standard
25810 The old format (ie.
25811  #pragma stack 0x5ff) is deprecated and will cause the stack pointer to
25812  cross page boundaries (or even exceed the available data RAM) and crash
25813  the program.
25814  Make sure that stack does not cross page boundaries when using the SMALL
25815  stack model.
25816 \end_layout
25817
25818 \end_inset
25819
25820
25821 \newline
25822 The format is as follows:
25823 \newline
25824
25825 \end_layout
25826
25827 \begin_layout LyX-Code
25828 #pragma stack bottom_address [stack_size]
25829 \newline
25830
25831 \end_layout
25832
25833 \begin_layout Standard
25834
25835 \emph on
25836 bottom_address
25837 \emph default
25838  is the lower bound of the stack section.
25839  The stack pointer initially will point at address (bottom_address+stack_size-1).
25840 \end_layout
25841
25842 \begin_layout LyX-Code
25843 Example:
25844 \end_layout
25845
25846 \begin_layout LyX-Code
25847
25848 \end_layout
25849
25850 \begin_layout LyX-Code
25851 /* initializes stack of 100 bytes at RAM address 0x200 */
25852 \end_layout
25853
25854 \begin_layout LyX-Code
25855 #pragma stack 0x200 100
25856 \end_layout
25857
25858 \begin_layout Standard
25859 If the stack_size field is omitted then a stack is created with the default
25860  size of 64.
25861  This size might be enough for most programs, but its not enough for operations
25862  with deep function nesting or excessive stack usage.
25863 \end_layout
25864
25865 \begin_layout Description
25866 code
25867 \begin_inset LatexCommand \index{PIC16!Pragmas!\#pragma code}
25868
25869 \end_inset
25870
25871  Force a function to a static FLASH address.
25872 \end_layout
25873
25874 \begin_layout LyX-Code
25875 Example:
25876 \end_layout
25877
25878 \begin_layout LyX-Code
25879
25880 \end_layout
25881
25882 \begin_layout LyX-Code
25883 /* place function test_func at 0x4000 */
25884 \end_layout
25885
25886 \begin_layout LyX-Code
25887 #pragma code test_func 0x4000
25888 \end_layout
25889
25890 \begin_layout LyX-Code
25891
25892 \end_layout
25893
25894 \begin_layout Description
25895 library instructs the linker to use a library module.
25896 \newline
25897 Usage:
25898 \end_layout
25899
25900 \begin_layout LyX-Code
25901 #pragma library module_name
25902 \end_layout
25903
25904 \begin_layout Standard
25905
25906 \emph on
25907 module_name
25908 \emph default
25909  can be any library or object file (including its path).
25910  Note that there are four reserved keywords which have special meaning.
25911  These are:
25912 \end_layout
25913
25914 \begin_layout Standard
25915 \align center
25916 \begin_inset Tabular
25917 <lyxtabular version="3" rows="6" columns="3">
25918 <features>
25919 <column alignment="center" valignment="top" leftline="true" width="0">
25920 <column alignment="block" valignment="top" leftline="true" width="20page%">
25921 <column alignment="left" valignment="top" leftline="true" rightline="true" width="0">
25922 <row topline="true" bottomline="true">
25923 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25924 \begin_inset Text
25925
25926 \begin_layout Standard
25927 Keyword
25928 \end_layout
25929
25930 \end_inset
25931 </cell>
25932 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25933 \begin_inset Text
25934
25935 \begin_layout Standard
25936 Description
25937 \end_layout
25938
25939 \end_inset
25940 </cell>
25941 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
25942 \begin_inset Text
25943
25944 \begin_layout Standard
25945 Module to link
25946 \end_layout
25947
25948 \end_inset
25949 </cell>
25950 </row>
25951 <row topline="true">
25952 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25953 \begin_inset Text
25954
25955 \begin_layout Standard
25956
25957 \series bold
25958 ignore
25959 \end_layout
25960
25961 \end_inset
25962 </cell>
25963 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25964 \begin_inset Text
25965
25966 \begin_layout Standard
25967 ignore all library pragmas
25968 \end_layout
25969
25970 \end_inset
25971 </cell>
25972 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
25973 \begin_inset Text
25974
25975 \begin_layout Standard
25976
25977 \emph on
25978 (none)
25979 \end_layout
25980
25981 \end_inset
25982 </cell>
25983 </row>
25984 <row topline="true">
25985 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25986 \begin_inset Text
25987
25988 \begin_layout Standard
25989
25990 \series bold
25991 c
25992 \end_layout
25993
25994 \end_inset
25995 </cell>
25996 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25997 \begin_inset Text
25998
25999 \begin_layout Standard
26000 link the C library
26001 \end_layout
26002
26003 \end_inset
26004 </cell>
26005 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26006 \begin_inset Text
26007
26008 \begin_layout Standard
26009
26010 \emph on
26011 libc18f
26012 \emph default
26013 .lib
26014 \end_layout
26015
26016 \end_inset
26017 </cell>
26018 </row>
26019 <row topline="true">
26020 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26021 \begin_inset Text
26022
26023 \begin_layout Standard
26024
26025 \series bold
26026 math
26027 \end_layout
26028
26029 \end_inset
26030 </cell>
26031 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26032 \begin_inset Text
26033
26034 \begin_layout Standard
26035 link the Math libarary
26036 \end_layout
26037
26038 \end_inset
26039 </cell>
26040 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26041 \begin_inset Text
26042
26043 \begin_layout Standard
26044
26045 \emph on
26046 libm18f
26047 \emph default
26048 .lib
26049 \end_layout
26050
26051 \end_inset
26052 </cell>
26053 </row>
26054 <row topline="true">
26055 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26056 \begin_inset Text
26057
26058 \begin_layout Standard
26059
26060 \series bold
26061 io
26062 \end_layout
26063
26064 \end_inset
26065 </cell>
26066 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26067 \begin_inset Text
26068
26069 \begin_layout Standard
26070 link the I/O library
26071 \end_layout
26072
26073 \end_inset
26074 </cell>
26075 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26076 \begin_inset Text
26077
26078 \begin_layout Standard
26079
26080 \emph on
26081 libio18f*
26082 \emph default
26083 .lib
26084 \end_layout
26085
26086 \end_inset
26087 </cell>
26088 </row>
26089 <row topline="true" bottomline="true">
26090 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26091 \begin_inset Text
26092
26093 \begin_layout Standard
26094
26095 \series bold
26096 debug
26097 \end_layout
26098
26099 \end_inset
26100 </cell>
26101 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26102 \begin_inset Text
26103
26104 \begin_layout Standard
26105 link the debug library
26106 \end_layout
26107
26108 \end_inset
26109 </cell>
26110 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26111 \begin_inset Text
26112
26113 \begin_layout Standard
26114
26115 \emph on
26116 libdebug
26117 \emph default
26118 .lib
26119 \end_layout
26120
26121 \end_inset
26122 </cell>
26123 </row>
26124 </lyxtabular>
26125
26126 \end_inset
26127
26128
26129 \newline
26130 * is the device number, i.e.
26131  452 for PIC18F452 MCU.
26132 \end_layout
26133
26134 \begin_layout Standard
26135 \noindent
26136 This feature allows for linking with specific libraries withoug having to
26137  explicit name them in the command line.
26138  Note that the 
26139 \noun on
26140 ignore
26141 \noun default
26142  keyword will reject all modules specified by the library pragma.
26143 \end_layout
26144
26145 \begin_layout Description
26146 udata The pragma udata instructs the compiler to emit code so that linker
26147  will place a variable at a specific memory bank.
26148 \end_layout
26149
26150 \begin_layout LyX-Code
26151 Example:
26152 \end_layout
26153
26154 \begin_layout LyX-Code
26155
26156 \end_layout
26157
26158 \begin_layout LyX-Code
26159 /* places variable foo at bank2 */
26160 \end_layout
26161
26162 \begin_layout LyX-Code
26163 #pragma udata bank2 foo
26164 \end_layout
26165
26166 \begin_layout LyX-Code
26167 char foo;
26168 \end_layout
26169
26170 \begin_layout Standard
26171 In order for this pragma to work extra SECTION directives should be added
26172  in the .lkr script.
26173  In the following example a sample .lkr file is shown:
26174 \end_layout
26175
26176 \begin_layout LyX-Code
26177
26178 \end_layout
26179
26180 \begin_layout LyX-Code
26181 // Sample linker script for the PIC18F452 processor
26182 \end_layout
26183
26184 \begin_layout LyX-Code
26185 LIBPATH .
26186 \end_layout
26187
26188 \begin_layout LyX-Code
26189 CODEPAGE   NAME=vectors    START=0x0            END=0x29           PROTECTED
26190 \end_layout
26191
26192 \begin_layout LyX-Code
26193 CODEPAGE   NAME=page       START=0x2A           END=0x7FFF
26194 \end_layout
26195
26196 \begin_layout LyX-Code
26197 CODEPAGE   NAME=idlocs     START=0x200000       END=0x200007       PROTECTED
26198 \end_layout
26199
26200 \begin_layout LyX-Code
26201 CODEPAGE   NAME=config     START=0x300000       END=0x30000D       PROTECTED
26202 \end_layout
26203
26204 \begin_layout LyX-Code
26205 CODEPAGE   NAME=devid      START=0x3FFFFE       END=0x3FFFFF       PROTECTED
26206 \end_layout
26207
26208 \begin_layout LyX-Code
26209 CODEPAGE   NAME=eedata     START=0xF00000       END=0xF000FF       PROTECTED
26210 \end_layout
26211
26212 \begin_layout LyX-Code
26213 ACCESSBANK NAME=accessram  START=0x0            END=0x7F
26214 \end_layout
26215
26216 \begin_layout LyX-Code
26217
26218 \end_layout
26219
26220 \begin_layout LyX-Code
26221 DATABANK   NAME=gpr0       START=0x80           END=0xFF
26222 \end_layout
26223
26224 \begin_layout LyX-Code
26225 DATABANK   NAME=gpr1       START=0x100          END=0x1FF
26226 \end_layout
26227
26228 \begin_layout LyX-Code
26229 DATABANK   NAME=gpr2       START=0x200          END=0x2FF
26230 \end_layout
26231
26232 \begin_layout LyX-Code
26233 DATABANK   NAME=gpr3       START=0x300          END=0x3FF
26234 \end_layout
26235
26236 \begin_layout LyX-Code
26237 DATABANK   NAME=gpr4       START=0x400          END=0x4FF
26238 \end_layout
26239
26240 \begin_layout LyX-Code
26241 DATABANK   NAME=gpr5       START=0x500          END=0x5FF
26242 \end_layout
26243
26244 \begin_layout LyX-Code
26245 ACCESSBANK NAME=accesssfr  START=0xF80          END=0xFFF          PROTECTED
26246 \end_layout
26247
26248 \begin_layout LyX-Code
26249
26250 \end_layout
26251
26252 \begin_layout LyX-Code
26253 SECTION    NAME=CONFIG     ROM=config
26254 \end_layout
26255
26256 \begin_layout LyX-Code
26257
26258 \end_layout
26259
26260 \begin_layout LyX-Code
26261 SECTION    NAME=bank0      RAM=gpr0       # these SECTION directives
26262 \end_layout
26263
26264 \begin_layout LyX-Code
26265 SECTION    NAME=bank1      RAM=gpr1       # should be added to link
26266 \end_layout
26267
26268 \begin_layout LyX-Code
26269 SECTION    NAME=bank2      RAM=gpr2       # section name 'bank?' with
26270 \end_layout
26271
26272 \begin_layout LyX-Code
26273 SECTION    NAME=bank3      RAM=gpr3       # a specific DATABANK name
26274 \end_layout
26275
26276 \begin_layout LyX-Code
26277 SECTION    NAME=bank4      RAM=gpr4
26278 \end_layout
26279
26280 \begin_layout LyX-Code
26281 SECTION    NAME=bank5      RAM=gpr5
26282 \end_layout
26283
26284 \begin_layout Standard
26285 The linker will recognise the section name set in the pragma statement and
26286  will position the variable at the memory bank set with the RAM field at
26287  the SECTION line in the linker script file.
26288 \end_layout
26289
26290 \begin_layout Subsection
26291 Header Files
26292 \begin_inset LatexCommand \label{sub:PIC16_Header-Files}
26293
26294 \end_inset
26295
26296
26297 \end_layout
26298
26299 \begin_layout Standard
26300 There is one main header file
26301 \begin_inset LatexCommand \index{PIC16!Header files}
26302
26303 \end_inset
26304
26305  that can be included to the source files using the pic16
26306 \begin_inset LatexCommand \index{PIC16}
26307
26308 \end_inset
26309
26310  port.
26311  That file is the 
26312 \series bold
26313 pic18fregs.h
26314 \series default
26315 .
26316  This header file contains the definitions for the processor special registers,
26317  so it is necessary if the source accesses them.
26318  It can be included by adding the following line in the beginning of the
26319  file:
26320 \end_layout
26321
26322 \begin_layout LyX-Code
26323 #include <pic18fregs.h>
26324 \end_layout
26325
26326 \begin_layout Standard
26327 The specific microcontroller is selected within the pic18fregs.h automatically,
26328  so the same source can be used with a variety of devices.
26329 \end_layout
26330
26331 \begin_layout Subsection
26332 Libraries
26333 \begin_inset LatexCommand \label{sub:pic16Libraries}
26334
26335 \end_inset
26336
26337
26338 \end_layout
26339
26340 \begin_layout Standard
26341 The libraries
26342 \begin_inset LatexCommand \index{PIC16!Libraries}
26343
26344 \end_inset
26345
26346  that PIC16
26347 \begin_inset LatexCommand \index{PIC16}
26348
26349 \end_inset
26350
26351  port depends on are the microcontroller device libraries which contain
26352  the symbol definitions for the microcontroller special function registers.
26353  These libraries have the format pic18fxxxx.lib, where 
26354 \emph on
26355 xxxx
26356 \emph default
26357  is the microcontroller identification number.
26358  The specific library is selected automatically by the compiler at link
26359  stage according to the selected device.
26360 \end_layout
26361
26362 \begin_layout Standard
26363 \noindent
26364 Libraries are created with gplib which is part of the gputils package 
26365 \begin_inset LatexCommand \url{http://sourceforge.net/projects/gputils}
26366
26367 \end_inset
26368
26369 .
26370 \end_layout
26371
26372 \begin_layout Subsubsection*
26373 Building the libraries
26374 \end_layout
26375
26376 \begin_layout Standard
26377 Before using SDCC/pic16 there are some libraries that need to be compiled.
26378  This process is done automatically if gputils are found at SDCC's compile
26379  time.
26380  Should you require to rebuild the pic16 libraries manually, these are the
26381  steps required to do so under Linux or Mac OS X (cygwin might work as well,
26382  but is untested):
26383 \end_layout
26384
26385 \begin_layout LyX-Code
26386 cd device/lib/pic16
26387 \end_layout
26388
26389 \begin_layout LyX-Code
26390 ./configure.gnu
26391 \end_layout
26392
26393 \begin_layout LyX-Code
26394 cd ..
26395 \end_layout
26396
26397 \begin_layout LyX-Code
26398 make model-pic16
26399 \end_layout
26400
26401 \begin_layout LyX-Code
26402 su -c 'make install'     # install the libraries, you need the root password
26403 \end_layout
26404
26405 \begin_layout LyX-Code
26406 cd ../..
26407 \end_layout
26408
26409 \begin_layout Standard
26410 If you need to install the headers too, do:
26411 \end_layout
26412
26413 \begin_layout LyX-Code
26414 cd device/include
26415 \end_layout
26416
26417 \begin_layout LyX-Code
26418 su -c 'make install'     # install the headers, you need the root password
26419 \end_layout
26420
26421 \begin_layout Subsection
26422 Adding New Devices to the Port
26423 \end_layout
26424
26425 \begin_layout Standard
26426 Adding support for a new 16
26427 \begin_inset ERT
26428 status collapsed
26429
26430 \begin_layout Standard
26431
26432
26433 \backslash
26434 ,
26435 \end_layout
26436
26437 \end_inset
26438
26439 bit PIC MCU requires the following steps:
26440 \end_layout
26441
26442 \begin_layout Enumerate
26443 Create picDEVICE.c and picDEVICE.h from pDEVICE.inc using
26444 \newline
26445
26446 \family typewriter
26447 perl /path/to/sdcc/support/scripts/inc2h-pic16.pl /path/to/gputils/header/pDEVICE.
26448 inc
26449 \end_layout
26450
26451 \begin_layout Enumerate
26452
26453 \family typewriter
26454 mv picDEVICE.h /path/to/sdcc/device/include/pic16
26455 \end_layout
26456
26457 \begin_layout Enumerate
26458
26459 \family typewriter
26460 mv picDEVICE.c /path/to/sdcc/device/lib/pic16/libdev
26461 \end_layout
26462
26463 \begin_layout Enumerate
26464 Add DEVICE to 
26465 \family typewriter
26466 /path/to/sdcc/device/lib/pic16/pics.all
26467 \family default
26468
26469 \newline
26470 Note: No 18f prefix here!
26471 \end_layout
26472
26473 \begin_layout Enumerate
26474 Edit 
26475 \family typewriter
26476 /path/to/sdcc/device/include/pic16/adc.h
26477 \newline
26478
26479 \family default
26480 Add the new devices to the correct ADC style class (depending on the number
26481  of ADC channels).
26482 \newline
26483 Do not touch 
26484 \family typewriter
26485 adc.h
26486 \family default
26487  if the device does not offer any ADC at all.
26488 \end_layout
26489
26490 \begin_layout Enumerate
26491 Edit 
26492 \family typewriter
26493 /path/to/sdcc/device/include/pic16/pic18fregs.h
26494 \family default
26495
26496 \newline
26497 The file format is self-explanatory, just add
26498 \newline
26499
26500 \family typewriter
26501 #elif defined(picDEVICE)
26502 \newline
26503 #
26504 \begin_inset ERT
26505 status collapsed
26506
26507 \begin_layout Standard
26508
26509
26510 \backslash
26511  
26512 \backslash
26513  
26514 \end_layout
26515
26516 \end_inset
26517
26518 include <picDEVICE.h>
26519 \family default
26520
26521 \newline
26522 at the right place (keep the file sorted, please).
26523 \end_layout
26524
26525 \begin_layout Enumerate
26526 Edit 
26527 \family typewriter
26528 /path/to/sdcc/device/include/pic16devices.txt
26529 \newline
26530
26531 \family default
26532 Copy and modify an existing entry or create a new one and insert it at the
26533  correct place (keep the file sorted, please).
26534 \end_layout
26535
26536 \begin_layout Enumerate
26537 Add the device to 
26538 \family typewriter
26539 /path/to/sdcc/device/lib/pic16/libdev/Makefile.am
26540 \family default
26541
26542 \newline
26543 Copy an existing entry and adjust the device name.
26544 \end_layout
26545
26546 \begin_layout Enumerate
26547 Add the device to 
26548 \family typewriter
26549 /path/to/sdcc/device/lib/pic16/libio/Makefile.am
26550 \family default
26551
26552 \newline
26553 Copy the record from the 18f2220 and adjust the device name.
26554 \newline
26555 If the new device
26556  does not offer ADC, I
26557 \begin_inset Formula $^{\text{2}}$
26558 \end_inset
26559
26560 C, and/or (E)USART functionality as assumed by the library, remove the lines
26561  with references to 
26562 \family typewriter
26563 adc/*.c
26564 \family default
26565
26566 \family typewriter
26567 usart/*.c
26568 \family default
26569 , or 
26570 \family typewriter
26571 usart/*.c
26572 \family default
26573 , respectively.
26574 \end_layout
26575
26576 \begin_layout Enumerate
26577 Update 
26578 \family typewriter
26579 libdev/Makefile.in
26580 \family default
26581  and 
26582 \family typewriter
26583 libio/Makefile.in
26584 \family default
26585  using
26586 \newline
26587
26588 \family typewriter
26589 ./bootstrap.sh
26590 \family default
26591
26592 \newline
26593 in 
26594 \family typewriter
26595 /path/to/sdcc/device/lib/pic16
26596 \family default
26597 .
26598 \end_layout
26599
26600 \begin_layout Enumerate
26601 Recompile the pic16 libraries as described in 
26602 \begin_inset LatexCommand \ref{sub:pic16Libraries}
26603
26604 \end_inset
26605
26606 .
26607 \end_layout
26608
26609 \begin_layout Subsection
26610 Memory Models
26611 \end_layout
26612
26613 \begin_layout Standard
26614 The following memory models are supported by the PIC16 port:
26615 \end_layout
26616
26617 \begin_layout Itemize
26618 small model
26619 \end_layout
26620
26621 \begin_layout Itemize
26622 large model
26623 \end_layout
26624
26625 \begin_layout Standard
26626 Memory model affects the default size of pointers within the source.
26627  The sizes are shown in the next table:
26628 \end_layout
26629
26630 \begin_layout Standard
26631 \align center
26632 \begin_inset Tabular
26633 <lyxtabular version="3" rows="3" columns="3">
26634 <features>
26635 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
26636 <column alignment="center" valignment="top" leftline="true" width="0">
26637 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
26638 <row topline="true" bottomline="true">
26639 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26640 \begin_inset Text
26641
26642 \begin_layout Standard
26643 Pointer sizes according to memory model
26644 \end_layout
26645
26646 \end_inset
26647 </cell>
26648 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26649 \begin_inset Text
26650
26651 \begin_layout Standard
26652 small model
26653 \end_layout
26654
26655 \end_inset
26656 </cell>
26657 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26658 \begin_inset Text
26659
26660 \begin_layout Standard
26661 large model
26662 \end_layout
26663
26664 \end_inset
26665 </cell>
26666 </row>
26667 <row topline="true" bottomline="true">
26668 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26669 \begin_inset Text
26670
26671 \begin_layout Standard
26672 code pointers
26673 \end_layout
26674
26675 \end_inset
26676 </cell>
26677 <cell multicolumn="1" alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26678 \begin_inset Text
26679
26680 \begin_layout Standard
26681 16-bits
26682 \end_layout
26683
26684 \end_inset
26685 </cell>
26686 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26687 \begin_inset Text
26688
26689 \begin_layout Standard
26690 24-bits
26691 \end_layout
26692
26693 \end_inset
26694 </cell>
26695 </row>
26696 <row topline="true" bottomline="true">
26697 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26698 \begin_inset Text
26699
26700 \begin_layout Standard
26701 data pointers
26702 \end_layout
26703
26704 \end_inset
26705 </cell>
26706 <cell multicolumn="1" alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
26707 \begin_inset Text
26708
26709 \begin_layout Standard
26710 16-bits
26711 \end_layout
26712
26713 \end_inset
26714 </cell>
26715 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26716 \begin_inset Text
26717
26718 \begin_layout Standard
26719 16-bits
26720 \end_layout
26721
26722 \end_inset
26723 </cell>
26724 </row>
26725 </lyxtabular>
26726
26727 \end_inset
26728
26729
26730 \end_layout
26731
26732 \begin_layout Standard
26733 It is advisable that all sources within a project are compiled with the
26734  same memory model.
26735  If one wants to override the default memory model, this can be done by
26736  declaring a pointer as 
26737 \series bold
26738 far
26739 \series default
26740  or 
26741 \series bold
26742 near
26743 \series default
26744 .
26745  Far selects large memory model's pointers, while near selects small memory
26746  model's pointers.
26747 \end_layout
26748
26749 \begin_layout Standard
26750 The standard device libraries (see 
26751 \begin_inset LatexCommand \ref{sub:PIC16_Header-Files}
26752
26753 \end_inset
26754
26755 ) contain no reference to pointers, so they can be used with both memory
26756  models.
26757 \end_layout
26758
26759 \begin_layout Subsection
26760 Stack
26761 \end_layout
26762
26763 \begin_layout Standard
26764 The stack
26765 \begin_inset LatexCommand \index{PIC16!stack}
26766
26767 \end_inset
26768
26769  implementation for the PIC16 port uses two indirect registers, FSR1 and
26770  FSR2.
26771 \end_layout
26772
26773 \begin_layout Description
26774 FSR1 is assigned as stack pointer
26775 \end_layout
26776
26777 \begin_layout Description
26778 FSR2 is assigned as frame pointer
26779 \end_layout
26780
26781 \begin_layout Standard
26782 The following stack models are supported by the PIC16 port
26783 \end_layout
26784
26785 \begin_layout Itemize
26786
26787 \noun on
26788 small
26789 \noun default
26790  model
26791 \end_layout
26792
26793 \begin_layout Itemize
26794
26795 \noun on
26796 large
26797 \noun default
26798  model
26799 \end_layout
26800
26801 \begin_layout Standard
26802
26803 \noun on
26804 Small
26805 \noun default
26806  model means that only the FSRxL byte is used to access stack and frame,
26807  while 
26808 \emph on
26809 \noun on
26810 large
26811 \emph default
26812 \noun default
26813  uses both FSRxL and FSRxH registers.
26814  The following table shows the stack/frame pointers sizes according to stack
26815  model and the maximum space they can address:
26816 \end_layout
26817
26818 \begin_layout Standard
26819 \align center
26820 \begin_inset Tabular
26821 <lyxtabular version="3" rows="3" columns="3">
26822 <features>
26823 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
26824 <column alignment="center" valignment="top" leftline="true" width="0">
26825 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
26826 <row topline="true" bottomline="true">
26827 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26828 \begin_inset Text
26829
26830 \begin_layout Standard
26831 Stack & Frame pointer sizes according to stack model
26832 \end_layout
26833
26834 \end_inset
26835 </cell>
26836 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26837 \begin_inset Text
26838
26839 \begin_layout Standard
26840 small
26841 \end_layout
26842
26843 \end_inset
26844 </cell>
26845 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26846 \begin_inset Text
26847
26848 \begin_layout Standard
26849 large
26850 \end_layout
26851
26852 \end_inset
26853 </cell>
26854 </row>
26855 <row topline="true">
26856 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26857 \begin_inset Text
26858
26859 \begin_layout Standard
26860 Stack pointer FSR1
26861 \end_layout
26862
26863 \end_inset
26864 </cell>
26865 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26866 \begin_inset Text
26867
26868 \begin_layout Standard
26869 8-bits
26870 \end_layout
26871
26872 \end_inset
26873 </cell>
26874 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26875 \begin_inset Text
26876
26877 \begin_layout Standard
26878 16-bits
26879 \end_layout
26880
26881 \end_inset
26882 </cell>
26883 </row>
26884 <row topline="true" bottomline="true">
26885 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26886 \begin_inset Text
26887
26888 \begin_layout Standard
26889 Frame pointer FSR2
26890 \end_layout
26891
26892 \end_inset
26893 </cell>
26894 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26895 \begin_inset Text
26896
26897 \begin_layout Standard
26898 8-bits
26899 \end_layout
26900
26901 \end_inset
26902 </cell>
26903 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26904 \begin_inset Text
26905
26906 \begin_layout Standard
26907 16-bits
26908 \end_layout
26909
26910 \end_inset
26911 </cell>
26912 </row>
26913 </lyxtabular>
26914
26915 \end_inset
26916
26917
26918 \end_layout
26919
26920 \begin_layout Standard
26921 \noindent
26922
26923 \noun on
26924 Large 
26925 \noun default
26926 stack model is currently not working properly throughout the code generator.
26927  So its use is not advised.
26928  Also there are some other points that need special care:
26929 \newline
26930
26931 \end_layout
26932
26933 \begin_layout Enumerate
26934 Do not create stack sections with size more than one physical bank (that
26935  is 256 bytes)
26936 \end_layout
26937
26938 \begin_layout Enumerate
26939 Stack sections should no cross physical bank limits (i.e.
26940  #pragma stack 0x50 0x100)
26941 \end_layout
26942
26943 \begin_layout Standard
26944 These limitations are caused by the fact that only FSRxL is modified when
26945  using SMALL stack model, so no more than 256 bytes of stack can be used.
26946  This problem will disappear after LARGE model is fully implemented.
26947 \end_layout
26948
26949 \begin_layout Subsection
26950 Functions
26951 \end_layout
26952
26953 \begin_layout Standard
26954 In addition to the standard SDCC function keywords, PIC16
26955 \begin_inset LatexCommand \index{PIC16}
26956
26957 \end_inset
26958
26959  port makes available two more:
26960 \end_layout
26961
26962 \begin_layout Description
26963 wparam
26964 \begin_inset LatexCommand \index{PIC16!wparam}
26965
26966 \end_inset
26967
26968  Use the WREG to pass one byte of the first function argument.
26969  This improves speed but you may not use this for functions with arguments
26970  that are called via function pointers, otherwise the first byte of the
26971  first parameter will get lost.
26972  Usage:
26973 \end_layout
26974
26975 \begin_layout LyX-Code
26976 void func_wparam(int a) wparam
26977 \end_layout
26978
26979 \begin_layout LyX-Code
26980 {
26981 \end_layout
26982
26983 \begin_layout LyX-Code
26984     /* WREG hold the lower part of a */
26985 \end_layout
26986
26987 \begin_layout LyX-Code
26988     /* the high part of a is stored in FSR2+2 (or +3 for large stack model)
26989  */
26990 \end_layout
26991
26992 \begin_layout LyX-Code
26993 ...
26994 \end_layout
26995
26996 \begin_layout LyX-Code
26997 }
26998 \end_layout
26999
27000 \begin_layout Description
27001 shadowregs
27002 \begin_inset LatexCommand \index{PIC16!shadowregs}
27003
27004 \end_inset
27005
27006  When entering/exiting an ISR, it is possible to take advantage of the PIC18F
27007  hardware shadow registers which hold the values of WREG, STATUS and BSR
27008  registers.
27009  This can be done by adding the keyword 
27010 \emph on
27011 shadowregs
27012 \emph default
27013  before the 
27014 \emph on
27015 interrupt
27016 \emph default
27017  keyword in the function's header.
27018 \end_layout
27019
27020 \begin_layout LyX-Code
27021 void isr_shadow(void) shadowregs interrupt 1
27022 \end_layout
27023
27024 \begin_layout LyX-Code
27025 {
27026 \end_layout
27027
27028 \begin_layout LyX-Code
27029 ...
27030 \end_layout
27031
27032 \begin_layout LyX-Code
27033 }
27034 \end_layout
27035
27036 \begin_layout Standard
27037
27038 \emph on
27039 shadowregs
27040 \emph default
27041  instructs the code generator not to store/restore WREG, STATUS, BSR when
27042  entering/exiting the ISR.
27043 \end_layout
27044
27045 \begin_layout Subsection
27046 Function return values
27047 \end_layout
27048
27049 \begin_layout Standard
27050 Return values from functions are placed to the appropriate registers following
27051  a modified Microchip policy optimized for SDCC.
27052  The following table shows these registers:
27053 \end_layout
27054
27055 \begin_layout Standard
27056 \align center
27057 \begin_inset Tabular
27058 <lyxtabular version="3" rows="6" columns="2">
27059 <features>
27060 <column alignment="center" valignment="top" leftline="true" width="0">
27061 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
27062 <row topline="true" bottomline="true">
27063 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27064 \begin_inset Text
27065
27066 \begin_layout Standard
27067 size
27068 \end_layout
27069
27070 \end_inset
27071 </cell>
27072 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27073 \begin_inset Text
27074
27075 \begin_layout Standard
27076 destination register
27077 \end_layout
27078
27079 \end_inset
27080 </cell>
27081 </row>
27082 <row topline="true">
27083 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27084 \begin_inset Text
27085
27086 \begin_layout Standard
27087 8 bits
27088 \end_layout
27089
27090 \end_inset
27091 </cell>
27092 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27093 \begin_inset Text
27094
27095 \begin_layout Standard
27096 WREG
27097 \end_layout
27098
27099 \end_inset
27100 </cell>
27101 </row>
27102 <row topline="true">
27103 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27104 \begin_inset Text
27105
27106 \begin_layout Standard
27107 16 bits
27108 \end_layout
27109
27110 \end_inset
27111 </cell>
27112 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27113 \begin_inset Text
27114
27115 \begin_layout Standard
27116 PRODL:WREG
27117 \end_layout
27118
27119 \end_inset
27120 </cell>
27121 </row>
27122 <row topline="true">
27123 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27124 \begin_inset Text
27125
27126 \begin_layout Standard
27127 24 bits
27128 \end_layout
27129
27130 \end_inset
27131 </cell>
27132 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27133 \begin_inset Text
27134
27135 \begin_layout Standard
27136 PRODH:PRODL:WREG
27137 \end_layout
27138
27139 \end_inset
27140 </cell>
27141 </row>
27142 <row topline="true">
27143 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27144 \begin_inset Text
27145
27146 \begin_layout Standard
27147 32 bits
27148 \end_layout
27149
27150 \end_inset
27151 </cell>
27152 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27153 \begin_inset Text
27154
27155 \begin_layout Standard
27156 FSR0L:PRODH:PRODL:WREG
27157 \end_layout
27158
27159 \end_inset
27160 </cell>
27161 </row>
27162 <row topline="true" bottomline="true">
27163 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27164 \begin_inset Text
27165
27166 \begin_layout Standard
27167 >32 bits
27168 \end_layout
27169
27170 \end_inset
27171 </cell>
27172 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27173 \begin_inset Text
27174
27175 \begin_layout Standard
27176 on stack, FSR0 points to the beginning
27177 \end_layout
27178
27179 \end_inset
27180 </cell>
27181 </row>
27182 </lyxtabular>
27183
27184 \end_inset
27185
27186
27187 \end_layout
27188
27189 \begin_layout Subsection
27190 Interrupts
27191 \end_layout
27192
27193 \begin_layout Standard
27194 An interrupt
27195 \begin_inset LatexCommand \index{PIC16!interrupt}
27196
27197 \end_inset
27198
27199  service routine (ISR) is declared using the 
27200 \emph on
27201 interrupt
27202 \emph default
27203  keyword.
27204 \end_layout
27205
27206 \begin_layout LyX-Code
27207 void isr(void) interrupt 
27208 \emph on
27209 n
27210 \end_layout
27211
27212 \begin_layout LyX-Code
27213 {
27214 \end_layout
27215
27216 \begin_layout LyX-Code
27217 ...
27218 \end_layout
27219
27220 \begin_layout LyX-Code
27221 }
27222 \end_layout
27223
27224 \begin_layout Standard
27225
27226 \emph on
27227 n
27228 \emph default
27229  is the interrupt number, which for PIC18F devices can be:
27230 \end_layout
27231
27232 \begin_layout Standard
27233 \align center
27234 \begin_inset Tabular
27235 <lyxtabular version="3" rows="4" columns="3">
27236 <features>
27237 <column alignment="center" valignment="top" leftline="true" width="0">
27238 <column alignment="center" valignment="top" leftline="true" width="0">
27239 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
27240 <row topline="true" bottomline="true">
27241 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27242 \begin_inset Text
27243
27244 \begin_layout Standard
27245
27246 \emph on
27247 n
27248 \end_layout
27249
27250 \end_inset
27251 </cell>
27252 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27253 \begin_inset Text
27254
27255 \begin_layout Standard
27256 Interrupt Vector
27257 \end_layout
27258
27259 \end_inset
27260 </cell>
27261 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27262 \begin_inset Text
27263
27264 \begin_layout Standard
27265 Interrupt Vector Address
27266 \end_layout
27267
27268 \end_inset
27269 </cell>
27270 </row>
27271 <row topline="true">
27272 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27273 \begin_inset Text
27274
27275 \begin_layout Standard
27276 0
27277 \end_layout
27278
27279 \end_inset
27280 </cell>
27281 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27282 \begin_inset Text
27283
27284 \begin_layout Standard
27285 RESET vector
27286 \end_layout
27287
27288 \end_inset
27289 </cell>
27290 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27291 \begin_inset Text
27292
27293 \begin_layout Standard
27294 0x000000
27295 \end_layout
27296
27297 \end_inset
27298 </cell>
27299 </row>
27300 <row topline="true">
27301 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27302 \begin_inset Text
27303
27304 \begin_layout Standard
27305
27306 \family roman
27307 \series medium
27308 \shape up
27309 \size normal
27310 \emph off
27311 \bar no
27312 \noun off
27313 \color none
27314 1
27315 \end_layout
27316
27317 \end_inset
27318 </cell>
27319 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27320 \begin_inset Text
27321
27322 \begin_layout Standard
27323
27324 \family roman
27325 \series medium
27326 \shape up
27327 \size normal
27328 \emph off
27329 \bar no
27330 \noun off
27331 \color none
27332 HIGH priority interrupts
27333 \end_layout
27334
27335 \end_inset
27336 </cell>
27337 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27338 \begin_inset Text
27339
27340 \begin_layout Standard
27341 0x000008
27342 \end_layout
27343
27344 \end_inset
27345 </cell>
27346 </row>
27347 <row topline="true" bottomline="true">
27348 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27349 \begin_inset Text
27350
27351 \begin_layout Standard
27352 2
27353 \end_layout
27354
27355 \end_inset
27356 </cell>
27357 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27358 \begin_inset Text
27359
27360 \begin_layout Standard
27361 LOW priority interrupts
27362 \end_layout
27363
27364 \end_inset
27365 </cell>
27366 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27367 \begin_inset Text
27368
27369 \begin_layout Standard
27370 0x000018
27371 \end_layout
27372
27373 \end_inset
27374 </cell>
27375 </row>
27376 </lyxtabular>
27377
27378 \end_inset
27379
27380
27381 \end_layout
27382
27383 \begin_layout Standard
27384 When generating assembly code for ISR the code generator places a 
27385 \noun on
27386 goto 
27387 \noun default
27388 instruction at the 
27389 \emph on
27390 Interrupt Vector Address
27391 \emph default
27392  which points at the genetated ISR.
27393  This single GOTO instruction is part of an automatically generated 
27394 \emph on
27395 interrupt entry point
27396 \emph default
27397  function.
27398  The actuall ISR code is placed as normally would in the code space.
27399  Upon interrupt request, the GOTO instruction is executed which jumps to
27400  the ISR code.
27401  When declaring interrupt functions as _naked this GOTO instruction is 
27402 \series bold
27403 not
27404 \series default
27405  generated.
27406  The whole interrupt functions is therefore placed at the Interrupt Vector
27407  Address of the specific interrupt.
27408  This is not a problem for the LOW priority interrupts, but it is a problem
27409  for the RESET and the HIGH priority interrupts because code may be written
27410  at the next interrupt's vector address and cause undeterminate program
27411  behaviour if that interrupt is raised.
27412 \begin_inset Foot
27413 status open
27414
27415 \begin_layout Standard
27416 This is not a problem when
27417 \end_layout
27418
27419 \begin_layout Enumerate
27420 this is a HIGH interrupt ISR and LOW interrupts are 
27421 \emph on
27422 disabled
27423 \emph default
27424  or not used.
27425 \end_layout
27426
27427 \begin_layout Enumerate
27428 when the ISR is small enough not to reach the next interrupt's vector address.
27429 \end_layout
27430
27431 \end_inset
27432
27433
27434 \end_layout
27435
27436 \begin_layout Standard
27437
27438 \emph on
27439 n
27440 \emph default
27441  may be omitted.
27442  This way a function is generated similar to an ISR, but it is not assigned
27443  to any interrupt.
27444 \end_layout
27445
27446 \begin_layout Standard
27447 When entering an interrupt, currently the PIC16
27448 \begin_inset LatexCommand \index{PIC16}
27449
27450 \end_inset
27451
27452  port automatically saves the following registers:
27453 \end_layout
27454
27455 \begin_layout Itemize
27456 WREG
27457 \end_layout
27458
27459 \begin_layout Itemize
27460 STATUS
27461 \end_layout
27462
27463 \begin_layout Itemize
27464 BSR
27465 \end_layout
27466
27467 \begin_layout Itemize
27468 PROD (PRODL and PRODH)
27469 \end_layout
27470
27471 \begin_layout Itemize
27472 FSR0 (FSR0L and FSR0H)
27473 \end_layout
27474
27475 \begin_layout Standard
27476 These registers are restored upon return from the interrupt routine.
27477 \begin_inset Foot
27478 status open
27479
27480 \begin_layout Standard
27481 NOTE that when the _naked attribute is specified for an interrupt routine,
27482  then NO registers are stored or restored.
27483 \end_layout
27484
27485 \end_inset
27486
27487
27488 \end_layout
27489
27490 \begin_layout Subsection
27491 Generic Pointers
27492 \end_layout
27493
27494 \begin_layout Standard
27495 Generic pointers are implemented in PIC16 port as 3-byte (24-bit) types.
27496  There are 3 types of generic pointers currently implemented data, code
27497  and eeprom pointers.
27498  They are differentiated by the value of the 7th and 6th bits of the upper
27499  byte:
27500 \end_layout
27501
27502 \begin_layout Standard
27503 \align center
27504 \begin_inset Tabular
27505 <lyxtabular version="3" rows="5" columns="5">
27506 <features>
27507 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
27508 <column alignment="center" valignment="top" width="0">
27509 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
27510 <column alignment="center" valignment="top" width="0">
27511 <column alignment="left" valignment="top" rightline="true" width="0">
27512 <row topline="true" bottomline="true">
27513 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27514 \begin_inset Text
27515
27516 \begin_layout Standard
27517 pointer type
27518 \end_layout
27519
27520 \end_inset
27521 </cell>
27522 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27523 \begin_inset Text
27524
27525 \begin_layout Standard
27526 7th bit
27527 \end_layout
27528
27529 \end_inset
27530 </cell>
27531 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27532 \begin_inset Text
27533
27534 \begin_layout Standard
27535 6th bit
27536 \end_layout
27537
27538 \end_inset
27539 </cell>
27540 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27541 \begin_inset Text
27542
27543 \begin_layout Standard
27544 rest of the pointer
27545 \end_layout
27546
27547 \end_inset
27548 </cell>
27549 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27550 \begin_inset Text
27551
27552 \begin_layout Standard
27553 description
27554 \end_layout
27555
27556 \end_inset
27557 </cell>
27558 </row>
27559 <row topline="true" bottomline="true">
27560 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27561 \begin_inset Text
27562
27563 \begin_layout Standard
27564 data 
27565 \end_layout
27566
27567 \end_inset
27568 </cell>
27569 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27570 \begin_inset Text
27571
27572 \begin_layout Standard
27573 1
27574 \end_layout
27575
27576 \end_inset
27577 </cell>
27578 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27579 \begin_inset Text
27580
27581 \begin_layout Standard
27582 0
27583 \end_layout
27584
27585 \end_inset
27586 </cell>
27587 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27588 \begin_inset Text
27589
27590 \begin_layout Standard
27591
27592 \family typewriter
27593 \shape slanted
27594 \emph on
27595 uuuuuu uuuuxxxx xxxxxxxx
27596 \end_layout
27597
27598 \end_inset
27599 </cell>
27600 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27601 \begin_inset Text
27602
27603 \begin_layout Standard
27604 a 12-bit data pointer in data RAM memory
27605 \end_layout
27606
27607 \end_inset
27608 </cell>
27609 </row>
27610 <row bottomline="true">
27611 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27612 \begin_inset Text
27613
27614 \begin_layout Standard
27615 code
27616 \end_layout
27617
27618 \end_inset
27619 </cell>
27620 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27621 \begin_inset Text
27622
27623 \begin_layout Standard
27624 0
27625 \end_layout
27626
27627 \end_inset
27628 </cell>
27629 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27630 \begin_inset Text
27631
27632 \begin_layout Standard
27633 0
27634 \end_layout
27635
27636 \end_inset
27637 </cell>
27638 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27639 \begin_inset Text
27640
27641 \begin_layout Standard
27642
27643 \family typewriter
27644 \shape slanted
27645 \emph on
27646 uxxxxx xxxxxxxx xxxxxxxx
27647 \end_layout
27648
27649 \end_inset
27650 </cell>
27651 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27652 \begin_inset Text
27653
27654 \begin_layout Standard
27655 a 21-bit code pointer in FLASH memory
27656 \end_layout
27657
27658 \end_inset
27659 </cell>
27660 </row>
27661 <row bottomline="true">
27662 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27663 \begin_inset Text
27664
27665 \begin_layout Standard
27666 eeprom
27667 \end_layout
27668
27669 \end_inset
27670 </cell>
27671 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27672 \begin_inset Text
27673
27674 \begin_layout Standard
27675 0
27676 \end_layout
27677
27678 \end_inset
27679 </cell>
27680 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27681 \begin_inset Text
27682
27683 \begin_layout Standard
27684 1
27685 \end_layout
27686
27687 \end_inset
27688 </cell>
27689 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27690 \begin_inset Text
27691
27692 \begin_layout Standard
27693
27694 \family typewriter
27695 \shape slanted
27696 \emph on
27697 uuuuuu uuuuuuxx xxxxxxxx
27698 \end_layout
27699
27700 \end_inset
27701 </cell>
27702 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27703 \begin_inset Text
27704
27705 \begin_layout Standard
27706 a 10-bit eeprom pointer in EEPROM memory
27707 \end_layout
27708
27709 \end_inset
27710 </cell>
27711 </row>
27712 <row bottomline="true">
27713 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27714 \begin_inset Text
27715
27716 \begin_layout Standard
27717 (unimplemented)
27718 \end_layout
27719
27720 \end_inset
27721 </cell>
27722 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27723 \begin_inset Text
27724
27725 \begin_layout Standard
27726 1
27727 \end_layout
27728
27729 \end_inset
27730 </cell>
27731 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27732 \begin_inset Text
27733
27734 \begin_layout Standard
27735 1
27736 \end_layout
27737
27738 \end_inset
27739 </cell>
27740 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27741 \begin_inset Text
27742
27743 \begin_layout Standard
27744
27745 \family typewriter
27746 \shape slanted
27747 \emph on
27748 xxxxxx xxxxxxxx xxxxxxxx
27749 \end_layout
27750
27751 \end_inset
27752 </cell>
27753 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27754 \begin_inset Text
27755
27756 \begin_layout Standard
27757 unimplemented pointer type
27758 \end_layout
27759
27760 \end_inset
27761 </cell>
27762 </row>
27763 </lyxtabular>
27764
27765 \end_inset
27766
27767
27768 \end_layout
27769
27770 \begin_layout Standard
27771 \noindent
27772 Generic pointer are read and written with a set of library functions which
27773  read/write 1, 2, 3, 4 bytes.
27774 \end_layout
27775
27776 \begin_layout Subsection
27777 PIC16 C Libraries
27778 \end_layout
27779
27780 \begin_layout Subsubsection
27781 Standard I/O Streams
27782 \end_layout
27783
27784 \begin_layout Standard
27785 In the 
27786 \emph on
27787 stdio.h
27788 \emph default
27789  the type FILE is defined as:
27790 \end_layout
27791
27792 \begin_layout LyX-Code
27793 typedef char * FILE;
27794 \end_layout
27795
27796 \begin_layout Standard
27797 This type is the stream type implemented I/O in the PIC18F devices.
27798  Also the standard input and output streams are declared in stdio.h:
27799 \end_layout
27800
27801 \begin_layout LyX-Code
27802 extern FILE * stdin;
27803 \end_layout
27804
27805 \begin_layout LyX-Code
27806 extern FILE * stdout;
27807 \end_layout
27808
27809 \begin_layout Standard
27810 The FILE type is actually a generic pointer which defines one more type
27811  of generic pointers, the 
27812 \emph on
27813 stream 
27814 \emph default
27815 pointer.
27816  This new type has the format:
27817 \end_layout
27818
27819 \begin_layout Standard
27820 \noindent
27821 \align center
27822 \begin_inset Tabular
27823 <lyxtabular version="3" rows="2" columns="7">
27824 <features>
27825 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
27826 <column alignment="center" valignment="top" width="0">
27827 <column alignment="center" valignment="top" leftline="true" width="0">
27828 <column alignment="center" valignment="top" leftline="true" width="0">
27829 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
27830 <column alignment="center" valignment="top" width="0">
27831 <column alignment="left" valignment="top" rightline="true" width="0">
27832 <row topline="true" bottomline="true">
27833 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27834 \begin_inset Text
27835
27836 \begin_layout Standard
27837 pointer type
27838 \end_layout
27839
27840 \end_inset
27841 </cell>
27842 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27843 \begin_inset Text
27844
27845 \begin_layout Standard
27846 <7:6>
27847 \end_layout
27848
27849 \end_inset
27850 </cell>
27851 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27852 \begin_inset Text
27853
27854 \begin_layout Standard
27855 <5>
27856 \end_layout
27857
27858 \end_inset
27859 </cell>
27860 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27861 \begin_inset Text
27862
27863 \begin_layout Standard
27864 <4>
27865 \end_layout
27866
27867 \end_inset
27868 </cell>
27869 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27870 \begin_inset Text
27871
27872 \begin_layout Standard
27873 <3:0>
27874 \end_layout
27875
27876 \end_inset
27877 </cell>
27878 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27879 \begin_inset Text
27880
27881 \begin_layout Standard
27882 rest of the pointer
27883 \end_layout
27884
27885 \end_inset
27886 </cell>
27887 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27888 \begin_inset Text
27889
27890 \begin_layout Standard
27891 descrption
27892 \end_layout
27893
27894 \end_inset
27895 </cell>
27896 </row>
27897 <row topline="true" bottomline="true">
27898 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27899 \begin_inset Text
27900
27901 \begin_layout Standard
27902 stream
27903 \end_layout
27904
27905 \end_inset
27906 </cell>
27907 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27908 \begin_inset Text
27909
27910 \begin_layout Standard
27911 00
27912 \end_layout
27913
27914 \end_inset
27915 </cell>
27916 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27917 \begin_inset Text
27918
27919 \begin_layout Standard
27920 1
27921 \end_layout
27922
27923 \end_inset
27924 </cell>
27925 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27926 \begin_inset Text
27927
27928 \begin_layout Standard
27929 0
27930 \end_layout
27931
27932 \end_inset
27933 </cell>
27934 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27935 \begin_inset Text
27936
27937 \begin_layout Standard
27938 nnnn
27939 \end_layout
27940
27941 \end_inset
27942 </cell>
27943 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27944 \begin_inset Text
27945
27946 \begin_layout Standard
27947
27948 \family typewriter
27949 \shape slanted
27950 \emph on
27951 uuuuuuuu uuuuuuuu
27952 \end_layout
27953
27954 \end_inset
27955 </cell>
27956 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27957 \begin_inset Text
27958
27959 \begin_layout Standard
27960 upper byte high nubble is 0x2n, the rest are zeroes
27961 \end_layout
27962
27963 \end_inset
27964 </cell>
27965 </row>
27966 </lyxtabular>
27967
27968 \end_inset
27969
27970
27971 \end_layout
27972
27973 \begin_layout Standard
27974 \noindent
27975 Currently implemented there are 3 types of streams defined:
27976 \end_layout
27977
27978 \begin_layout Standard
27979 \noindent
27980 \align center
27981 \begin_inset Tabular
27982 <lyxtabular version="3" rows="4" columns="4">
27983 <features>
27984 <column alignment="center" valignment="top" leftline="true" width="0">
27985 <column alignment="center" valignment="top" leftline="true" width="0">
27986 <column alignment="center" valignment="top" leftline="true" width="0">
27987 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
27988 <row topline="true" bottomline="true">
27989 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27990 \begin_inset Text
27991
27992 \begin_layout Standard
27993 stream type
27994 \end_layout
27995
27996 \end_inset
27997 </cell>
27998 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27999 \begin_inset Text
28000
28001 \begin_layout Standard
28002 value
28003 \end_layout
28004
28005 \end_inset
28006 </cell>
28007 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28008 \begin_inset Text
28009
28010 \begin_layout Standard
28011 module
28012 \end_layout
28013
28014 \end_inset
28015 </cell>
28016 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28017 \begin_inset Text
28018
28019 \begin_layout Standard
28020 description
28021 \end_layout
28022
28023 \end_inset
28024 </cell>
28025 </row>
28026 <row topline="true">
28027 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28028 \begin_inset Text
28029
28030 \begin_layout Standard
28031 STREAM_USART
28032 \end_layout
28033
28034 \end_inset
28035 </cell>
28036 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28037 \begin_inset Text
28038
28039 \begin_layout Standard
28040
28041 \family typewriter
28042 0x200000UL
28043 \end_layout
28044
28045 \end_inset
28046 </cell>
28047 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28048 \begin_inset Text
28049
28050 \begin_layout Standard
28051 USART
28052 \end_layout
28053
28054 \end_inset
28055 </cell>
28056 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28057 \begin_inset Text
28058
28059 \begin_layout Standard
28060 Writes/Reads characters via the USART peripheral
28061 \end_layout
28062
28063 \end_inset
28064 </cell>
28065 </row>
28066 <row topline="true">
28067 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28068 \begin_inset Text
28069
28070 \begin_layout Standard
28071 STREAM_MSSP
28072 \end_layout
28073
28074 \end_inset
28075 </cell>
28076 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28077 \begin_inset Text
28078
28079 \begin_layout Standard
28080
28081 \family typewriter
28082 0x210000UL
28083 \end_layout
28084
28085 \end_inset
28086 </cell>
28087 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28088 \begin_inset Text
28089
28090 \begin_layout Standard
28091 MSSP
28092 \end_layout
28093
28094 \end_inset
28095 </cell>
28096 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28097 \begin_inset Text
28098
28099 \begin_layout Standard
28100 Writes/Reads characters via the MSSP peripheral
28101 \end_layout
28102
28103 \end_inset
28104 </cell>
28105 </row>
28106 <row topline="true" bottomline="true">
28107 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28108 \begin_inset Text
28109
28110 \begin_layout Standard
28111 STREAM_USER
28112 \end_layout
28113
28114 \end_inset
28115 </cell>
28116 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28117 \begin_inset Text
28118
28119 \begin_layout Standard
28120
28121 \family typewriter
28122 0x2f0000UL
28123 \end_layout
28124
28125 \end_inset
28126 </cell>
28127 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28128 \begin_inset Text
28129
28130 \begin_layout Standard
28131 (none)
28132 \end_layout
28133
28134 \end_inset
28135 </cell>
28136 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28137 \begin_inset Text
28138
28139 \begin_layout Standard
28140 Writes/Reads characters via used defined functions
28141 \end_layout
28142
28143 \end_inset
28144 </cell>
28145 </row>
28146 </lyxtabular>
28147
28148 \end_inset
28149
28150
28151 \end_layout
28152
28153 \begin_layout Standard
28154 \noindent
28155 The stream identifiers are declared as macros in the stdio.h header.
28156 \end_layout
28157
28158 \begin_layout Standard
28159 \noindent
28160 In the libc library there exist the functions that are used to write to
28161  each of the above streams.
28162  These are
28163 \end_layout
28164
28165 \begin_layout Description
28166 _
28167 \begin_inset ERT
28168 status collapsed
28169
28170 \begin_layout Standard
28171
28172
28173 \backslash
28174 /
28175 \end_layout
28176
28177 \end_inset
28178
28179 _stream_usart_putchar writes a character at the USART stream
28180 \end_layout
28181
28182 \begin_layout Description
28183 _
28184 \begin_inset ERT
28185 status collapsed
28186
28187 \begin_layout Standard
28188
28189
28190 \backslash
28191 /
28192 \end_layout
28193
28194 \end_inset
28195
28196 _stream_mssp_putchar writes a character at the MSSP stream
28197 \end_layout
28198
28199 \begin_layout Description
28200 putchar dummy function.
28201  This writes a character to a user specified manner.
28202 \end_layout
28203
28204 \begin_layout Standard
28205 In order to increase performance 
28206 \emph on
28207 putchar 
28208 \emph default
28209 is declared in stdio.h as having its parameter in WREG (it has the wparam
28210  keyword).
28211  In stdio.h exists the macro PUTCHAR(arg) that defines the putchar function
28212  in a user-friendly way.
28213  
28214 \emph on
28215 arg
28216 \emph default
28217  is the name of the variable that holds the character to print.
28218  An example follows:
28219 \end_layout
28220
28221 \begin_layout LyX-Code
28222 #include <pic18fregs.h>
28223 \newline
28224 #include <stdio.h>
28225 \newline
28226
28227 \newline
28228 PUTCHAR( c )
28229 \end_layout
28230
28231 \begin_layout LyX-Code
28232 {
28233 \end_layout
28234
28235 \begin_layout LyX-Code
28236     PORTA = c;    /* dump character c to PORTA */
28237 \end_layout
28238
28239 \begin_layout LyX-Code
28240
28241 \newline
28242
28243 \newline
28244 void main(void)
28245 \end_layout
28246
28247 \begin_layout LyX-Code
28248 {
28249 \end_layout
28250
28251 \begin_layout LyX-Code
28252     stdout = STREAM_USER;    /* this is not necessary, since stdout points
28253 \end_layout
28254
28255 \begin_layout LyX-Code
28256                               * by default to STREAM_USER */
28257 \end_layout
28258
28259 \begin_layout LyX-Code
28260     printf (
28261 \begin_inset Quotes sld
28262 \end_inset
28263
28264 This is a printf test
28265 \backslash
28266 n
28267 \begin_inset Quotes srd
28268 \end_inset
28269
28270 );
28271 \end_layout
28272
28273 \begin_layout LyX-Code
28274 }
28275 \end_layout
28276
28277 \begin_layout LyX-Code
28278
28279 \end_layout
28280
28281 \begin_layout Subsubsection
28282 Printing functions
28283 \end_layout
28284
28285 \begin_layout Standard
28286 PIC16 contains an implementation of the printf-family of functions.
28287  There exist the following functions:
28288 \end_layout
28289
28290 \begin_layout LyX-Code
28291 extern unsigned int sprintf(char *buf, char *fmt, ...);
28292 \end_layout
28293
28294 \begin_layout LyX-Code
28295 extern unsigned int vsprintf(char *buf, char *fmt, va_list ap);
28296 \end_layout
28297
28298 \begin_layout LyX-Code
28299
28300 \end_layout
28301
28302 \begin_layout LyX-Code
28303 extern unsigned int printf(char *fmt, ...);
28304 \end_layout
28305
28306 \begin_layout LyX-Code
28307 extern unsigned int vprintf(char *fmt, va_lista ap);
28308 \end_layout
28309
28310 \begin_layout LyX-Code
28311
28312 \end_layout
28313
28314 \begin_layout LyX-Code
28315 extern unsigned int fprintf(FILE *fp, char *fmt, ...);
28316 \end_layout
28317
28318 \begin_layout LyX-Code
28319 extern unsigned int vfprintf(FILE *fp, char *fmt, va_list ap);
28320 \end_layout
28321
28322 \begin_layout Standard
28323 For sprintf and vsprintf 
28324 \emph on
28325 buf 
28326 \emph default
28327 should normally be a data pointer where the resulting string will be placed.
28328  No range checking is done so the user should allocate the necessery buffer.
28329  For fprintf and vfprintf 
28330 \emph on
28331 fp
28332 \emph default
28333  should be a stream pointer (i.e.
28334  stdout, STREAM_MSSP, etc...).
28335 \end_layout
28336
28337 \begin_layout Subsubsection
28338 Signals
28339 \end_layout
28340
28341 \begin_layout Standard
28342 The PIC18F family of microcontrollers supports a number of interrupt sources.
28343  A list of these interrupts is shown in the following table:
28344 \end_layout
28345
28346 \begin_layout Standard
28347 \align center
28348 \begin_inset Tabular
28349 <lyxtabular version="3" rows="11" columns="4">
28350 <features>
28351 <column alignment="left" valignment="top" leftline="true" width="0">
28352 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
28353 <column alignment="left" valignment="top" leftline="true" width="0">
28354 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
28355 <row topline="true" bottomline="true">
28356 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28357 \begin_inset Text
28358
28359 \begin_layout Standard
28360 signal name
28361 \end_layout
28362
28363 \end_inset
28364 </cell>
28365 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28366 \begin_inset Text
28367
28368 \begin_layout Standard
28369 description
28370 \end_layout
28371
28372 \end_inset
28373 </cell>
28374 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28375 \begin_inset Text
28376
28377 \begin_layout Standard
28378 signal name
28379 \end_layout
28380
28381 \end_inset
28382 </cell>
28383 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28384 \begin_inset Text
28385
28386 \begin_layout Standard
28387 descritpion
28388 \end_layout
28389
28390 \end_inset
28391 </cell>
28392 </row>
28393 <row topline="true">
28394 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28395 \begin_inset Text
28396
28397 \begin_layout Standard
28398 SIG_RB
28399 \end_layout
28400
28401 \end_inset
28402 </cell>
28403 <cell multicolumn="1" alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28404 \begin_inset Text
28405
28406 \begin_layout Standard
28407 PORTB change interrupt
28408 \end_layout
28409
28410 \end_inset
28411 </cell>
28412 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28413 \begin_inset Text
28414
28415 \begin_layout Standard
28416 SIG_EE
28417 \end_layout
28418
28419 \end_inset
28420 </cell>
28421 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28422 \begin_inset Text
28423
28424 \begin_layout Standard
28425 EEPROM/FLASH write complete interrupt
28426 \end_layout
28427
28428 \end_inset
28429 </cell>
28430 </row>
28431 <row topline="true">
28432 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28433 \begin_inset Text
28434
28435 \begin_layout Standard
28436 SIG_INT0
28437 \end_layout
28438
28439 \end_inset
28440 </cell>
28441 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28442 \begin_inset Text
28443
28444 \begin_layout Standard
28445 INT0 external interrupt
28446 \end_layout
28447
28448 \end_inset
28449 </cell>
28450 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28451 \begin_inset Text
28452
28453 \begin_layout Standard
28454 SIG_BCOL
28455 \end_layout
28456
28457 \end_inset
28458 </cell>
28459 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28460 \begin_inset Text
28461
28462 \begin_layout Standard
28463 Bus collision interrupt
28464 \end_layout
28465
28466 \end_inset
28467 </cell>
28468 </row>
28469 <row topline="true">
28470 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28471 \begin_inset Text
28472
28473 \begin_layout Standard
28474 SIG_INT1
28475 \end_layout
28476
28477 \end_inset
28478 </cell>
28479 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28480 \begin_inset Text
28481
28482 \begin_layout Standard
28483 INT1 external interrupt
28484 \end_layout
28485
28486 \end_inset
28487 </cell>
28488 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28489 \begin_inset Text
28490
28491 \begin_layout Standard
28492 SIG_LVD
28493 \end_layout
28494
28495 \end_inset
28496 </cell>
28497 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28498 \begin_inset Text
28499
28500 \begin_layout Standard
28501 Low voltage detect interrupt
28502 \end_layout
28503
28504 \end_inset
28505 </cell>
28506 </row>
28507 <row topline="true">
28508 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28509 \begin_inset Text
28510
28511 \begin_layout Standard
28512 SIG_INT2
28513 \end_layout
28514
28515 \end_inset
28516 </cell>
28517 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28518 \begin_inset Text
28519
28520 \begin_layout Standard
28521 INT2 external interrupt
28522 \end_layout
28523
28524 \end_inset
28525 </cell>
28526 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28527 \begin_inset Text
28528
28529 \begin_layout Standard
28530 SIG_PSP
28531 \end_layout
28532
28533 \end_inset
28534 </cell>
28535 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28536 \begin_inset Text
28537
28538 \begin_layout Standard
28539 Parallel slave port interrupt
28540 \end_layout
28541
28542 \end_inset
28543 </cell>
28544 </row>
28545 <row topline="true">
28546 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28547 \begin_inset Text
28548
28549 \begin_layout Standard
28550 SIG_CCP1
28551 \end_layout
28552
28553 \end_inset
28554 </cell>
28555 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28556 \begin_inset Text
28557
28558 \begin_layout Standard
28559 CCP1 module interrupt
28560 \end_layout
28561
28562 \end_inset
28563 </cell>
28564 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28565 \begin_inset Text
28566
28567 \begin_layout Standard
28568 SIG_AD
28569 \end_layout
28570
28571 \end_inset
28572 </cell>
28573 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28574 \begin_inset Text
28575
28576 \begin_layout Standard
28577 AD convertion complete interrupt
28578 \end_layout
28579
28580 \end_inset
28581 </cell>
28582 </row>
28583 <row topline="true">
28584 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28585 \begin_inset Text
28586
28587 \begin_layout Standard
28588 SIG_CCP2
28589 \end_layout
28590
28591 \end_inset
28592 </cell>
28593 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28594 \begin_inset Text
28595
28596 \begin_layout Standard
28597 CCP2 module interrupt
28598 \end_layout
28599
28600 \end_inset
28601 </cell>
28602 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28603 \begin_inset Text
28604
28605 \begin_layout Standard
28606 SIG_RC
28607 \end_layout
28608
28609 \end_inset
28610 </cell>
28611 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28612 \begin_inset Text
28613
28614 \begin_layout Standard
28615 USART receive interrupt
28616 \end_layout
28617
28618 \end_inset
28619 </cell>
28620 </row>
28621 <row topline="true">
28622 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28623 \begin_inset Text
28624
28625 \begin_layout Standard
28626 SIG_TMR0
28627 \end_layout
28628
28629 \end_inset
28630 </cell>
28631 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28632 \begin_inset Text
28633
28634 \begin_layout Standard
28635 TMR0 overflow interrupt
28636 \end_layout
28637
28638 \end_inset
28639 </cell>
28640 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28641 \begin_inset Text
28642
28643 \begin_layout Standard
28644 SIG_TX
28645 \end_layout
28646
28647 \end_inset
28648 </cell>
28649 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28650 \begin_inset Text
28651
28652 \begin_layout Standard
28653 USART transmit interrupt
28654 \end_layout
28655
28656 \end_inset
28657 </cell>
28658 </row>
28659 <row topline="true">
28660 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28661 \begin_inset Text
28662
28663 \begin_layout Standard
28664 SIG_TMR1
28665 \end_layout
28666
28667 \end_inset
28668 </cell>
28669 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28670 \begin_inset Text
28671
28672 \begin_layout Standard
28673 TMR1 overflow interrupt
28674 \end_layout
28675
28676 \end_inset
28677 </cell>
28678 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28679 \begin_inset Text
28680
28681 \begin_layout Standard
28682 SIG_MSSP
28683 \end_layout
28684
28685 \end_inset
28686 </cell>
28687 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28688 \begin_inset Text
28689
28690 \begin_layout Standard
28691 SSP receive/transmit interrupt
28692 \end_layout
28693
28694 \end_inset
28695 </cell>
28696 </row>
28697 <row topline="true">
28698 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28699 \begin_inset Text
28700
28701 \begin_layout Standard
28702 SIG_TMR2
28703 \end_layout
28704
28705 \end_inset
28706 </cell>
28707 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28708 \begin_inset Text
28709
28710 \begin_layout Standard
28711 TMR2 matches PR2 interrupt
28712 \end_layout
28713
28714 \end_inset
28715 </cell>
28716 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28717 \begin_inset Text
28718
28719 \begin_layout Standard
28720
28721 \end_layout
28722
28723 \end_inset
28724 </cell>
28725 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28726 \begin_inset Text
28727
28728 \begin_layout Standard
28729
28730 \end_layout
28731
28732 \end_inset
28733 </cell>
28734 </row>
28735 <row topline="true" bottomline="true">
28736 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28737 \begin_inset Text
28738
28739 \begin_layout Standard
28740 SIG_TMR3
28741 \end_layout
28742
28743 \end_inset
28744 </cell>
28745 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28746 \begin_inset Text
28747
28748 \begin_layout Standard
28749 TMR3 overflow interrupt
28750 \end_layout
28751
28752 \end_inset
28753 </cell>
28754 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28755 \begin_inset Text
28756
28757 \begin_layout Standard
28758
28759 \end_layout
28760
28761 \end_inset
28762 </cell>
28763 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28764 \begin_inset Text
28765
28766 \begin_layout Standard
28767
28768 \end_layout
28769
28770 \end_inset
28771 </cell>
28772 </row>
28773 </lyxtabular>
28774
28775 \end_inset
28776
28777
28778 \end_layout
28779
28780 \begin_layout Standard
28781 \noindent
28782 The prototypes for these names are defined in the header file 
28783 \emph on
28784 signal.h
28785 \emph default
28786  .
28787 \end_layout
28788
28789 \begin_layout Standard
28790 \noindent
28791 In order to simplify signal handling, a number of macros is provided:
28792 \end_layout
28793
28794 \begin_layout List
28795 \labelwidthstring 00.00.0000
28796 DEF_INTHIGH(name) begin the definition of the interrupt dispatch table for
28797  high priority interrupts.
28798  
28799 \emph on
28800 name
28801 \emph default
28802  is the function name to use.
28803 \end_layout
28804
28805 \begin_layout List
28806 \labelwidthstring 00.00.0000
28807 DEF_INTLOW(name) begin the definition of the interrupt dispatch table fo
28808  low priority interrupt.
28809  
28810 \emph on
28811 name
28812 \emph default
28813  is the function name to use.
28814 \end_layout
28815
28816 \begin_layout List
28817 \labelwidthstring 00.00.0000
28818 DEF_HANDLER(sig,handler) define a handler for signal 
28819 \emph on
28820 sig.
28821 \end_layout
28822
28823 \begin_layout List
28824 \labelwidthstring 00.00.0000
28825 END_DEF end the declaration of the dispatch table.
28826 \end_layout
28827
28828 \begin_layout Standard
28829 Additionally there are two more macros to simplify the declaration of the
28830  signal handler:
28831 \end_layout
28832
28833 \begin_layout List
28834 \labelwidthstring 00.00.0000
28835
28836 \series medium
28837 SIGHANDLER(handler) 
28838 \series default
28839 this declares the function prototype for the 
28840 \emph on
28841 handler
28842 \emph default
28843  function.
28844 \end_layout
28845
28846 \begin_layout List
28847 \labelwidthstring 00.00.0000
28848 SIGHANDLERNAKED(handler) same as SIGHANDLER() but declares a naked function.
28849 \end_layout
28850
28851 \begin_layout Standard
28852 An example of using the macros above is shown below:
28853 \end_layout
28854
28855 \begin_layout LyX-Code
28856 #include <pic18fregs.h>
28857 \end_layout
28858
28859 \begin_layout LyX-Code
28860 #include <signal.h>
28861 \newline
28862
28863 \newline
28864 DEF_INTHIGH(high_int)
28865 \end_layout
28866
28867 \begin_layout LyX-Code
28868 DEF_HANDLER(SIG_TMR0, _tmr0_handler)
28869 \end_layout
28870
28871 \begin_layout LyX-Code
28872 DEF_HANDLER(SIG_BCOL, _bcol_handler)
28873 \end_layout
28874
28875 \begin_layout LyX-Code
28876 END_DEF
28877 \newline
28878
28879 \newline
28880 SIGHANDLER(_tmr0_handler)
28881 \end_layout
28882
28883 \begin_layout LyX-Code
28884 {
28885 \end_layout
28886
28887 \begin_layout LyX-Code
28888   /* action to be taken when timer 0 overflows */
28889 \end_layout
28890
28891 \begin_layout LyX-Code
28892 }
28893 \newline
28894
28895 \newline
28896 SIGHANDLERNAKED(_bcol_handler)
28897 \end_layout
28898
28899 \begin_layout LyX-Code
28900 {
28901 \end_layout
28902
28903 \begin_layout LyX-Code
28904   _asm
28905 \end_layout
28906
28907 \begin_layout LyX-Code
28908     /* action to be taken when bus collision occurs */
28909 \end_layout
28910
28911 \begin_layout LyX-Code
28912     retfie
28913 \end_layout
28914
28915 \begin_layout LyX-Code
28916  _endasm;
28917 \end_layout
28918
28919 \begin_layout LyX-Code
28920 }
28921 \end_layout
28922
28923 \begin_layout Standard
28924
28925 \series bold
28926 NOTES:
28927 \series default
28928  Special care should be taken when using the above scheme:
28929 \end_layout
28930
28931 \begin_layout Itemize
28932 do not place a colon (;) at the end of the DEF_* and END_DEF macros.
28933 \end_layout
28934
28935 \begin_layout Itemize
28936 when declaring SIGHANDLERNAKED handler never forget to use 
28937 \emph on
28938 retfie
28939 \emph default
28940  for proper returning.
28941 \end_layout
28942
28943 \begin_layout Subsection
28944 PIC16 Port -- Tips
28945 \end_layout
28946
28947 \begin_layout Standard
28948 Here you can find some general tips for compiling programs with SDCC/pic16.
28949 \end_layout
28950
28951 \begin_layout Subsubsection
28952 Stack size
28953 \end_layout
28954
28955 \begin_layout Standard
28956 The default stack
28957 \begin_inset LatexCommand \index{PIC16!stack}
28958
28959 \end_inset
28960
28961  size (that is 64 bytes) probably is enough for many programs.
28962  One must take care that when there are many levels of function nesting,
28963  or there is excessive usage of stack, its size should be extended.
28964  An example of such a case is the printf/sprintf family of functions.
28965  If you encounter problems like not being able to print integers, then you
28966  need to set the stack size around the maximum (256 for small stack model).
28967  The following diagram shows what happens when calling printf to print an
28968  integer:
28969 \end_layout
28970
28971 \begin_layout LyX-Code
28972 printf () --> ltoa () --> ultoa () --> divschar ()
28973 \end_layout
28974
28975 \begin_layout Standard
28976 It is should be understood that stack is easily consumed when calling complicate
28977 d functions.
28978  Using command line arguments like -
28979 \begin_inset ERT
28980 status collapsed
28981
28982 \begin_layout Standard
28983
28984
28985 \backslash
28986 /
28987 \end_layout
28988
28989 \end_inset
28990
28991 -fommit-frame-pointer might reduce stack usage by not creating unnecessery
28992  stack frames.
28993  Other ways to reduce stack usage may exist.
28994 \end_layout
28995
28996 \begin_layout Subsection
28997 Known Bugs
28998 \end_layout
28999
29000 \begin_layout Subsubsection
29001 Extended Instruction Set
29002 \end_layout
29003
29004 \begin_layout Standard
29005 The PIC16 port emits code which is incompatible with the extended instruction
29006  set available with many newer devices.
29007  Make sure to always explicitly disable it, usually using
29008 \end_layout
29009
29010 \begin_layout Standard
29011
29012 \family typewriter
29013 static __code char __at(__CONFIG4L) conf4l = /* more flags & */ _XINST_OFF_4L;
29014 \end_layout
29015
29016 \begin_layout Standard
29017 \noindent
29018 Some devices (namely 18f2455, 18f2550, 18f4455, and 18f4550) use _ENHCPU_OFF_4L
29019  instead of _XINST_OFF_4L.
29020 \end_layout
29021
29022 \begin_layout Subsubsection
29023 Regression Tests
29024 \end_layout
29025
29026 \begin_layout Standard
29027 The PIC16 port currently passes most but not all of the tests in SDCC's
29028  regression test
29029 \begin_inset LatexCommand \index{Regression test (PIC16)}
29030
29031 \end_inset
29032
29033  suite (see section 
29034 \begin_inset LatexCommand \ref{sec:Quality-control}
29035
29036 \end_inset
29037
29038 ), thus no automatic regression tests are currently performed for the PIC16
29039  target.
29040 \end_layout
29041
29042 \begin_layout Chapter
29043 Debugging
29044 \end_layout
29045
29046 \begin_layout Standard
29047 There are several approaches to debugging your code.
29048  This chapter is meant to show your options and to give detail on some of
29049  them:
29050 \newline
29051
29052 \newline
29053 When writing your code:
29054 \end_layout
29055
29056 \begin_layout Itemize
29057 write your code with debugging in mind (avoid duplicating code, put conceptually
29058  similar variables into structs, use structured code, have strategic points
29059  within your code where all variables are consistent, ...)
29060 \end_layout
29061
29062 \begin_layout Itemize
29063 run a syntax-checking tool like splint
29064 \begin_inset LatexCommand \index{splint (syntax checking tool)}
29065
29066 \end_inset
29067
29068
29069 \begin_inset LatexCommand \index{lint (syntax checking tool)}
29070
29071 \end_inset
29072
29073  (see -
29074 \begin_inset ERT
29075 status collapsed
29076
29077 \begin_layout Standard
29078
29079
29080 \backslash
29081 /
29082 \end_layout
29083
29084 \end_inset
29085
29086 -more-pedantic 
29087 \begin_inset LatexCommand \ref{lyx:more-pedantic-SPLINT}
29088
29089 \end_inset
29090
29091 ) over the code.
29092 \end_layout
29093
29094 \begin_layout Itemize
29095 for the high level code use a C-compiler (like f.e.
29096  GCC) to compile run and debug the code on your host.
29097  See (see -
29098 \begin_inset ERT
29099 status collapsed
29100
29101 \begin_layout Standard
29102
29103
29104 \backslash
29105 /
29106 \end_layout
29107
29108 \end_inset
29109
29110 -more-pedantic 
29111 \begin_inset LatexCommand \ref{lyx:more-pedantic-SPLINT}
29112
29113 \end_inset
29114
29115 ) on how to handle syntax extensions like __xdata, __at(), ...
29116  
29117 \end_layout
29118
29119 \begin_layout Itemize
29120 use another C-compiler to compile code for your target.
29121  Always an option but not recommended:) And not very likely to help you.
29122  If you seriously consider walking this path you should at least occasionally
29123  check portability of your code.
29124  Most commercial compiler vendors will offer an evaluation version so you
29125  can test compile your code or snippets of your code.
29126 \end_layout
29127
29128 \begin_layout Standard
29129 Debugging on a simulator:
29130 \end_layout
29131
29132 \begin_layout Itemize
29133 there is a separate section about SDCDB (section 
29134 \begin_inset LatexCommand \ref{cha:Debugging-with-SDCDB}
29135
29136 \end_inset
29137
29138 ) below.
29139 \end_layout
29140
29141 \begin_layout Itemize
29142 or (8051 specific) use a freeware/commercial simulator which interfaces
29143  to the AOMF
29144 \begin_inset LatexCommand \index{AOMF, AOMF51}
29145
29146 \end_inset
29147
29148  file (see 
29149 \begin_inset LatexCommand \ref{OMF file}
29150
29151 \end_inset
29152
29153 ) optionally generated by SDCC.
29154 \end_layout
29155
29156 \begin_layout Standard
29157 Debugging On-target: 
29158 \end_layout
29159
29160 \begin_layout Itemize
29161 use a MCU port pin to serially output debug data to the RS232 port of your
29162  host.
29163  You'll probably want some level shifting device typically involving a MAX232
29164  or similar IC.
29165  If the hardware serial port of the MCU is not available search for 'Software
29166  UART' in your favourite search machine.
29167 \end_layout
29168
29169 \begin_layout Itemize
29170 use an on-target monitor.
29171  In this context a monitor is a small program which usually accepts commands
29172  via a serial line and allows to set program counter, to single step through
29173  a program and read/write memory locations.
29174  For the 8051 good examples of monitors are paulmon and cmon51 (see section
29175  
29176 \begin_inset LatexCommand \ref{sec:Related-open-source-tools}
29177
29178 \end_inset
29179
29180 ).
29181 \end_layout
29182
29183 \begin_layout Itemize
29184 toggle MCU port pins at strategic points within your code and use an oscilloscop
29185 e.
29186  A 
29187 \emph on
29188 digital oscilloscope
29189 \emph default
29190
29191 \begin_inset LatexCommand \index{Oscilloscope}
29192
29193 \end_inset
29194
29195  with deep trace memory is really helpful especially if you have to debug
29196  a realtime application.
29197  If you need to monitor more pins than your oscilloscope provides you can
29198  sometimes get away with a small R-2R network.
29199  On a single channel oscilloscope you could f.e.
29200  monitor 2 push-pull driven pins by connecting one via a 10\InsetSpace ~
29201 k
29202 \begin_inset Formula $\Omega$
29203 \end_inset
29204
29205  resistor and the other one by a 5\InsetSpace ~
29206 k
29207 \begin_inset Formula $\Omega$
29208 \end_inset
29209
29210  resistor to the oscilloscope probe (check output drive capability of the
29211  pins you want to monitor).
29212  If you need to monitor many more pins a 
29213 \emph on
29214 logic analyzer
29215 \emph default
29216  will be handy.
29217 \end_layout
29218
29219 \begin_layout Itemize
29220 use an ICE (
29221 \emph on
29222 i
29223 \emph default
29224
29225 \emph on
29226 c
29227 \emph default
29228 ircuit 
29229 \emph on
29230 e
29231 \emph default
29232 mulator
29233 \begin_inset LatexCommand \index{ICE (in circuit emulator)}
29234
29235 \end_inset
29236
29237 ).
29238  Usually very expensive.
29239  And very nice to have too.
29240  And usually locks you (for years...) to the devices the ICE can emulate.
29241  
29242 \end_layout
29243
29244 \begin_layout Itemize
29245 use a remote debugger.
29246  In most 8-bit systems the symbol information is not available on the target,
29247  and a complete debugger is too bulky for the target system.
29248  Therefore usually a debugger on the host system connects to an on-target
29249  debugging stub which accepts only primitive commands.
29250  
29251 \newline
29252 Terms to enter into your favourite search engine could be 'remote debugging',
29253  'gdb stub' or 'inferior debugger'.
29254  (is there one?)
29255 \end_layout
29256
29257 \begin_layout Itemize
29258 use an on target hardware debugger.
29259  Some of the more modern MCUs include hardware support for setting break
29260  points and monitoring/changing variables by using dedicated hardware pins.
29261  This facility doesn't require additional code to run on the target and
29262  
29263 \emph on
29264 usually
29265 \emph default
29266  doesn't affect runtime behaviour until a breakpoint is hit.
29267  For the mcs51 most hardware debuggers use the AOMF
29268 \begin_inset LatexCommand \index{AOMF, AOMF51}
29269
29270 \end_inset
29271
29272  file (see 
29273 \begin_inset LatexCommand \ref{OMF file}
29274
29275 \end_inset
29276
29277 ) as input file.
29278  
29279 \end_layout
29280
29281 \begin_layout Standard
29282 Last not least:
29283 \end_layout
29284
29285 \begin_layout Itemize
29286 if you are not familiar with any of the following terms you're likely to
29287  run into problems rather sooner than later: 
29288 \emph on
29289 volatile
29290 \emph default
29291
29292 \emph on
29293 atomic
29294 \emph default
29295
29296 \emph on
29297 memory map
29298 \emph default
29299
29300 \emph on
29301 overlay
29302 \emph default
29303 .
29304  As an embedded programmer you 
29305 \emph on
29306 have
29307 \emph default
29308  to know them so why not look them up 
29309 \emph on
29310 before
29311 \emph default
29312  you have problems?)
29313 \end_layout
29314
29315 \begin_layout Itemize
29316 tell someone else about your problem (actually this is a surprisingly effective
29317  means to hunt down the bug even if the listener is not familiar with your
29318  environment).
29319  As 'failure to communicate' is probably one of the job-induced deformations
29320  of an embedded programmer this is highly encouraged.
29321 \end_layout
29322
29323 \begin_layout Section
29324 Debugging with SDCDB
29325 \begin_inset LatexCommand \label{cha:Debugging-with-SDCDB}
29326
29327 \end_inset
29328
29329
29330 \begin_inset LatexCommand \index{SDCDB (debugger)}
29331
29332 \end_inset
29333
29334  
29335 \end_layout
29336
29337 \begin_layout Standard
29338 SDCC is distributed with a source level debugger
29339 \begin_inset LatexCommand \index{Debugger}
29340
29341 \end_inset
29342
29343 .
29344  The debugger uses a command line interface, the command repertoire of the
29345  debugger has been kept as close to gdb
29346 \begin_inset LatexCommand \index{gdb}
29347
29348 \end_inset
29349
29350  (the GNU debugger) as possible.
29351  The configuration and build process is part of the standard compiler installati
29352 on, which also builds and installs the debugger in the target directory
29353  specified during configuration.
29354  The debugger allows you debug BOTH at the C source and at the ASM source
29355  level.
29356 \end_layout
29357
29358 \begin_layout Subsection
29359 Compiling for Debugging
29360 \end_layout
29361
29362 \begin_layout Standard
29363 The -
29364 \begin_inset ERT
29365 status collapsed
29366
29367 \begin_layout Standard
29368
29369
29370 \backslash
29371 /
29372 \end_layout
29373
29374 \end_inset
29375
29376 -debug
29377 \begin_inset LatexCommand \index{-\/-debug}
29378
29379 \end_inset
29380
29381  option must be specified for all files for which debug information is to
29382  be generated.
29383  The compiler generates a .adb file for each of these files.
29384  The linker creates the .cdb
29385 \begin_inset LatexCommand \index{<file>.cdb}
29386
29387 \end_inset
29388
29389  file from the .adb
29390 \begin_inset LatexCommand \index{<file>.adb}
29391
29392 \end_inset
29393
29394  files and the address information.
29395  This .cdb is used by the debugger.
29396 \end_layout
29397
29398 \begin_layout Subsection
29399 How the Debugger Works
29400 \end_layout
29401
29402 \begin_layout Standard
29403 When the -
29404 \begin_inset ERT
29405 status collapsed
29406
29407 \begin_layout Standard
29408
29409
29410 \backslash
29411 /
29412 \end_layout
29413
29414 \end_inset
29415
29416 -debug option is specified the compiler generates extra symbol information
29417  some of which are put into the assembler source and some are put into the
29418  .adb file.
29419  Then the linker creates the .cdb file from the individual .adb files with
29420  the address information for the symbols.
29421  The debugger reads the symbolic information generated by the compiler &
29422  the address information generated by the linker.
29423  It uses the SIMULATOR (Daniel's S51) to execute the program, the program
29424  execution is controlled by the debugger.
29425  When a command is issued for the debugger, it translates it into appropriate
29426  commands for the simulator.
29427  (Currently SDCDM only connects to the simulator but 
29428 \emph on
29429 newcdb
29430 \emph default
29431  at 
29432 \begin_inset LatexCommand \url{http://ec2drv.sf.net/}
29433
29434 \end_inset
29435
29436  is an effort to connect directly to the hardware.) 
29437 \end_layout
29438
29439 \begin_layout Subsection
29440 Starting the Debugger SDCDB
29441 \end_layout
29442
29443 \begin_layout Standard
29444 The debugger can be started using the following command line.
29445  (Assume the file you are debugging has the file name foo).
29446 \newline
29447
29448 \newline
29449
29450 \family sans
29451 \series bold
29452 sdcdb foo
29453 \newline
29454
29455 \family default
29456 \series default
29457
29458 \newline
29459 The debugger will look for the following files.
29460 \end_layout
29461
29462 \begin_layout Itemize
29463 foo.c - the source file.
29464 \end_layout
29465
29466 \begin_layout Itemize
29467 foo.cdb - the debugger symbol information file.
29468 \end_layout
29469
29470 \begin_layout Itemize
29471 foo.ihx - the Intel hex format
29472 \begin_inset LatexCommand \index{Intel hex format}
29473
29474 \end_inset
29475
29476  object file.
29477 \end_layout
29478
29479 \begin_layout Subsection
29480 SDCDB Command Line Options
29481 \end_layout
29482
29483 \begin_layout Itemize
29484 -
29485 \begin_inset ERT
29486 status collapsed
29487
29488 \begin_layout Standard
29489
29490
29491 \backslash
29492 /
29493 \end_layout
29494
29495 \end_inset
29496
29497 -directory=<source file directory> this option can used to specify the directory
29498  search list.
29499  The debugger will look into the directory list specified for source, cdb
29500  & ihx files.
29501  The items in the directory list must be separated by ':', e.g.
29502  if the source files can be in the directories /home/src1 and /home/src2,
29503  the -
29504 \begin_inset ERT
29505 status collapsed
29506
29507 \begin_layout Standard
29508
29509
29510 \backslash
29511 /
29512 \end_layout
29513
29514 \end_inset
29515
29516 -directory option should be -
29517 \begin_inset ERT
29518 status collapsed
29519
29520 \begin_layout Standard
29521
29522
29523 \backslash
29524 /
29525 \end_layout
29526
29527 \end_inset
29528
29529 -directory=/home/src1:/home/src2.
29530  Note there can be no spaces in the option.
29531  
29532 \end_layout
29533
29534 \begin_layout Itemize
29535 -cd <directory> - change to the <directory>.
29536 \end_layout
29537
29538 \begin_layout Itemize
29539 -fullname - used by GUI front ends.
29540 \end_layout
29541
29542 \begin_layout Itemize
29543 -cpu <cpu-type> - this argument is passed to the simulator please see the
29544  simulator docs for details.
29545 \end_layout
29546
29547 \begin_layout Itemize
29548 -X <Clock frequency > this options is passed to the simulator please see
29549  the simulator docs for details.
29550 \end_layout
29551
29552 \begin_layout Itemize
29553 -s <serial port file> passed to simulator see the simulator docs for details.
29554 \end_layout
29555
29556 \begin_layout Itemize
29557 -S <serial in,out> passed to simulator see the simulator docs for details.
29558 \end_layout
29559
29560 \begin_layout Itemize
29561 -k <port number> passed to simulator see the simulator docs for details.
29562 \end_layout
29563
29564 \begin_layout Subsection
29565 SDCDB Debugger Commands
29566 \end_layout
29567
29568 \begin_layout Standard
29569 As mentioned earlier the command interface for the debugger has been deliberatel
29570 y kept as close the GNU debugger gdb, as possible.
29571  This will help the integration with existing graphical user interfaces
29572  (like ddd, xxgdb or xemacs) existing for the GNU debugger.
29573  If you use a graphical user interface for the debugger you can skip this
29574  section.
29575 \end_layout
29576
29577 \begin_layout Subsubsection*
29578 break [line | file:line | function | file:function]
29579 \end_layout
29580
29581 \begin_layout Standard
29582 Set breakpoint at specified line or function:
29583 \newline
29584
29585 \newline
29586
29587 \family sans
29588 \series bold
29589 sdcdb>break 100 
29590 \newline
29591 sdcdb>break foo.c:100
29592 \newline
29593 sdcdb>break funcfoo
29594 \newline
29595 sdcdb>break foo.c:funcfoo
29596 \end_layout
29597
29598 \begin_layout Subsubsection*
29599 clear [line | file:line | function | file:function ]
29600 \end_layout
29601
29602 \begin_layout Standard
29603 Clear breakpoint at specified line or function:
29604 \newline
29605
29606 \newline
29607
29608 \family sans
29609 \series bold
29610 sdcdb>clear 100
29611 \newline
29612 sdcdb>clear foo.c:100
29613 \newline
29614 sdcdb>clear funcfoo
29615 \newline
29616 sdcdb>clear foo.c:funcfoo
29617 \end_layout
29618
29619 \begin_layout Subsubsection*
29620 continue
29621 \end_layout
29622
29623 \begin_layout Standard
29624 Continue program being debugged, after breakpoint.
29625 \end_layout
29626
29627 \begin_layout Subsubsection*
29628 finish
29629 \end_layout
29630
29631 \begin_layout Standard
29632 Execute till the end of the current function.
29633 \end_layout
29634
29635 \begin_layout Subsubsection*
29636 delete [n]
29637 \end_layout
29638
29639 \begin_layout Standard
29640 Delete breakpoint number 'n'.
29641  If used without any option clear ALL user defined break points.
29642 \end_layout
29643
29644 \begin_layout Subsubsection*
29645 info [break | stack | frame | registers ]
29646 \end_layout
29647
29648 \begin_layout Itemize
29649 info break - list all breakpoints
29650 \end_layout
29651
29652 \begin_layout Itemize
29653 info stack - show the function call stack.
29654 \end_layout
29655
29656 \begin_layout Itemize
29657 info frame - show information about the current execution frame.
29658 \end_layout
29659
29660 \begin_layout Itemize
29661 info registers - show content of all registers.
29662 \end_layout
29663
29664 \begin_layout Subsubsection*
29665 step
29666 \end_layout
29667
29668 \begin_layout Standard
29669 Step program until it reaches a different source line.
29670  Note: pressing <return> repeats the last command.
29671 \end_layout
29672
29673 \begin_layout Subsubsection*
29674 next
29675 \end_layout
29676
29677 \begin_layout Standard
29678 Step program, proceeding through subroutine calls.
29679 \end_layout
29680
29681 \begin_layout Subsubsection*
29682 run
29683 \end_layout
29684
29685 \begin_layout Standard
29686 Start debugged program.
29687 \end_layout
29688
29689 \begin_layout Subsubsection*
29690 ptype variable 
29691 \end_layout
29692
29693 \begin_layout Standard
29694 Print type information of the variable.
29695 \end_layout
29696
29697 \begin_layout Subsubsection*
29698 print variable
29699 \end_layout
29700
29701 \begin_layout Standard
29702 print value of variable.
29703 \end_layout
29704
29705 \begin_layout Subsubsection*
29706 file filename
29707 \end_layout
29708
29709 \begin_layout Standard
29710 load the given file name.
29711  Note this is an alternate method of loading file for debugging.
29712 \end_layout
29713
29714 \begin_layout Subsubsection*
29715 frame
29716 \end_layout
29717
29718 \begin_layout Standard
29719 print information about current frame.
29720 \end_layout
29721
29722 \begin_layout Subsubsection*
29723 set srcmode
29724 \end_layout
29725
29726 \begin_layout Standard
29727 Toggle between C source & assembly source.
29728 \end_layout
29729
29730 \begin_layout Subsubsection*
29731 ! simulator command
29732 \end_layout
29733
29734 \begin_layout Standard
29735 Send the string following '!' to the simulator, the simulator response is
29736  displayed.
29737  Note the debugger does not interpret the command being sent to the simulator,
29738  so if a command like 'go' is sent the debugger can loose its execution
29739  context and may display incorrect values.
29740 \end_layout
29741
29742 \begin_layout Subsubsection*
29743 quit
29744 \end_layout
29745
29746 \begin_layout Standard
29747 "Watch me now.
29748  Iam going Down.
29749  My name is Bobby Brown"
29750 \end_layout
29751
29752 \begin_layout Subsection
29753 Interfacing SDCDB with DDD
29754 \end_layout
29755
29756 \begin_layout Standard
29757 \begin_inset Note Note
29758 status collapsed
29759
29760 \begin_layout Standard
29761 The screenshot was converted from png to eps with: 
29762 \begin_inset Quotes sld
29763 \end_inset
29764
29765 bmeps -c -e8f -p3 ddd_example.png >ddd_example.eps
29766 \begin_inset Quotes srd
29767 \end_inset
29768
29769  which produces a pretty compact eps file which is free from compression
29770  artifacts.
29771 \end_layout
29772
29773 \begin_layout Standard
29774 The screenshot was included in sdccman.lyx cvs version 1.120 but later removed
29775  as this broke the build system on Sourceforge (pdf-file was broken.
29776  pdflatex does not accept eps files).
29777 \end_layout
29778
29779 \end_inset
29780
29781
29782 \end_layout
29783
29784 \begin_layout Standard
29785 The 
29786 \emph on
29787 p
29788 \emph default
29789 ortable 
29790 \emph on
29791 n
29792 \emph default
29793 etwork 
29794 \emph on
29795 g
29796 \emph default
29797 raphics File 
29798 \size footnotesize
29799
29800 \begin_inset LatexCommand \url{http://sdcc.svn.sourceforge.net/viewvc/*checkout*/sdcc/trunk/sdcc/doc/figures/ddd_example.png}
29801
29802 \end_inset
29803
29804
29805 \size default
29806  shows a screenshot of a debugging session with DDD
29807 \begin_inset LatexCommand \index{DDD (debugger)}
29808
29809 \end_inset
29810
29811  (Unix only) on a simulated 8032.
29812  The debugging session might not run as smoothly as the screenshot suggests.
29813  The debugger allows setting of breakpoints, displaying and changing variables,
29814  single stepping through C and assembler code.
29815  
29816 \newline
29817 The source was compiled with 
29818 \family sans
29819 \series bold
29820
29821 \newline
29822
29823 \newline
29824 sdcc -
29825 \family default
29826 \series default
29827
29828 \begin_inset ERT
29829 status collapsed
29830
29831 \begin_layout Standard
29832
29833
29834 \backslash
29835 /
29836 \end_layout
29837
29838 \end_inset
29839
29840
29841 \family sans
29842 \series bold
29843 -debug ddd_example.c
29844 \family default
29845 \series default
29846  
29847 \family sans
29848 \series bold
29849
29850 \newline
29851
29852 \family default
29853 \series default
29854
29855 \newline
29856 and DDD was invoked with 
29857 \family sans
29858 \series bold
29859
29860 \newline
29861
29862 \newline
29863 ddd -debugger "sdcdb -cpu 8032 ddd_example"
29864 \end_layout
29865
29866 \begin_layout Standard
29867 \begin_inset Note Note
29868 status open
29869
29870 \begin_layout Standard
29871 Check that the double quotes or an apostroph within the command line survive
29872  the LyX tool chain.
29873  Previously the apostrophs got slanted in the PDF output so a cut and paste
29874  did not work.
29875 \end_layout
29876
29877 \end_inset
29878
29879
29880 \end_layout
29881
29882 \begin_layout Subsection
29883 Interfacing SDCDB with XEmacs
29884 \begin_inset LatexCommand \index{XEmacs}
29885
29886 \end_inset
29887
29888
29889 \begin_inset LatexCommand \index{Emacs}
29890
29891 \end_inset
29892
29893
29894 \end_layout
29895
29896 \begin_layout Standard
29897 Two files (in emacs lisp) are provided for the interfacing with XEmacs,
29898  sdcdb.el and sdcdbsrc.el.
29899  These two files can be found in the $(prefix)/bin directory after the installat
29900 ion is complete.
29901  These files need to be loaded into XEmacs for the interface to work.
29902  This can be done at XEmacs startup time by inserting the following into
29903  your '.xemacs' file (which can be found in your HOME directory): 
29904 \newline
29905
29906 \newline
29907
29908 \family typewriter
29909 (load-file sdcdbsrc.el) 
29910 \family default
29911
29912 \newline
29913
29914 \newline
29915 .xemacs is a lisp file so the () around the command is REQUIRED.
29916  The files can also be loaded dynamically while XEmacs is running, set the
29917  environment variable 'EMACSLOADPATH' to the installation bin directory
29918  (<installdir>/bin), then enter the following command ESC-x load-file sdcdbsrc.
29919  To start the interface enter the following command: 
29920 \newline
29921
29922 \newline
29923
29924 \family sans
29925 \series bold
29926 ESC-x sdcdbsrc
29927 \family default
29928 \series default
29929
29930 \newline
29931
29932 \newline
29933 You will prompted to enter the file name to be debugged.
29934  
29935 \newline
29936
29937 \newline
29938 The command line options that are passed to the simulator directly are
29939  bound to default values in the file sdcdbsrc.el.
29940  The variables are listed below, these values maybe changed as required.
29941 \end_layout
29942
29943 \begin_layout Itemize
29944 sdcdbsrc-cpu-type '51
29945 \end_layout
29946
29947 \begin_layout Itemize
29948 sdcdbsrc-frequency '11059200
29949 \end_layout
29950
29951 \begin_layout Itemize
29952 sdcdbsrc-serial nil
29953 \end_layout
29954
29955 \begin_layout Standard
29956 The following is a list of key mapping for the debugger interface.
29957 \end_layout
29958
29959 \begin_layout Standard
29960 \InsetSpace ~
29961
29962 \family typewriter
29963
29964 \newline
29965 ;;\InsetSpace ~
29966 Current Listing :: 
29967 \newline
29968 ;;key\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 binding\InsetSpace ~
29983 \InsetSpace ~
29984 \InsetSpace ~
29985 \InsetSpace ~
29986 \InsetSpace ~
29987 \InsetSpace ~
29988 \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 \InsetSpace ~
30004 Comment 
30005 \newline
30006 ;;---\InsetSpace ~
30007 \InsetSpace ~
30008 \InsetSpace ~
30009 \InsetSpace ~
30010 \InsetSpace ~
30011 \InsetSpace ~
30012 \InsetSpace ~
30013 \InsetSpace ~
30014 \InsetSpace ~
30015 \InsetSpace ~
30016 \InsetSpace ~
30017 \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 \InsetSpace ~
30033 \InsetSpace ~
30034 \InsetSpace ~
30035 \InsetSpace ~
30036 \InsetSpace ~
30037 \InsetSpace ~
30038 \InsetSpace ~
30039 \InsetSpace ~
30040 \InsetSpace ~
30041 \InsetSpace ~
30042 -------
30043 \newline
30044 ;; 
30045 \newline
30046 ;;\InsetSpace ~
30047 n\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 \InsetSpace ~
30061 \InsetSpace ~
30062 sdcdb-next-fro
30063 m-src\InsetSpace ~
30064 \InsetSpace ~
30065 \InsetSpace ~
30066 \InsetSpace ~
30067 \InsetSpace ~
30068 \InsetSpace ~
30069 \InsetSpace ~
30070 \InsetSpace ~
30071 \InsetSpace ~
30072 \InsetSpace ~
30073 SDCDB next command 
30074 \newline
30075 ;;\InsetSpace ~
30076 b\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 \InsetSpace ~
30090 \InsetSpace ~
30091 sdcdb-back-from-src\InsetSpace ~
30092 \InsetSpace ~
30093 \InsetSpace ~
30094 \InsetSpace ~
30095 \InsetSpace ~
30096 \InsetSpace ~
30097 \InsetSpace ~
30098 \InsetSpace ~
30099 \InsetSpace ~
30100 \InsetSpace ~
30101 SDCDB back command 
30102 \newline
30103 ;;\InsetSpace ~
30104 c\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 \InsetSpace ~
30118 \InsetSpace ~
30119 sdcdb-cont-f
30120 rom-src\InsetSpace ~
30121 \InsetSpace ~
30122 \InsetSpace ~
30123 \InsetSpace ~
30124 \InsetSpace ~
30125 \InsetSpace ~
30126 \InsetSpace ~
30127 \InsetSpace ~
30128 \InsetSpace ~
30129 \InsetSpace ~
30130 SDCDB continue command
30131 \newline
30132 ;;\InsetSpace ~
30133 s\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 sdcdb-step-from-src\InsetSpace ~
30149 \InsetSpace ~
30150 \InsetSpace ~
30151 \InsetSpace ~
30152 \InsetSpace ~
30153 \InsetSpace ~
30154 \InsetSpace ~
30155 \InsetSpace ~
30156 \InsetSpace ~
30157 \InsetSpace ~
30158 SDCDB step command 
30159 \newline
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 sdcdb-w
30177 hatis-c-sexp\InsetSpace ~
30178 \InsetSpace ~
30179 \InsetSpace ~
30180 \InsetSpace ~
30181 \InsetSpace ~
30182 \InsetSpace ~
30183 \InsetSpace ~
30184 \InsetSpace ~
30185 \InsetSpace ~
30186 \InsetSpace ~
30187 SDCDB ptypecommand for data at 
30188 \newline
30189 ;;\InsetSpace ~
30190 \InsetSpace ~
30191 \InsetSpace ~
30192 \InsetSpace ~
30193 \InsetSpace ~
30194 \InsetSpace ~
30195 \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 \InsetSpace ~
30210 \InsetSpace ~
30211 \InsetSpace ~
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 buffer point 
30237 \newline
30238 ;;\InsetSpace ~
30239 x\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 sdcdbsrc-delete\InsetSpace ~
30255 \InsetSpace ~
30256 \InsetSpace ~
30257 \InsetSpace ~
30258 \InsetSpace ~
30259 \InsetSpace ~
30260 \InsetSpace ~
30261 \InsetSpace ~
30262 \InsetSpace ~
30263 \InsetSpace ~
30264 \InsetSpace ~
30265 \InsetSpace ~
30266 \InsetSpace ~
30267 \InsetSpace ~
30268 SDCD
30269 B Delete all breakpoints if no arg 
30270 \newline
30271 ;;\InsetSpace ~
30272 \InsetSpace ~
30273 \InsetSpace ~
30274 \InsetSpace ~
30275 \InsetSpace ~
30276 \InsetSpace ~
30277 \InsetSpace ~
30278 \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 \InsetSpace ~
30294 \InsetSpace ~
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 given or delete arg (C-u arg x) 
30319 \newline
30320 ;;\InsetSpace ~
30321 m\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 sdcdbsrc
30337 -frame\InsetSpace ~
30338 \InsetSpace ~
30339 \InsetSpace ~
30340 \InsetSpace ~
30341 \InsetSpace ~
30342 \InsetSpace ~
30343 \InsetSpace ~
30344 \InsetSpace ~
30345 \InsetSpace ~
30346 \InsetSpace ~
30347 \InsetSpace ~
30348 \InsetSpace ~
30349 \InsetSpace ~
30350 \InsetSpace ~
30351 \InsetSpace ~
30352 SDCDB Display current frame if no arg, 
30353 \newline
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 \InsetSpace ~
30393 \InsetSpace ~
30394 \InsetSpace ~
30395 \InsetSpace ~
30396 \InsetSpace ~
30397 \InsetSpace ~
30398 \InsetSpace ~
30399 \InsetSpace ~
30400 \InsetSpace ~
30401 given or display frame arg
30402  
30403 \newline
30404 ;;\InsetSpace ~
30405 \InsetSpace ~
30406 \InsetSpace ~
30407 \InsetSpace ~
30408 \InsetSpace ~
30409 \InsetSpace ~
30410 \InsetSpace ~
30411 \InsetSpace ~
30412 \InsetSpace ~
30413 \InsetSpace ~
30414 \InsetSpace ~
30415 \InsetSpace ~
30416 \InsetSpace ~
30417 \InsetSpace ~
30418 \InsetSpace ~
30419 \InsetSpace ~
30420 \InsetSpace ~
30421 \InsetSpace ~
30422 \InsetSpace ~
30423 \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 \InsetSpace ~
30439 \InsetSpace ~
30440 \InsetSpace ~
30441 \InsetSpace ~
30442 \InsetSpace ~
30443 \InsetSpace ~
30444 \InsetSpace ~
30445 \InsetSpace ~
30446 \InsetSpace ~
30447 \InsetSpace ~
30448 \InsetSpace ~
30449 \InsetSpace ~
30450 \InsetSpace ~
30451 buffer point 
30452 \newline
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 sdcdbsrc-goto-sdcdb\InsetSpace ~
30470 \InsetSpace ~
30471 \InsetSpace ~
30472 \InsetSpace ~
30473 \InsetSpace ~
30474 \InsetSpace ~
30475 \InsetSpace ~
30476 \InsetSpace ~
30477 \InsetSpace ~
30478 \InsetSpace ~
30479 Goto the SDCDB output buffer 
30480 \newline
30481 ;;\InsetSpace ~
30482 p\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 sdcdb-prin
30498 t-c-sexp\InsetSpace ~
30499 \InsetSpace ~
30500 \InsetSpace ~
30501 \InsetSpace ~
30502 \InsetSpace ~
30503 \InsetSpace ~
30504 \InsetSpace ~
30505 \InsetSpace ~
30506 \InsetSpace ~
30507 \InsetSpace ~
30508 \InsetSpace ~
30509 SDCDB print command for data at 
30510 \newline
30511 ;;\InsetSpace ~
30512 \InsetSpace ~
30513 \InsetSpace ~
30514 \InsetSpace ~
30515 \InsetSpace ~
30516 \InsetSpace ~
30517 \InsetSpace ~
30518 \InsetSpace ~
30519 \InsetSpace ~
30520 \InsetSpace ~
30521 \InsetSpace ~
30522 \InsetSpace ~
30523 \InsetSpace ~
30524 \InsetSpace ~
30525 \InsetSpace ~
30526 \InsetSpace ~
30527 \InsetSpace ~
30528 \InsetSpace ~
30529 \InsetSpace ~
30530 \InsetSpace ~
30531 \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 \InsetSpace ~
30547 \InsetSpace ~
30548 \InsetSpace ~
30549 \InsetSpace ~
30550 \InsetSpace ~
30551 \InsetSpace ~
30552 \InsetSpace ~
30553 \InsetSpace ~
30554 \InsetSpace ~
30555 \InsetSpace ~
30556 \InsetSpace ~
30557 \InsetSpace ~
30558 buffer point 
30559 \newline
30560 ;;\InsetSpace ~
30561 g\InsetSpace ~
30562 \InsetSpace ~
30563 \InsetSpace ~
30564 \InsetSpace ~
30565 \InsetSpace ~
30566 \InsetSpace ~
30567 \InsetSpace ~
30568 \InsetSpace ~
30569 \InsetSpace ~
30570 \InsetSpace ~
30571 \InsetSpace ~
30572 \InsetSpace ~
30573 \InsetSpace ~
30574 \InsetSpace ~
30575 \InsetSpace ~
30576 sdcdbsrc-goto-sdcdb\InsetSpace ~
30577 \InsetSpace ~
30578 \InsetSpace ~
30579 \InsetSpace ~
30580 \InsetSpace ~
30581 \InsetSpace ~
30582 \InsetSpace ~
30583 \InsetSpace ~
30584 \InsetSpace ~
30585 \InsetSpace ~
30586 Got
30587 o the SDCDB output buffer 
30588 \newline
30589 ;;\InsetSpace ~
30590 t\InsetSpace ~
30591 \InsetSpace ~
30592 \InsetSpace ~
30593 \InsetSpace ~
30594 \InsetSpace ~
30595 \InsetSpace ~
30596 \InsetSpace ~
30597 \InsetSpace ~
30598 \InsetSpace ~
30599 \InsetSpace ~
30600 \InsetSpace ~
30601 \InsetSpace ~
30602 \InsetSpace ~
30603 \InsetSpace ~
30604 \InsetSpace ~
30605 sdcdbsrc-mode\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 \InsetSpace ~
30621 Toggles Sdcdbsrc mode (turns it
30622  off) 
30623 \newline
30624 ;; 
30625 \newline
30626 ;;\InsetSpace ~
30627 C-c\InsetSpace ~
30628 C-f\InsetSpace ~
30629 \InsetSpace ~
30630 \InsetSpace ~
30631 \InsetSpace ~
30632 \InsetSpace ~
30633 \InsetSpace ~
30634 \InsetSpace ~
30635 \InsetSpace ~
30636 \InsetSpace ~
30637 sdcdb-finish-from-src\InsetSpace ~
30638 \InsetSpace ~
30639 \InsetSpace ~
30640 \InsetSpace ~
30641 \InsetSpace ~
30642 \InsetSpace ~
30643 \InsetSpace ~
30644 \InsetSpace ~
30645 SDCDB finish command 
30646 \newline
30647 ;; 
30648 \newline
30649 ;;\InsetSpace ~
30650 C-x\InsetSpace ~
30651 SPC\InsetSpace ~
30652 \InsetSpace ~
30653 \InsetSpace ~
30654 \InsetSpace ~
30655 \InsetSpace ~
30656 \InsetSpace ~
30657 \InsetSpace ~
30658 \InsetSpace ~
30659 \InsetSpace ~
30660 sdcdb-brea
30661 k\InsetSpace ~
30662 \InsetSpace ~
30663 \InsetSpace ~
30664 \InsetSpace ~
30665 \InsetSpace ~
30666 \InsetSpace ~
30667 \InsetSpace ~
30668 \InsetSpace ~
30669 \InsetSpace ~
30670 \InsetSpace ~
30671 \InsetSpace ~
30672 \InsetSpace ~
30673 \InsetSpace ~
30674 \InsetSpace ~
30675 \InsetSpace ~
30676 \InsetSpace ~
30677 \InsetSpace ~
30678 \InsetSpace ~
30679 Set break for line with point 
30680 \newline
30681 ;;\InsetSpace ~
30682 ESC\InsetSpace ~
30683 t\InsetSpace ~
30684 \InsetSpace ~
30685 \InsetSpace ~
30686 \InsetSpace ~
30687 \InsetSpace ~
30688 \InsetSpace ~
30689 \InsetSpace ~
30690 \InsetSpace ~
30691 \InsetSpace ~
30692 \InsetSpace ~
30693 \InsetSpace ~
30694 sdcdbsrc-mode\InsetSpace ~
30695 \InsetSpace ~
30696 \InsetSpace ~
30697 \InsetSpace ~
30698 \InsetSpace ~
30699 \InsetSpace ~
30700 \InsetSpace ~
30701 \InsetSpace ~
30702 \InsetSpace ~
30703 \InsetSpace ~
30704 \InsetSpace ~
30705 \InsetSpace ~
30706 \InsetSpace ~
30707 \InsetSpace ~
30708 \InsetSpace ~
30709 \InsetSpace ~
30710 Toggle Sdcdbsrc mode 
30711 \newline
30712 ;;\InsetSpace ~
30713 ESC\InsetSpace ~
30714 m\InsetSpace ~
30715 \InsetSpace ~
30716 \InsetSpace ~
30717 \InsetSpace ~
30718 \InsetSpace ~
30719 \InsetSpace ~
30720 \InsetSpace ~
30721 \InsetSpace ~
30722 \InsetSpace ~
30723 \InsetSpace ~
30724 \InsetSpace ~
30725 sdc
30726 dbsrc-srcmode\InsetSpace ~
30727 \InsetSpace ~
30728 \InsetSpace ~
30729 \InsetSpace ~
30730 \InsetSpace ~
30731 \InsetSpace ~
30732 \InsetSpace ~
30733 \InsetSpace ~
30734 \InsetSpace ~
30735 \InsetSpace ~
30736 \InsetSpace ~
30737 \InsetSpace ~
30738 \InsetSpace ~
30739 Toggle list mode 
30740 \newline
30741 ;; 
30742 \newline
30743
30744 \family default
30745
30746 \newpage
30747
30748 \end_layout
30749
30750 \begin_layout Chapter
30751 TIPS
30752 \end_layout
30753
30754 \begin_layout Standard
30755 Here are a few guidelines that will help the compiler generate more efficient
30756  code, some of the tips are specific to this compiler others are generally
30757  good programming practice.
30758 \end_layout
30759
30760 \begin_layout Itemize
30761 Use the smallest data type to represent your data-value.
30762  If it is known in advance that the value is going to be less than 256 then
30763  use an 'unsigned char' instead of a 'short' or 'int'.
30764  Please note, that ANSI C requires both signed and unsigned chars to be
30765  promoted to 'signed int'
30766 \begin_inset LatexCommand \index{promotion to signed int}
30767
30768 \end_inset
30769
30770
30771 \begin_inset Marginal
30772 status collapsed
30773
30774 \begin_layout Standard
30775
30776 \series bold
30777 \InsetSpace ~
30778 !
30779 \end_layout
30780
30781 \end_inset
30782
30783  before doing any operation.
30784  This promotion
30785 \begin_inset LatexCommand \index{type promotion}
30786
30787 \end_inset
30788
30789
30790 \begin_inset LatexCommand \label{type promotion}
30791
30792 \end_inset
30793
30794  can be omitted, if the result is the same.
30795  The effect of the promotion rules together with the sign-extension is often
30796  surprising:
30797 \end_layout
30798
30799 \begin_deeper
30800 \begin_layout Verse
30801
30802 \family typewriter
30803 unsigned char uc = 0xfe;
30804 \newline
30805 if (uc * uc < 0) /* this is true! */
30806 \newline
30807 {
30808 \newline
30809 \InsetSpace ~
30810 \InsetSpace ~
30811 \InsetSpace ~
30812 \InsetSpace ~
30813 ....
30814 \newline
30815 }
30816 \end_layout
30817
30818 \begin_layout Standard
30819
30820 \family typewriter
30821 uc * uc
30822 \family default
30823  is evaluated as 
30824 \family typewriter
30825 (int) uc * (int) uc = (int) 0xfe * (int) 0xfe = (int) 0xfc04 = -1024
30826 \family default
30827 .
30828  
30829 \newline
30830 Another one:
30831 \end_layout
30832
30833 \begin_layout Verse
30834
30835 \family typewriter
30836 (unsigned char) -12 / (signed char) -3 = ...
30837 \end_layout
30838
30839 \begin_layout Standard
30840 No, the result is not 4:
30841 \end_layout
30842
30843 \begin_layout Verse
30844
30845 \family typewriter
30846 (int) (unsigned char) -12 / (int) (signed char) -3 =
30847 \newline
30848 (int) (unsigned char)
30849  0xf4 / (int) (signed char) 0xfd =
30850 \newline
30851 (int) 0x00f4 / (int) 0xfffd =
30852 \newline
30853 (int) 0x00f4
30854  / (int) 0xfffd =
30855 \newline
30856 (int) 244 / (int) -3 =
30857 \newline
30858 (int) -81 = (int) 0xffaf;
30859 \end_layout
30860
30861 \begin_layout Standard
30862 Don't complain, that gcc gives you a different result.
30863  gcc uses 32 bit ints, while SDCC uses 16 bit ints.
30864  Therefore the results are different.
30865 \newline
30866 From 
30867 \begin_inset Quotes sld
30868 \end_inset
30869
30870 comp.lang.c FAQ
30871 \begin_inset Quotes srd
30872 \end_inset
30873
30874 :
30875 \end_layout
30876
30877 \begin_layout Quote
30878
30879 \emph on
30880 If well-defined overflow characteristics are important and negative values
30881  are not, or if you want to steer clear of sign-extension problems when
30882  manipulating bits or bytes, use one of the corresponding unsigned types.
30883  (Beware when mixing signed and unsigned values in expressions, though.)
30884 \newline
30885 Although
30886  character types (especially unsigned char) can be used as "tiny" integers,
30887  doing so is sometimes more trouble than it's worth, due to unpredictable
30888  sign extension and increased code size.
30889 \end_layout
30890
30891 \end_deeper
30892 \begin_layout Itemize
30893 Use unsigned when it is known in advance that the value is not going to
30894  be negative.
30895  This helps especially if you are doing division or multiplication, bit-shifting
30896  or are using an array index.
30897 \end_layout
30898
30899 \begin_layout Itemize
30900 NEVER jump into a LOOP.
30901 \end_layout
30902
30903 \begin_layout Itemize
30904 Declare the variables to be local
30905 \begin_inset LatexCommand \index{local variables}
30906
30907 \end_inset
30908
30909  whenever possible, especially loop control variables (induction).
30910 \end_layout
30911
30912 \begin_layout Itemize
30913 Have a look at the assembly listing to get a 
30914 \begin_inset Quotes sld
30915 \end_inset
30916
30917 feeling
30918 \begin_inset Quotes srd
30919 \end_inset
30920
30921  for the code generation.
30922 \end_layout
30923
30924 \begin_layout Section
30925 Porting code from or to other compilers
30926 \begin_inset LatexCommand \label{sec:Porting-code-to-other-compilers}
30927
30928 \end_inset
30929
30930
30931 \end_layout
30932
30933 \begin_layout Itemize
30934 check whether endianness of the compilers differs and adapt where needed.
30935 \end_layout
30936
30937 \begin_layout Itemize
30938 check the device specific header files
30939 \begin_inset LatexCommand \index{Header files}
30940
30941 \end_inset
30942
30943
30944 \begin_inset LatexCommand \index{Include files}
30945
30946 \end_inset
30947
30948  for compiler specific syntax.
30949  Eventually include the file <compiler.h
30950 \begin_inset LatexCommand \index{compiler.h (include file)}
30951
30952 \end_inset
30953
30954
30955 \begin_inset LatexCommand \url{http://sdcc.svn.sourceforge.net/viewvc/sdcc/trunk/sdcc/device/include/mcs51/compiler.h?view=markup}
30956
30957 \end_inset
30958
30959  to allow using common header files.
30960  (see f.e.
30961  cc2510fx.h 
30962 \begin_inset LatexCommand \url{http://sdcc.svn.sourceforge.net/viewvc/sdcc/trunk/sdcc/device/include/mcs51/cc2510fx.h?view=markup}
30963
30964 \end_inset
30965
30966 ).
30967 \end_layout
30968
30969 \begin_layout Itemize
30970 check whether the startup code contains the correct initialization (watchdog,
30971  peripherals).
30972 \end_layout
30973
30974 \begin_layout Itemize
30975 check whether the sizes of short, int, long match.
30976 \end_layout
30977
30978 \begin_layout Itemize
30979 check if some 16 or 32 bit hardware registers require a specific addressing
30980  order (least significant or most significant byte first) and adapt if needed
30981  (
30982 \emph on
30983 first
30984 \emph default
30985  and 
30986 \emph on
30987 last
30988 \emph default
30989  relate to time and not to lower/upper memory location here, so this is
30990  
30991 \emph on
30992 not
30993 \emph default
30994  the same as endianness).
30995 \end_layout
30996
30997 \begin_layout Itemize
30998 check whether the keyword 
30999 \emph on
31000 volatile
31001 \emph default
31002  is used where needed.
31003  The compilers might differ in their optimization characteristics (as different
31004  versions of the same compiler might also use more clever optimizations
31005  this is good idea anyway).
31006  See section 
31007 \begin_inset LatexCommand \ref{sub:Common-interrupt-pitfall-volatile}
31008
31009 \end_inset
31010
31011 .
31012 \end_layout
31013
31014 \begin_layout Itemize
31015 check that the compilers are not told to supress warnings.
31016 \end_layout
31017
31018 \begin_layout Itemize
31019 check and convert compiler specific extensions (interrupts, memory areas,
31020  pragmas etc.).
31021 \end_layout
31022
31023 \begin_layout Itemize
31024 check for differences in type promotion.
31025  Especially check for math operations on 
31026 \family typewriter
31027 char
31028 \family default
31029  or 
31030 \family typewriter
31031 unsigned char
31032 \family default
31033  variables.
31034  For the sake of C99 compatibility SDCC will probably promote these to 
31035 \family typewriter
31036 int
31037 \family default
31038  more often than other compilers.
31039  Eventually insert explicit casts to 
31040 \family typewriter
31041 (char) 
31042 \family default
31043 or
31044 \family typewriter
31045  (unsigned char)
31046 \family default
31047 .
31048  Also check that the ~\InsetSpace ~
31049 operator
31050 \begin_inset LatexCommand \index{\~\/ Operator}
31051
31052 \end_inset
31053
31054  is not used on 
31055 \family typewriter
31056 bit
31057 \begin_inset LatexCommand \index{bit}
31058
31059 \end_inset
31060
31061
31062 \family default
31063  variables, use the !\InsetSpace ~
31064 operator instead.
31065  See sections 
31066 \begin_inset LatexCommand \ref{type promotion}
31067
31068 \end_inset
31069
31070  and 
31071 \begin_inset LatexCommand \ref{sec:Compatibility-with-previous}
31072
31073 \end_inset
31074
31075 .
31076 \end_layout
31077
31078 \begin_layout Itemize
31079 check the assembly code generated for interrupt routines (f.e.
31080  for calls to possibly non-reentrant library functions).
31081 \end_layout
31082
31083 \begin_layout Itemize
31084 check whether timing loops result in proper timing (or preferably consider
31085  a rewrite of the code with timer based delays instead).
31086 \end_layout
31087
31088 \begin_layout Itemize
31089 check for differences in printf parameters (some compilers push (va_arg
31090 \begin_inset LatexCommand \index{vararg, va\_arg}
31091
31092 \end_inset
31093
31094 ) char variables as 
31095 \family typewriter
31096 int
31097 \family default
31098  others push them as 
31099 \family typewriter
31100 char
31101 \family default
31102 .
31103  See section 
31104 \begin_inset LatexCommand \ref{sec:Compatibility-with-previous}
31105
31106 \end_inset
31107
31108 ).
31109 \end_layout
31110
31111 \begin_layout Itemize
31112 check the resulting memory map
31113 \begin_inset LatexCommand \index{Memory map}
31114
31115 \end_inset
31116
31117 .
31118  Usage of different memory spaces: code, stack, data (for mcs51/ds390 additional
31119 ly idata, pdata, xdata).
31120  Eventually check if unexpected library functions are included.
31121 \end_layout
31122
31123 \begin_layout Section
31124 Tools
31125 \begin_inset LatexCommand \index{Tools}
31126
31127 \end_inset
31128
31129  included in the distribution
31130 \end_layout
31131
31132 \begin_layout Standard
31133 \align left
31134 \begin_inset Tabular
31135 <lyxtabular version="3" rows="12" columns="3">
31136 <features>
31137 <column alignment="left" valignment="top" leftline="true" width="0pt">
31138 <column alignment="left" valignment="top" leftline="true" width="0pt">
31139 <column alignment="left" valignment="top" leftline="true" rightline="true" width="0pt">
31140 <row topline="true" bottomline="true">
31141 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31142 \begin_inset Text
31143
31144 \begin_layout Standard
31145
31146 \series bold
31147 Name
31148 \end_layout
31149
31150 \end_inset
31151 </cell>
31152 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31153 \begin_inset Text
31154
31155 \begin_layout Standard
31156
31157 \series bold
31158 Purpose
31159 \end_layout
31160
31161 \end_inset
31162 </cell>
31163 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31164 \begin_inset Text
31165
31166 \begin_layout Standard
31167
31168 \series bold
31169 Directory
31170 \end_layout
31171
31172 \end_inset
31173 </cell>
31174 </row>
31175 <row topline="true">
31176 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31177 \begin_inset Text
31178
31179 \begin_layout Standard
31180 uCsim
31181 \begin_inset LatexCommand \index{uCsim}
31182
31183 \end_inset
31184
31185
31186 \end_layout
31187
31188 \end_inset
31189 </cell>
31190 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31191 \begin_inset Text
31192
31193 \begin_layout Standard
31194 Simulator for various architectures
31195 \end_layout
31196
31197 \end_inset
31198 </cell>
31199 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31200 \begin_inset Text
31201
31202 \begin_layout Standard
31203 sdcc/sim/ucsim
31204 \end_layout
31205
31206 \end_inset
31207 </cell>
31208 </row>
31209 <row topline="true">
31210 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31211 \begin_inset Text
31212
31213 \begin_layout Standard
31214 keil2sdcc.pl
31215 \end_layout
31216
31217 \end_inset
31218 </cell>
31219 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31220 \begin_inset Text
31221
31222 \begin_layout Standard
31223 header file
31224 \begin_inset LatexCommand \index{Header files}
31225
31226 \end_inset
31227
31228
31229 \begin_inset LatexCommand \index{Include files}
31230
31231 \end_inset
31232
31233  conversion
31234 \end_layout
31235
31236 \end_inset
31237 </cell>
31238 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31239 \begin_inset Text
31240
31241 \begin_layout Standard
31242 sdcc/support/scripts
31243 \end_layout
31244
31245 \end_inset
31246 </cell>
31247 </row>
31248 <row topline="true">
31249 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31250 \begin_inset Text
31251
31252 \begin_layout Standard
31253 mh2h.c
31254 \end_layout
31255
31256 \end_inset
31257 </cell>
31258 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31259 \begin_inset Text
31260
31261 \begin_layout Standard
31262 header file conversion
31263 \end_layout
31264
31265 \end_inset
31266 </cell>
31267 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31268 \begin_inset Text
31269
31270 \begin_layout Standard
31271 sdcc/support/scripts
31272 \end_layout
31273
31274 \end_inset
31275 </cell>
31276 </row>
31277 <row topline="true">
31278 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31279 \begin_inset Text
31280
31281 \begin_layout Standard
31282 as-gbz80
31283 \end_layout
31284
31285 \end_inset
31286 </cell>
31287 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31288 \begin_inset Text
31289
31290 \begin_layout Standard
31291 Assembler
31292 \end_layout
31293
31294 \end_inset
31295 </cell>
31296 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31297 \begin_inset Text
31298
31299 \begin_layout Standard
31300
31301 \family roman
31302 \series medium
31303 \shape up
31304 \size normal
31305 \emph off
31306 \bar no
31307 \noun off
31308 \color none
31309 sdcc/bin
31310 \end_layout
31311
31312 \end_inset
31313 </cell>
31314 </row>
31315 <row topline="true">
31316 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31317 \begin_inset Text
31318
31319 \begin_layout Standard
31320 as-z80
31321 \end_layout
31322
31323 \end_inset
31324 </cell>
31325 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31326 \begin_inset Text
31327
31328 \begin_layout Standard
31329 Assembler
31330 \end_layout
31331
31332 \end_inset
31333 </cell>
31334 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31335 \begin_inset Text
31336
31337 \begin_layout Standard
31338
31339 \family roman
31340 \series medium
31341 \shape up
31342 \size normal
31343 \emph off
31344 \bar no
31345 \noun off
31346 \color none
31347 sdcc/bin
31348 \end_layout
31349
31350 \end_inset
31351 </cell>
31352 </row>
31353 <row topline="true">
31354 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31355 \begin_inset Text
31356
31357 \begin_layout Standard
31358 asx8051
31359 \end_layout
31360
31361 \end_inset
31362 </cell>
31363 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31364 \begin_inset Text
31365
31366 \begin_layout Standard
31367 Assembler
31368 \end_layout
31369
31370 \end_inset
31371 </cell>
31372 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31373 \begin_inset Text
31374
31375 \begin_layout Standard
31376
31377 \family roman
31378 \series medium
31379 \shape up
31380 \size normal
31381 \emph off
31382 \bar no
31383 \noun off
31384 \color none
31385 sdcc/bin
31386 \end_layout
31387
31388 \end_inset
31389 </cell>
31390 </row>
31391 <row topline="true">
31392 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31393 \begin_inset Text
31394
31395 \begin_layout Standard
31396 SDCDB
31397 \end_layout
31398
31399 \end_inset
31400 </cell>
31401 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31402 \begin_inset Text
31403
31404 \begin_layout Standard
31405 Simulator
31406 \end_layout
31407
31408 \end_inset
31409 </cell>
31410 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31411 \begin_inset Text
31412
31413 \begin_layout Standard
31414
31415 \family roman
31416 \series medium
31417 \shape up
31418 \size normal
31419 \emph off
31420 \bar no
31421 \noun off
31422 \color none
31423 sdcc/bin
31424 \end_layout
31425
31426 \end_inset
31427 </cell>
31428 </row>
31429 <row topline="true">
31430 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31431 \begin_inset Text
31432
31433 \begin_layout Standard
31434 aslink
31435 \end_layout
31436
31437 \end_inset
31438 </cell>
31439 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31440 \begin_inset Text
31441
31442 \begin_layout Standard
31443 Linker
31444 \end_layout
31445
31446 \end_inset
31447 </cell>
31448 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31449 \begin_inset Text
31450
31451 \begin_layout Standard
31452
31453 \family roman
31454 \series medium
31455 \shape up
31456 \size normal
31457 \emph off
31458 \bar no
31459 \noun off
31460 \color none
31461 sdcc/bin
31462 \end_layout
31463
31464 \end_inset
31465 </cell>
31466 </row>
31467 <row topline="true">
31468 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31469 \begin_inset Text
31470
31471 \begin_layout Standard
31472 link-z80
31473 \end_layout
31474
31475 \end_inset
31476 </cell>
31477 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31478 \begin_inset Text
31479
31480 \begin_layout Standard
31481 Linker
31482 \end_layout
31483
31484 \end_inset
31485 </cell>
31486 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31487 \begin_inset Text
31488
31489 \begin_layout Standard
31490
31491 \family roman
31492 \series medium
31493 \shape up
31494 \size normal
31495 \emph off
31496 \bar no
31497 \noun off
31498 \color none
31499 sdcc/bin
31500 \end_layout
31501
31502 \end_inset
31503 </cell>
31504 </row>
31505 <row topline="true">
31506 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31507 \begin_inset Text
31508
31509 \begin_layout Standard
31510 link-gbz80
31511 \end_layout
31512
31513 \end_inset
31514 </cell>
31515 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31516 \begin_inset Text
31517
31518 \begin_layout Standard
31519 Linker
31520 \end_layout
31521
31522 \end_inset
31523 </cell>
31524 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31525 \begin_inset Text
31526
31527 \begin_layout Standard
31528
31529 \family roman
31530 \series medium
31531 \shape up
31532 \size normal
31533 \emph off
31534 \bar no
31535 \noun off
31536 \color none
31537 sdcc/bin
31538 \end_layout
31539
31540 \end_inset
31541 </cell>
31542 </row>
31543 <row topline="true" bottomline="true">
31544 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31545 \begin_inset Text
31546
31547 \begin_layout Standard
31548 packihx
31549 \end_layout
31550
31551 \end_inset
31552 </cell>
31553 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31554 \begin_inset Text
31555
31556 \begin_layout Standard
31557 Intel Hex packer 
31558 \begin_inset LatexCommand \index{packihx (tool)}
31559
31560 \end_inset
31561
31562
31563 \end_layout
31564
31565 \end_inset
31566 </cell>
31567 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31568 \begin_inset Text
31569
31570 \begin_layout Standard
31571
31572 \family roman
31573 \series medium
31574 \shape up
31575 \size normal
31576 \emph off
31577 \bar no
31578 \noun off
31579 \color none
31580 sdcc/bin
31581 \end_layout
31582
31583 \end_inset
31584 </cell>
31585 </row>
31586 </lyxtabular>
31587
31588 \end_inset
31589
31590
31591 \newline
31592
31593 \end_layout
31594
31595 \begin_layout Section
31596 Documentation
31597 \begin_inset LatexCommand \index{Documentation}
31598
31599 \end_inset
31600
31601  included in the distribution
31602 \end_layout
31603
31604 \begin_layout Standard
31605 \align left
31606 \begin_inset Tabular
31607 <lyxtabular version="3" rows="10" columns="2">
31608 <features>
31609 <column alignment="block" valignment="top" leftline="true" width="40col%">
31610 <column alignment="block" valignment="top" leftline="true" rightline="true" width="60col%">
31611 <row topline="true" bottomline="true" endhead="true">
31612 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31613 \begin_inset Text
31614
31615 \begin_layout Standard
31616
31617 \series bold
31618 Subject / Title
31619 \end_layout
31620
31621 \end_inset
31622 </cell>
31623 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31624 \begin_inset Text
31625
31626 \begin_layout Standard
31627
31628 \series bold
31629 Filename / Where to get
31630 \end_layout
31631
31632 \end_inset
31633 </cell>
31634 </row>
31635 <row topline="true">
31636 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31637 \begin_inset Text
31638
31639 \begin_layout Standard
31640 SDCC Compiler User Guide
31641 \end_layout
31642
31643 \end_inset
31644 </cell>
31645 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31646 \begin_inset Text
31647
31648 \begin_layout Standard
31649 You're reading it right now
31650 \emph on
31651  \InsetSpace ~
31652 \InsetSpace ~
31653 \InsetSpace ~
31654
31655 \hfill
31656 online at:
31657 \emph default
31658
31659 \newline
31660
31661 \begin_inset LatexCommand \url{http://sdcc.sourceforge.net/doc/sdccman.pdf}
31662
31663 \end_inset
31664
31665
31666 \end_layout
31667
31668 \end_inset
31669 </cell>
31670 </row>
31671 <row topline="true">
31672 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31673 \begin_inset Text
31674
31675 \begin_layout Standard
31676 Changelog of SDCC
31677 \end_layout
31678
31679 \end_inset
31680 </cell>
31681 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31682 \begin_inset Text
31683
31684 \begin_layout Standard
31685 sdcc/Changelog
31686 \emph on
31687  \InsetSpace ~
31688 \InsetSpace ~
31689 \InsetSpace ~
31690
31691 \hfill
31692 online at:
31693 \emph default
31694
31695 \newline
31696
31697 \begin_inset LatexCommand \url{http://sdcc.svn.sourceforge.net/viewvc/*checkout*/sdcc/trunk/sdcc/ChangeLog}
31698
31699 \end_inset
31700
31701
31702 \end_layout
31703
31704 \end_inset
31705 </cell>
31706 </row>
31707 <row topline="true">
31708 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31709 \begin_inset Text
31710
31711 \begin_layout Standard
31712 ASXXXX
31713 \begin_inset LatexCommand \index{asXXXX (as-gbz80, as-hc08, asx8051, as-z80)}
31714
31715 \end_inset
31716
31717
31718 \begin_inset LatexCommand \index{Assembler documentation}
31719
31720 \end_inset
31721
31722  Assemblers and
31723 \newline
31724 ASLINK
31725 \begin_inset LatexCommand \index{aslink}
31726
31727 \end_inset
31728
31729
31730 \begin_inset LatexCommand \index{Linker documentation}
31731
31732 \end_inset
31733
31734  Relocating Linker
31735 \end_layout
31736
31737 \end_inset
31738 </cell>
31739 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31740 \begin_inset Text
31741
31742 \begin_layout Standard
31743 sdcc/as/doc/asxhtm.html 
31744 \emph on
31745 \InsetSpace ~
31746 \InsetSpace ~
31747 \InsetSpace ~
31748
31749 \hfill
31750 online at:
31751 \emph default
31752
31753 \newline
31754
31755 \begin_inset LatexCommand \url{http://sdcc.svn.sourceforge.net/viewvc/*checkout*/sdcc/trunk/sdcc/as/doc/asxhtm.html}
31756
31757 \end_inset
31758
31759
31760 \end_layout
31761
31762 \end_inset
31763 </cell>
31764 </row>
31765 <row topline="true">
31766 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31767 \begin_inset Text
31768
31769 \begin_layout Standard
31770 SDCC regression test
31771 \begin_inset LatexCommand \index{Regression test}
31772
31773 \end_inset
31774
31775
31776 \end_layout
31777
31778 \end_inset
31779 </cell>
31780 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31781 \begin_inset Text
31782
31783 \begin_layout Standard
31784 sdcc/doc/test_suite_spec.pdf 
31785 \emph on
31786 \InsetSpace ~
31787 \InsetSpace ~
31788 \InsetSpace ~
31789
31790 \hfill
31791 online at:
31792 \emph default
31793
31794 \newline
31795
31796 \begin_inset LatexCommand \url{http://sdcc.sourceforge.net/doc/test_suite_spec.pdf}
31797
31798 \end_inset
31799
31800
31801 \end_layout
31802
31803 \end_inset
31804 </cell>
31805 </row>
31806 <row topline="true">
31807 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31808 \begin_inset Text
31809
31810 \begin_layout Standard
31811 Various notes
31812 \end_layout
31813
31814 \end_inset
31815 </cell>
31816 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31817 \begin_inset Text
31818
31819 \begin_layout Standard
31820 sdcc/doc/* 
31821 \emph on
31822 \InsetSpace ~
31823 \InsetSpace ~
31824 \InsetSpace ~
31825
31826 \hfill
31827 online at:
31828 \emph default
31829
31830 \newline
31831
31832 \begin_inset LatexCommand \url{http://sdcc.svn.sourceforge.net/viewvc/sdcc/trunk/sdcc/doc/}
31833
31834 \end_inset
31835
31836
31837 \end_layout
31838
31839 \end_inset
31840 </cell>
31841 </row>
31842 <row topline="true">
31843 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31844 \begin_inset Text
31845
31846 \begin_layout Standard
31847 Notes on debugging with SDCDB
31848 \begin_inset LatexCommand \index{SDCDB (debugger)}
31849
31850 \end_inset
31851
31852
31853 \end_layout
31854
31855 \end_inset
31856 </cell>
31857 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31858 \begin_inset Text
31859
31860 \begin_layout Standard
31861 sdcc/debugger/README 
31862 \emph on
31863 \InsetSpace ~
31864 \InsetSpace ~
31865 \InsetSpace ~
31866
31867 \hfill
31868 online at
31869 \emph default
31870 :
31871 \newline
31872
31873 \begin_inset LatexCommand \url{http://sdcc.svn.sourceforge.net/viewvc/*checkout*/sdcc/trunk/sdcc/debugger/README}
31874
31875 \end_inset
31876
31877
31878 \end_layout
31879
31880 \end_inset
31881 </cell>
31882 </row>
31883 <row topline="true">
31884 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31885 \begin_inset Text
31886
31887 \begin_layout Standard
31888 uCsim
31889 \begin_inset LatexCommand \index{uCsim}
31890
31891 \end_inset
31892
31893  Software simulator for microcontrollers
31894 \end_layout
31895
31896 \end_inset
31897 </cell>
31898 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31899 \begin_inset Text
31900
31901 \begin_layout Standard
31902
31903 \family roman
31904 \series medium
31905 \shape up
31906 \size normal
31907 \emph off
31908 \bar no
31909 \noun off
31910 \color none
31911 sdcc/sim/ucsim/doc
31912 \family default
31913 \series default
31914 \shape default
31915 \size default
31916 \emph default
31917 \bar default
31918 \noun default
31919 /index.html 
31920 \emph on
31921 \InsetSpace ~
31922 \InsetSpace ~
31923 \InsetSpace ~
31924
31925 \hfill
31926 online at:
31927 \emph default
31928
31929 \newline
31930
31931 \begin_inset LatexCommand \url{http://sdcc.svn.sourceforge.net/viewvc/*checkout*/sdcc/trunk/sdcc/sim/ucsim/doc/index.html}
31932
31933 \end_inset
31934
31935
31936 \end_layout
31937
31938 \end_inset
31939 </cell>
31940 </row>
31941 <row topline="true">
31942 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31943 \begin_inset Text
31944
31945 \begin_layout Standard
31946 Temporary notes on the pic16
31947 \begin_inset LatexCommand \index{PIC16}
31948
31949 \end_inset
31950
31951  port
31952 \end_layout
31953
31954 \end_inset
31955 </cell>
31956 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31957 \begin_inset Text
31958
31959 \begin_layout Standard
31960 sdcc/src/pic16/NOTES 
31961 \emph on
31962 \InsetSpace ~
31963 \InsetSpace ~
31964 \InsetSpace ~
31965
31966 \hfill
31967 online at:
31968 \newline
31969
31970 \emph default
31971
31972 \begin_inset LatexCommand \url{http://sdcc.svn.sourceforge.net/viewvc/*checkout*/sdcc/trunk/sdcc/src/pic16/NOTES}
31973
31974 \end_inset
31975
31976
31977 \end_layout
31978
31979 \end_inset
31980 </cell>
31981 </row>
31982 <row topline="true" bottomline="true">
31983 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31984 \begin_inset Text
31985
31986 \begin_layout Standard
31987 SDCC internal documentation (debugging file format)
31988 \end_layout
31989
31990 \end_inset
31991 </cell>
31992 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31993 \begin_inset Text
31994
31995 \begin_layout Standard
31996 sdcc/doc/
31997 \family roman
31998 \series medium
31999 \shape up
32000 \size normal
32001 \emph off
32002 \bar no
32003 \noun off
32004 \color none
32005 cdbfileformat.pd
32006 \family default
32007 \series default
32008 \shape default
32009 \size default
32010 \emph default
32011 \bar default
32012 \noun default
32013 f
32014 \emph on
32015  \InsetSpace ~
32016 \InsetSpace ~
32017 \InsetSpace ~
32018
32019 \hfill
32020 online at:
32021 \emph default
32022
32023 \newline
32024
32025 \begin_inset LatexCommand \url{http://sdcc.sourceforge.net/doc/cdbfileformat.pdf}
32026
32027 \end_inset
32028
32029
32030 \end_layout
32031
32032 \end_inset
32033 </cell>
32034 </row>
32035 </lyxtabular>
32036
32037 \end_inset
32038
32039
32040 \newline
32041
32042 \end_layout
32043
32044 \begin_layout Section
32045 Related open source tools
32046 \begin_inset LatexCommand \label{sec:Related-open-source-tools}
32047
32048 \end_inset
32049
32050
32051 \begin_inset LatexCommand \index{Related tools}
32052
32053 \end_inset
32054
32055
32056 \end_layout
32057
32058 \begin_layout Standard
32059 \align left
32060 \begin_inset Tabular
32061 <lyxtabular version="3" rows="16" columns="3">
32062 <features>
32063 <column alignment="left" valignment="top" leftline="true" width="0pt">
32064 <column alignment="block" valignment="top" leftline="true" width="30line%">
32065 <column alignment="left" valignment="top" leftline="true" rightline="true" width="40col%">
32066 <row topline="true" bottomline="true">
32067 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32068 \begin_inset Text
32069
32070 \begin_layout Standard
32071
32072 \series bold
32073 Name
32074 \end_layout
32075
32076 \end_inset
32077 </cell>
32078 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32079 \begin_inset Text
32080
32081 \begin_layout Standard
32082
32083 \series bold
32084 Purpose
32085 \end_layout
32086
32087 \end_inset
32088 </cell>
32089 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32090 \begin_inset Text
32091
32092 \begin_layout Standard
32093
32094 \series bold
32095 Where to get
32096 \end_layout
32097
32098 \end_inset
32099 </cell>
32100 </row>
32101 <row topline="true">
32102 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32103 \begin_inset Text
32104
32105 \begin_layout Standard
32106 gpsim
32107 \begin_inset LatexCommand \index{gpsim (pic simulator)}
32108
32109 \end_inset
32110
32111
32112 \end_layout
32113
32114 \end_inset
32115 </cell>
32116 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32117 \begin_inset Text
32118
32119 \begin_layout Standard
32120 PIC simulator
32121 \end_layout
32122
32123 \end_inset
32124 </cell>
32125 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32126 \begin_inset Text
32127
32128 \begin_layout Standard
32129 \begin_inset LatexCommand \url{http://www.dattalo.com/gnupic/gpsim.html}
32130
32131 \end_inset
32132
32133
32134 \end_layout
32135
32136 \end_inset
32137 </cell>
32138 </row>
32139 <row topline="true">
32140 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32141 \begin_inset Text
32142
32143 \begin_layout Standard
32144 gputils
32145 \begin_inset LatexCommand \index{gputils (pic tools)}
32146
32147 \end_inset
32148
32149
32150 \end_layout
32151
32152 \end_inset
32153 </cell>
32154 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32155 \begin_inset Text
32156
32157 \begin_layout Standard
32158 GNU PIC utilities
32159 \end_layout
32160
32161 \end_inset
32162 </cell>
32163 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32164 \begin_inset Text
32165
32166 \begin_layout Standard
32167 \begin_inset LatexCommand \url{http://sourceforge.net/projects/gputils}
32168
32169 \end_inset
32170
32171
32172 \end_layout
32173
32174 \end_inset
32175 </cell>
32176 </row>
32177 <row topline="true">
32178 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32179 \begin_inset Text
32180
32181 \begin_layout Standard
32182 flP5
32183 \end_layout
32184
32185 \end_inset
32186 </cell>
32187 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32188 \begin_inset Text
32189
32190 \begin_layout Standard
32191 PIC programmer
32192 \end_layout
32193
32194 \end_inset
32195 </cell>
32196 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32197 \begin_inset Text
32198
32199 \begin_layout Standard
32200 \begin_inset LatexCommand \url{http://freshmeat.net/projects/flp5/}
32201
32202 \end_inset
32203
32204
32205 \end_layout
32206
32207 \end_inset
32208 </cell>
32209 </row>
32210 <row topline="true">
32211 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32212 \begin_inset Text
32213
32214 \begin_layout Standard
32215 ec2drv/newcdb
32216 \end_layout
32217
32218 \end_inset
32219 </cell>
32220 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32221 \begin_inset Text
32222
32223 \begin_layout Standard
32224 Tools for Silicon Laboratories JTAG debug adapter, partly based on SDCDB
32225  (Unix only)
32226 \end_layout
32227
32228 \end_inset
32229 </cell>
32230 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32231 \begin_inset Text
32232
32233 \begin_layout Standard
32234 \begin_inset LatexCommand \url{http://sourceforge.net/projects/ec2drv}
32235
32236 \end_inset
32237
32238
32239 \end_layout
32240
32241 \end_inset
32242 </cell>
32243 </row>
32244 <row topline="true">
32245 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32246 \begin_inset Text
32247
32248 \begin_layout Standard
32249 indent
32250 \begin_inset LatexCommand \index{indent (source formatting tool)}
32251
32252 \end_inset
32253
32254
32255 \end_layout
32256
32257 \end_inset
32258 </cell>
32259 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32260 \begin_inset Text
32261
32262 \begin_layout Standard
32263 Formats C source - Master of the white spaces
32264 \end_layout
32265
32266 \end_inset
32267 </cell>
32268 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32269 \begin_inset Text
32270
32271 \begin_layout Standard
32272 \begin_inset LatexCommand \url{http://directory.fsf.org/GNU/indent.html}
32273
32274 \end_inset
32275
32276
32277 \end_layout
32278
32279 \end_inset
32280 </cell>
32281 </row>
32282 <row topline="true">
32283 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32284 \begin_inset Text
32285
32286 \begin_layout Standard
32287 srecord
32288 \begin_inset LatexCommand \index{srecord (bin, hex, ... tool)}
32289
32290 \end_inset
32291
32292
32293 \end_layout
32294
32295 \end_inset
32296 </cell>
32297 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32298 \begin_inset Text
32299
32300 \begin_layout Standard
32301 Object file conversion, checksumming, ...
32302 \end_layout
32303
32304 \end_inset
32305 </cell>
32306 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32307 \begin_inset Text
32308
32309 \begin_layout Standard
32310 \begin_inset LatexCommand \url{http://sourceforge.net/projects/srecord}
32311
32312 \end_inset
32313
32314
32315 \end_layout
32316
32317 \end_inset
32318 </cell>
32319 </row>
32320 <row topline="true">
32321 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32322 \begin_inset Text
32323
32324 \begin_layout Standard
32325 objdump
32326 \begin_inset LatexCommand \index{objdump (tool)}
32327
32328 \end_inset
32329
32330
32331 \end_layout
32332
32333 \end_inset
32334 </cell>
32335 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32336 \begin_inset Text
32337
32338 \begin_layout Standard
32339 Object file conversion, ...
32340 \end_layout
32341
32342 \end_inset
32343 </cell>
32344 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32345 \begin_inset Text
32346
32347 \begin_layout Standard
32348 Part of binutils (should be there anyway)
32349 \end_layout
32350
32351 \end_inset
32352 </cell>
32353 </row>
32354 <row topline="true">
32355 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32356 \begin_inset Text
32357
32358 \begin_layout Standard
32359 cmon51
32360 \end_layout
32361
32362 \end_inset
32363 </cell>
32364 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32365 \begin_inset Text
32366
32367 \begin_layout Standard
32368 8051 monitor (hex up-/download, single step, disassemble)
32369 \end_layout
32370
32371 \end_inset
32372 </cell>
32373 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32374 \begin_inset Text
32375
32376 \begin_layout Standard
32377 \begin_inset LatexCommand \url{http://sourceforge.net/projects/cmon51}
32378
32379 \end_inset
32380
32381
32382 \end_layout
32383
32384 \end_inset
32385 </cell>
32386 </row>
32387 <row topline="true">
32388 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32389 \begin_inset Text
32390
32391 \begin_layout Standard
32392 doxygen
32393 \begin_inset LatexCommand \index{doxygen (source documentation tool)}
32394
32395 \end_inset
32396
32397
32398 \end_layout
32399
32400 \end_inset
32401 </cell>
32402 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32403 \begin_inset Text
32404
32405 \begin_layout Standard
32406 Source code documentation system
32407 \end_layout
32408
32409 \end_inset
32410 </cell>
32411 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32412 \begin_inset Text
32413
32414 \begin_layout Standard
32415 \begin_inset LatexCommand \url{http://www.doxygen.org}
32416
32417 \end_inset
32418
32419
32420 \end_layout
32421
32422 \end_inset
32423 </cell>
32424 </row>
32425 <row topline="true">
32426 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32427 \begin_inset Text
32428
32429 \begin_layout Standard
32430 kdevelop
32431 \end_layout
32432
32433 \end_inset
32434 </cell>
32435 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32436 \begin_inset Text
32437
32438 \begin_layout Standard
32439 IDE (has anyone tried integrating SDCC & SDCDB? Unix only)
32440 \end_layout
32441
32442 \end_inset
32443 </cell>
32444 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32445 \begin_inset Text
32446
32447 \begin_layout Standard
32448 \begin_inset LatexCommand \url{http://www.kdevelop.org}
32449
32450 \end_inset
32451
32452
32453 \end_layout
32454
32455 \end_inset
32456 </cell>
32457 </row>
32458 <row topline="true">
32459 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32460 \begin_inset Text
32461
32462 \begin_layout Standard
32463 paulmon
32464 \end_layout
32465
32466 \end_inset
32467 </cell>
32468 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32469 \begin_inset Text
32470
32471 \begin_layout Standard
32472 8051 monitor (hex up-/download, single step, disassemble)
32473 \end_layout
32474
32475 \end_inset
32476 </cell>
32477 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32478 \begin_inset Text
32479
32480 \begin_layout Standard
32481 \begin_inset LatexCommand \url{http://www.pjrc.com/tech/8051/paulmon2.html}
32482
32483 \end_inset
32484
32485
32486 \end_layout
32487
32488 \end_inset
32489 </cell>
32490 </row>
32491 <row topline="true">
32492 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32493 \begin_inset Text
32494
32495 \begin_layout Standard
32496 splint
32497 \begin_inset LatexCommand \index{splint (syntax checking tool)}
32498
32499 \end_inset
32500
32501
32502 \end_layout
32503
32504 \end_inset
32505 </cell>
32506 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32507 \begin_inset Text
32508
32509 \begin_layout Standard
32510 Statically checks c sources (see 
32511 \begin_inset LatexCommand \ref{lyx:more-pedantic-SPLINT}
32512
32513 \end_inset
32514
32515 )
32516 \end_layout
32517
32518 \end_inset
32519 </cell>
32520 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32521 \begin_inset Text
32522
32523 \begin_layout Standard
32524 \begin_inset LatexCommand \url{http://www.splint.org}
32525
32526 \end_inset
32527
32528
32529 \end_layout
32530
32531 \end_inset
32532 </cell>
32533 </row>
32534 <row topline="true" bottomline="true">
32535 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32536 \begin_inset Text
32537
32538 \begin_layout Standard
32539 ddd
32540 \begin_inset LatexCommand \index{DDD (debugger)}
32541
32542 \end_inset
32543
32544
32545 \end_layout
32546
32547 \end_inset
32548 </cell>
32549 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32550 \begin_inset Text
32551
32552 \begin_layout Standard
32553 Debugger, serves nicely as GUI to SDCDB
32554 \begin_inset LatexCommand \index{SDCDB (debugger)}
32555
32556 \end_inset
32557
32558  (Unix only)
32559 \end_layout
32560
32561 \end_inset
32562 </cell>
32563 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32564 \begin_inset Text
32565
32566 \begin_layout Standard
32567 \begin_inset LatexCommand \url{http://www.gnu.org/software/ddd/}
32568
32569 \end_inset
32570
32571
32572 \end_layout
32573
32574 \end_inset
32575 </cell>
32576 </row>
32577 <row bottomline="true">
32578 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32579 \begin_inset Text
32580
32581 \begin_layout Standard
32582 d52
32583 \begin_inset LatexCommand \index{d52}
32584
32585 \end_inset
32586
32587
32588 \begin_inset LatexCommand \index{d52 (disassembler)}
32589
32590 \end_inset
32591
32592
32593 \end_layout
32594
32595 \end_inset
32596 </cell>
32597 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32598 \begin_inset Text
32599
32600 \begin_layout Standard
32601 Disassembler, can count instruction cycles
32602 \begin_inset LatexCommand \index{instruction cycles (count)}
32603
32604 \end_inset
32605
32606 , use with options -pnd
32607 \end_layout
32608
32609 \end_inset
32610 </cell>
32611 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32612 \begin_inset Text
32613
32614 \begin_layout Standard
32615 \begin_inset LatexCommand \url{http://www.8052.com/users/disasm/}
32616
32617 \end_inset
32618
32619
32620 \end_layout
32621
32622 \end_inset
32623 </cell>
32624 </row>
32625 <row bottomline="true">
32626 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32627 \begin_inset Text
32628
32629 \begin_layout Standard
32630 cmake
32631 \begin_inset LatexCommand \index{cmake}
32632
32633 \end_inset
32634
32635
32636 \end_layout
32637
32638 \end_inset
32639 </cell>
32640 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32641 \begin_inset Text
32642
32643 \begin_layout Standard
32644 Cross platform build system, generates Makefiles
32645 \begin_inset LatexCommand \index{Makefile}
32646
32647 \end_inset
32648
32649  and project workspaces
32650 \begin_inset LatexCommand \index{project workspace}
32651
32652 \end_inset
32653
32654
32655 \end_layout
32656
32657 \end_inset
32658 </cell>
32659 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32660 \begin_inset Text
32661
32662 \begin_layout Standard
32663 \begin_inset LatexCommand \url{http://www.cmake.org}
32664
32665 \end_inset
32666
32667  \InsetSpace ~
32668 \InsetSpace ~
32669 \InsetSpace ~
32670 \InsetSpace ~
32671 and a dedicated wiki entry: 
32672 \begin_inset LatexCommand \url{http://www.cmake.org/Wiki/CmakeSdcc}
32673
32674 \end_inset
32675
32676
32677 \end_layout
32678
32679 \end_inset
32680 </cell>
32681 </row>
32682 </lyxtabular>
32683
32684 \end_inset
32685
32686
32687 \newline
32688
32689 \end_layout
32690
32691 \begin_layout Section
32692 Related documentation / recommended reading
32693 \end_layout
32694
32695 \begin_layout Standard
32696 \align left
32697 \begin_inset Tabular
32698 <lyxtabular version="3" rows="7" columns="3">
32699 <features>
32700 <column alignment="left" valignment="top" leftline="true" width="0pt">
32701 <column alignment="left" valignment="top" leftline="true" width="0">
32702 <column alignment="left" valignment="top" leftline="true" rightline="true" width="0pt">
32703 <row topline="true" bottomline="true">
32704 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32705 \begin_inset Text
32706
32707 \begin_layout Standard
32708
32709 \series bold
32710 Name
32711 \end_layout
32712
32713 \end_inset
32714 </cell>
32715 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32716 \begin_inset Text
32717
32718 \begin_layout Standard
32719
32720 \series bold
32721 Subject / Title
32722 \end_layout
32723
32724 \end_inset
32725 </cell>
32726 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32727 \begin_inset Text
32728
32729 \begin_layout Standard
32730
32731 \series bold
32732 Where to get
32733 \end_layout
32734
32735 \end_inset
32736 </cell>
32737 </row>
32738 <row topline="true">
32739 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32740 \begin_inset Text
32741
32742 \begin_layout Standard
32743
32744 \family roman
32745 \series medium
32746 \shape up
32747 \size normal
32748 \emph off
32749 \bar no
32750 \noun off
32751 \color none
32752 c-refcard.pdf
32753 \end_layout
32754
32755 \end_inset
32756 </cell>
32757 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32758 \begin_inset Text
32759
32760 \begin_layout Standard
32761 C Reference Card
32762 \begin_inset LatexCommand \index{C Reference card}
32763
32764 \end_inset
32765
32766 , 2 pages
32767 \end_layout
32768
32769 \end_inset
32770 </cell>
32771 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32772 \begin_inset Text
32773
32774 \begin_layout Standard
32775 \begin_inset LatexCommand \url{http://refcards.com/refcards/c/index.html}
32776
32777 \end_inset
32778
32779
32780 \end_layout
32781
32782 \end_inset
32783 </cell>
32784 </row>
32785 <row topline="true">
32786 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32787 \begin_inset Text
32788
32789 \begin_layout Standard
32790 c-faq
32791 \end_layout
32792
32793 \end_inset
32794 </cell>
32795 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32796 \begin_inset Text
32797
32798 \begin_layout Standard
32799 C-FAQ
32800 \begin_inset LatexCommand \index{C FAQ}
32801
32802 \end_inset
32803
32804
32805 \end_layout
32806
32807 \end_inset
32808 </cell>
32809 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32810 \begin_inset Text
32811
32812 \begin_layout Standard
32813 \begin_inset LatexCommand \url{http://www.c-faq.com}
32814
32815 \end_inset
32816
32817
32818 \end_layout
32819
32820 \end_inset
32821 </cell>
32822 </row>
32823 <row topline="true">
32824 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32825 \begin_inset Text
32826
32827 \begin_layout Standard
32828 ISO/IEC 9899:TC2
32829 \end_layout
32830
32831 \end_inset
32832 </cell>
32833 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32834 \begin_inset Text
32835
32836 \begin_layout Standard
32837 \begin_inset Quotes sld
32838 \end_inset
32839
32840 C-Standard
32841 \begin_inset Quotes srd
32842 \end_inset
32843
32844
32845 \end_layout
32846
32847 \end_inset
32848 </cell>
32849 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32850 \begin_inset Text
32851
32852 \begin_layout Standard
32853
32854 \size footnotesize
32855 \begin_inset LatexCommand \url{http://www.open-std.org/jtc1/sc22/wg14/www/standards.html#9899}
32856
32857 \end_inset
32858
32859
32860 \end_layout
32861
32862 \end_inset
32863 </cell>
32864 </row>
32865 <row topline="true">
32866 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32867 \begin_inset Text
32868
32869 \begin_layout Standard
32870 ISO/IEC DTR 18037
32871 \end_layout
32872
32873 \end_inset
32874 </cell>
32875 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32876 \begin_inset Text
32877
32878 \begin_layout Standard
32879 \begin_inset Quotes sld
32880 \end_inset
32881
32882 Extensions for Embedded C
32883 \begin_inset Quotes srd
32884 \end_inset
32885
32886
32887 \end_layout
32888
32889 \end_inset
32890 </cell>
32891 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32892 \begin_inset Text
32893
32894 \begin_layout Standard
32895
32896 \size footnotesize
32897 \begin_inset LatexCommand \url{http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1021.pdf}
32898
32899 \end_inset
32900
32901
32902 \end_layout
32903
32904 \end_inset
32905 </cell>
32906 </row>
32907 <row topline="true">
32908 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32909 \begin_inset Text
32910
32911 \begin_layout Standard
32912
32913 \end_layout
32914
32915 \end_inset
32916 </cell>
32917 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32918 \begin_inset Text
32919
32920 \begin_layout Standard
32921 Latest datasheet of target CPU
32922 \end_layout
32923
32924 \end_inset
32925 </cell>
32926 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32927 \begin_inset Text
32928
32929 \begin_layout Standard
32930 vendor
32931 \end_layout
32932
32933 \end_inset
32934 </cell>
32935 </row>
32936 <row topline="true" bottomline="true">
32937 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32938 \begin_inset Text
32939
32940 \begin_layout Standard
32941
32942 \end_layout
32943
32944 \end_inset
32945 </cell>
32946 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32947 \begin_inset Text
32948
32949 \begin_layout Standard
32950 Revision history of datasheet
32951 \end_layout
32952
32953 \end_inset
32954 </cell>
32955 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32956 \begin_inset Text
32957
32958 \begin_layout Standard
32959 vendor
32960 \end_layout
32961
32962 \end_inset
32963 </cell>
32964 </row>
32965 </lyxtabular>
32966
32967 \end_inset
32968
32969
32970 \newline
32971
32972 \end_layout
32973
32974 \begin_layout Section
32975 Application notes specifically for SDCC
32976 \end_layout
32977
32978 \begin_layout Standard
32979 SDCC makes no claims about the completeness of this list and about up-to-datenes
32980 s or correctness of the application notes
32981 \begin_inset LatexCommand \index{Application notes}
32982
32983 \end_inset
32984
32985 .
32986 \end_layout
32987
32988 \begin_layout Standard
32989 \align left
32990
32991 \size footnotesize
32992 \begin_inset Tabular
32993 <lyxtabular version="3" rows="7" columns="3">
32994 <features>
32995 <column alignment="block" valignment="top" leftline="true" width="17col%">
32996 <column alignment="block" valignment="top" leftline="true" width="27col%">
32997 <column alignment="block" valignment="top" leftline="true" rightline="true" width="57col%">
32998 <row topline="true" bottomline="true">
32999 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33000 \begin_inset Text
33001
33002 \begin_layout Standard
33003
33004 \series bold
33005 \size footnotesize
33006 Vendor
33007 \end_layout
33008
33009 \end_inset
33010 </cell>
33011 <cell alignment="left" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
33012 \begin_inset Text
33013
33014 \begin_layout Standard
33015
33016 \series bold
33017 \size footnotesize
33018 Subject / Title
33019 \end_layout
33020
33021 \end_inset
33022 </cell>
33023 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
33024 \begin_inset Text
33025
33026 \begin_layout Standard
33027
33028 \series bold
33029 \size footnotesize
33030 Where to get
33031 \end_layout
33032
33033 \end_inset
33034 </cell>
33035 </row>
33036 <row topline="true">
33037 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33038 \begin_inset Text
33039
33040 \begin_layout Standard
33041
33042 \size footnotesize
33043 Maxim / Dallas
33044 \end_layout
33045
33046 \end_inset
33047 </cell>
33048 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33049 \begin_inset Text
33050
33051 \begin_layout Standard
33052
33053 \size footnotesize
33054 Using the SDCC Compiler for the DS80C400
33055 \begin_inset LatexCommand \index{DS80C400}
33056
33057 \end_inset
33058
33059
33060 \end_layout
33061
33062 \end_inset
33063 </cell>
33064 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
33065 \begin_inset Text
33066
33067 \begin_layout Standard
33068
33069 \size footnotesize
33070 \begin_inset LatexCommand \url{http://pdfserv.maxim-ic.com/en/an/AN3346.pdf}
33071
33072 \end_inset
33073
33074
33075 \end_layout
33076
33077 \end_inset
33078 </cell>
33079 </row>
33080 <row topline="true">
33081 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33082 \begin_inset Text
33083
33084 \begin_layout Standard
33085
33086 \size footnotesize
33087 Maxim / Dallas
33088 \end_layout
33089
33090 \end_inset
33091 </cell>
33092 <cell multicolumn="1" alignment="left" valignment="top" topline="true" leftline="true" usebox="none" width="30line%">
33093 \begin_inset Text
33094
33095 \begin_layout Standard
33096
33097 \size footnotesize
33098 Using the Free SDCC C Compiler to Develop Firmware for the DS89C420/430/440/450
33099 \begin_inset LatexCommand \index{DS89C4x0}
33100
33101 \end_inset
33102
33103  Family of Microcontrollers
33104 \end_layout
33105
33106 \end_inset
33107 </cell>
33108 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
33109 \begin_inset Text
33110
33111 \begin_layout Standard
33112
33113 \size footnotesize
33114 \begin_inset LatexCommand \url{http://pdfserv.maxim-ic.com/en/an/AN3477.pdf}
33115
33116 \end_inset
33117
33118
33119 \end_layout
33120
33121 \end_inset
33122 </cell>
33123 </row>
33124 <row topline="true">
33125 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33126 \begin_inset Text
33127
33128 \begin_layout Standard
33129
33130 \size footnotesize
33131 Silicon Laboratories / Cygnal
33132 \end_layout
33133
33134 \end_inset
33135 </cell>
33136 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33137 \begin_inset Text
33138
33139 \begin_layout Standard
33140
33141 \size footnotesize
33142 Integrating SDCC 8051 Tools Into The Silicon Labs IDE
33143 \begin_inset LatexCommand \index{IDE}
33144
33145 \end_inset
33146
33147
33148 \end_layout
33149
33150 \end_inset
33151 </cell>
33152 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
33153 \begin_inset Text
33154
33155 \begin_layout Standard
33156
33157 \size footnotesize
33158 \begin_inset LatexCommand \url{http://www.silabs.com/public/documents/tpub_doc/anote/Microcontrollers/en/an198.pdf}
33159
33160 \end_inset
33161
33162
33163 \end_layout
33164
33165 \end_inset
33166 </cell>
33167 </row>
33168 <row topline="true">
33169 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33170 \begin_inset Text
33171
33172 \begin_layout Standard
33173
33174 \size footnotesize
33175 Ramtron / Goal Semiconductor
33176 \end_layout
33177
33178 \end_inset
33179 </cell>
33180 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33181 \begin_inset Text
33182
33183 \begin_layout Standard
33184
33185 \size footnotesize
33186 Interfacing SDCC to Syn and Textpad
33187 \end_layout
33188
33189 \end_inset
33190 </cell>
33191 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
33192 \begin_inset Text
33193
33194 \begin_layout Standard
33195
33196 \size footnotesize
33197 \begin_inset LatexCommand \url{http://www.ramtron.com/doc/Products/Microcontroller/Support_Tools.asp}
33198
33199 \end_inset
33200
33201
33202 \end_layout
33203
33204 \end_inset
33205 </cell>
33206 </row>
33207 <row topline="true">
33208 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33209 \begin_inset Text
33210
33211 \begin_layout Standard
33212
33213 \size footnotesize
33214 Ramtron / Goal Semiconductor
33215 \end_layout
33216
33217 \end_inset
33218 </cell>
33219 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33220 \begin_inset Text
33221
33222 \begin_layout Standard
33223
33224 \size footnotesize
33225 Installing and Configuring SDCC and Crimson Editor 
33226 \end_layout
33227
33228 \end_inset
33229 </cell>
33230 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
33231 \begin_inset Text
33232
33233 \begin_layout Standard
33234
33235 \size footnotesize
33236 \begin_inset LatexCommand \url{http://www.ramtron.com/doc/Products/Microcontroller/Support_Tools.asp}
33237
33238 \end_inset
33239
33240
33241 \end_layout
33242
33243 \end_inset
33244 </cell>
33245 </row>
33246 <row topline="true" bottomline="true">
33247 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33248 \begin_inset Text
33249
33250 \begin_layout Standard
33251
33252 \size footnotesize
33253 Texas Instruments
33254 \end_layout
33255
33256 \end_inset
33257 </cell>
33258 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33259 \begin_inset Text
33260
33261 \begin_layout Standard
33262
33263 \size footnotesize
33264 MSC12xx Programming with SDCC
33265 \end_layout
33266
33267 \end_inset
33268 </cell>
33269 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
33270 \begin_inset Text
33271
33272 \begin_layout Standard
33273
33274 \size footnotesize
33275 \begin_inset LatexCommand \url{http://focus.ti.com/general/docs/lit/getliterature.tsp?literatureNumber=sbaa109&fileType=pdf}
33276
33277 \end_inset
33278
33279
33280 \end_layout
33281
33282 \end_inset
33283 </cell>
33284 </row>
33285 </lyxtabular>
33286
33287 \end_inset
33288
33289
33290 \end_layout
33291
33292 \begin_layout Section
33293 Some Questions
33294 \end_layout
33295
33296 \begin_layout Standard
33297 Some questions answered, some pointers given - it might be time to in turn
33298  ask 
33299 \emph on
33300 you
33301 \emph default
33302  some questions: 
33303 \end_layout
33304
33305 \begin_layout Itemize
33306 can you solve your project with the selected microcontroller? Would you
33307  find out early or rather late that your target is too small/slow/whatever?
33308  Can you switch to a slightly better device if it doesn't fit?
33309 \end_layout
33310
33311 \begin_layout Itemize
33312 should you solve the problem with an 8 bit CPU? Or would a 16/32 bit CPU
33313  and/or another programming language be more adequate? Would an operating
33314  system on the target device help?
33315 \end_layout
33316
33317 \begin_layout Itemize
33318 if you solved the problem, will the marketing department be happy?
33319 \end_layout
33320
33321 \begin_layout Itemize
33322 if the marketing department is happy, will customers be happy?
33323 \end_layout
33324
33325 \begin_layout Itemize
33326 if you're the project manager, marketing department and maybe even the customer
33327  in one person, have you tried to see the project from the outside?
33328 \end_layout
33329
33330 \begin_layout Itemize
33331 is the project done if you think it is done? Or is just that other interface/pro
33332 tocol/feature/configuration/option missing? How about website, manual(s),
33333  internationali(z|s)ation, packaging, labels, 2nd source for components,
33334  electromagnetic compatability/interference, documentation for production,
33335  production test software, update mechanism, patent issues?
33336 \end_layout
33337
33338 \begin_layout Itemize
33339 is your project adequately positioned in that magic triangle: fame, fortune,
33340  fun?
33341 \end_layout
33342
33343 \begin_layout Standard
33344 Maybe not all answers to these questions are known and some answers may
33345  even be 
33346 \emph on
33347 no
33348 \emph default
33349 , nevertheless knowing these questions may help you to avoid burnout
33350 \begin_inset Foot
33351 status open
33352
33353 \begin_layout Standard
33354 burnout is bad for electronic devices, programmers and motorcycle tyres
33355 \end_layout
33356
33357 \end_inset
33358
33359 .
33360  Chances are you didn't want to hear some of them...
33361 \end_layout
33362
33363 \begin_layout Chapter
33364 Support
33365 \begin_inset LatexCommand \index{Support}
33366
33367 \end_inset
33368
33369
33370 \end_layout
33371
33372 \begin_layout Standard
33373 SDCC has grown to be a large project.
33374  The compiler alone (without the preprocessor, assembler and linker) is
33375  well over 150,000 lines of code (blank stripped).
33376  The open source nature of this project is a key to its continued growth
33377  and support.
33378  You gain the benefit and support of many active software developers and
33379  end users.
33380  Is SDCC perfect? No, that's why we need your help.
33381  The developers take pride in fixing reported bugs.
33382  You can help by reporting the bugs and helping other SDCC users.
33383  There are lots of ways to contribute, and we encourage you to take part
33384  in making SDCC a great software package.
33385  
33386 \end_layout
33387
33388 \begin_layout Standard
33389 The SDCC project is hosted on the SDCC sourceforge site at 
33390 \begin_inset LatexCommand \htmlurl{http://sourceforge.net/projects/sdcc}
33391
33392 \end_inset
33393
33394 .
33395  You'll find the complete set of mailing lists
33396 \begin_inset LatexCommand \index{Mailing list(s)}
33397
33398 \end_inset
33399
33400 , forums, bug reporting system, patch submission
33401 \begin_inset LatexCommand \index{Patch submission}
33402
33403 \end_inset
33404
33405  system, download
33406 \begin_inset LatexCommand \index{download}
33407
33408 \end_inset
33409
33410  area and Subversion code repository
33411 \begin_inset LatexCommand \index{Subversion code repository}
33412
33413 \end_inset
33414
33415  there.
33416 \end_layout
33417
33418 \begin_layout Section
33419 Reporting Bugs
33420 \begin_inset LatexCommand \index{Bug reporting}
33421
33422 \end_inset
33423
33424
33425 \begin_inset LatexCommand \index{Reporting bugs}
33426
33427 \end_inset
33428
33429
33430 \end_layout
33431
33432 \begin_layout Standard
33433 The recommended way of reporting bugs is using the infrastructure of the
33434  sourceforge site.
33435  You can follow the status of bug reports there and have an overview about
33436  the known bugs.
33437 \end_layout
33438
33439 \begin_layout Standard
33440 Bug reports are automatically forwarded to the developer mailing list and
33441  will be fixed ASAP.
33442  When reporting a bug, it is very useful to include a small test program
33443  (the smaller the better) which reproduces the problem.
33444  If you can isolate the problem by looking at the generated assembly code,
33445  this can be very helpful.
33446  Compiling your program with the -
33447 \begin_inset ERT
33448 status collapsed
33449
33450 \begin_layout Standard
33451
33452
33453 \backslash
33454 /
33455 \end_layout
33456
33457 \end_inset
33458
33459 -dumpall
33460 \begin_inset LatexCommand \index{-\/-dumpall}
33461
33462 \end_inset
33463
33464  option can sometimes be useful in locating optimization problems.
33465  When reporting a bug please make sure you:
33466 \end_layout
33467
33468 \begin_layout Enumerate
33469 Attach the code you are compiling with SDCC.
33470  
33471 \end_layout
33472
33473 \begin_layout Enumerate
33474 Specify the exact command you use to run SDCC, or attach your Makefile.
33475  
33476 \end_layout
33477
33478 \begin_layout Enumerate
33479 Specify the SDCC version (type "
33480 \family sans
33481 \series bold
33482 sdcc -v
33483 \family default
33484 \series default
33485 "), your platform, and operating system.
33486  
33487 \end_layout
33488
33489 \begin_layout Enumerate
33490 Provide an exact copy of any error message or incorrect output.
33491  
33492 \end_layout
33493
33494 \begin_layout Enumerate
33495 Put something meaningful in the subject of your message.
33496 \end_layout
33497
33498 \begin_layout Standard
33499 Please attempt to include these 5 important parts, as applicable, in all
33500  requests for support or when reporting any problems or bugs with SDCC.
33501  Though this will make your message lengthy, it will greatly improve your
33502  chance that SDCC users and developers will be able to help you.
33503  Some SDCC developers are frustrated by bug reports without code provided
33504  that they can use to reproduce and ultimately fix the problem, so please
33505  be sure to provide sample code if you are reporting a bug! 
33506 \end_layout
33507
33508 \begin_layout Standard
33509 Please have a short check that you are using a recent version of SDCC and
33510  the bug is not yet known.
33511  This is the link for reporting bugs: 
33512 \begin_inset LatexCommand \htmlurl{http://sourceforge.net/tracker/?group_id=599&atid=100599}
33513
33514 \end_inset
33515
33516 .
33517  With SDCC on average having more than 200 downloads
33518 \begin_inset LatexCommand \index{download}
33519
33520 \end_inset
33521
33522  on sourceforge per day
33523 \begin_inset Foot
33524 status open
33525
33526 \begin_layout Standard
33527 220 daily downloads on average Jan-Sept 2006 and about 150 daily downloads
33528  between 2002 and 2005.
33529  This does not include other methods of distribution.
33530 \end_layout
33531
33532 \end_inset
33533
33534  there must be some users.
33535  So it's not exactly easy to find a new bug.
33536  If you find one we need it: 
33537 \emph on
33538 reporting bugs is good
33539 \emph default
33540 .
33541 \end_layout
33542
33543 \begin_layout Section
33544 Requesting Features
33545 \begin_inset LatexCommand \label{sub:Requesting-Features}
33546
33547 \end_inset
33548
33549
33550 \begin_inset LatexCommand \index{Feature request}
33551
33552 \end_inset
33553
33554
33555 \begin_inset LatexCommand \index{Requesting features}
33556
33557 \end_inset
33558
33559
33560 \end_layout
33561
33562 \begin_layout Standard
33563 Like bug reports feature requests are forwarded to the developer mailing
33564  list.
33565  This is the link for requesting features: 
33566 \begin_inset LatexCommand \htmlurl{http://sourceforge.net/tracker/?group_id=599&atid=350599}
33567
33568 \end_inset
33569
33570 .
33571 \end_layout
33572
33573 \begin_layout Section
33574 Submitting patches
33575 \end_layout
33576
33577 \begin_layout Standard
33578 Like bug reports contributed patches are forwarded to the developer mailing
33579  list.
33580  This is the link for submitting patches
33581 \begin_inset LatexCommand \index{Patch submission}
33582
33583 \end_inset
33584
33585
33586 \begin_inset LatexCommand \url{http://sourceforge.net/tracker/?group_id=599&atid=300599}
33587
33588 \end_inset
33589
33590 .
33591 \end_layout
33592
33593 \begin_layout Standard
33594 You need to specify some parameters to the 
33595 \family typewriter
33596 diff
33597 \family default
33598  command for the patches to be useful.
33599  If you modified more than one file a patch created f.e.
33600  with 
33601 \family sans
33602 \series bold
33603
33604 \begin_inset Quotes sld
33605 \end_inset
33606
33607 diff -Naur unmodified_directory modified_directory >my_changes.patch
33608 \begin_inset Quotes srd
33609 \end_inset
33610
33611
33612 \family default
33613 \series default
33614  will be fine, otherwise 
33615 \family sans
33616 \series bold
33617
33618 \begin_inset Quotes sld
33619 \end_inset
33620
33621 diff -u sourcefile.c.orig sourcefile.c >my_changes.patch
33622 \begin_inset Quotes srd
33623 \end_inset
33624
33625
33626 \series default
33627  
33628 \family default
33629 will do.
33630 \end_layout
33631
33632 \begin_layout Section
33633 Getting Help
33634 \end_layout
33635
33636 \begin_layout Standard
33637 These links should take you directly to the 
33638 \begin_inset LatexCommand \url[Mailing lists]{http://sourceforge.net/mail/?group_id=599}
33639
33640 \end_inset
33641
33642
33643 \begin_inset Foot
33644 status open
33645
33646 \begin_layout Standard
33647 Traffic on sdcc-devel and sdcc-user is about 100 mails/month each not counting
33648  automated messages (mid 2003)
33649 \end_layout
33650
33651 \end_inset
33652
33653  and the 
33654 \begin_inset LatexCommand \url[Forums]{http://sourceforge.net/forum/?group_id=599}
33655
33656 \end_inset
33657
33658 , lists
33659 \begin_inset LatexCommand \index{Mailing list(s)}
33660
33661 \end_inset
33662
33663  and forums are archived and searchable so if you are lucky someone already
33664  had a similar problem.
33665  While mails to the lists themselves are delivered promptly their web front
33666  end on sourceforge sometimes shows a severe time lag (up to several weeks),
33667  if you're seriously using SDCC please consider subscribing to the lists.
33668 \end_layout
33669
33670 \begin_layout Section
33671 ChangeLog
33672 \end_layout
33673
33674 \begin_layout Standard
33675 You can follow the status of the Subversion version
33676 \begin_inset LatexCommand \index{version}
33677
33678 \end_inset
33679
33680  of SDCC by watching the Changelog
33681 \begin_inset LatexCommand \index{Changelog}
33682
33683 \end_inset
33684
33685  in the Subversion repository
33686 \size footnotesize
33687  
33688 \begin_inset LatexCommand \htmlurl{http://sdcc.svn.sourceforge.net/viewcvs.cgi/*checkout*/sdcc/trunk/sdcc/ChangeLog}
33689
33690 \end_inset
33691
33692 .
33693 \end_layout
33694
33695 \begin_layout Section
33696 Subversion Source Code Repository
33697 \end_layout
33698
33699 \begin_layout Standard
33700 The output of 
33701 \family sans
33702 \series bold
33703 sdcc -
33704 \family default
33705
33706 \begin_inset ERT
33707 status open
33708
33709 \begin_layout Standard
33710
33711
33712 \backslash
33713 /
33714 \end_layout
33715
33716 \end_inset
33717
33718
33719 \family sans
33720 -version
33721 \family default
33722 \series default
33723  or the filenames of the snapshot versions of SDCC include date and its
33724  Subversion
33725 \begin_inset LatexCommand \index{Subversion code repository}
33726
33727 \end_inset
33728
33729  number.
33730  Subversion allows to download the source of recent or previous versions
33731  
33732 \begin_inset LatexCommand \url{http://sourceforge.net/svn/?group_id=599}
33733
33734 \end_inset
33735
33736  (by number or by date).
33737  An on-line source code browser and detailled instructions are also available
33738  there.
33739  SDCC versions starting from 1999 up to now are available (currently the
33740  versions prior to the conversion from cvs
33741 \begin_inset LatexCommand \index{cvs|see{Subversion}}
33742
33743 \end_inset
33744
33745  to Subversion (April 2006) are either by accessible by Subversion or by
33746  cvs).
33747 \end_layout
33748
33749 \begin_layout Section
33750 Release policy
33751 \begin_inset LatexCommand \index{Release policy}
33752
33753 \end_inset
33754
33755
33756 \end_layout
33757
33758 \begin_layout Standard
33759 Historically there often were long delays between official releases and
33760  the sourceforge download area tends to get not updated at all.
33761  Excuses in the past might have referred to problems with live range analysis,
33762  but as this was fixed a while ago, the current problem is that another
33763  excuse has to be found.
33764  Kidding aside, we have to get better there! On the other hand there are
33765  daily snapshots available at 
33766 \begin_inset LatexCommand \htmlurl[snap]{http://sdcc.sourceforge.net/snap.php}
33767
33768 \end_inset
33769
33770 , and you can always build the very last version (hopefully with many bugs
33771  fixed, and features added) from the source code available at 
33772 \begin_inset LatexCommand \htmlurl[Source]{http://sdcc.sourceforge.net/snap.php#Source}
33773
33774 \end_inset
33775
33776 .
33777  The SDCC Wiki
33778 \begin_inset LatexCommand \index{wiki}
33779
33780 \end_inset
33781
33782
33783 \begin_inset LatexCommand \index{SDCC Wiki}
33784
33785 \end_inset
33786
33787  at 
33788 \begin_inset LatexCommand \url{http://sdcc.wiki.sourceforge.net/}
33789
33790 \end_inset
33791
33792  also holds some information about past and future releases.
33793 \end_layout
33794
33795 \begin_layout Section
33796 Examples
33797 \begin_inset LatexCommand \index{Examples}
33798
33799 \end_inset
33800
33801
33802 \end_layout
33803
33804 \begin_layout Standard
33805 You'll find some small examples in the directory 
33806 \emph on
33807 sdcc/device/examples/.
33808  
33809 \emph default
33810 More examples and libraries are available at
33811 \emph on
33812  The SDCC Open Knowledge Resource 
33813 \begin_inset LatexCommand \url{http://sdccokr.dl9sec.de/}
33814
33815 \end_inset
33816
33817  
33818 \emph default
33819 web site or at 
33820 \begin_inset LatexCommand \url{http://www.pjrc.com/tech/8051/}
33821
33822 \end_inset
33823
33824 .
33825 \end_layout
33826
33827 \begin_layout Standard
33828 \begin_inset Note Note
33829 status collapsed
33830
33831 \begin_layout Standard
33832 I did insert a reference to Paul's web site here although it seems rather
33833  dedicated to a specific 8032 board (I think it's okay because it f.e.
33834  shows LCD/Harddisc interface and has a free 8051 monitor.
33835  Independent 8032 board vendors face hard competition of heavily subsidized
33836  development boards anyway).
33837 \end_layout
33838
33839 \begin_layout Standard
33840 Maybe we should include some links to real world applications.
33841  Preferably pointer to pointers (one for each architecture) so this stays
33842  manageable here?
33843 \end_layout
33844
33845 \end_inset
33846
33847
33848 \end_layout
33849
33850 \begin_layout Section
33851 Quality control
33852 \begin_inset LatexCommand \label{sec:Quality-control}
33853
33854 \end_inset
33855
33856
33857 \begin_inset LatexCommand \index{Quality control}
33858
33859 \end_inset
33860
33861
33862 \end_layout
33863
33864 \begin_layout Standard
33865 The compiler is passed through snaphot build compile and build checks.
33866  The so called 
33867 \shape italic
33868 regression tests
33869 \shape default
33870
33871 \begin_inset LatexCommand \index{Regression test}
33872
33873 \end_inset
33874
33875  check that SDCC itself compiles flawlessly on several host platforms (i386,
33876  Opteron, 64 bit Alpha, ppc64, Mac OS X on ppc and i386, Solaris on Sparc)
33877  and checks the quality of the code generated by SDCC by running the code
33878  for several target platforms through simulators.
33879  The regression test suite comprises more than 100 files which expand to
33880  more than 500 test cases which include more than 4500 tests.
33881  The results of these tests are published daily on SDCC's snapshot page
33882  (click on the red or green symbols on the right side of 
33883 \begin_inset LatexCommand \url{http://sdcc.sourceforge.net/snap.php}
33884
33885 \end_inset
33886
33887 ).
33888 \end_layout
33889
33890 \begin_layout Standard
33891 There is a separate document 
33892 \shape italic
33893 test_suite.pdf 
33894 \begin_inset LatexCommand \index{Test suite}
33895
33896 \end_inset
33897
33898
33899 \shape default
33900  
33901 \begin_inset LatexCommand \url{http://sdcc.sourceforge.net/doc/test_suite_spec.pdf}
33902
33903 \end_inset
33904
33905  about the regression test suite.
33906 \end_layout
33907
33908 \begin_layout Standard
33909 You'll find the test code in the directory 
33910 \shape italic
33911 sdcc/support/regression
33912 \shape default
33913 .
33914  You can run these tests manually by running 
33915 \family sans
33916 make
33917 \family default
33918  in this directory (or f.e.
33919  
33920 \family sans
33921 \series bold
33922
33923 \begin_inset Quotes sld
33924 \end_inset
33925
33926 make test-mcs51
33927 \begin_inset Quotes srd
33928 \end_inset
33929
33930
33931 \family default
33932 \series default
33933  if you don't want to run the complete tests).
33934  The test code might also be interesting if you want to look for examples
33935 \begin_inset LatexCommand \index{Examples}
33936
33937 \end_inset
33938
33939  checking corner cases of SDCC or if you plan to submit patches
33940 \begin_inset LatexCommand \index{Patch submission}
33941
33942 \end_inset
33943
33944 .
33945 \end_layout
33946
33947 \begin_layout Standard
33948 The PIC14 port uses a different set of regression tests 
33949 \begin_inset LatexCommand \index{Regression test (PIC14)}
33950
33951 \end_inset
33952
33953 , you'll find them in the directory 
33954 \shape italic
33955 sdcc/src/regression
33956 \shape default
33957 .
33958 \end_layout
33959
33960 \begin_layout Section
33961 Use of SDCC in Education
33962 \end_layout
33963
33964 \begin_layout Standard
33965 In short: 
33966 \emph on
33967 highly
33968 \emph default
33969  encouraged
33970 \begin_inset Foot
33971 status open
33972
33973 \begin_layout Standard
33974 the phrase "use in education" might evoke the association "
33975 \emph on
33976 only
33977 \emph default
33978  fit for use in education".
33979  This connotation is not intended but nevertheless risked as the licensing
33980  of SDCC makes it difficult to offer educational discounts
33981 \end_layout
33982
33983 \end_inset
33984
33985 .
33986  If your rationales are to:
33987 \end_layout
33988
33989 \begin_layout Enumerate
33990 give students a chance to understand the 
33991 \emph on
33992 complete
33993 \emph default
33994  steps of code generation
33995 \end_layout
33996
33997 \begin_layout Enumerate
33998 have a curriculum that can be extended for years.
33999  Then you could use an fpga board as target and your curriculum will seamlessly
34000  extend from logic synthesis (
34001 \begin_inset LatexCommand \url[http://www.opencores.org]{opencores.org}
34002
34003 \end_inset
34004
34005
34006 \begin_inset LatexCommand \url[Oregano]{http://www.oregano.at/ip/ip01.htm}
34007
34008 \end_inset
34009
34010 ), over assembly programming, to C to FPGA compilers (
34011 \begin_inset LatexCommand \url[FPGAC]{http://sf.net/projects/fpgac}
34012
34013 \end_inset
34014
34015 ) and to C.
34016 \end_layout
34017
34018 \begin_layout Enumerate
34019 be able to insert excursions about skills like using a revision control
34020  system, submitting/applying patches, using a type-setting (as opposed to
34021  word-processing) engine LyX/LaTeX, using 
34022 \begin_inset LatexCommand \url[SourceForge]{http://www.sf.net}
34023
34024 \end_inset
34025
34026 , following some 
34027 \begin_inset LatexCommand \url[netiquette]{http://en.wikipedia.org/wiki/Netiquette}
34028
34029 \end_inset
34030
34031 , understanding BSD/LGPL/GPL/Proprietary licensing, growth models of Open
34032  Source Software, CPU simulation, compiler regression tests
34033 \begin_inset LatexCommand \index{Regression test}
34034
34035 \end_inset
34036
34037 .
34038  
34039 \newline
34040 And if there should be a shortage of ideas then you can always point students
34041  to the ever-growing feature request list 
34042 \begin_inset LatexCommand \htmlurl{http://sourceforge.net/tracker/?group_id=599&atid=350599}
34043
34044 \end_inset
34045
34046 .
34047 \end_layout
34048
34049 \begin_layout Enumerate
34050 not tie students to a specific host platform and instead allow them to use
34051  a host platform of 
34052 \emph on
34053 their
34054 \emph default
34055  choice (among them Alpha, i386, i386_64, Mac OS X, Mips, Sparc, Windows
34056  and eventually 
34057 \begin_inset LatexCommand \url[OLPC]{http://www.laptop.org}
34058
34059 \end_inset
34060
34061 )
34062 \end_layout
34063
34064 \begin_layout Enumerate
34065 not encourage students to use illegal copies of educational software
34066 \end_layout
34067
34068 \begin_layout Enumerate
34069 be immune to licensing/availability/price changes of the chosen tool chain
34070 \end_layout
34071
34072 \begin_layout Enumerate
34073 be able to change to a new target platform without having to adopt a new
34074  tool chain
34075 \end_layout
34076
34077 \begin_layout Enumerate
34078 have complete control over and insight into the tool chain
34079 \end_layout
34080
34081 \begin_layout Enumerate
34082 make your students aware about the pros and cons of open source software
34083  development
34084 \end_layout
34085
34086 \begin_layout Enumerate
34087 give back to the public as you are probably at least partially publically
34088  funded
34089 \end_layout
34090
34091 \begin_layout Enumerate
34092 give students a chance to publically prove their skills and to possibly
34093  see a world wide impact
34094 \end_layout
34095
34096 \begin_layout Standard
34097 then SDCC is probably among the first choices.
34098  Well, probably SDCC might be the only choice.
34099 \newpage
34100
34101 \end_layout
34102
34103 \begin_layout Chapter
34104 SDCC Technical Data
34105 \end_layout
34106
34107 \begin_layout Section
34108 Optimizations
34109 \begin_inset LatexCommand \index{Optimizations}
34110
34111 \end_inset
34112
34113
34114 \end_layout
34115
34116 \begin_layout Standard
34117 SDCC performs a host of standard optimizations in addition to some MCU specific
34118  optimizations.
34119  
34120 \end_layout
34121
34122 \begin_layout Subsection
34123 Sub-expression Elimination
34124 \begin_inset LatexCommand \index{Subexpression elimination}
34125
34126 \end_inset
34127
34128
34129 \end_layout
34130
34131 \begin_layout Standard
34132 The compiler does local and 
34133 \emph on
34134 g
34135 \emph default
34136 lobal 
34137 \emph on
34138 c
34139 \emph default
34140 ommon 
34141 \emph on
34142 s
34143 \emph default
34144 ubexpression 
34145 \emph on
34146 e
34147 \emph default
34148 limination, e.g.: 
34149 \end_layout
34150
34151 \begin_layout Verse
34152
34153 \family typewriter
34154 i = x + y + 1; 
34155 \newline
34156 j = x + y;
34157 \end_layout
34158
34159 \begin_layout Standard
34160 will be translated to
34161 \end_layout
34162
34163 \begin_layout Verse
34164
34165 \family typewriter
34166 iTemp = x + y; 
34167 \newline
34168 i = iTemp + 1; 
34169 \newline
34170 j = iTemp;
34171 \end_layout
34172
34173 \begin_layout Standard
34174 Some subexpressions are not as obvious as the above example, e.g.:
34175 \end_layout
34176
34177 \begin_layout Verse
34178
34179 \family typewriter
34180 a->b[i].c = 10; 
34181 \newline
34182 a->b[i].d = 11;
34183 \end_layout
34184
34185 \begin_layout Standard
34186 In this case the address arithmetic a->b[i] will be computed only once;
34187  the equivalent code in C would be.
34188 \end_layout
34189
34190 \begin_layout Verse
34191
34192 \family typewriter
34193 iTemp = a->b[i]; 
34194 \newline
34195 iTemp.c = 10; 
34196 \newline
34197 iTemp.d = 11;
34198 \end_layout
34199
34200 \begin_layout Standard
34201 The compiler will try to keep these temporary variables in registers.
34202 \end_layout
34203
34204 \begin_layout Subsection
34205 Dead-Code Elimination
34206 \begin_inset LatexCommand \index{Dead-code elimination}
34207
34208 \end_inset
34209
34210
34211 \end_layout
34212
34213 \begin_layout Verse
34214
34215 \family typewriter
34216 int global;
34217 \newline
34218
34219 \newline
34220 void f () { 
34221 \newline
34222 \InsetSpace ~
34223 \InsetSpace ~
34224 int i; 
34225 \newline
34226 \InsetSpace ~
34227 \InsetSpace ~
34228 i = 1; \InsetSpace ~
34229 \InsetSpace ~
34230 \InsetSpace ~
34231 \InsetSpace ~
34232 \InsetSpace ~
34233 /* dead store */ 
34234 \newline
34235 \InsetSpace ~
34236 \InsetSpace ~
34237 global = 1;\InsetSpace ~
34238 /* dead
34239  store */ 
34240 \newline
34241 \InsetSpace ~
34242 \InsetSpace ~
34243 global = 2; 
34244 \newline
34245 \InsetSpace ~
34246 \InsetSpace ~
34247 return; 
34248 \newline
34249 \InsetSpace ~
34250 \InsetSpace ~
34251 global = 3;\InsetSpace ~
34252 /* unreachable */ 
34253 \newline
34254 }
34255 \end_layout
34256
34257 \begin_layout Standard
34258 will be changed to
34259 \end_layout
34260
34261 \begin_layout Verse
34262
34263 \family typewriter
34264 int global;
34265 \newline
34266
34267 \newline
34268 void f () {
34269 \newline
34270 \InsetSpace ~
34271 \InsetSpace ~
34272 global = 2; 
34273 \newline
34274 }
34275 \end_layout
34276
34277 \begin_layout Subsection
34278 Copy-Propagation
34279 \begin_inset LatexCommand \index{Copy propagation}
34280
34281 \end_inset
34282
34283
34284 \end_layout
34285
34286 \begin_layout Verse
34287
34288 \family typewriter
34289 int f() { 
34290 \newline
34291 \InsetSpace ~
34292 \InsetSpace ~
34293 int i, j; 
34294 \newline
34295 \InsetSpace ~
34296 \InsetSpace ~
34297 i = 10; 
34298 \newline
34299 \InsetSpace ~
34300 \InsetSpace ~
34301 j = i; 
34302 \newline
34303 \InsetSpace ~
34304 \InsetSpace ~
34305 return j; 
34306 \newline
34307 }
34308 \end_layout
34309
34310 \begin_layout Standard
34311 will be changed to 
34312 \end_layout
34313
34314 \begin_layout Verse
34315
34316 \family typewriter
34317 int f() { 
34318 \newline
34319 \InsetSpace ~
34320 \InsetSpace ~
34321 int i, j; 
34322 \newline
34323 \InsetSpace ~
34324 \InsetSpace ~
34325 i = 10; 
34326 \newline
34327 \InsetSpace ~
34328 \InsetSpace ~
34329 j = 10; 
34330 \newline
34331 \InsetSpace ~
34332 \InsetSpace ~
34333 return 10; 
34334 \newline
34335 }
34336 \end_layout
34337
34338 \begin_layout Standard
34339 Note: the dead stores created by this copy propagation will be eliminated
34340  by dead-code elimination.
34341 \end_layout
34342
34343 \begin_layout Subsection
34344 Loop Optimizations
34345 \begin_inset LatexCommand \index{Loop optimization}
34346
34347 \end_inset
34348
34349
34350 \begin_inset LatexCommand \label{sub:Loop-Optimizations}
34351
34352 \end_inset
34353
34354
34355 \end_layout
34356
34357 \begin_layout Standard
34358 Two types of loop optimizations are done by SDCC 
34359 \emph on
34360 loop invariant
34361 \emph default
34362  lifting and
34363 \emph on
34364  strength reduction
34365 \emph default
34366  of loop induction variables.
34367  In addition to the strength reduction the optimizer marks the induction
34368  variables and the register allocator tries to keep the induction variables
34369  in registers for the duration of the loop.
34370  Because of this preference of the register allocator
34371 \begin_inset LatexCommand \index{Register allocation}
34372
34373 \end_inset
34374
34375 , loop induction optimization causes an increase in register pressure, which
34376  may cause unwanted spilling of other temporary variables into the stack
34377 \begin_inset LatexCommand \index{stack}
34378
34379 \end_inset
34380
34381  / data space.
34382  The compiler will generate a warning message when it is forced to allocate
34383  extra space either on the stack or data space.
34384  If this extra space allocation is undesirable then induction optimization
34385  can be eliminated either for the entire source file (with -
34386 \begin_inset ERT
34387 status collapsed
34388
34389 \begin_layout Standard
34390
34391
34392 \backslash
34393 /
34394 \end_layout
34395
34396 \end_inset
34397
34398 -noinduction option) or for a given function only using #pragma\InsetSpace ~
34399 noinduction
34400 \begin_inset LatexCommand \index{\#pragma noinduction}
34401
34402 \end_inset
34403
34404 .
34405 \newline
34406
34407 \newline
34408 Loop Invariant:
34409 \end_layout
34410
34411 \begin_layout Verse
34412
34413 \family typewriter
34414 for (i = 0 ; i < 100 ; i ++) 
34415 \newline
34416 \InsetSpace ~
34417 \InsetSpace ~
34418 \InsetSpace ~
34419 \InsetSpace ~
34420 f += k + l;
34421 \end_layout
34422
34423 \begin_layout Standard
34424 changed to
34425 \end_layout
34426
34427 \begin_layout Verse
34428
34429 \family typewriter
34430 itemp = k + l; 
34431 \newline
34432 for (i = 0; i < 100; i++) 
34433 \newline
34434 \InsetSpace ~
34435 \InsetSpace ~
34436 \InsetSpace ~
34437 \InsetSpace ~
34438 f += itemp;
34439 \end_layout
34440
34441 \begin_layout Standard
34442 As mentioned previously some loop invariants are not as apparent, all static
34443  address computations are also moved out of the loop.
34444 \newline
34445
34446 \newline
34447 Strength Reduction
34448 \begin_inset LatexCommand \index{Strength reduction}
34449
34450 \end_inset
34451
34452 , this optimization substitutes an expression by a cheaper expression:
34453 \end_layout
34454
34455 \begin_layout Verse
34456
34457 \family typewriter
34458 for (i=0;i < 100; i++)
34459 \newline
34460 \InsetSpace ~
34461 \InsetSpace ~
34462 \InsetSpace ~
34463 \InsetSpace ~
34464 ar[i*5] = i*3;
34465 \end_layout
34466
34467 \begin_layout Standard
34468 changed to
34469 \end_layout
34470
34471 \begin_layout Verse
34472
34473 \family typewriter
34474 itemp1 = 0; 
34475 \newline
34476 itemp2 = 0; 
34477 \newline
34478 for (i=0;i< 100;i++) { 
34479 \newline
34480 \InsetSpace ~
34481 \InsetSpace ~
34482 \InsetSpace ~
34483 \InsetSpace ~
34484 ar[itemp1] = itemp2; 
34485 \newline
34486 \InsetSpace ~
34487 \InsetSpace ~
34488 \InsetSpace ~
34489 \InsetSpace ~
34490 itemp1
34491  += 5; 
34492 \newline
34493 \InsetSpace ~
34494 \InsetSpace ~
34495 \InsetSpace ~
34496 \InsetSpace ~
34497 itemp2 += 3; 
34498 \newline
34499 }
34500 \end_layout
34501
34502 \begin_layout Standard
34503 The more expensive multiplication
34504 \begin_inset LatexCommand \index{Multiplication}
34505
34506 \end_inset
34507
34508  is changed to a less expensive addition.
34509 \end_layout
34510
34511 \begin_layout Subsection
34512 Loop Reversing
34513 \begin_inset LatexCommand \index{Loop reversing}
34514
34515 \end_inset
34516
34517
34518 \end_layout
34519
34520 \begin_layout Standard
34521 This optimization is done to reduce the overhead of checking loop boundaries
34522  for every iteration.
34523  Some simple loops can be reversed and implemented using a 
34524 \begin_inset Quotes eld
34525 \end_inset
34526
34527 decrement and jump if not zero
34528 \begin_inset Quotes erd
34529 \end_inset
34530
34531  instruction.
34532  SDCC checks for the following criterion to determine if a loop is reversible
34533  (note: more sophisticated compilers use data-dependency analysis to make
34534  this determination, SDCC uses a more simple minded analysis).
34535 \end_layout
34536
34537 \begin_layout Itemize
34538 The 'for' loop is of the form 
34539 \newline
34540
34541 \newline
34542
34543 \family typewriter
34544 for(<symbol> = <expression>; <sym> [< | <=] <expression>; [<sym>++ | <sym>
34545  += 1])
34546 \newline
34547 \InsetSpace ~
34548 \InsetSpace ~
34549 \InsetSpace ~
34550 \InsetSpace ~
34551 <for body>
34552 \end_layout
34553
34554 \begin_layout Itemize
34555 The <for body> does not contain 
34556 \begin_inset Quotes eld
34557 \end_inset
34558
34559 continue
34560 \begin_inset Quotes erd
34561 \end_inset
34562
34563  or 'break
34564 \begin_inset Quotes erd
34565 \end_inset
34566
34567 .
34568 \end_layout
34569
34570 \begin_layout Itemize
34571 All goto's are contained within the loop.
34572 \end_layout
34573
34574 \begin_layout Itemize
34575 No function calls within the loop.
34576 \end_layout
34577
34578 \begin_layout Itemize
34579 The loop control variable <sym> is not assigned any value within the loop
34580 \end_layout
34581
34582 \begin_layout Itemize
34583 The loop control variable does NOT participate in any arithmetic operation
34584  within the loop.
34585 \end_layout
34586
34587 \begin_layout Itemize
34588 There are NO switch statements in the loop.
34589 \end_layout
34590
34591 \begin_layout Subsection
34592 Algebraic Simplifications
34593 \end_layout
34594
34595 \begin_layout Standard
34596 SDCC does numerous algebraic simplifications, the following is a small sub-set
34597  of these optimizations.
34598 \end_layout
34599
34600 \begin_layout Verse
34601
34602 \family typewriter
34603 i = j + 0;\InsetSpace ~
34604 \InsetSpace ~
34605 \InsetSpace ~
34606 \InsetSpace ~
34607  /* changed to: */\InsetSpace ~
34608 \InsetSpace ~
34609 \InsetSpace ~
34610 \InsetSpace ~
34611  i = j; 
34612 \newline
34613 i /= 2;\InsetSpace ~
34614 \InsetSpace ~
34615 \InsetSpace ~
34616 \InsetSpace ~
34617 \InsetSpace ~
34618 \InsetSpace ~
34619 \InsetSpace ~
34620  /* changed to: */\InsetSpace ~
34621 \InsetSpace ~
34622 \InsetSpace ~
34623 \InsetSpace ~
34624  i >>= 1; 
34625 \newline
34626 i
34627  = j - j;\InsetSpace ~
34628 \InsetSpace ~
34629 \InsetSpace ~
34630 \InsetSpace ~
34631  /* changed to: */\InsetSpace ~
34632 \InsetSpace ~
34633 \InsetSpace ~
34634 \InsetSpace ~
34635  i = 0; 
34636 \newline
34637 i = j / 1;\InsetSpace ~
34638 \InsetSpace ~
34639 \InsetSpace ~
34640 \InsetSpace ~
34641  /* changed to: */\InsetSpace ~
34642 \InsetSpace ~
34643 \InsetSpace ~
34644 \InsetSpace ~
34645  i = j;
34646 \end_layout
34647
34648 \begin_layout Standard
34649 Note the subexpressions
34650 \begin_inset LatexCommand \index{Subexpression}
34651
34652 \end_inset
34653
34654  given above are generally introduced by macro expansions or as a result
34655  of copy/constant propagation.
34656 \end_layout
34657
34658 \begin_layout Subsection
34659 'switch' Statements
34660 \begin_inset LatexCommand \label{sub:'switch'-Statements}
34661
34662 \end_inset
34663
34664
34665 \begin_inset LatexCommand \index{switch statement}
34666
34667 \end_inset
34668
34669
34670 \end_layout
34671
34672 \begin_layout Standard
34673 SDCC can optimize switch statements to jump tables
34674 \begin_inset LatexCommand \index{jump tables}
34675
34676 \end_inset
34677
34678 .
34679  It makes the decision based on an estimate of the generated code size.
34680  SDCC is quite liberal in the requirements for jump table generation: 
34681 \end_layout
34682
34683 \begin_layout Itemize
34684 The labels need not be in order, and the starting number need not be one
34685  or zero, the case labels are in numerical sequence or not too many case
34686  labels are missing.
34687 \end_layout
34688
34689 \begin_deeper
34690 \begin_layout Verse
34691
34692 \family typewriter
34693 switch(i) {\InsetSpace ~
34694 \InsetSpace ~
34695 \InsetSpace ~
34696 \InsetSpace ~
34697 \InsetSpace ~
34698 \InsetSpace ~
34699 \InsetSpace ~
34700 \InsetSpace ~
34701 \InsetSpace ~
34702 \InsetSpace ~
34703 \InsetSpace ~
34704 \InsetSpace ~
34705 \InsetSpace ~
34706 \InsetSpace ~
34707 \InsetSpace ~
34708 \InsetSpace ~
34709 \InsetSpace ~
34710 \InsetSpace ~
34711 \InsetSpace ~
34712 \InsetSpace ~
34713 \InsetSpace ~
34714 \InsetSpace ~
34715 \InsetSpace ~
34716 \InsetSpace ~
34717 \InsetSpace ~
34718 \InsetSpace ~
34719 switch (i) { 
34720 \newline
34721 \InsetSpace ~
34722 \InsetSpace ~
34723 \InsetSpace ~
34724 case 4: ...\InsetSpace ~
34725 \InsetSpace ~
34726 \InsetSpace ~
34727 \InsetSpace ~
34728 \InsetSpace ~
34729 \InsetSpace ~
34730 \InsetSpace ~
34731 \InsetSpace ~
34732 \InsetSpace ~
34733 \InsetSpace ~
34734 \InsetSpace ~
34735 \InsetSpace ~
34736 \InsetSpace ~
34737 \InsetSpace ~
34738 \InsetSpace ~
34739 \InsetSpace ~
34740 \InsetSpace ~
34741 \InsetSpace ~
34742 \InsetSpace ~
34743 \InsetSpace ~
34744 \InsetSpace ~
34745 \InsetSpace ~
34746 \InsetSpace ~
34747 \InsetSpace ~
34748 \InsetSpace ~
34749 \InsetSpace ~
34750 case 0: ...
34751  
34752 \newline
34753 \InsetSpace ~
34754 \InsetSpace ~
34755 \InsetSpace ~
34756 case 5: ...\InsetSpace ~
34757 \InsetSpace ~
34758 \InsetSpace ~
34759 \InsetSpace ~
34760 \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 case 1: ...
34783  
34784 \newline
34785 \InsetSpace ~
34786 \InsetSpace ~
34787 \InsetSpace ~
34788 case 3: ...\InsetSpace ~
34789 \InsetSpace ~
34790 \InsetSpace ~
34791 \InsetSpace ~
34792 \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
34815 \newline
34816 \InsetSpace ~
34817 \InsetSpace ~
34818 \InsetSpace ~
34819 case 6: ...\InsetSpace ~
34820 \InsetSpace ~
34821 \InsetSpace ~
34822 \InsetSpace ~
34823 \InsetSpace ~
34824 \InsetSpace ~
34825 \InsetSpace ~
34826 \InsetSpace ~
34827 \InsetSpace ~
34828 \InsetSpace ~
34829 \InsetSpace ~
34830 \InsetSpace ~
34831 \InsetSpace ~
34832 \InsetSpace ~
34833 \InsetSpace ~
34834 \InsetSpace ~
34835 \InsetSpace ~
34836 \InsetSpace ~
34837 \InsetSpace ~
34838 \InsetSpace ~
34839 \InsetSpace ~
34840 \InsetSpace ~
34841 \InsetSpace ~
34842 \InsetSpace ~
34843 \InsetSpace ~
34844 \InsetSpace ~
34845 case 3: ...
34846  
34847 \newline
34848 \InsetSpace ~
34849 \InsetSpace ~
34850 \InsetSpace ~
34851 case 7: ...\InsetSpace ~
34852 \InsetSpace ~
34853 \InsetSpace ~
34854 \InsetSpace ~
34855 \InsetSpace ~
34856 \InsetSpace ~
34857 \InsetSpace ~
34858 \InsetSpace ~
34859 \InsetSpace ~
34860 \InsetSpace ~
34861 \InsetSpace ~
34862 \InsetSpace ~
34863 \InsetSpace ~
34864 \InsetSpace ~
34865 \InsetSpace ~
34866 \InsetSpace ~
34867 \InsetSpace ~
34868 \InsetSpace ~
34869 \InsetSpace ~
34870 \InsetSpace ~
34871 \InsetSpace ~
34872 \InsetSpace ~
34873 \InsetSpace ~
34874 \InsetSpace ~
34875 \InsetSpace ~
34876 \InsetSpace ~
34877 case 4: ...
34878  
34879 \newline
34880 \InsetSpace ~
34881 \InsetSpace ~
34882 \InsetSpace ~
34883 case 8: ...\InsetSpace ~
34884 \InsetSpace ~
34885 \InsetSpace ~
34886 \InsetSpace ~
34887 \InsetSpace ~
34888 \InsetSpace ~
34889 \InsetSpace ~
34890 \InsetSpace ~
34891 \InsetSpace ~
34892 \InsetSpace ~
34893 \InsetSpace ~
34894 \InsetSpace ~
34895 \InsetSpace ~
34896 \InsetSpace ~
34897 \InsetSpace ~
34898 \InsetSpace ~
34899 \InsetSpace ~
34900 \InsetSpace ~
34901 \InsetSpace ~
34902 \InsetSpace ~
34903 \InsetSpace ~
34904 \InsetSpace ~
34905 \InsetSpace ~
34906 \InsetSpace ~
34907 \InsetSpace ~
34908 \InsetSpace ~
34909 case 5: ...
34910  
34911 \newline
34912 \InsetSpace ~
34913 \InsetSpace ~
34914 \InsetSpace ~
34915 case 9: ...\InsetSpace ~
34916 \InsetSpace ~
34917 \InsetSpace ~
34918 \InsetSpace ~
34919 \InsetSpace ~
34920 \InsetSpace ~
34921 \InsetSpace ~
34922 \InsetSpace ~
34923 \InsetSpace ~
34924 \InsetSpace ~
34925 \InsetSpace ~
34926 \InsetSpace ~
34927 \InsetSpace ~
34928 \InsetSpace ~
34929 \InsetSpace ~
34930 \InsetSpace ~
34931 \InsetSpace ~
34932 \InsetSpace ~
34933 \InsetSpace ~
34934 \InsetSpace ~
34935 \InsetSpace ~
34936 \InsetSpace ~
34937 \InsetSpace ~
34938 \InsetSpace ~
34939 \InsetSpace ~
34940 \InsetSpace ~
34941 case 6: ...
34942  
34943 \newline
34944 \InsetSpace ~
34945 \InsetSpace ~
34946 \InsetSpace ~
34947 case 10: ...\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 case 7: ...
34973  
34974 \newline
34975 \InsetSpace ~
34976 \InsetSpace ~
34977 \InsetSpace ~
34978 case 11: ...\InsetSpace ~
34979 \InsetSpace ~
34980 \InsetSpace ~
34981 \InsetSpace ~
34982 \InsetSpace ~
34983 \InsetSpace ~
34984 \InsetSpace ~
34985 \InsetSpace ~
34986 \InsetSpace ~
34987 \InsetSpace ~
34988 \InsetSpace ~
34989 \InsetSpace ~
34990 \InsetSpace ~
34991 \InsetSpace ~
34992 \InsetSpace ~
34993 \InsetSpace ~
34994 \InsetSpace ~
34995 \InsetSpace ~
34996 \InsetSpace ~
34997 \InsetSpace ~
34998 \InsetSpace ~
34999 \InsetSpace ~
35000 \InsetSpace ~
35001 \InsetSpace ~
35002 \InsetSpace ~
35003 case 8: ...
35004  
35005 \newline
35006 }\InsetSpace ~
35007 \InsetSpace ~
35008 \InsetSpace ~
35009 \InsetSpace ~
35010 \InsetSpace ~
35011 \InsetSpace ~
35012 \InsetSpace ~
35013 \InsetSpace ~
35014 \InsetSpace ~
35015 \InsetSpace ~
35016 \InsetSpace ~
35017 \InsetSpace ~
35018 \InsetSpace ~
35019 \InsetSpace ~
35020 \InsetSpace ~
35021 \InsetSpace ~
35022 \InsetSpace ~
35023 \InsetSpace ~
35024 \InsetSpace ~
35025 \InsetSpace ~
35026 \InsetSpace ~
35027 \InsetSpace ~
35028 \InsetSpace ~
35029 \InsetSpace ~
35030 \InsetSpace ~
35031 \InsetSpace ~
35032 \InsetSpace ~
35033 \InsetSpace ~
35034 \InsetSpace ~
35035 \InsetSpace ~
35036 \InsetSpace ~
35037 \InsetSpace ~
35038 \InsetSpace ~
35039 \InsetSpace ~
35040 \InsetSpace ~
35041 \InsetSpace ~
35042 }
35043 \end_layout
35044
35045 \begin_layout Standard
35046 Both the above switch statements will be implemented using a jump-table.
35047  The example to the right side is slightly more efficient as the check for
35048  the lower boundary of the jump-table is not needed.
35049 \end_layout
35050
35051 \end_deeper
35052 \begin_layout Itemize
35053 The number of case labels is not larger than supported by the target architectur
35054 e.
35055 \end_layout
35056
35057 \begin_layout Itemize
35058 If the case labels are not in numerical sequence ('gaps' between cases)
35059  SDCC checks whether a jump table with additionally inserted dummy cases
35060  is still attractive.
35061  
35062 \end_layout
35063
35064 \begin_layout Itemize
35065 If the starting number is not zero and a check for the lower boundary of
35066  the jump-table can thus be eliminated SDCC might insert dummy cases 0,
35067  ...
35068  .
35069 \end_layout
35070
35071 \begin_layout Standard
35072 Switch statements which have large gaps in the numeric sequence or those
35073  that have too many case labels can be split into more than one switch statement
35074  for efficient code generation, e.g.:
35075 \end_layout
35076
35077 \begin_layout Verse
35078
35079 \family typewriter
35080 switch (i) { 
35081 \newline
35082 \InsetSpace ~
35083 \InsetSpace ~
35084 case 1: ...
35085  
35086 \newline
35087 \InsetSpace ~
35088 \InsetSpace ~
35089 case 2: ...
35090  
35091 \newline
35092 \InsetSpace ~
35093 \InsetSpace ~
35094 case 3: ...
35095  
35096 \newline
35097 \InsetSpace ~
35098 \InsetSpace ~
35099 case 4: ...
35100  
35101 \newline
35102 \InsetSpace ~
35103 \InsetSpace ~
35104 case 5: ...
35105  
35106 \newline
35107 \InsetSpace ~
35108 \InsetSpace ~
35109 case 6: ...
35110  
35111 \newline
35112 \InsetSpace ~
35113 \InsetSpace ~
35114 case 7: ...
35115  
35116 \newline
35117 \InsetSpace ~
35118 \InsetSpace ~
35119 case 101: ...
35120  
35121 \newline
35122 \InsetSpace ~
35123 \InsetSpace ~
35124 case 102: ...
35125  
35126 \newline
35127 \InsetSpace ~
35128 \InsetSpace ~
35129 case 103: ...
35130  
35131 \newline
35132 \InsetSpace ~
35133 \InsetSpace ~
35134 case 104: ...
35135  
35136 \newline
35137 \InsetSpace ~
35138 \InsetSpace ~
35139 case 105: ...
35140  
35141 \newline
35142 \InsetSpace ~
35143 \InsetSpace ~
35144 case 106: ...
35145  
35146 \newline
35147 \InsetSpace ~
35148 \InsetSpace ~
35149 case 107: ...
35150  
35151 \newline
35152 }
35153 \end_layout
35154
35155 \begin_layout Standard
35156 If the above switch statement is broken down into two switch statements
35157 \end_layout
35158
35159 \begin_layout Verse
35160
35161 \family typewriter
35162 switch (i) { 
35163 \newline
35164 \InsetSpace ~
35165 \InsetSpace ~
35166 case 1: ...
35167  
35168 \newline
35169 \InsetSpace ~
35170 \InsetSpace ~
35171 case 2: ...
35172  
35173 \newline
35174 \InsetSpace ~
35175 \InsetSpace ~
35176 case 3: ...
35177  
35178 \newline
35179 \InsetSpace ~
35180 \InsetSpace ~
35181 case 4: ...
35182  
35183 \newline
35184 \InsetSpace ~
35185 \InsetSpace ~
35186 case 5: ...
35187  
35188 \newline
35189 \InsetSpace ~
35190 \InsetSpace ~
35191 case 6: ...
35192  
35193 \newline
35194 \InsetSpace ~
35195 \InsetSpace ~
35196 case 7: ...
35197  
35198 \newline
35199 }
35200 \end_layout
35201
35202 \begin_layout Standard
35203 and
35204 \end_layout
35205
35206 \begin_layout Verse
35207
35208 \family typewriter
35209 switch (i) { 
35210 \newline
35211 \InsetSpace ~
35212 \InsetSpace ~
35213 case 101: ...
35214  
35215 \newline
35216 \InsetSpace ~
35217 \InsetSpace ~
35218 case 102: ...
35219  
35220 \newline
35221 \InsetSpace ~
35222 \InsetSpace ~
35223 case 103: ...
35224  
35225 \newline
35226 \InsetSpace ~
35227 \InsetSpace ~
35228 case 104: ...
35229  
35230 \newline
35231 \InsetSpace ~
35232 \InsetSpace ~
35233 case 105: ...
35234  
35235 \newline
35236 \InsetSpace ~
35237 \InsetSpace ~
35238 case 106: ...
35239  
35240 \newline
35241 \InsetSpace ~
35242 \InsetSpace ~
35243 case 107: ...
35244  
35245 \newline
35246 }
35247 \end_layout
35248
35249 \begin_layout Standard
35250 then both the switch statements will be implemented using jump-tables whereas
35251  the unmodified switch statement will not be.
35252 \end_layout
35253
35254 \begin_layout Standard
35255 \begin_inset Note Note
35256 status collapsed
35257
35258 \begin_layout Standard
35259 There might be reasons which SDCC cannot know about to either favour or
35260  not favour jump tables.
35261  If the target system has to be as quick for the last switch case as for
35262  the first (pro jump table), or if the switch argument is known to be zero
35263  in the majority of the cases (contra jump table).
35264 \end_layout
35265
35266 \end_inset
35267
35268
35269 \end_layout
35270
35271 \begin_layout Standard
35272 The pragma nojtbound
35273 \begin_inset LatexCommand \index{\#pragma nojtbound}
35274
35275 \end_inset
35276
35277  can be used to turn off checking the 
35278 \emph on
35279 j
35280 \emph default
35281 ump 
35282 \emph on
35283 t
35284 \emph default
35285 able 
35286 \emph on
35287 bound
35288 \emph default
35289 aries.
35290  It has no effect if a default label is supplied.
35291  Use of this pragma is dangerous: if the switch
35292 \begin_inset LatexCommand \index{switch statement}
35293
35294 \end_inset
35295
35296  argument is not matched by a case statement the processor will happily
35297  jump into Nirvana.
35298 \end_layout
35299
35300 \begin_layout Subsection
35301 Bit-shifting Operations
35302 \begin_inset LatexCommand \index{Bit shifting}
35303
35304 \end_inset
35305
35306 .
35307 \end_layout
35308
35309 \begin_layout Standard
35310 Bit shifting is one of the most frequently used operation in embedded programmin
35311 g.
35312  SDCC tries to implement bit-shift operations in the most efficient way
35313  possible, e.g.:
35314 \end_layout
35315
35316 \begin_layout Verse
35317
35318 \family typewriter
35319 unsigned char i;
35320 \newline
35321 ...
35322  
35323 \newline
35324 i >>= 4; 
35325 \newline
35326 ...
35327 \end_layout
35328
35329 \begin_layout Standard
35330 generates the following code:
35331 \end_layout
35332
35333 \begin_layout Verse
35334
35335 \family typewriter
35336 mov\InsetSpace ~
35337  a,_i 
35338 \newline
35339 swap a 
35340 \newline
35341 anl\InsetSpace ~
35342  a,#0x0f 
35343 \newline
35344 mov\InsetSpace ~
35345  _i,a
35346 \end_layout
35347
35348 \begin_layout Standard
35349 In general SDCC will never setup a loop if the shift count is known.
35350  Another example:
35351 \end_layout
35352
35353 \begin_layout Verse
35354
35355 \family typewriter
35356 unsigned int i; 
35357 \newline
35358 ...
35359  
35360 \newline
35361 i >>= 9; 
35362 \newline
35363 ...
35364 \end_layout
35365
35366 \begin_layout Standard
35367 will generate:
35368 \end_layout
35369
35370 \begin_layout Verse
35371
35372 \family typewriter
35373 mov\InsetSpace ~
35374 \InsetSpace ~
35375 a,(_i + 1) 
35376 \newline
35377 mov\InsetSpace ~
35378 \InsetSpace ~
35379 (_i + 1),#0x00 
35380 \newline
35381 clr\InsetSpace ~
35382 \InsetSpace ~
35383
35384 \newline
35385 rrc\InsetSpace ~
35386 \InsetSpace ~
35387
35388 \newline
35389 mov\InsetSpace ~
35390 \InsetSpace ~
35391 _i,a
35392 \end_layout
35393
35394 \begin_layout Subsection
35395 Bit-rotation
35396 \begin_inset LatexCommand \index{Bit rotation}
35397
35398 \end_inset
35399
35400
35401 \end_layout
35402
35403 \begin_layout Standard
35404 A special case of the bit-shift operation is bit rotation
35405 \begin_inset LatexCommand \index{rotating bits}
35406
35407 \end_inset
35408
35409 , SDCC recognizes the following expression to be a left bit-rotation:
35410 \end_layout
35411
35412 \begin_layout Verse
35413
35414 \family typewriter
35415 \series bold
35416 unsigned
35417 \series default
35418 \InsetSpace ~
35419 \InsetSpace ~
35420 char i;\InsetSpace ~
35421 \InsetSpace ~
35422 \InsetSpace ~
35423 \InsetSpace ~
35424 \InsetSpace ~
35425 \InsetSpace ~
35426 \InsetSpace ~
35427 \InsetSpace ~
35428 \InsetSpace ~
35429 \InsetSpace ~
35430 \InsetSpace ~
35431 /* unsigned is needed for rotation */ 
35432 \newline
35433 ...
35434  
35435 \newline
35436 i = ((i << 1) | (i >> 7)); 
35437 \family default
35438
35439 \newline
35440
35441 \family typewriter
35442 ...
35443 \end_layout
35444
35445 \begin_layout Standard
35446 will generate the following code:
35447 \end_layout
35448
35449 \begin_layout Verse
35450
35451 \family typewriter
35452 mov\InsetSpace ~
35453 \InsetSpace ~
35454 a,_i 
35455 \newline
35456 rl\InsetSpace ~
35457 \InsetSpace ~
35458 \InsetSpace ~
35459
35460 \newline
35461 mov\InsetSpace ~
35462 \InsetSpace ~
35463 _i,a
35464 \end_layout
35465
35466 \begin_layout Standard
35467 SDCC uses pattern matching on the parse tree to determine this operation.Variatio
35468 ns of this case will also be recognized as bit-rotation, i.e.: 
35469 \end_layout
35470
35471 \begin_layout Verse
35472
35473 \family typewriter
35474 i = ((i >> 7) | (i << 1)); /* left-bit rotation */
35475 \end_layout
35476
35477 \begin_layout Subsection
35478 Nibble and Byte Swapping
35479 \end_layout
35480
35481 \begin_layout Standard
35482 Other special cases of the bit-shift operations are nibble or byte swapping
35483 \begin_inset LatexCommand \index{swapping nibbles/bytes}
35484
35485 \end_inset
35486
35487 , SDCC recognizes the following expressions:
35488 \end_layout
35489
35490 \begin_layout Verse
35491
35492 \family typewriter
35493 \series bold
35494 unsigned
35495 \series default
35496 \InsetSpace ~
35497 \InsetSpace ~
35498 char i; 
35499 \newline
35500
35501 \series bold
35502 unsigned
35503 \series default
35504 \InsetSpace ~
35505 \InsetSpace ~
35506 int j; 
35507 \newline
35508 ...
35509  
35510 \newline
35511 i = ((i << 4) | (i >> 4)); 
35512 \family default
35513
35514 \newline
35515
35516 \family typewriter
35517 j = ((j << 8) | (j >> 8)); 
35518 \end_layout
35519
35520 \begin_layout Standard
35521 and generates a swap instruction for the nibble swapping
35522 \begin_inset LatexCommand \index{Nibble swapping}
35523
35524 \end_inset
35525
35526  or move instructions for the byte swapping
35527 \begin_inset LatexCommand \index{Byte swapping}
35528
35529 \end_inset
35530
35531 .
35532  The 
35533 \begin_inset Quotes sld
35534 \end_inset
35535
35536 j
35537 \begin_inset Quotes srd
35538 \end_inset
35539
35540  example can be used to convert from little to big-endian or vice versa.
35541  If you want to change the endianness of a 
35542 \emph on
35543 signed
35544 \emph default
35545  integer you have to cast to 
35546 \family typewriter
35547 (unsigned int)
35548 \family default
35549  first.
35550 \end_layout
35551
35552 \begin_layout Standard
35553 Note that SDCC stores numbers in little-endian
35554 \begin_inset Foot
35555 status open
35556
35557 \begin_layout Standard
35558 Usually 8-bit processors don't care much about endianness.
35559  This is not the case for the standard 8051 which only has an instruction
35560  to increment its 
35561 \emph on
35562 dptr
35563 \emph default
35564
35565 \begin_inset LatexCommand \index{DPTR}
35566
35567 \end_inset
35568
35569 -datapointer
35570 \emph on
35571  
35572 \emph default
35573 so little-endian is the more efficient byte order.
35574 \end_layout
35575
35576 \end_inset
35577
35578
35579 \begin_inset LatexCommand \index{little-endian}
35580
35581 \end_inset
35582
35583
35584 \begin_inset LatexCommand \index{Endianness}
35585
35586 \end_inset
35587
35588  format (i.e.
35589  lowest order first).
35590 \end_layout
35591
35592 \begin_layout Subsection
35593 Highest Order Bit
35594 \begin_inset LatexCommand \index{Highest Order Bit}
35595
35596 \end_inset
35597
35598  / Any Order Bit
35599 \begin_inset LatexCommand \index{Any Order Bit}
35600
35601 \end_inset
35602
35603
35604 \end_layout
35605
35606 \begin_layout Standard
35607 It is frequently required to obtain the highest order bit of an integral
35608  type (long, int, short or char types).
35609  Also obtaining any other order bit is not uncommon.
35610  SDCC recognizes the following expressions to yield the highest order bit
35611  and generates optimized code for it, e.g.:
35612 \end_layout
35613
35614 \begin_layout Verse
35615
35616 \family typewriter
35617 unsigned int gint; 
35618 \newline
35619
35620 \newline
35621 foo () { 
35622 \newline
35623 \InsetSpace ~
35624 \InsetSpace ~
35625 unsigned char hob1, aob1; 
35626 \newline
35627 \InsetSpace ~
35628 \InsetSpace ~
35629 bit hob2, hob3, aob2,
35630  aob3; 
35631 \newline
35632 \InsetSpace ~
35633 \InsetSpace ~
35634 ...
35635  
35636 \newline
35637 \InsetSpace ~
35638 \InsetSpace ~
35639 hob1 = (gint >> 15) & 1; 
35640 \newline
35641 \InsetSpace ~
35642 \InsetSpace ~
35643 hob2 = (gint >> 15) & 1; 
35644 \newline
35645 \InsetSpace ~
35646 \InsetSpace ~
35647 hob3 = gint & 0x8000;
35648  
35649 \newline
35650 \InsetSpace ~
35651 \InsetSpace ~
35652 aob1 = (gint >> 9) & 1; 
35653 \newline
35654 \InsetSpace ~
35655 \InsetSpace ~
35656 aob2 = (gint >> 8) & 1; 
35657 \newline
35658 \InsetSpace ~
35659 \InsetSpace ~
35660 aob3 = gint & 0x0800; 
35661 \newline
35662 \InsetSpace ~
35663 \InsetSpace ~
35664 ..
35665  
35666 \newline
35667 }
35668 \end_layout
35669
35670 \begin_layout Standard
35671 will generate the following code:
35672 \end_layout
35673
35674 \begin_layout Verse
35675
35676 \family typewriter
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 \InsetSpace ~
35692 \InsetSpace ~
35693 \InsetSpace ~
35694 \InsetSpace ~
35695 \InsetSpace ~
35696 \InsetSpace ~
35697 \InsetSpace ~
35698 \InsetSpace ~
35699 \InsetSpace ~
35700 \InsetSpace ~
35701 \InsetSpace ~
35702  61 ;\InsetSpace ~
35703  hob.c 7 
35704 \newline
35705 000A E5*01\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 \InsetSpace ~
35720  62\InsetSpace ~
35721 \InsetSpace ~
35722 \InsetSpace ~
35723 \InsetSpace ~
35724 \InsetSpace ~
35725 \InsetSpace ~
35726 \InsetSpace ~
35727 \InsetSpace ~
35728  mov\InsetSpace ~
35729 \InsetSpace ~
35730  a,(_gint + 1) 
35731 \newline
35732 000C 23\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 \InsetSpace ~
35748 \InsetSpace ~
35749 \InsetSpace ~
35750  63\InsetSpace ~
35751 \InsetSpace ~
35752 \InsetSpace ~
35753 \InsetSpace ~
35754 \InsetSpace ~
35755 \InsetSpace ~
35756 \InsetSpace ~
35757 \InsetSpace ~
35758  rl\InsetSpace ~
35759 \InsetSpace ~
35760 \InsetSpace ~
35761  a 
35762 \newline
35763 000D 54 01\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
35779  64\InsetSpace ~
35780 \InsetSpace ~
35781 \InsetSpace ~
35782 \InsetSpace ~
35783 \InsetSpace ~
35784 \InsetSpace ~
35785 \InsetSpace ~
35786 \InsetSpace ~
35787  anl\InsetSpace ~
35788 \InsetSpace ~
35789  a,#0x01 
35790 \newline
35791 000F F5*02\InsetSpace ~
35792 \InsetSpace ~
35793 \InsetSpace ~
35794 \InsetSpace ~
35795 \InsetSpace ~
35796 \InsetSpace ~
35797 \InsetSpace ~
35798 \InsetSpace ~
35799 \InsetSpace ~
35800 \InsetSpace ~
35801 \InsetSpace ~
35802 \InsetSpace ~
35803 \InsetSpace ~
35804 \InsetSpace ~
35805 \InsetSpace ~
35806  65\InsetSpace ~
35807 \InsetSpace ~
35808 \InsetSpace ~
35809 \InsetSpace ~
35810 \InsetSpace ~
35811 \InsetSpace ~
35812 \InsetSpace ~
35813 \InsetSpace ~
35814  mov\InsetSpace ~
35815 \InsetSpace ~
35816  _foo_hob1_1_1,a 
35817 \newline
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 \InsetSpace ~
35834 \InsetSpace ~
35835 \InsetSpace ~
35836 \InsetSpace ~
35837 \InsetSpace ~
35838 \InsetSpace ~
35839 \InsetSpace ~
35840 \InsetSpace ~
35841 \InsetSpace ~
35842 \InsetSpace ~
35843  66 ;\InsetSpace ~
35844  hob.c 8 
35845 \newline
35846 0011 E5*01\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 \InsetSpace ~
35861
35862  67\InsetSpace ~
35863 \InsetSpace ~
35864 \InsetSpace ~
35865 \InsetSpace ~
35866 \InsetSpace ~
35867 \InsetSpace ~
35868 \InsetSpace ~
35869 \InsetSpace ~
35870  mov\InsetSpace ~
35871 \InsetSpace ~
35872  a,(_gint + 1) 
35873 \newline
35874 0013 33\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  68\InsetSpace ~
35893 \InsetSpace ~
35894 \InsetSpace ~
35895 \InsetSpace ~
35896 \InsetSpace ~
35897 \InsetSpace ~
35898 \InsetSpace ~
35899 \InsetSpace ~
35900  rlc\InsetSpace ~
35901 \InsetSpace ~
35902  a 
35903 \newline
35904 0014 92*00\InsetSpace ~
35905 \InsetSpace ~
35906 \InsetSpace ~
35907 \InsetSpace ~
35908 \InsetSpace ~
35909 \InsetSpace ~
35910 \InsetSpace ~
35911 \InsetSpace ~
35912 \InsetSpace ~
35913 \InsetSpace ~
35914 \InsetSpace ~
35915 \InsetSpace ~
35916 \InsetSpace ~
35917 \InsetSpace ~
35918 \InsetSpace ~
35919  69\InsetSpace ~
35920 \InsetSpace ~
35921 \InsetSpace ~
35922 \InsetSpace ~
35923 \InsetSpace ~
35924 \InsetSpace ~
35925 \InsetSpace ~
35926 \InsetSpace ~
35927  mov\InsetSpace ~
35928 \InsetSpace ~
35929  _foo_hob2_1_1,c
35930  
35931 \newline
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 \InsetSpace ~
35947 \InsetSpace ~
35948 \InsetSpace ~
35949 \InsetSpace ~
35950 \InsetSpace ~
35951 \InsetSpace ~
35952 \InsetSpace ~
35953 \InsetSpace ~
35954 \InsetSpace ~
35955 \InsetSpace ~
35956 \InsetSpace ~
35957  66 ;\InsetSpace ~
35958  hob.c 9 
35959 \newline
35960 0016 E5*01\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 \InsetSpace ~
35974 \InsetSpace ~
35975  67\InsetSpace ~
35976 \InsetSpace ~
35977 \InsetSpace ~
35978 \InsetSpace ~
35979 \InsetSpace ~
35980 \InsetSpace ~
35981 \InsetSpace ~
35982 \InsetSpace ~
35983  mov\InsetSpace ~
35984 \InsetSpace ~
35985  a,(_gint + 1) 
35986 \newline
35987 0018 33\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  68\InsetSpace ~
36006 \InsetSpace ~
36007 \InsetSpace ~
36008 \InsetSpace ~
36009 \InsetSpace ~
36010 \InsetSpace ~
36011 \InsetSpace ~
36012 \InsetSpace ~
36013  rlc\InsetSpace ~
36014 \InsetSpace ~
36015  a 
36016 \newline
36017 0019 92*01\InsetSpace ~
36018 \InsetSpace ~
36019 \InsetSpace ~
36020 \InsetSpace ~
36021 \InsetSpace ~
36022 \InsetSpace ~
36023 \InsetSpace ~
36024 \InsetSpace ~
36025 \InsetSpace ~
36026 \InsetSpace ~
36027 \InsetSpace ~
36028 \InsetSpace ~
36029 \InsetSpace ~
36030 \InsetSpace ~
36031 \InsetSpace ~
36032
36033  69\InsetSpace ~
36034 \InsetSpace ~
36035 \InsetSpace ~
36036 \InsetSpace ~
36037 \InsetSpace ~
36038 \InsetSpace ~
36039 \InsetSpace ~
36040 \InsetSpace ~
36041  mov\InsetSpace ~
36042 \InsetSpace ~
36043  _foo_hob3_1_1,c 
36044 \newline
36045 \InsetSpace ~
36046 \InsetSpace ~
36047 \InsetSpace ~
36048 \InsetSpace ~
36049 \InsetSpace ~
36050 \InsetSpace ~
36051 \InsetSpace ~
36052 \InsetSpace ~
36053 \InsetSpace ~
36054 \InsetSpace ~
36055 \InsetSpace ~
36056 \InsetSpace ~
36057 \InsetSpace ~
36058 \InsetSpace ~
36059 \InsetSpace ~
36060 \InsetSpace ~
36061 \InsetSpace ~
36062 \InsetSpace ~
36063 \InsetSpace ~
36064 \InsetSpace ~
36065 \InsetSpace ~
36066 \InsetSpace ~
36067 \InsetSpace ~
36068 \InsetSpace ~
36069 \InsetSpace ~
36070  70 ;\InsetSpace ~
36071  hob.c 10 
36072 \newline
36073 001B E5*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  71\InsetSpace ~
36089 \InsetSpace ~
36090 \InsetSpace ~
36091 \InsetSpace ~
36092 \InsetSpace ~
36093 \InsetSpace ~
36094 \InsetSpace ~
36095 \InsetSpace ~
36096  mov\InsetSpace ~
36097 \InsetSpace ~
36098  a,(_gint + 1) 
36099 \newline
36100 001D
36101  03\InsetSpace ~
36102 \InsetSpace ~
36103 \InsetSpace ~
36104 \InsetSpace ~
36105 \InsetSpace ~
36106 \InsetSpace ~
36107 \InsetSpace ~
36108 \InsetSpace ~
36109 \InsetSpace ~
36110 \InsetSpace ~
36111 \InsetSpace ~
36112 \InsetSpace ~
36113 \InsetSpace ~
36114 \InsetSpace ~
36115 \InsetSpace ~
36116 \InsetSpace ~
36117 \InsetSpace ~
36118 \InsetSpace ~
36119  72\InsetSpace ~
36120 \InsetSpace ~
36121 \InsetSpace ~
36122 \InsetSpace ~
36123 \InsetSpace ~
36124 \InsetSpace ~
36125 \InsetSpace ~
36126 \InsetSpace ~
36127  rr\InsetSpace ~
36128 \InsetSpace ~
36129 \InsetSpace ~
36130  a 
36131 \newline
36132 001E 54 01\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  73\InsetSpace ~
36148 \InsetSpace ~
36149 \InsetSpace ~
36150 \InsetSpace ~
36151 \InsetSpace ~
36152 \InsetSpace ~
36153 \InsetSpace ~
36154 \InsetSpace ~
36155  anl\InsetSpace ~
36156 \InsetSpace ~
36157  a,#0x01 
36158 \newline
36159 0020 F5*03\InsetSpace ~
36160 \InsetSpace ~
36161 \InsetSpace ~
36162 \InsetSpace ~
36163 \InsetSpace ~
36164 \InsetSpace ~
36165 \InsetSpace ~
36166 \InsetSpace ~
36167 \InsetSpace ~
36168 \InsetSpace ~
36169 \InsetSpace ~
36170 \InsetSpace ~
36171 \InsetSpace ~
36172 \InsetSpace ~
36173 \InsetSpace ~
36174  74\InsetSpace ~
36175 \InsetSpace ~
36176 \InsetSpace ~
36177 \InsetSpace ~
36178 \InsetSpace ~
36179 \InsetSpace ~
36180 \InsetSpace ~
36181 \InsetSpace ~
36182  mov\InsetSpace ~
36183 \InsetSpace ~
36184  _foo_aob1_1_1,a
36185  
36186 \newline
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 \InsetSpace ~
36202 \InsetSpace ~
36203 \InsetSpace ~
36204 \InsetSpace ~
36205 \InsetSpace ~
36206 \InsetSpace ~
36207 \InsetSpace ~
36208 \InsetSpace ~
36209 \InsetSpace ~
36210 \InsetSpace ~
36211 \InsetSpace ~
36212  75 ;\InsetSpace ~
36213  hob.c 11 
36214 \newline
36215 0022 E5*01\InsetSpace ~
36216 \InsetSpace ~
36217 \InsetSpace ~
36218 \InsetSpace ~
36219 \InsetSpace ~
36220 \InsetSpace ~
36221 \InsetSpace ~
36222 \InsetSpace ~
36223 \InsetSpace ~
36224 \InsetSpace ~
36225 \InsetSpace ~
36226 \InsetSpace ~
36227 \InsetSpace ~
36228 \InsetSpace ~
36229 \InsetSpace ~
36230  76\InsetSpace ~
36231 \InsetSpace ~
36232 \InsetSpace ~
36233 \InsetSpace ~
36234 \InsetSpace ~
36235 \InsetSpace ~
36236 \InsetSpace ~
36237 \InsetSpace ~
36238  mov\InsetSpace ~
36239 \InsetSpace ~
36240  a,(_gint + 1) 
36241 \newline
36242 0024 13\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  77\InsetSpace ~
36261 \InsetSpace ~
36262 \InsetSpace ~
36263 \InsetSpace ~
36264 \InsetSpace ~
36265 \InsetSpace ~
36266 \InsetSpace ~
36267 \InsetSpace ~
36268  rrc\InsetSpace ~
36269 \InsetSpace ~
36270  a 
36271 \newline
36272 0025 92*02\InsetSpace ~
36273 \InsetSpace ~
36274 \InsetSpace ~
36275 \InsetSpace ~
36276 \InsetSpace ~
36277 \InsetSpace ~
36278 \InsetSpace ~
36279 \InsetSpace ~
36280 \InsetSpace ~
36281 \InsetSpace ~
36282 \InsetSpace ~
36283 \InsetSpace ~
36284 \InsetSpace ~
36285 \InsetSpace ~
36286 \InsetSpace ~
36287
36288  78\InsetSpace ~
36289 \InsetSpace ~
36290 \InsetSpace ~
36291 \InsetSpace ~
36292 \InsetSpace ~
36293 \InsetSpace ~
36294 \InsetSpace ~
36295 \InsetSpace ~
36296  mov\InsetSpace ~
36297 \InsetSpace ~
36298  _foo_aob2_1_1,c 
36299 \newline
36300 \InsetSpace ~
36301 \InsetSpace ~
36302 \InsetSpace ~
36303 \InsetSpace ~
36304 \InsetSpace ~
36305 \InsetSpace ~
36306 \InsetSpace ~
36307 \InsetSpace ~
36308 \InsetSpace ~
36309 \InsetSpace ~
36310 \InsetSpace ~
36311 \InsetSpace ~
36312 \InsetSpace ~
36313 \InsetSpace ~
36314 \InsetSpace ~
36315 \InsetSpace ~
36316 \InsetSpace ~
36317 \InsetSpace ~
36318 \InsetSpace ~
36319 \InsetSpace ~
36320 \InsetSpace ~
36321 \InsetSpace ~
36322 \InsetSpace ~
36323 \InsetSpace ~
36324 \InsetSpace ~
36325  79 ;\InsetSpace ~
36326  hob.c 12 
36327 \newline
36328 0027 E5*01\InsetSpace ~
36329 \InsetSpace ~
36330 \InsetSpace ~
36331 \InsetSpace ~
36332 \InsetSpace ~
36333 \InsetSpace ~
36334 \InsetSpace ~
36335 \InsetSpace ~
36336 \InsetSpace ~
36337 \InsetSpace ~
36338 \InsetSpace ~
36339 \InsetSpace ~
36340 \InsetSpace ~
36341 \InsetSpace ~
36342 \InsetSpace ~
36343  80\InsetSpace ~
36344 \InsetSpace ~
36345 \InsetSpace ~
36346 \InsetSpace ~
36347 \InsetSpace ~
36348 \InsetSpace ~
36349 \InsetSpace ~
36350 \InsetSpace ~
36351  mov\InsetSpace ~
36352 \InsetSpace ~
36353  a,(_gint + 1) 
36354 \newline
36355 0029
36356  A2 E3\InsetSpace ~
36357 \InsetSpace ~
36358 \InsetSpace ~
36359 \InsetSpace ~
36360 \InsetSpace ~
36361 \InsetSpace ~
36362 \InsetSpace ~
36363 \InsetSpace ~
36364 \InsetSpace ~
36365 \InsetSpace ~
36366 \InsetSpace ~
36367 \InsetSpace ~
36368 \InsetSpace ~
36369 \InsetSpace ~
36370 \InsetSpace ~
36371  81\InsetSpace ~
36372 \InsetSpace ~
36373 \InsetSpace ~
36374 \InsetSpace ~
36375 \InsetSpace ~
36376 \InsetSpace ~
36377 \InsetSpace ~
36378 \InsetSpace ~
36379  mov\InsetSpace ~
36380 \InsetSpace ~
36381  c,acc[3] 
36382 \newline
36383 002B 92*03\InsetSpace ~
36384 \InsetSpace ~
36385 \InsetSpace ~
36386 \InsetSpace ~
36387 \InsetSpace ~
36388 \InsetSpace ~
36389 \InsetSpace ~
36390 \InsetSpace ~
36391 \InsetSpace ~
36392 \InsetSpace ~
36393 \InsetSpace ~
36394 \InsetSpace ~
36395 \InsetSpace ~
36396 \InsetSpace ~
36397 \InsetSpace ~
36398  82\InsetSpace ~
36399 \InsetSpace ~
36400 \InsetSpace ~
36401 \InsetSpace ~
36402 \InsetSpace ~
36403 \InsetSpace ~
36404 \InsetSpace ~
36405 \InsetSpace ~
36406  mov\InsetSpace ~
36407 \InsetSpace ~
36408  _foo_aob3_1_1,c 
36409 \end_layout
36410
36411 \begin_layout Standard
36412 Other variations of these cases however will 
36413 \emph on
36414 not
36415 \emph default
36416  be recognized.
36417  They are standard C expressions, so I heartily recommend these be the only
36418  way to get the highest order bit, (it is portable).
36419  Of course it will be recognized even if it is embedded in other expressions,
36420  e.g.:
36421 \end_layout
36422
36423 \begin_layout Verse
36424
36425 \family typewriter
36426 xyz = gint + ((gint >> 15) & 1);
36427 \end_layout
36428
36429 \begin_layout Standard
36430 will still be recognized.
36431 \end_layout
36432
36433 \begin_layout Subsection
36434 Higher Order Byte
36435 \begin_inset LatexCommand \index{Higher Order Byte}
36436
36437 \end_inset
36438
36439  / Higher Order Word
36440 \begin_inset LatexCommand \index{Higher Order Word}
36441
36442 \end_inset
36443
36444
36445 \end_layout
36446
36447 \begin_layout Standard
36448 It is also frequently required to obtain a higher order byte or word of
36449  a larger integral type (long, int or short types).
36450  SDCC recognizes the following expressions to yield the higher order byte
36451  or word and generates optimized code for it, e.g.:
36452 \end_layout
36453
36454 \begin_layout Verse
36455
36456 \family typewriter
36457 unsigned int gint; 
36458 \newline
36459 unsigned long int glong; 
36460 \newline
36461
36462 \newline
36463 foo () { 
36464 \newline
36465 \InsetSpace ~
36466 \InsetSpace ~
36467 unsigned char hob1,
36468  hob2; 
36469 \newline
36470 \InsetSpace ~
36471 \InsetSpace ~
36472 unsigned int how1, how2; 
36473 \newline
36474 \InsetSpace ~
36475 \InsetSpace ~
36476 ...
36477  
36478 \newline
36479 \InsetSpace ~
36480 \InsetSpace ~
36481 hob1 = (gint >> 8) & 0xFF; 
36482 \newline
36483 \InsetSpace ~
36484 \InsetSpace ~
36485 hob2 = glong >> 24; 
36486 \newline
36487 \InsetSpace ~
36488 \InsetSpace ~
36489 how1 = (glong >> 16) & 0xFFFF;
36490  
36491 \newline
36492 \InsetSpace ~
36493 \InsetSpace ~
36494 how2 = glong >> 8; 
36495 \newline
36496 \InsetSpace ~
36497 \InsetSpace ~
36498 ..
36499  
36500 \newline
36501 }
36502 \end_layout
36503
36504 \begin_layout Standard
36505 will generate the following code:
36506 \end_layout
36507
36508 \begin_layout Verse
36509
36510 \family typewriter
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 \InsetSpace ~
36530 \InsetSpace ~
36531 \InsetSpace ~
36532 \InsetSpace ~
36533 \InsetSpace ~
36534 \InsetSpace ~
36535 \InsetSpace ~
36536  91 ;\InsetSpace ~
36537  hob.c 15 
36538 \newline
36539 0037 85*01*06\InsetSpace ~
36540 \InsetSpace ~
36541 \InsetSpace ~
36542 \InsetSpace ~
36543 \InsetSpace ~
36544 \InsetSpace ~
36545 \InsetSpace ~
36546 \InsetSpace ~
36547 \InsetSpace ~
36548 \InsetSpace ~
36549 \InsetSpace ~
36550 \InsetSpace ~
36551  92\InsetSpace ~
36552 \InsetSpace ~
36553 \InsetSpace ~
36554 \InsetSpace ~
36555 \InsetSpace ~
36556 \InsetSpace ~
36557 \InsetSpace ~
36558 \InsetSpace ~
36559  mov\InsetSpace ~
36560 \InsetSpace ~
36561  _foo_hob1_1_1,(_gint + 1) 
36562 \newline
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 \InsetSpace ~
36583 \InsetSpace ~
36584 \InsetSpace ~
36585 \InsetSpace ~
36586 \InsetSpace ~
36587 \InsetSpace ~
36588  93 ;\InsetSpace ~
36589  hob.c
36590  16 
36591 \newline
36592 003A 85*05*07\InsetSpace ~
36593 \InsetSpace ~
36594 \InsetSpace ~
36595 \InsetSpace ~
36596 \InsetSpace ~
36597 \InsetSpace ~
36598 \InsetSpace ~
36599 \InsetSpace ~
36600 \InsetSpace ~
36601 \InsetSpace ~
36602 \InsetSpace ~
36603 \InsetSpace ~
36604  94\InsetSpace ~
36605 \InsetSpace ~
36606 \InsetSpace ~
36607 \InsetSpace ~
36608 \InsetSpace ~
36609 \InsetSpace ~
36610 \InsetSpace ~
36611 \InsetSpace ~
36612  mov\InsetSpace ~
36613 \InsetSpace ~
36614  _foo_hob2_1_1,(_glong + 3) 
36615 \newline
36616 \InsetSpace ~
36617 \InsetSpace ~
36618 \InsetSpace ~
36619 \InsetSpace ~
36620 \InsetSpace ~
36621 \InsetSpace ~
36622 \InsetSpace ~
36623 \InsetSpace ~
36624 \InsetSpace ~
36625 \InsetSpace ~
36626 \InsetSpace ~
36627 \InsetSpace ~
36628 \InsetSpace ~
36629 \InsetSpace ~
36630 \InsetSpace ~
36631 \InsetSpace ~
36632 \InsetSpace ~
36633 \InsetSpace ~
36634 \InsetSpace ~
36635 \InsetSpace ~
36636 \InsetSpace ~
36637 \InsetSpace ~
36638 \InsetSpace ~
36639 \InsetSpace ~
36640 \InsetSpace ~
36641  95 ;\InsetSpace ~
36642  hob.c 17 
36643 \newline
36644 003D 85*04*08\InsetSpace ~
36645 \InsetSpace ~
36646 \InsetSpace ~
36647 \InsetSpace ~
36648 \InsetSpace ~
36649 \InsetSpace ~
36650 \InsetSpace ~
36651 \InsetSpace ~
36652 \InsetSpace ~
36653 \InsetSpace ~
36654 \InsetSpace ~
36655 \InsetSpace ~
36656
36657  96\InsetSpace ~
36658 \InsetSpace ~
36659 \InsetSpace ~
36660 \InsetSpace ~
36661 \InsetSpace ~
36662 \InsetSpace ~
36663 \InsetSpace ~
36664 \InsetSpace ~
36665  mov\InsetSpace ~
36666 \InsetSpace ~
36667  _foo_how1_1_1,(_glong + 2) 
36668 \newline
36669 0040 85*05*09\InsetSpace ~
36670 \InsetSpace ~
36671 \InsetSpace ~
36672 \InsetSpace ~
36673 \InsetSpace ~
36674 \InsetSpace ~
36675 \InsetSpace ~
36676 \InsetSpace ~
36677 \InsetSpace ~
36678 \InsetSpace ~
36679 \InsetSpace ~
36680 \InsetSpace ~
36681  97\InsetSpace ~
36682 \InsetSpace ~
36683 \InsetSpace ~
36684 \InsetSpace ~
36685 \InsetSpace ~
36686 \InsetSpace ~
36687 \InsetSpace ~
36688 \InsetSpace ~
36689  mov\InsetSpace ~
36690 \InsetSpace ~
36691  (_foo_how1_1_1 +
36692  1),(_glong + 3) 
36693 \newline
36694 0043 85*03*0A\InsetSpace ~
36695 \InsetSpace ~
36696 \InsetSpace ~
36697 \InsetSpace ~
36698 \InsetSpace ~
36699 \InsetSpace ~
36700 \InsetSpace ~
36701 \InsetSpace ~
36702 \InsetSpace ~
36703 \InsetSpace ~
36704 \InsetSpace ~
36705 \InsetSpace ~
36706  98\InsetSpace ~
36707 \InsetSpace ~
36708 \InsetSpace ~
36709 \InsetSpace ~
36710 \InsetSpace ~
36711 \InsetSpace ~
36712 \InsetSpace ~
36713 \InsetSpace ~
36714  mov\InsetSpace ~
36715 \InsetSpace ~
36716  _foo_how2_1_1,(_glong + 1) 
36717 \newline
36718 0046 85*04*0B\InsetSpace ~
36719 \InsetSpace ~
36720 \InsetSpace ~
36721 \InsetSpace ~
36722 \InsetSpace ~
36723 \InsetSpace ~
36724 \InsetSpace ~
36725 \InsetSpace ~
36726 \InsetSpace ~
36727 \InsetSpace ~
36728 \InsetSpace ~
36729 \InsetSpace ~
36730
36731  99\InsetSpace ~
36732 \InsetSpace ~
36733 \InsetSpace ~
36734 \InsetSpace ~
36735 \InsetSpace ~
36736 \InsetSpace ~
36737 \InsetSpace ~
36738 \InsetSpace ~
36739  mov\InsetSpace ~
36740 \InsetSpace ~
36741  (_foo_how2_1_1 + 1),(_glong + 2) 
36742 \end_layout
36743
36744 \begin_layout Standard
36745 Again, variations of these cases may 
36746 \emph on
36747 not
36748 \emph default
36749  be recognized.
36750  They are standard C expressions, so I heartily recommend these be the only
36751  way to get the higher order byte/word, (it is portable).
36752  Of course it will be recognized even if it is embedded in other expressions,
36753  e.g.:
36754 \end_layout
36755
36756 \begin_layout Verse
36757
36758 \family typewriter
36759 xyz = gint + ((gint >> 8) & 0xFF);
36760 \end_layout
36761
36762 \begin_layout Standard
36763 will still be recognized.
36764 \end_layout
36765
36766 \begin_layout Subsection
36767 Peephole Optimizer
36768 \begin_inset LatexCommand \label{sub:Peephole-Optimizer}
36769
36770 \end_inset
36771
36772
36773 \begin_inset LatexCommand \index{Peephole optimizer}
36774
36775 \end_inset
36776
36777
36778 \end_layout
36779
36780 \begin_layout Standard
36781 The compiler uses a rule based, pattern matching and re-writing mechanism
36782  for peep-hole optimization.
36783  It is inspired by 
36784 \emph on
36785 copt
36786 \emph default
36787  a peep-hole optimizer by Christopher W.
36788  Fraser (cwfraser\InsetSpace ~
36789 @\InsetSpace ~
36790 microsoft.com).
36791  A default set of rules are compiled into the compiler, additional rules
36792  may be added with the 
36793 \emph on
36794 -
36795 \begin_inset ERT
36796 status collapsed
36797
36798 \begin_layout Standard
36799
36800
36801 \backslash
36802 /
36803 \end_layout
36804
36805 \end_inset
36806
36807 -peep-file
36808 \begin_inset LatexCommand \index{-\/-peep-file}
36809
36810 \end_inset
36811
36812  <filename>
36813 \emph default
36814  option.
36815  The rule language is best illustrated with examples.
36816 \end_layout
36817
36818 \begin_layout Verse
36819
36820 \family typewriter
36821 replace { 
36822 \newline
36823 \InsetSpace ~
36824 \InsetSpace ~
36825 mov %1,a 
36826 \newline
36827 \InsetSpace ~
36828 \InsetSpace ~
36829 mov a,%1
36830 \newline
36831 } by {
36832 \newline
36833 \InsetSpace ~
36834 \InsetSpace ~
36835 mov %1,a
36836 \newline
36837 }
36838 \end_layout
36839
36840 \begin_layout Standard
36841 The above rule will change the following assembly
36842 \begin_inset LatexCommand \index{Assembler routines}
36843
36844 \end_inset
36845
36846  sequence:
36847 \end_layout
36848
36849 \begin_layout Verse
36850
36851 \family typewriter
36852 mov r1,a 
36853 \newline
36854 mov a,r1
36855 \end_layout
36856
36857 \begin_layout Standard
36858 to
36859 \end_layout
36860
36861 \begin_layout Verse
36862
36863 \family typewriter
36864 mov r1,a
36865 \end_layout
36866
36867 \begin_layout Standard
36868 Note: All occurrences of a 
36869 \emph on
36870 %n
36871 \emph default
36872  (pattern variable) must denote the same string.
36873  With the above rule, the assembly sequence:
36874 \end_layout
36875
36876 \begin_layout Verse
36877
36878 \family typewriter
36879 mov r1,a 
36880 \newline
36881 mov a,r2
36882 \end_layout
36883
36884 \begin_layout Standard
36885 will remain unmodified.
36886 \newline
36887
36888 \newline
36889 Other special case optimizations may be added by the
36890  user (via 
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 -peep-file option
36906 \emph default
36907 ).
36908  E.g.
36909  some variants of the 8051 MCU
36910 \begin_inset LatexCommand \index{MCS51 variants}
36911
36912 \end_inset
36913
36914  allow only 
36915 \family typewriter
36916 ajmp
36917 \family default
36918  and 
36919 \family typewriter
36920 acall
36921 \family default
36922 .
36923  The following two rules will change all 
36924 \family typewriter
36925 ljmp
36926 \family default
36927  and 
36928 \family typewriter
36929 lcall
36930 \family default
36931  to 
36932 \family typewriter
36933 ajmp
36934 \family default
36935  and 
36936 \family typewriter
36937 acall
36938 \end_layout
36939
36940 \begin_layout Verse
36941
36942 \family typewriter
36943 replace { lcall %1 } by { acall %1 } 
36944 \newline
36945 replace { ljmp %1 } by { ajmp %1 }
36946 \end_layout
36947
36948 \begin_layout Standard
36949 (NOTE: from version 2.7.3 on, you can use option -
36950 \emph on
36951
36952 \begin_inset ERT
36953 status collapsed
36954
36955 \begin_layout Standard
36956
36957
36958 \backslash
36959 /
36960 \end_layout
36961
36962 \end_inset
36963
36964
36965 \emph default
36966 -acall-ajmp
36967 \begin_inset LatexCommand \index{-\/-acall-ajmp}
36968
36969 \end_inset
36970
36971 , which also takes care of aligning the interrupt vectors properly.)
36972 \newline
36973
36974 \end_layout
36975
36976 \begin_layout Standard
36977 The 
36978 \emph on
36979 inline-assembler code
36980 \emph default
36981  is also passed through the peep hole optimizer, thus the peephole optimizer
36982  can also be used as an assembly level macro expander.
36983  The rules themselves are MCU dependent whereas the rule language infra-structur
36984 e is MCU independent.
36985  Peephole optimization rules for other MCU can be easily programmed using
36986  the rule language.
36987 \newline
36988
36989 \newline
36990 The syntax for a rule is as follows:
36991 \end_layout
36992
36993 \begin_layout Verse
36994
36995 \family typewriter
36996 rule := replace [ restart ] '{' <assembly sequence> '
36997 \backslash
36998 n' 
36999 \newline
37000 \InsetSpace ~
37001  \InsetSpace ~
37002  \InsetSpace ~
37003  \InsetSpace ~
37004  \InsetSpace ~
37005  \InsetSpace ~
37006  \InsetSpace ~
37007  \InsetSpace ~
37008  \InsetSpace ~
37009  \InsetSpace ~
37010  \InsetSpace ~
37011  \InsetSpace ~
37012  \InsetSpace ~
37013  \InsetSpace ~
37014  '}' by '{' '
37015 \backslash
37016 n' 
37017 \newline
37018 \InsetSpace ~
37019  \InsetSpace ~
37020  \InsetSpace ~
37021  \InsetSpace ~
37022  \InsetSpace ~
37023  \InsetSpace ~
37024  \InsetSpace ~
37025  \InsetSpace ~
37026  \InsetSpace ~
37027  \InsetSpace ~
37028  \InsetSpace ~
37029  \InsetSpace ~
37030  \InsetSpace ~
37031  \InsetSpace ~
37032  \InsetSpace ~
37033  \InsetSpace ~
37034  <assembly sequence> '
37035 \backslash
37036 n' 
37037 \newline
37038 \InsetSpace ~
37039  \InsetSpace ~
37040  \InsetSpace ~
37041  \InsetSpace ~
37042  \InsetSpace ~
37043  \InsetSpace ~
37044  \InsetSpace ~
37045  \InsetSpace ~
37046  \InsetSpace ~
37047  \InsetSpace ~
37048  \InsetSpace ~
37049  \InsetSpace ~
37050  \InsetSpace ~
37051  \InsetSpace ~
37052  '}' [if <functionName> ] '
37053 \backslash
37054 n' 
37055 \end_layout
37056
37057 \begin_layout Standard
37058 <assembly sequence> := assembly instruction (each instruction including
37059  labels must be on a separate line).
37060 \newline
37061
37062 \newline
37063 The optimizer will apply to the rules
37064  one by one from the top in the sequence of their appearance, it will terminate
37065  when all rules are exhausted.
37066  If the 'restart' option is specified, then the optimizer will start matching
37067  the rules again from the top, this option for a rule is expensive (performance)
37068 , it is intended to be used in situations where a transformation will trigger
37069  the same rule again.
37070  An example of this (not a good one, it has side effects) is the following
37071  rule:
37072 \end_layout
37073
37074 \begin_layout Verse
37075
37076 \family typewriter
37077 replace restart { 
37078 \newline
37079 \InsetSpace ~
37080 \InsetSpace ~
37081 pop %1 
37082 \newline
37083 \InsetSpace ~
37084 \InsetSpace ~
37085 push %1 } by { 
37086 \newline
37087 \InsetSpace ~
37088 \InsetSpace ~
37089 ; nop 
37090 \newline
37091 }
37092 \end_layout
37093
37094 \begin_layout Standard
37095 Note that the replace pattern cannot be a blank, but can be a comment line.
37096  Without the 'restart' option only the innermost 'pop' 'push' pair would
37097  be eliminated, i.e.:
37098 \end_layout
37099
37100 \begin_layout Verse
37101
37102 \family typewriter
37103 pop ar1 
37104 \newline
37105 pop ar2 
37106 \newline
37107 push ar2 
37108 \newline
37109 push ar1
37110 \end_layout
37111
37112 \begin_layout Standard
37113 would result in:
37114 \end_layout
37115
37116 \begin_layout Verse
37117
37118 \family typewriter
37119 pop ar1 
37120 \newline
37121 ; nop 
37122 \newline
37123 push ar1
37124 \end_layout
37125
37126 \begin_layout Standard
37127
37128 \emph on
37129 with
37130 \emph default
37131  the restart option the rule will be applied again to the resulting code
37132  and then all the pop-push pairs will be eliminated to yield:
37133 \end_layout
37134
37135 \begin_layout Verse
37136
37137 \family typewriter
37138 ; nop 
37139 \newline
37140 ; nop
37141 \end_layout
37142
37143 \begin_layout Standard
37144 A conditional function can be attached to a rule.
37145  Attaching rules are somewhat more involved, let me illustrate this with
37146  an example.
37147 \end_layout
37148
37149 \begin_layout Verse
37150
37151 \family typewriter
37152 replace { 
37153 \newline
37154 \InsetSpace ~
37155  \InsetSpace ~
37156  \InsetSpace ~
37157 ljmp %5 
37158 \newline
37159 %2:
37160 \newline
37161 } by { 
37162 \newline
37163 \InsetSpace ~
37164  \InsetSpace ~
37165  \InsetSpace ~
37166 sjmp %5 
37167 \newline
37168 %2:
37169 \newline
37170 } if labelInRange
37171 \end_layout
37172
37173 \begin_layout Standard
37174 The optimizer does a look-up of a function name table defined in function
37175  
37176 \emph on
37177 callFuncByName
37178 \emph default
37179  in the source file SDCCpeeph.c, with the name 
37180 \emph on
37181 labelInRange
37182 \emph default
37183 .
37184  If it finds a corresponding entry the function is called.
37185  Note there can be no parameters specified for these functions, in this
37186  case the use of 
37187 \emph on
37188 %5
37189 \emph default
37190  is crucial, since the function 
37191 \emph on
37192 labelInRange
37193 \emph default
37194  expects to find the label in that particular variable (the hash table containin
37195 g the variable bindings is passed as a parameter).
37196  If you want to code more such functions, take a close look at the function
37197  labelInRange and the calling mechanism in source file SDCCpeeph.c.
37198  Currently implemented are 
37199 \emph on
37200 labelInRange, labelRefCount, labelIsReturnOnly, operandsNotSame, xramMovcOption,
37201  24bitMode, portIsDS390, 24bitModeAndPortDS390 
37202 \emph default
37203 and
37204 \emph on
37205  notVolatile
37206 \emph default
37207 .
37208 \end_layout
37209
37210 \begin_layout Standard
37211 I know this whole thing is a little kludgey, but maybe some day we will
37212  have some better means.
37213  If you are looking at this file, you will see the default rules that are
37214  compiled into the compiler, you can add your own rules in the default set
37215  there if you get tired of specifying the -
37216 \begin_inset ERT
37217 status collapsed
37218
37219 \begin_layout Standard
37220
37221
37222 \backslash
37223 /
37224 \end_layout
37225
37226 \end_inset
37227
37228 -peep-file option.
37229 \end_layout
37230
37231 \begin_layout Section
37232 ANSI-Compliance
37233 \begin_inset LatexCommand \index{ANSI-compliance}
37234
37235 \end_inset
37236
37237
37238 \begin_inset LatexCommand \label{sub:ANSI-Compliance}
37239
37240 \end_inset
37241
37242
37243 \end_layout
37244
37245 \begin_layout Standard
37246 The latest publically available version of the standard 
37247 \emph on
37248 ISO/IEC 9899 - Programming languages - C
37249 \emph default
37250  should be available at: 
37251 \begin_inset LatexCommand \url{http://www.open-std.org/jtc1/sc22/wg14/www/standards.html#9899}
37252
37253 \end_inset
37254
37255 .
37256 \newline
37257
37258 \end_layout
37259
37260 \begin_layout Standard
37261 Deviations from the compliance:
37262 \end_layout
37263
37264 \begin_layout Itemize
37265 functions are not reentrant
37266 \begin_inset LatexCommand \index{reentrant}
37267
37268 \end_inset
37269
37270  unless explicitly declared as such or the 
37271 \series bold
37272 -
37273 \begin_inset ERT
37274 status collapsed
37275
37276 \begin_layout Standard
37277
37278
37279 \backslash
37280 /
37281 \end_layout
37282
37283 \end_inset
37284
37285 -stack-auto
37286 \begin_inset LatexCommand \index{-\/-stack-auto}
37287
37288 \end_inset
37289
37290
37291 \series default
37292  command line option is specified.
37293 \end_layout
37294
37295 \begin_layout Itemize
37296 structures
37297 \begin_inset LatexCommand \index{struct}
37298
37299 \end_inset
37300
37301  and unions
37302 \begin_inset LatexCommand \index{union}
37303
37304 \end_inset
37305
37306  cannot be assigned values directly, cannot be passed as function parameters
37307  or assigned to each other and cannot be a return value
37308 \begin_inset LatexCommand \index{return value}
37309
37310 \end_inset
37311
37312  from a function, e.g.:
37313 \end_layout
37314
37315 \begin_deeper
37316 \begin_layout Verse
37317
37318 \family typewriter
37319 struct s { ...
37320  }; 
37321 \newline
37322 struct s s1, s2; 
37323 \newline
37324 foo() 
37325 \newline
37326
37327 \newline
37328 \InsetSpace ~
37329 \InsetSpace ~
37330 \InsetSpace ~
37331 \InsetSpace ~
37332 ...
37333  
37334 \newline
37335 \InsetSpace ~
37336 \InsetSpace ~
37337 \InsetSpace ~
37338 \InsetSpace ~
37339 s1 = s2 ; /* is invalid in SDCC although allowed in ANSI */ 
37340 \newline
37341 \InsetSpace ~
37342 \InsetSpace ~
37343 \InsetSpace ~
37344 \InsetSpace ~
37345 ...
37346  
37347 \newline
37348 }
37349 \newline
37350
37351 \series bold
37352 struct
37353 \series default
37354  s foo1 (
37355 \series bold
37356 struct
37357 \series default
37358  s parms) /* invalid in SDCC although allowed in ANSI */
37359 \newline
37360
37361 \newline
37362 \InsetSpace ~
37363 \InsetSpace ~
37364 \InsetSpace ~
37365 \InsetSpace ~
37366 struct s rets;
37367  
37368 \newline
37369 \InsetSpace ~
37370 \InsetSpace ~
37371 \InsetSpace ~
37372 \InsetSpace ~
37373 ...
37374  
37375 \newline
37376 \InsetSpace ~
37377 \InsetSpace ~
37378 \InsetSpace ~
37379 \InsetSpace ~
37380 return rets; /* is invalid in SDCC although allowed in ANSI */ 
37381 \newline
37382 }
37383 \end_layout
37384
37385 \end_deeper
37386 \begin_layout Itemize
37387 initialization of structure arrays must be fully braced.
37388 \end_layout
37389
37390 \begin_deeper
37391 \begin_layout Verse
37392
37393 \family typewriter
37394 struct s { char x } a[] = {1, 2};\InsetSpace ~
37395 \InsetSpace ~
37396 \InsetSpace ~
37397 \InsetSpace ~
37398 \InsetSpace ~
37399 /* invalid in SDCC */
37400 \newline
37401 struct s { char x
37402  } a[] = {{1}, {2}}; /* OK */
37403 \end_layout
37404
37405 \end_deeper
37406 \begin_layout Itemize
37407 'long long
37408 \begin_inset LatexCommand \index{long long (not supported)}
37409
37410 \end_inset
37411
37412 ' (64 bit integers
37413 \begin_inset LatexCommand \index{int (64 bit) (not supported)}
37414
37415 \end_inset
37416
37417 ) not supported.
37418 \end_layout
37419
37420 \begin_layout Itemize
37421 'double
37422 \begin_inset LatexCommand \index{double (not supported)}
37423
37424 \end_inset
37425
37426 ' precision floating point 
37427 \begin_inset LatexCommand \index{Floating point support}
37428
37429 \end_inset
37430
37431 not supported.
37432 \end_layout
37433
37434 \begin_layout Itemize
37435 Old K&R style
37436 \begin_inset LatexCommand \index{K\&R style}
37437
37438 \end_inset
37439
37440  function declarations are NOT allowed.
37441 \end_layout
37442
37443 \begin_deeper
37444 \begin_layout Verse
37445
37446 \family typewriter
37447 foo(i,j) /* this old style of function declarations */ 
37448 \newline
37449 int i,j; /* is valid
37450  in ANSI but not valid in SDCC */ 
37451 \newline
37452
37453 \newline
37454 \InsetSpace ~
37455 \InsetSpace ~
37456 \InsetSpace ~
37457 \InsetSpace ~
37458 ...
37459  
37460 \newline
37461 }
37462 \end_layout
37463
37464 \end_deeper
37465 \begin_layout Itemize
37466 Most enhancements in C99 are not supported, e.g.:
37467 \end_layout
37468
37469 \begin_deeper
37470 \begin_layout Verse
37471
37472 \family typewriter
37473 for (
37474 \series bold
37475 int
37476 \series default
37477  i=0; i<10; i++) /* is invalid in SDCC although allowed in C99 */
37478 \end_layout
37479
37480 \end_deeper
37481 \begin_layout Itemize
37482 But some have been added recently in SDCC 2.7.0.
37483  They must be considered alpha quality however.
37484 \end_layout
37485
37486 \begin_deeper
37487 \begin_layout Verse
37488
37489 \family typewriter
37490 \series bold
37491 inline
37492 \begin_inset LatexCommand \index{inline (not supported)}
37493
37494 \end_inset
37495
37496
37497 \series default
37498  int increment (int a) { return a+1; } /* inlines the increment without
37499  function call overhead */
37500 \newline
37501 int * 
37502 \series bold
37503 restrict
37504 \begin_inset LatexCommand \index{inline (not supported)}
37505
37506 \end_inset
37507
37508
37509 \series default
37510  p; /* accepted but ignored */
37511 \end_layout
37512
37513 \end_deeper
37514 \begin_layout Itemize
37515 Certain words that are valid identifiers in the standard may be reserved
37516  words in SDCC unless the 
37517 \series bold
37518 -
37519 \begin_inset ERT
37520 status collapsed
37521
37522 \begin_layout Standard
37523
37524
37525 \backslash
37526 /
37527 \end_layout
37528
37529 \end_inset
37530
37531 -std-c89
37532 \begin_inset LatexCommand \index{-\/-std-c89}
37533
37534 \end_inset
37535
37536  
37537 \series default
37538 or
37539 \series bold
37540  -
37541 \begin_inset ERT
37542 status collapsed
37543
37544 \begin_layout Standard
37545
37546
37547 \backslash
37548 /
37549 \end_layout
37550
37551 \end_inset
37552
37553 -std-c99
37554 \begin_inset LatexCommand \index{-\/-std-c99}
37555
37556 \end_inset
37557
37558
37559 \series default
37560  command line options are used.
37561  These may include (depending on the selected processor): 'at', 'banked',
37562  'bit', 'code', 'critical', 'data', 'eeprom', 'far', 'flash', 'idata', 'interrup
37563 t', 'near', 'nonbanked', 'pdata', 'reentrant', 'sbit', 'sfr', 'shadowregs',
37564  'sram', 'using', 'wparam', 'xdata', '_overlay', '_asm', '_endasm', and
37565  '_naked'.
37566  Compliant equivalents of these keywords are always available in a form
37567  that begin with two underscores
37568 \begin_inset LatexCommand \index{\_\_ (prefix for extended keywords)}
37569
37570 \end_inset
37571
37572 , f.e.
37573  '__data' instead of 'data'.
37574 \end_layout
37575
37576 \begin_layout Itemize
37577 Integer promotion of variable arguments is not performed if the argument
37578  is explicitly taypecasted unless the
37579 \series bold
37580  -
37581 \begin_inset ERT
37582 status collapsed
37583
37584 \begin_layout Standard
37585
37586
37587 \backslash
37588 /
37589 \end_layout
37590
37591 \end_inset
37592
37593 -std-c89
37594 \begin_inset LatexCommand \index{-\/-std-c89}
37595
37596 \end_inset
37597
37598  
37599 \series default
37600 or
37601 \series bold
37602  -
37603 \begin_inset ERT
37604 status collapsed
37605
37606 \begin_layout Standard
37607
37608
37609 \backslash
37610 /
37611 \end_layout
37612
37613 \end_inset
37614
37615 -std-c99
37616 \begin_inset LatexCommand \index{-\/-std-c99}
37617
37618 \end_inset
37619
37620
37621 \series default
37622  command line options are used.
37623 \end_layout
37624
37625 \begin_deeper
37626 \begin_layout Verse
37627
37628 \family typewriter
37629 void vararg_func (char *str, ...) { str; }
37630 \newline
37631
37632 \newline
37633 void main (void)
37634 \newline
37635 {
37636 \newline
37637 \InsetSpace ~
37638 \InsetSpace ~
37639 char c = 10;
37640 \newline
37641
37642 \newline
37643 \InsetSpace ~
37644 \InsetSpace ~
37645 /* argument
37646  u is promoted to int before
37647 \newline
37648 \InsetSpace ~
37649 \InsetSpace ~
37650 \InsetSpace ~
37651 * passing to function */
37652 \newline
37653 \InsetSpace ~
37654 \InsetSpace ~
37655 vararg_func ("%c", c);
37656 \newline
37657
37658 \newline
37659 \InsetSpace ~
37660 \InsetSpace ~
37661 /*
37662  argument u is not promoted to int,
37663 \newline
37664 \InsetSpace ~
37665 \InsetSpace ~
37666 \InsetSpace ~
37667 * it is passed as char to function
37668 \newline
37669 \InsetSpace ~
37670 \InsetSpace ~
37671 \InsetSpace ~
37672 * if
37673  --std-cXX is not defined;
37674 \newline
37675 \InsetSpace ~
37676 \InsetSpace ~
37677 \InsetSpace ~
37678 * is promoted to int before passing
37679 \newline
37680 \InsetSpace ~
37681 \InsetSpace ~
37682 \InsetSpace ~
37683 * to function
37684  if --std-cXX is defined */
37685 \newline
37686 \InsetSpace ~
37687 \InsetSpace ~
37688 vararg_func ("%bc", (char)u);
37689 \newline
37690 }
37691 \end_layout
37692
37693 \end_deeper
37694 \begin_layout Section
37695 Cyclomatic Complexity
37696 \begin_inset LatexCommand \index{Cyclomatic complexity}
37697
37698 \end_inset
37699
37700
37701 \end_layout
37702
37703 \begin_layout Standard
37704 Cyclomatic complexity of a function is defined as the number of independent
37705  paths the program can take during execution of the function.
37706  This is an important number since it defines the number test cases you
37707  have to generate to validate the function.
37708  The accepted industry standard for complexity number is 10, if the cyclomatic
37709  complexity reported by SDCC exceeds 10 you should think about simplification
37710  of the function logic.
37711  Note that the complexity level is not related to the number of lines of
37712  code in a function.
37713  Large functions can have low complexity, and small functions can have large
37714  complexity levels.
37715  
37716 \newline
37717
37718 \newline
37719 SDCC uses the following formula to compute the complexity:
37720 \newline
37721
37722 \end_layout
37723
37724 \begin_layout Standard
37725 complexity = (number of edges in control flow graph) - (number of nodes
37726  in control flow graph) + 2;
37727 \newline
37728
37729 \newline
37730 Having said that the industry standard is 10,
37731  you should be aware that in some cases it be may unavoidable to have a
37732  complexity level of less than 10.
37733  For example if you have switch statement with more than 10 case labels,
37734  each case label adds one to the complexity level.
37735  The complexity level is by no means an absolute measure of the algorithmic
37736  complexity of the function, it does however provide a good starting point
37737  for which functions you might look at for further optimization.
37738 \end_layout
37739
37740 \begin_layout Section
37741 Retargetting for other Processors
37742 \end_layout
37743
37744 \begin_layout Standard
37745 The issues for retargetting the compiler are far too numerous to be covered
37746  by this document.
37747  What follows is a brief description of each of the seven phases of the
37748  compiler and its MCU dependency.
37749 \end_layout
37750
37751 \begin_layout Itemize
37752 Parsing the source and building the annotated parse tree.
37753  This phase is largely MCU independent (except for the language extensions).
37754  Syntax & semantic checks are also done in this phase, along with some initial
37755  optimizations like back patching labels and the pattern matching optimizations
37756  like bit-rotation etc.
37757 \end_layout
37758
37759 \begin_layout Itemize
37760 The second phase involves generating an intermediate code which can be easy
37761  manipulated during the later phases.
37762  This phase is entirely MCU independent.
37763  The intermediate code generation assumes the target machine has unlimited
37764  number of registers, and designates them with the name iTemp.
37765  The compiler can be made to dump a human readable form of the code generated
37766  by using the -
37767 \begin_inset ERT
37768 status collapsed
37769
37770 \begin_layout Standard
37771
37772
37773 \backslash
37774 /
37775 \end_layout
37776
37777 \end_inset
37778
37779 -dumpraw option.
37780 \end_layout
37781
37782 \begin_layout Itemize
37783 This phase does the bulk of the standard optimizations and is also MCU independe
37784 nt.
37785  This phase can be broken down into several sub-phases:
37786 \newline
37787
37788 \newline
37789 Break down intermediate
37790  code (iCode) into basic blocks.
37791 \newline
37792 Do control flow & data flow analysis on the
37793  basic blocks.
37794 \newline
37795 Do local common subexpression elimination, then global subexpressio
37796 n elimination
37797 \newline
37798 Dead code elimination
37799 \newline
37800 Loop optimizations
37801 \newline
37802 If loop optimizations
37803  caused any changes then do 'global subexpression elimination' and 'dead
37804  code elimination' again.
37805 \end_layout
37806
37807 \begin_layout Itemize
37808 This phase determines the live-ranges; by live range I mean those iTemp
37809  variables defined by the compiler that still survive after all the optimization
37810 s.
37811  Live range analysis
37812 \begin_inset LatexCommand \index{Live range analysis}
37813
37814 \end_inset
37815
37816  is essential for register allocation, since these computation determines
37817  which of these iTemps will be assigned to registers, and for how long.
37818 \end_layout
37819
37820 \begin_layout Itemize
37821 Phase five is register allocation.
37822  There are two parts to this process.
37823 \newline
37824
37825 \newline
37826 The first part I call 'register packing'
37827  (for lack of a better term).
37828  In this case several MCU specific expression folding is done to reduce
37829  register pressure.
37830 \newline
37831
37832 \newline
37833 The second part is more MCU independent and deals with
37834  allocating registers to the remaining live ranges.
37835  A lot of MCU specific code does creep into this phase because of the limited
37836  number of index registers available in the 8051.
37837 \end_layout
37838
37839 \begin_layout Itemize
37840 The Code generation phase is (unhappily), entirely MCU dependent and very
37841  little (if any at all) of this code can be reused for other MCU.
37842  However the scheme for allocating a homogenized assembler operand for each
37843  iCode operand may be reused.
37844 \end_layout
37845
37846 \begin_layout Itemize
37847 As mentioned in the optimization section the peep-hole optimizer is rule
37848  based system, which can reprogrammed for other MCUs.
37849 \end_layout
37850
37851 \begin_layout Standard
37852 More information is available on SDCC Wiki
37853 \begin_inset LatexCommand \index{wiki}
37854
37855 \end_inset
37856
37857  (preliminary link 
37858 \begin_inset LatexCommand \url{http://sdcc.wiki.sourceforge.net/SDCC+internals+and+porting}
37859
37860 \end_inset
37861
37862 ) and in the thread 
37863 \begin_inset LatexCommand \url{http://sf.net/mailarchive/message.php?msg_id=13954144}
37864
37865 \end_inset
37866
37867  .
37868 \end_layout
37869
37870 \begin_layout Chapter
37871 Compiler internals
37872 \begin_inset LatexCommand \index{Compiler internals}
37873
37874 \end_inset
37875
37876
37877 \end_layout
37878
37879 \begin_layout Section
37880 The anatomy of the compiler
37881 \begin_inset LatexCommand \label{sub:The-anatomy-of}
37882
37883 \end_inset
37884
37885
37886 \end_layout
37887
37888 \begin_layout Standard
37889
37890 \shape italic
37891 This is an excerpt from an article published in Circuit Cellar Magazine
37892  in 
37893 \series bold
37894 August 2000
37895 \series default
37896 .
37897  It's a little outdated (the compiler is much more efficient now and user/develo
37898 per friendly), but pretty well exposes the guts of it all.
37899 \shape default
37900
37901 \newline
37902
37903 \newline
37904 The current version of SDCC can generate code for Intel 8051 and Z80 MCU.
37905  It is fairly easy to retarget for other 8-bit MCU.
37906  Here we take a look at some of the internals of the compiler.
37907  
37908 \end_layout
37909
37910 \begin_layout Paragraph*
37911 Parsing
37912 \begin_inset LatexCommand \index{Parsing}
37913
37914 \end_inset
37915
37916  
37917 \end_layout
37918
37919 \begin_layout Standard
37920 Parsing the input source file and creating an AST (Annotated Syntax Tree
37921 \begin_inset LatexCommand \index{Annotated syntax tree}
37922
37923 \end_inset
37924
37925 ).
37926  This phase also involves propagating types (annotating each node of the
37927  parse tree with type information) and semantic analysis.
37928  There are some MCU specific parsing rules.
37929  For example the storage classes, the extended storage classes are MCU specific
37930  while there may be a xdata storage class for 8051 there is no such storage
37931  class for z80 or Atmel AVR.
37932  SDCC allows MCU specific storage class extensions, i.e.
37933  xdata will be treated as a storage class specifier when parsing 8051 C
37934  code but will be treated as a C identifier when parsing z80 or ATMEL AVR
37935  C code.
37936 \end_layout
37937
37938 \begin_layout Paragraph*
37939 Generating iCode
37940 \begin_inset LatexCommand \index{iCode}
37941
37942 \end_inset
37943
37944
37945 \end_layout
37946
37947 \begin_layout Standard
37948 Intermediate code generation.
37949  In this phase the AST is broken down into three-operand form (iCode).
37950  These three operand forms are represented as doubly linked lists.
37951  ICode is the term given to the intermediate form generated by the compiler.
37952  ICode example section shows some examples of iCode generated for some simple
37953  C source functions.
37954 \end_layout
37955
37956 \begin_layout Paragraph*
37957 Optimizations
37958 \begin_inset LatexCommand \index{Optimizations}
37959
37960 \end_inset
37961
37962 .
37963 \end_layout
37964
37965 \begin_layout Standard
37966 Bulk of the target independent optimizations is performed in this phase.
37967  The optimizations include constant propagation, common sub-expression eliminati
37968 on, loop invariant code movement, strength reduction of loop induction variables
37969  and dead-code elimination.
37970 \end_layout
37971
37972 \begin_layout Paragraph*
37973 Live range analysis
37974 \begin_inset LatexCommand \index{Live range analysis}
37975
37976 \end_inset
37977
37978
37979 \end_layout
37980
37981 \begin_layout Standard
37982 During intermediate code generation phase, the compiler assumes the target
37983  machine has infinite number of registers and generates a lot of temporary
37984  variables.
37985  The live range computation determines the lifetime of each of these compiler-ge
37986 nerated temporaries.
37987  A picture speaks a thousand words.
37988  ICode example sections show the live range annotations for each of the
37989  operand.
37990  It is important to note here, each iCode is assigned a number in the order
37991  of its execution in the function.
37992  The live ranges are computed in terms of these numbers.
37993  The from number is the number of the iCode which first defines the operand
37994  and the to number signifies the iCode which uses this operand last.
37995 \end_layout
37996
37997 \begin_layout Paragraph*
37998 Register Allocation
37999 \begin_inset LatexCommand \index{Register allocation}
38000
38001 \end_inset
38002
38003
38004 \end_layout
38005
38006 \begin_layout Standard
38007 The register allocation determines the type and number of registers needed
38008  by each operand.
38009  In most MCUs only a few registers can be used for indirect addressing.
38010  In case of 8051 for example the registers R0 & R1 can be used to indirectly
38011  address the internal ram and DPTR to indirectly address the external ram.
38012  The compiler will try to allocate the appropriate register to pointer variables
38013  if it can.
38014  ICode example section shows the operands annotated with the registers assigned
38015  to them.
38016  The compiler will try to keep operands in registers as much as possible;
38017  there are several schemes the compiler uses to do achieve this.
38018  When the compiler runs out of registers the compiler will check to see
38019  if there are any live operands which is not used or defined in the current
38020  basic block being processed, if there are any found then it will push that
38021  operand and use the registers in this block, the operand will then be popped
38022  at the end of the basic block.
38023  
38024 \end_layout
38025
38026 \begin_layout Standard
38027 There are other MCU specific considerations in this phase.
38028  Some MCUs have an accumulator; very short-lived operands could be assigned
38029  to the accumulator instead of a general-purpose register.
38030 \end_layout
38031
38032 \begin_layout Paragraph*
38033 Code generation
38034 \end_layout
38035
38036 \begin_layout Standard
38037 Figure II gives a table of iCode
38038 \begin_inset LatexCommand \index{iCode}
38039
38040 \end_inset
38041
38042  operations supported by the compiler.
38043  The code generation involves translating these operations into corresponding
38044  assembly code for the processor.
38045  This sounds overly simple but that is the essence of code generation.
38046  Some of the iCode operations are generated on a MCU specific manner for
38047  example, the z80 port does not use registers to pass parameters so the
38048  SEND and RECV iCode operations will not be generated, and it also does
38049  not support JUMPTABLES.
38050  
38051 \newline
38052
38053 \end_layout
38054
38055 \begin_layout Standard
38056
38057 \size footnotesize
38058 Figure II 
38059 \begin_inset Tabular
38060 <lyxtabular version="3" rows="39" columns="4">
38061 <features islongtable="true" headBottomDL="true">
38062 <column alignment="block" valignment="top" leftline="true" width="13col%">
38063 <column alignment="left" valignment="top" leftline="true" width="13col%">
38064 <column alignment="block" valignment="top" leftline="true" width="22col%">
38065 <column alignment="block" valignment="top" leftline="true" rightline="true" width="40col%">
38066 <row topline="true" bottomline="true" endhead="true">
38067 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38068 \begin_inset Text
38069
38070 \begin_layout Standard
38071
38072 \series bold
38073 iCode
38074 \series default
38075
38076 \begin_inset LatexCommand \index{iCode}
38077
38078 \end_inset
38079
38080
38081 \end_layout
38082
38083 \end_inset
38084 </cell>
38085 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38086 \begin_inset Text
38087
38088 \begin_layout Standard
38089
38090 \series bold
38091 Operands
38092 \end_layout
38093
38094 \end_inset
38095 </cell>
38096 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38097 \begin_inset Text
38098
38099 \begin_layout Standard
38100
38101 \series bold
38102 Description
38103 \end_layout
38104
38105 \end_inset
38106 </cell>
38107 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
38108 \begin_inset Text
38109
38110 \begin_layout Standard
38111
38112 \series bold
38113 C Equivalent
38114 \end_layout
38115
38116 \end_inset
38117 </cell>
38118 </row>
38119 <row topline="true">
38120 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38121 \begin_inset Text
38122
38123 \begin_layout Standard
38124
38125 \size footnotesize
38126 '!'
38127 \end_layout
38128
38129 \end_inset
38130 </cell>
38131 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38132 \begin_inset Text
38133
38134 \begin_layout Standard
38135
38136 \size footnotesize
38137 IC_LEFT() IC_RESULT()
38138 \end_layout
38139
38140 \end_inset
38141 </cell>
38142 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38143 \begin_inset Text
38144
38145 \begin_layout Standard
38146
38147 \size footnotesize
38148 NOT operation 
38149 \end_layout
38150
38151 \end_inset
38152 </cell>
38153 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
38154 \begin_inset Text
38155
38156 \begin_layout Standard
38157
38158 \size footnotesize
38159 IC_RESULT = ! IC_LEFT;
38160 \end_layout
38161
38162 \end_inset
38163 </cell>
38164 </row>
38165 <row topline="true">
38166 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38167 \begin_inset Text
38168
38169 \begin_layout Standard
38170
38171 \size footnotesize
38172 '~'
38173 \end_layout
38174
38175 \end_inset
38176 </cell>
38177 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38178 \begin_inset Text
38179
38180 \begin_layout Standard
38181
38182 \size footnotesize
38183 IC_LEFT() IC_RESULT()
38184 \end_layout
38185
38186 \end_inset
38187 </cell>
38188 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38189 \begin_inset Text
38190
38191 \begin_layout Standard
38192
38193 \size footnotesize
38194 Bitwise complement of 
38195 \end_layout
38196
38197 \end_inset
38198 </cell>
38199 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
38200 \begin_inset Text
38201
38202 \begin_layout Standard
38203
38204 \size footnotesize
38205 IC_RESULT = ~IC_LEFT;
38206 \end_layout
38207
38208 \end_inset
38209 </cell>
38210 </row>
38211 <row topline="true">
38212 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38213 \begin_inset Text
38214
38215 \begin_layout Standard
38216
38217 \size footnotesize
38218 RRC
38219 \end_layout
38220
38221 \end_inset
38222 </cell>
38223 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38224 \begin_inset Text
38225
38226 \begin_layout Standard
38227
38228 \size footnotesize
38229 IC_LEFT() IC_RESULT()
38230 \end_layout
38231
38232 \end_inset
38233 </cell>
38234 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38235 \begin_inset Text
38236
38237 \begin_layout Standard
38238
38239 \size footnotesize
38240 Rotate right with carry
38241 \end_layout
38242
38243 \end_inset
38244 </cell>
38245 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
38246 \begin_inset Text
38247
38248 \begin_layout Standard
38249
38250 \size footnotesize
38251 IC_RESULT = (IC_LEFT << 1) | (IC_LEFT >> (sizeof(IC_LEFT)*8-1));
38252 \end_layout
38253
38254 \end_inset
38255 </cell>
38256 </row>
38257 <row topline="true">
38258 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38259 \begin_inset Text
38260
38261 \begin_layout Standard
38262
38263 \size footnotesize
38264 RLC
38265 \end_layout
38266
38267 \end_inset
38268 </cell>
38269 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38270 \begin_inset Text
38271
38272 \begin_layout Standard
38273
38274 \size footnotesize
38275 IC_LEFT() IC_RESULT()
38276 \end_layout
38277
38278 \end_inset
38279 </cell>
38280 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38281 \begin_inset Text
38282
38283 \begin_layout Standard
38284
38285 \size footnotesize
38286 Rotate left with carry
38287 \end_layout
38288
38289 \end_inset
38290 </cell>
38291 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
38292 \begin_inset Text
38293
38294 \begin_layout Standard
38295
38296 \size footnotesize
38297 IC_RESULT = (IC_LEFT << (sizeof(LC_LEFT)*8-1) ) | (IC_LEFT >> 1);
38298 \end_layout
38299
38300 \end_inset
38301 </cell>
38302 </row>
38303 <row topline="true">
38304 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38305 \begin_inset Text
38306
38307 \begin_layout Standard
38308
38309 \size footnotesize
38310 GETHBIT
38311 \end_layout
38312
38313 \end_inset
38314 </cell>
38315 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38316 \begin_inset Text
38317
38318 \begin_layout Standard
38319
38320 \size footnotesize
38321 IC_LEFT() IC_RESULT()
38322 \end_layout
38323
38324 \end_inset
38325 </cell>
38326 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38327 \begin_inset Text
38328
38329 \begin_layout Standard
38330
38331 \size footnotesize
38332 Get the highest order bit of IC_LEFT
38333 \end_layout
38334
38335 \end_inset
38336 </cell>
38337 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
38338 \begin_inset Text
38339
38340 \begin_layout Standard
38341
38342 \size footnotesize
38343 IC_RESULT = (IC_LEFT >> (sizeof(IC_LEFT)*8 -1));
38344 \end_layout
38345
38346 \end_inset
38347 </cell>
38348 </row>
38349 <row topline="true">
38350 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38351 \begin_inset Text
38352
38353 \begin_layout Standard
38354
38355 \size footnotesize
38356 UNARYMINUS
38357 \end_layout
38358
38359 \end_inset
38360 </cell>
38361 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38362 \begin_inset Text
38363
38364 \begin_layout Standard
38365
38366 \size footnotesize
38367 IC_LEFT() IC_RESULT()
38368 \end_layout
38369
38370 \end_inset
38371 </cell>
38372 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38373 \begin_inset Text
38374
38375 \begin_layout Standard
38376
38377 \size footnotesize
38378 Unary minus
38379 \end_layout
38380
38381 \end_inset
38382 </cell>
38383 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
38384 \begin_inset Text
38385
38386 \begin_layout Standard
38387
38388 \size footnotesize
38389 IC_RESULT = - IC_LEFT;
38390 \end_layout
38391
38392 \end_inset
38393 </cell>
38394 </row>
38395 <row topline="true">
38396 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38397 \begin_inset Text
38398
38399 \begin_layout Standard
38400
38401 \size footnotesize
38402 IPUSH
38403 \end_layout
38404
38405 \end_inset
38406 </cell>
38407 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38408 \begin_inset Text
38409
38410 \begin_layout Standard
38411
38412 \size footnotesize
38413 IC_LEFT()
38414 \end_layout
38415
38416 \end_inset
38417 </cell>
38418 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38419 \begin_inset Text
38420
38421 \begin_layout Standard
38422
38423 \size footnotesize
38424 Push the operand into stack
38425 \end_layout
38426
38427 \end_inset
38428 </cell>
38429 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
38430 \begin_inset Text
38431
38432 \begin_layout Standard
38433
38434 \size footnotesize
38435 NONE
38436 \end_layout
38437
38438 \end_inset
38439 </cell>
38440 </row>
38441 <row topline="true">
38442 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38443 \begin_inset Text
38444
38445 \begin_layout Standard
38446
38447 \size footnotesize
38448 IPOP
38449 \end_layout
38450
38451 \end_inset
38452 </cell>
38453 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38454 \begin_inset Text
38455
38456 \begin_layout Standard
38457
38458 \size footnotesize
38459 IC_LEFT()
38460 \end_layout
38461
38462 \end_inset
38463 </cell>
38464 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38465 \begin_inset Text
38466
38467 \begin_layout Standard
38468
38469 \size footnotesize
38470 Pop the operand from the stack 
38471 \end_layout
38472
38473 \end_inset
38474 </cell>
38475 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
38476 \begin_inset Text
38477
38478 \begin_layout Standard
38479
38480 \size footnotesize
38481 NONE
38482 \end_layout
38483
38484 \end_inset
38485 </cell>
38486 </row>
38487 <row topline="true">
38488 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38489 \begin_inset Text
38490
38491 \begin_layout Standard
38492
38493 \size footnotesize
38494 CALL
38495 \end_layout
38496
38497 \end_inset
38498 </cell>
38499 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38500 \begin_inset Text
38501
38502 \begin_layout Standard
38503
38504 \size footnotesize
38505 IC_LEFT() IC_RESULT()
38506 \end_layout
38507
38508 \end_inset
38509 </cell>
38510 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38511 \begin_inset Text
38512
38513 \begin_layout Standard
38514
38515 \size footnotesize
38516 Call the function represented by IC_LEFT 
38517 \end_layout
38518
38519 \end_inset
38520 </cell>
38521 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
38522 \begin_inset Text
38523
38524 \begin_layout Standard
38525
38526 \size footnotesize
38527 IC_RESULT = IC_LEFT();
38528 \end_layout
38529
38530 \end_inset
38531 </cell>
38532 </row>
38533 <row topline="true">
38534 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38535 \begin_inset Text
38536
38537 \begin_layout Standard
38538
38539 \size footnotesize
38540 PCALL
38541 \end_layout
38542
38543 \end_inset
38544 </cell>
38545 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38546 \begin_inset Text
38547
38548 \begin_layout Standard
38549
38550 \size footnotesize
38551 IC_LEFT() IC_RESULT()
38552 \end_layout
38553
38554 \end_inset
38555 </cell>
38556 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38557 \begin_inset Text
38558
38559 \begin_layout Standard
38560
38561 \size footnotesize
38562 Call via function pointer
38563 \end_layout
38564
38565 \end_inset
38566 </cell>
38567 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
38568 \begin_inset Text
38569
38570 \begin_layout Standard
38571
38572 \size footnotesize
38573 IC_RESULT = (*IC_LEFT)();
38574 \end_layout
38575
38576 \end_inset
38577 </cell>
38578 </row>
38579 <row topline="true">
38580 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38581 \begin_inset Text
38582
38583 \begin_layout Standard
38584
38585 \size footnotesize
38586 RETURN
38587 \end_layout
38588
38589 \end_inset
38590 </cell>
38591 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38592 \begin_inset Text
38593
38594 \begin_layout Standard
38595
38596 \size footnotesize
38597 IC_LEFT()
38598 \end_layout
38599
38600 \end_inset
38601 </cell>
38602 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38603 \begin_inset Text
38604
38605 \begin_layout Standard
38606
38607 \size footnotesize
38608 Return the value in operand IC_LEFT 
38609 \end_layout
38610
38611 \end_inset
38612 </cell>
38613 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
38614 \begin_inset Text
38615
38616 \begin_layout Standard
38617
38618 \size footnotesize
38619 return IC_LEFT;
38620 \end_layout
38621
38622 \end_inset
38623 </cell>
38624 </row>
38625 <row topline="true">
38626 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38627 \begin_inset Text
38628
38629 \begin_layout Standard
38630
38631 \size footnotesize
38632 LABEL
38633 \end_layout
38634
38635 \end_inset
38636 </cell>
38637 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38638 \begin_inset Text
38639
38640 \begin_layout Standard
38641
38642 \size footnotesize
38643 IC_LABEL() 
38644 \end_layout
38645
38646 \end_inset
38647 </cell>
38648 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38649 \begin_inset Text
38650
38651 \begin_layout Standard
38652
38653 \size footnotesize
38654 Label
38655 \end_layout
38656
38657 \end_inset
38658 </cell>
38659 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
38660 \begin_inset Text
38661
38662 \begin_layout Standard
38663
38664 \size footnotesize
38665 IC_LABEL:
38666 \end_layout
38667
38668 \end_inset
38669 </cell>
38670 </row>
38671 <row topline="true">
38672 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38673 \begin_inset Text
38674
38675 \begin_layout Standard
38676
38677 \size footnotesize
38678 GOTO
38679 \end_layout
38680
38681 \end_inset
38682 </cell>
38683 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38684 \begin_inset Text
38685
38686 \begin_layout Standard
38687
38688 \size footnotesize
38689 IC_LABEL() 
38690 \end_layout
38691
38692 \end_inset
38693 </cell>
38694 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38695 \begin_inset Text
38696
38697 \begin_layout Standard
38698
38699 \size footnotesize
38700 Goto label
38701 \end_layout
38702
38703 \end_inset
38704 </cell>
38705 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
38706 \begin_inset Text
38707
38708 \begin_layout Standard
38709
38710 \size footnotesize
38711 goto IC_LABEL();
38712 \end_layout
38713
38714 \end_inset
38715 </cell>
38716 </row>
38717 <row topline="true">
38718 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38719 \begin_inset Text
38720
38721 \begin_layout Standard
38722
38723 \size footnotesize
38724 '+'
38725 \end_layout
38726
38727 \end_inset
38728 </cell>
38729 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38730 \begin_inset Text
38731
38732 \begin_layout Standard
38733
38734 \size footnotesize
38735 IC_LEFT() IC_RIGHT() IC_RESULT()
38736 \end_layout
38737
38738 \end_inset
38739 </cell>
38740 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38741 \begin_inset Text
38742
38743 \begin_layout Standard
38744
38745 \size footnotesize
38746 Addition
38747 \end_layout
38748
38749 \end_inset
38750 </cell>
38751 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
38752 \begin_inset Text
38753
38754 \begin_layout Standard
38755
38756 \size footnotesize
38757 IC_RESULT = IC_LEFT + IC_RIGHT
38758 \end_layout
38759
38760 \end_inset
38761 </cell>
38762 </row>
38763 <row topline="true">
38764 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38765 \begin_inset Text
38766
38767 \begin_layout Standard
38768
38769 \size footnotesize
38770 '-'
38771 \end_layout
38772
38773 \end_inset
38774 </cell>
38775 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38776 \begin_inset Text
38777
38778 \begin_layout Standard
38779
38780 \size footnotesize
38781 IC_LEFT() IC_RIGHT() IC_RESULT()
38782 \end_layout
38783
38784 \end_inset
38785 </cell>
38786 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38787 \begin_inset Text
38788
38789 \begin_layout Standard
38790
38791 \size footnotesize
38792 Subtraction
38793 \end_layout
38794
38795 \end_inset
38796 </cell>
38797 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
38798 \begin_inset Text
38799
38800 \begin_layout Standard
38801
38802 \size footnotesize
38803 IC_RESULT = IC_LEFT - IC_RIGHT 
38804 \end_layout
38805
38806 \end_inset
38807 </cell>
38808 </row>
38809 <row topline="true">
38810 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38811 \begin_inset Text
38812
38813 \begin_layout Standard
38814
38815 \size footnotesize
38816 '*'
38817 \end_layout
38818
38819 \end_inset
38820 </cell>
38821 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38822 \begin_inset Text
38823
38824 \begin_layout Standard
38825
38826 \size footnotesize
38827 IC_LEFT() IC_RIGHT() IC_RESULT()
38828 \end_layout
38829
38830 \end_inset
38831 </cell>
38832 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38833 \begin_inset Text
38834
38835 \begin_layout Standard
38836
38837 \size footnotesize
38838 Multiplication 
38839 \end_layout
38840
38841 \end_inset
38842 </cell>
38843 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
38844 \begin_inset Text
38845
38846 \begin_layout Standard
38847
38848 \size footnotesize
38849 IC_RESULT = IC_LEFT * IC_RIGHT;
38850 \end_layout
38851
38852 \end_inset
38853 </cell>
38854 </row>
38855 <row topline="true">
38856 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38857 \begin_inset Text
38858
38859 \begin_layout Standard
38860
38861 \size footnotesize
38862 '/'
38863 \end_layout
38864
38865 \end_inset
38866 </cell>
38867 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38868 \begin_inset Text
38869
38870 \begin_layout Standard
38871
38872 \size footnotesize
38873 IC_LEFT() IC_RIGHT() IC_RESULT()
38874 \end_layout
38875
38876 \end_inset
38877 </cell>
38878 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38879 \begin_inset Text
38880
38881 \begin_layout Standard
38882
38883 \size footnotesize
38884 Division
38885 \end_layout
38886
38887 \end_inset
38888 </cell>
38889 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
38890 \begin_inset Text
38891
38892 \begin_layout Standard
38893
38894 \size footnotesize
38895 IC_RESULT = IC_LEFT / IC_RIGHT;
38896 \end_layout
38897
38898 \end_inset
38899 </cell>
38900 </row>
38901 <row topline="true">
38902 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38903 \begin_inset Text
38904
38905 \begin_layout Standard
38906
38907 \size footnotesize
38908 '%'
38909 \end_layout
38910
38911 \end_inset
38912 </cell>
38913 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38914 \begin_inset Text
38915
38916 \begin_layout Standard
38917
38918 \size footnotesize
38919 IC_LEFT() IC_RIGHT() IC_RESULT()
38920 \end_layout
38921
38922 \end_inset
38923 </cell>
38924 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38925 \begin_inset Text
38926
38927 \begin_layout Standard
38928
38929 \size footnotesize
38930 Modulus
38931 \end_layout
38932
38933 \end_inset
38934 </cell>
38935 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
38936 \begin_inset Text
38937
38938 \begin_layout Standard
38939
38940 \size footnotesize
38941 IC_RESULT = IC_LEFT % IC_RIGHT;
38942 \end_layout
38943
38944 \end_inset
38945 </cell>
38946 </row>
38947 <row topline="true">
38948 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38949 \begin_inset Text
38950
38951 \begin_layout Standard
38952
38953 \size footnotesize
38954 '<'
38955 \end_layout
38956
38957 \end_inset
38958 </cell>
38959 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38960 \begin_inset Text
38961
38962 \begin_layout Standard
38963
38964 \size footnotesize
38965 IC_LEFT() IC_RIGHT() IC_RESULT()
38966 \end_layout
38967
38968 \end_inset
38969 </cell>
38970 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38971 \begin_inset Text
38972
38973 \begin_layout Standard
38974
38975 \size footnotesize
38976 Less than
38977 \end_layout
38978
38979 \end_inset
38980 </cell>
38981 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
38982 \begin_inset Text
38983
38984 \begin_layout Standard
38985
38986 \size footnotesize
38987 IC_RESULT = IC_LEFT < IC_RIGHT;
38988 \end_layout
38989
38990 \end_inset
38991 </cell>
38992 </row>
38993 <row topline="true">
38994 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38995 \begin_inset Text
38996
38997 \begin_layout Standard
38998
38999 \size footnotesize
39000 '>'
39001 \end_layout
39002
39003 \end_inset
39004 </cell>
39005 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39006 \begin_inset Text
39007
39008 \begin_layout Standard
39009
39010 \size footnotesize
39011 IC_LEFT() IC_RIGHT() IC_RESULT()
39012 \end_layout
39013
39014 \end_inset
39015 </cell>
39016 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39017 \begin_inset Text
39018
39019 \begin_layout Standard
39020
39021 \size footnotesize
39022 Greater than 
39023 \end_layout
39024
39025 \end_inset
39026 </cell>
39027 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
39028 \begin_inset Text
39029
39030 \begin_layout Standard
39031
39032 \size footnotesize
39033 IC_RESULT = IC_LEFT > IC_RIGHT;
39034 \end_layout
39035
39036 \end_inset
39037 </cell>
39038 </row>
39039 <row topline="true">
39040 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39041 \begin_inset Text
39042
39043 \begin_layout Standard
39044
39045 \size footnotesize
39046 EQ_OP
39047 \end_layout
39048
39049 \end_inset
39050 </cell>
39051 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39052 \begin_inset Text
39053
39054 \begin_layout Standard
39055
39056 \size footnotesize
39057 IC_LEFT() IC_RIGHT() IC_RESULT()
39058 \end_layout
39059
39060 \end_inset
39061 </cell>
39062 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39063 \begin_inset Text
39064
39065 \begin_layout Standard
39066
39067 \size footnotesize
39068 Equal to 
39069 \end_layout
39070
39071 \end_inset
39072 </cell>
39073 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
39074 \begin_inset Text
39075
39076 \begin_layout Standard
39077
39078 \size footnotesize
39079 IC_RESULT = IC_LEFT == IC_RIGHT;
39080 \end_layout
39081
39082 \end_inset
39083 </cell>
39084 </row>
39085 <row topline="true">
39086 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39087 \begin_inset Text
39088
39089 \begin_layout Standard
39090
39091 \size footnotesize
39092 AND_OP
39093 \end_layout
39094
39095 \end_inset
39096 </cell>
39097 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39098 \begin_inset Text
39099
39100 \begin_layout Standard
39101
39102 \size footnotesize
39103 IC_LEFT() IC_RIGHT() IC_RESULT() 
39104 \end_layout
39105
39106 \end_inset
39107 </cell>
39108 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39109 \begin_inset Text
39110
39111 \begin_layout Standard
39112
39113 \size footnotesize
39114 Logical and operation
39115 \end_layout
39116
39117 \end_inset
39118 </cell>
39119 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
39120 \begin_inset Text
39121
39122 \begin_layout Standard
39123
39124 \size footnotesize
39125 IC_RESULT = IC_LEFT && IC_RIGHT; 
39126 \end_layout
39127
39128 \end_inset
39129 </cell>
39130 </row>
39131 <row topline="true">
39132 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39133 \begin_inset Text
39134
39135 \begin_layout Standard
39136
39137 \size footnotesize
39138 OR_OP
39139 \end_layout
39140
39141 \end_inset
39142 </cell>
39143 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39144 \begin_inset Text
39145
39146 \begin_layout Standard
39147
39148 \size footnotesize
39149 IC_LEFT() IC_RIGHT() IC_RESULT() 
39150 \end_layout
39151
39152 \end_inset
39153 </cell>
39154 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39155 \begin_inset Text
39156
39157 \begin_layout Standard
39158
39159 \size footnotesize
39160 Logical or operation 
39161 \end_layout
39162
39163 \end_inset
39164 </cell>
39165 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
39166 \begin_inset Text
39167
39168 \begin_layout Standard
39169
39170 \size footnotesize
39171 IC_RESULT = IC_LEFT || IC_RIGHT; 
39172 \end_layout
39173
39174 \end_inset
39175 </cell>
39176 </row>
39177 <row topline="true">
39178 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39179 \begin_inset Text
39180
39181 \begin_layout Standard
39182
39183 \size footnotesize
39184 '^'
39185 \end_layout
39186
39187 \end_inset
39188 </cell>
39189 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39190 \begin_inset Text
39191
39192 \begin_layout Standard
39193
39194 \size footnotesize
39195 IC_LEFT() IC_RIGHT() IC_RESULT() 
39196 \end_layout
39197
39198 \end_inset
39199 </cell>
39200 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39201 \begin_inset Text
39202
39203 \begin_layout Standard
39204
39205 \size footnotesize
39206 Exclusive OR
39207 \end_layout
39208
39209 \end_inset
39210 </cell>
39211 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
39212 \begin_inset Text
39213
39214 \begin_layout Standard
39215
39216 \size footnotesize
39217 IC_RESULT = IC_LEFT ^ IC_RIGHT;
39218 \end_layout
39219
39220 \end_inset
39221 </cell>
39222 </row>
39223 <row topline="true">
39224 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39225 \begin_inset Text
39226
39227 \begin_layout Standard
39228
39229 \size footnotesize
39230 '|'
39231 \end_layout
39232
39233 \end_inset
39234 </cell>
39235 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39236 \begin_inset Text
39237
39238 \begin_layout Standard
39239
39240 \size footnotesize
39241 IC_LEFT() IC_RIGHT() IC_RESULT() 
39242 \end_layout
39243
39244 \end_inset
39245 </cell>
39246 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39247 \begin_inset Text
39248
39249 \begin_layout Standard
39250
39251 \size footnotesize
39252 Bitwise OR 
39253 \end_layout
39254
39255 \end_inset
39256 </cell>
39257 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
39258 \begin_inset Text
39259
39260 \begin_layout Standard
39261
39262 \size footnotesize
39263 IC_RESULT = IC_LEFT | IC_RIGHT;
39264 \end_layout
39265
39266 \end_inset
39267 </cell>
39268 </row>
39269 <row topline="true">
39270 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39271 \begin_inset Text
39272
39273 \begin_layout Standard
39274
39275 \size footnotesize
39276 BITWISEAND
39277 \end_layout
39278
39279 \end_inset
39280 </cell>
39281 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39282 \begin_inset Text
39283
39284 \begin_layout Standard
39285
39286 \size footnotesize
39287 IC_LEFT() IC_RIGHT() IC_RESULT()
39288 \end_layout
39289
39290 \end_inset
39291 </cell>
39292 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39293 \begin_inset Text
39294
39295 \begin_layout Standard
39296
39297 \size footnotesize
39298 Bitwise AND 
39299 \end_layout
39300
39301 \end_inset
39302 </cell>
39303 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
39304 \begin_inset Text
39305
39306 \begin_layout Standard
39307
39308 \size footnotesize
39309 IC_RESULT = IC_LEFT & IC_RIGHT;
39310 \end_layout
39311
39312 \end_inset
39313 </cell>
39314 </row>
39315 <row topline="true">
39316 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39317 \begin_inset Text
39318
39319 \begin_layout Standard
39320
39321 \size footnotesize
39322 LEFT_OP
39323 \end_layout
39324
39325 \end_inset
39326 </cell>
39327 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39328 \begin_inset Text
39329
39330 \begin_layout Standard
39331
39332 \size footnotesize
39333 IC_LEFT() IC_RIGHT() IC_RESULT()
39334 \end_layout
39335
39336 \end_inset
39337 </cell>
39338 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39339 \begin_inset Text
39340
39341 \begin_layout Standard
39342
39343 \size footnotesize
39344 Left shift 
39345 \end_layout
39346
39347 \end_inset
39348 </cell>
39349 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
39350 \begin_inset Text
39351
39352 \begin_layout Standard
39353
39354 \size footnotesize
39355 IC_RESULT = IC_LEFT << IC_RIGHT 
39356 \end_layout
39357
39358 \end_inset
39359 </cell>
39360 </row>
39361 <row topline="true">
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 RIGHT_OP
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 IC_LEFT() IC_RIGHT() IC_RESULT()
39380 \end_layout
39381
39382 \end_inset
39383 </cell>
39384 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39385 \begin_inset Text
39386
39387 \begin_layout Standard
39388
39389 \size footnotesize
39390 Right shift
39391 \end_layout
39392
39393 \end_inset
39394 </cell>
39395 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
39396 \begin_inset Text
39397
39398 \begin_layout Standard
39399
39400 \size footnotesize
39401 IC_RESULT = IC_LEFT >> IC_RIGHT 
39402 \end_layout
39403
39404 \end_inset
39405 </cell>
39406 </row>
39407 <row topline="true">
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 GET_VALUE_
39415 \newline
39416 AT_ ADDRESS
39417 \end_layout
39418
39419 \end_inset
39420 </cell>
39421 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39422 \begin_inset Text
39423
39424 \begin_layout Standard
39425
39426 \size footnotesize
39427 IC_LEFT() IC_RESULT()
39428 \end_layout
39429
39430 \end_inset
39431 </cell>
39432 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39433 \begin_inset Text
39434
39435 \begin_layout Standard
39436
39437 \size footnotesize
39438 Indirect fetch 
39439 \end_layout
39440
39441 \end_inset
39442 </cell>
39443 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
39444 \begin_inset Text
39445
39446 \begin_layout Standard
39447
39448 \size footnotesize
39449 IC_RESULT = (*IC_LEFT);
39450 \end_layout
39451
39452 \end_inset
39453 </cell>
39454 </row>
39455 <row topline="true">
39456 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39457 \begin_inset Text
39458
39459 \begin_layout Standard
39460
39461 \size footnotesize
39462 POINTER_SET
39463 \end_layout
39464
39465 \end_inset
39466 </cell>
39467 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39468 \begin_inset Text
39469
39470 \begin_layout Standard
39471
39472 \size footnotesize
39473 IC_RIGHT() IC_RESULT() 
39474 \end_layout
39475
39476 \end_inset
39477 </cell>
39478 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39479 \begin_inset Text
39480
39481 \begin_layout Standard
39482
39483 \size footnotesize
39484 Indirect set
39485 \end_layout
39486
39487 \end_inset
39488 </cell>
39489 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
39490 \begin_inset Text
39491
39492 \begin_layout Standard
39493
39494 \size footnotesize
39495 (*IC_RESULT) = IC_RIGHT;
39496 \end_layout
39497
39498 \end_inset
39499 </cell>
39500 </row>
39501 <row topline="true">
39502 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39503 \begin_inset Text
39504
39505 \begin_layout Standard
39506
39507 \size footnotesize
39508 '='
39509 \end_layout
39510
39511 \end_inset
39512 </cell>
39513 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39514 \begin_inset Text
39515
39516 \begin_layout Standard
39517
39518 \size footnotesize
39519 IC_RIGHT() IC_RESULT()
39520 \end_layout
39521
39522 \end_inset
39523 </cell>
39524 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39525 \begin_inset Text
39526
39527 \begin_layout Standard
39528
39529 \size footnotesize
39530 Assignment
39531 \end_layout
39532
39533 \end_inset
39534 </cell>
39535 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
39536 \begin_inset Text
39537
39538 \begin_layout Standard
39539
39540 \size footnotesize
39541 IC_RESULT = IC_RIGHT;
39542 \end_layout
39543
39544 \end_inset
39545 </cell>
39546 </row>
39547 <row topline="true">
39548 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39549 \begin_inset Text
39550
39551 \begin_layout Standard
39552
39553 \size footnotesize
39554 IFX
39555 \end_layout
39556
39557 \end_inset
39558 </cell>
39559 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39560 \begin_inset Text
39561
39562 \begin_layout Standard
39563
39564 \size footnotesize
39565 IC_COND IC_TRUE IC_LABEL
39566 \end_layout
39567
39568 \end_inset
39569 </cell>
39570 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39571 \begin_inset Text
39572
39573 \begin_layout Standard
39574
39575 \size footnotesize
39576 Conditional jump.
39577  If true label is present then jump to true label if condition is true else
39578  jump to false label if condition is false 
39579 \end_layout
39580
39581 \end_inset
39582 </cell>
39583 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
39584 \begin_inset Text
39585
39586 \begin_layout Standard
39587
39588 \size footnotesize
39589 if (IC_COND) goto IC_TRUE; 
39590 \newline
39591 \InsetSpace ~
39592 \InsetSpace ~
39593 Or 
39594 \newline
39595 If (!IC_COND) goto IC_FALSE;
39596 \end_layout
39597
39598 \end_inset
39599 </cell>
39600 </row>
39601 <row topline="true">
39602 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39603 \begin_inset Text
39604
39605 \begin_layout Standard
39606
39607 \size footnotesize
39608 ADDRESS_OF
39609 \end_layout
39610
39611 \end_inset
39612 </cell>
39613 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39614 \begin_inset Text
39615
39616 \begin_layout Standard
39617
39618 \size footnotesize
39619 IC_LEFT() IC_RESULT()
39620 \end_layout
39621
39622 \end_inset
39623 </cell>
39624 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39625 \begin_inset Text
39626
39627 \begin_layout Standard
39628
39629 \size footnotesize
39630 Address of 
39631 \end_layout
39632
39633 \end_inset
39634 </cell>
39635 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
39636 \begin_inset Text
39637
39638 \begin_layout Standard
39639
39640 \size footnotesize
39641 IC_RESULT = &IC_LEFT();
39642 \end_layout
39643
39644 \end_inset
39645 </cell>
39646 </row>
39647 <row topline="true">
39648 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39649 \begin_inset Text
39650
39651 \begin_layout Standard
39652
39653 \size footnotesize
39654 JUMPTABLE
39655 \end_layout
39656
39657 \end_inset
39658 </cell>
39659 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39660 \begin_inset Text
39661
39662 \begin_layout Standard
39663
39664 \size footnotesize
39665 IC_JTCOND IC_JTLABELS
39666 \end_layout
39667
39668 \end_inset
39669 </cell>
39670 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39671 \begin_inset Text
39672
39673 \begin_layout Standard
39674
39675 \size footnotesize
39676 Jump to list of labels depending on the value of JTCOND
39677 \end_layout
39678
39679 \end_inset
39680 </cell>
39681 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
39682 \begin_inset Text
39683
39684 \begin_layout Standard
39685
39686 \size footnotesize
39687 Switch statement
39688 \end_layout
39689
39690 \end_inset
39691 </cell>
39692 </row>
39693 <row topline="true">
39694 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39695 \begin_inset Text
39696
39697 \begin_layout Standard
39698
39699 \size footnotesize
39700 CAST
39701 \end_layout
39702
39703 \end_inset
39704 </cell>
39705 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39706 \begin_inset Text
39707
39708 \begin_layout Standard
39709
39710 \size footnotesize
39711 IC_RIGHT() IC_LEFT() IC_RESULT()
39712 \end_layout
39713
39714 \end_inset
39715 </cell>
39716 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39717 \begin_inset Text
39718
39719 \begin_layout Standard
39720
39721 \size footnotesize
39722 Cast types 
39723 \end_layout
39724
39725 \end_inset
39726 </cell>
39727 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
39728 \begin_inset Text
39729
39730 \begin_layout Standard
39731
39732 \size footnotesize
39733 IC_RESULT = (typeof IC_LEFT) IC_RIGHT;
39734 \end_layout
39735
39736 \end_inset
39737 </cell>
39738 </row>
39739 <row topline="true">
39740 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39741 \begin_inset Text
39742
39743 \begin_layout Standard
39744
39745 \size footnotesize
39746 SEND
39747 \end_layout
39748
39749 \end_inset
39750 </cell>
39751 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39752 \begin_inset Text
39753
39754 \begin_layout Standard
39755
39756 \size footnotesize
39757 IC_LEFT()
39758 \end_layout
39759
39760 \end_inset
39761 </cell>
39762 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39763 \begin_inset Text
39764
39765 \begin_layout Standard
39766
39767 \size footnotesize
39768 This is used for passing parameters in registers; 
39769 \newline
39770 move IC_LEFT to the next
39771  available parameter register.
39772 \end_layout
39773
39774 \end_inset
39775 </cell>
39776 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
39777 \begin_inset Text
39778
39779 \begin_layout Standard
39780
39781 \size footnotesize
39782 None
39783 \end_layout
39784
39785 \end_inset
39786 </cell>
39787 </row>
39788 <row topline="true">
39789 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39790 \begin_inset Text
39791
39792 \begin_layout Standard
39793
39794 \size footnotesize
39795 RECV
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 \size footnotesize
39806 IC_RESULT()
39807 \end_layout
39808
39809 \end_inset
39810 </cell>
39811 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39812 \begin_inset Text
39813
39814 \begin_layout Standard
39815
39816 \size footnotesize
39817 This is used for receiving parameters passed in registers;
39818 \newline
39819 Move the values
39820  in the next parameter register to IC_RESULT 
39821 \end_layout
39822
39823 \end_inset
39824 </cell>
39825 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
39826 \begin_inset Text
39827
39828 \begin_layout Standard
39829
39830 \size footnotesize
39831 None
39832 \end_layout
39833
39834 \end_inset
39835 </cell>
39836 </row>
39837 <row topline="true" bottomline="true">
39838 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39839 \begin_inset Text
39840
39841 \begin_layout Standard
39842
39843 \shape slanted
39844 \size footnotesize
39845 (some more have been added)
39846 \end_layout
39847
39848 \end_inset
39849 </cell>
39850 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39851 \begin_inset Text
39852
39853 \begin_layout Standard
39854
39855 \end_layout
39856
39857 \end_inset
39858 </cell>
39859 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39860 \begin_inset Text
39861
39862 \begin_layout Standard
39863
39864 \end_layout
39865
39866 \end_inset
39867 </cell>
39868 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
39869 \begin_inset Text
39870
39871 \begin_layout Standard
39872
39873 \shape slanted
39874 \size footnotesize
39875 see f.e.
39876  
39877 \family typewriter
39878 gen51Code()
39879 \family default
39880  in 
39881 \family typewriter
39882 src/mcs51/gen.c
39883 \end_layout
39884
39885 \end_inset
39886 </cell>
39887 </row>
39888 </lyxtabular>
39889
39890 \end_inset
39891
39892
39893 \end_layout
39894
39895 \begin_layout Standard
39896 \begin_inset Note Note
39897 status collapsed
39898
39899 \begin_layout Standard
39900 In the original article Figure II was announced to be downloadable on 
39901 \shape italic
39902 Circuit Cellar
39903 \shape default
39904 's web site.
39905  ftp://ftp.circuitcellar.com/pub/Circuit_Cellar/2000/121/dutta.ZIP
39906 \end_layout
39907
39908 \end_inset
39909
39910
39911 \end_layout
39912
39913 \begin_layout Paragraph*
39914 ICode Example
39915 \begin_inset LatexCommand \index{iCode}
39916
39917 \end_inset
39918
39919
39920 \end_layout
39921
39922 \begin_layout Standard
39923 This section shows some details of iCode.
39924  The example C code does not do anything useful; it is used as an example
39925  to illustrate the intermediate code generated by the compiler.
39926 \end_layout
39927
39928 \begin_layout Verse
39929
39930 \family typewriter
39931 1.\InsetSpace ~
39932 xdata int * p;
39933 \newline
39934 2.\InsetSpace ~
39935 int gint;
39936 \newline
39937 3.\InsetSpace ~
39938 /* This function does nothing useful.
39939  It is used
39940 \newline
39941 4.\InsetSpace ~
39942 \InsetSpace ~
39943 \InsetSpace ~
39944 \InsetSpace ~
39945 for the purpose of explaining iCode */
39946 \newline
39947 5.\InsetSpace ~
39948 short function (data
39949  int *x)
39950 \newline
39951 6.\InsetSpace ~
39952 {
39953 \newline
39954 7.\InsetSpace ~
39955 \InsetSpace ~
39956 \InsetSpace ~
39957 short i=10; \InsetSpace ~
39958 \InsetSpace ~
39959 /* dead initialization eliminated */
39960 \newline
39961 8.\InsetSpace ~
39962 \InsetSpace ~
39963 \InsetSpace ~
39964 short sum=10;
39965  /* dead initialization eliminated */
39966 \newline
39967 9.\InsetSpace ~
39968 \InsetSpace ~
39969 \InsetSpace ~
39970 short mul;
39971 \newline
39972 10.\InsetSpace ~
39973 \InsetSpace ~
39974 int j ;
39975 \newline
39976 11.\InsetSpace ~
39977 \InsetSpace ~
39978 while (*x) *x++
39979  = *p++; 
39980 \newline
39981 12.\InsetSpace ~
39982 \InsetSpace ~
39983 \InsetSpace ~
39984 \InsetSpace ~
39985 sum = 0 ; 
39986 \newline
39987 13.\InsetSpace ~
39988 \InsetSpace ~
39989 mul = 0;
39990 \newline
39991 14.\InsetSpace ~
39992 \InsetSpace ~
39993 /* compiler detects i,j to be induction
39994  variables */
39995 \newline
39996 15.\InsetSpace ~
39997 \InsetSpace ~
39998 for (i = 0, j = 10 ; i < 10 ; i++, j
39999 \family default
40000 -
40001 \begin_inset ERT
40002 status collapsed
40003
40004 \begin_layout Standard
40005
40006
40007 \backslash
40008 /
40009 \end_layout
40010
40011 \end_inset
40012
40013 -
40014 \family typewriter
40015 ) {
40016 \newline
40017 16.\InsetSpace ~
40018 \InsetSpace ~
40019 \InsetSpace ~
40020 \InsetSpace ~
40021 sum += i;
40022 \newline
40023 17.\InsetSpace ~
40024 \InsetSpace ~
40025 \InsetSpace ~
40026 \InsetSpace ~
40027 mul += i * 3; \InsetSpace ~
40028 \InsetSpace ~
40029 /* this multiplication remains */
40030 \newline
40031 18.\InsetSpace ~
40032 \InsetSpace ~
40033 \InsetSpace ~
40034 \InsetSpace ~
40035 gint +=
40036  j * 3;\InsetSpace ~
40037 \InsetSpace ~
40038 /* this multiplication changed to addition */
40039 \newline
40040 19.\InsetSpace ~
40041 \InsetSpace ~
40042 }
40043 \newline
40044 20.\InsetSpace ~
40045 \InsetSpace ~
40046 return sum+mul;
40047 \newline
40048 21.\InsetSpace ~
40049 }
40050 \end_layout
40051
40052 \begin_layout Standard
40053 In addition to the operands each iCode contains information about the filename
40054  and line it corresponds to in the source file.
40055  The first field in the listing should be interpreted as follows:
40056 \newline
40057
40058 \shape italic
40059 \size footnotesize
40060 Filename(linenumber: iCode Execution sequence number : ICode hash table
40061  key : loop depth of the iCode).
40062 \shape default
40063 \size default
40064
40065 \newline
40066 Then follows the human readable form of the ICode operation.
40067  Each operand of this triplet form can be of three basic types a) compiler
40068  generated temporary b) user defined variable c) a constant value.
40069  Note that local variables and parameters are replaced by compiler generated
40070  temporaries.
40071  Live ranges
40072 \begin_inset LatexCommand \index{Live range analysis}
40073
40074 \end_inset
40075
40076  are computed only for temporaries (i.e.
40077  live ranges are not computed for global variables).
40078  Registers
40079 \begin_inset LatexCommand \index{Register allocation}
40080
40081 \end_inset
40082
40083  are allocated for temporaries only.
40084  Operands are formatted in the following manner:
40085 \newline
40086
40087 \shape italic
40088 \size footnotesize
40089 Operand Name [lr live-from : live-to ] { type information } [ registers
40090  allocated ].
40091 \shape default
40092 \size default
40093
40094 \newline
40095 As mentioned earlier the live ranges are computed in terms of the execution
40096  sequence number of the iCodes, for example 
40097 \newline
40098 the iTemp0 is live from (i.e.
40099  first defined in iCode with execution sequence number 3, and is last used
40100  in the iCode with sequence number 5).
40101  For induction variables such as iTemp21 the live range computation extends
40102  the lifetime from the start to the end of the loop.
40103 \newline
40104 The register allocator
40105  used the live range information to allocate registers, the same registers
40106  may be used for different temporaries if their live ranges do not overlap,
40107  for example r0 is allocated to both iTemp6 and to iTemp17 since their live
40108  ranges do not overlap.
40109  In addition the allocator also takes into consideration the type and usage
40110  of a temporary, for example itemp6 is a pointer to near space and is used
40111  as to fetch data from (i.e.
40112  used in GET_VALUE_AT_ADDRESS) so it is allocated a pointer register (r0).
40113  Some short lived temporaries are allocated to special registers which have
40114  meaning to the code generator e.g.
40115  iTemp13 is allocated to a pseudo register CC which tells the back end that
40116  the temporary is used only for a conditional jump the code generation makes
40117  use of this information to optimize a compare and jump ICode.
40118 \newline
40119 There are several
40120  loop optimizations
40121 \begin_inset LatexCommand \index{Loop optimization}
40122
40123 \end_inset
40124
40125  performed by the compiler.
40126  It can detect induction variables iTemp21(i) and iTemp23(j).
40127  Also note the compiler does selective strength reduction
40128 \begin_inset LatexCommand \index{Strength reduction}
40129
40130 \end_inset
40131
40132 , i.e.
40133  the multiplication of an induction variable in line 18 (gint = j * 3) is
40134  changed to addition, a new temporary iTemp17 is allocated and assigned
40135  a initial value, a constant 3 is then added for each iteration of the loop.
40136  The compiler does not change the multiplication
40137 \begin_inset LatexCommand \index{Multiplication}
40138
40139 \end_inset
40140
40141  in line 17 however since the processor does support an 8 * 8 bit multiplication.
40142 \newline
40143
40144 Note the dead code elimination
40145 \begin_inset LatexCommand \index{Dead-code elimination}
40146
40147 \end_inset
40148
40149  optimization eliminated the dead assignments in line 7 & 8 to I and sum
40150  respectively.
40151 \newline
40152
40153 \end_layout
40154
40155 \begin_layout Standard
40156
40157 \size footnotesize
40158 Sample.c (5:1:0:0) _entry($9) :
40159 \end_layout
40160
40161 \begin_layout Standard
40162
40163 \size footnotesize
40164 Sample.c(5:2:1:0) proc _function [lr0:0]{function short}
40165 \end_layout
40166
40167 \begin_layout Standard
40168
40169 \size footnotesize
40170 Sample.c(11:3:2:0) iTemp0 [lr3:5]{_near * int}[r2] = recv 
40171 \end_layout
40172
40173 \begin_layout Standard
40174
40175 \size footnotesize
40176 Sample.c(11:4:53:0) preHeaderLbl0($11) :
40177 \end_layout
40178
40179 \begin_layout Standard
40180
40181 \size footnotesize
40182 Sample.c(11:5:55:0) iTemp6 [lr5:16]{_near * int}[r0] := iTemp0 [lr3:5]{_near
40183  * int}[r2]
40184 \end_layout
40185
40186 \begin_layout Standard
40187
40188 \size footnotesize
40189 Sample.c(11:6:5:1) _whilecontinue_0($1) :
40190 \end_layout
40191
40192 \begin_layout Standard
40193
40194 \size footnotesize
40195 Sample.c(11:7:7:1) iTemp4 [lr7:8]{int}[r2 r3] = @[iTemp6 [lr5:16]{_near *
40196  int}[r0]]
40197 \end_layout
40198
40199 \begin_layout Standard
40200
40201 \size footnotesize
40202 Sample.c(11:8:8:1) if iTemp4 [lr7:8]{int}[r2 r3] == 0 goto _whilebreak_0($3)
40203 \end_layout
40204
40205 \begin_layout Standard
40206
40207 \size footnotesize
40208 Sample.c(11:9:14:1) iTemp7 [lr9:13]{_far * int}[DPTR] := _p [lr0:0]{_far
40209  * int}
40210 \end_layout
40211
40212 \begin_layout Standard
40213
40214 \size footnotesize
40215 Sample.c(11:10:15:1) _p [lr0:0]{_far * int} = _p [lr0:0]{_far * int} + 0x2
40216  {short}
40217 \end_layout
40218
40219 \begin_layout Standard
40220
40221 \size footnotesize
40222 Sample.c(11:13:18:1) iTemp10 [lr13:14]{int}[r2 r3] = @[iTemp7 [lr9:13]{_far
40223  * int}[DPTR]]
40224 \end_layout
40225
40226 \begin_layout Standard
40227
40228 \size footnotesize
40229 Sample.c(11:14:19:1) *(iTemp6 [lr5:16]{_near * int}[r0]) := iTemp10 [lr13:14]{int
40230 }[r2 r3]
40231 \end_layout
40232
40233 \begin_layout Standard
40234
40235 \size footnotesize
40236 Sample.c(11:15:12:1) iTemp6 [lr5:16]{_near * int}[r0] = iTemp6 [lr5:16]{_near
40237  * int}[r0] + 0x2 {short}
40238 \end_layout
40239
40240 \begin_layout Standard
40241
40242 \size footnotesize
40243 Sample.c(11:16:20:1) goto _whilecontinue_0($1)
40244 \end_layout
40245
40246 \begin_layout Standard
40247
40248 \size footnotesize
40249 Sample.c(11:17:21:0)_whilebreak_0($3) :
40250 \end_layout
40251
40252 \begin_layout Standard
40253
40254 \size footnotesize
40255 Sample.c(12:18:22:0) iTemp2 [lr18:40]{short}[r2] := 0x0 {short}
40256 \end_layout
40257
40258 \begin_layout Standard
40259
40260 \size footnotesize
40261 Sample.c(13:19:23:0) iTemp11 [lr19:40]{short}[r3] := 0x0 {short}
40262 \end_layout
40263
40264 \begin_layout Standard
40265
40266 \size footnotesize
40267 Sample.c(15:20:54:0)preHeaderLbl1($13) :
40268 \end_layout
40269
40270 \begin_layout Standard
40271
40272 \size footnotesize
40273 Sample.c(15:21:56:0) iTemp21 [lr21:38]{short}[r4] := 0x0 {short}
40274 \end_layout
40275
40276 \begin_layout Standard
40277
40278 \size footnotesize
40279 Sample.c(15:22:57:0) iTemp23 [lr22:38]{int}[r5 r6] := 0xa {int}
40280 \end_layout
40281
40282 \begin_layout Standard
40283
40284 \size footnotesize
40285 Sample.c(15:23:58:0) iTemp17 [lr23:38]{int}[r7 r0] := 0x1e {int}
40286 \end_layout
40287
40288 \begin_layout Standard
40289
40290 \size footnotesize
40291 Sample.c(15:24:26:1)_forcond_0($4) :
40292 \end_layout
40293
40294 \begin_layout Standard
40295
40296 \size footnotesize
40297 Sample.c(15:25:27:1) iTemp13 [lr25:26]{char}[CC] = iTemp21 [lr21:38]{short}[r4]
40298  < 0xa {short}
40299 \end_layout
40300
40301 \begin_layout Standard
40302
40303 \size footnotesize
40304 Sample.c(15:26:28:1) if iTemp13 [lr25:26]{char}[CC] == 0 goto _forbreak_0($7)
40305 \end_layout
40306
40307 \begin_layout Standard
40308
40309 \size footnotesize
40310 Sample.c(16:27:31:1) iTemp2 [lr18:40]{short}[r2] = iTemp2 [lr18:40]{short}[r2]
40311  + ITemp21 [lr21:38]{short}[r4]
40312 \end_layout
40313
40314 \begin_layout Standard
40315
40316 \size footnotesize
40317 Sample.c(17:29:33:1) iTemp15 [lr29:30]{short}[r1] = iTemp21 [lr21:38]{short}[r4]
40318  * 0x3 {short}
40319 \end_layout
40320
40321 \begin_layout Standard
40322
40323 \size footnotesize
40324 Sample.c(17:30:34:1) iTemp11 [lr19:40]{short}[r3] = iTemp11 [lr19:40]{short}[r3]
40325  + iTemp15 [lr29:30]{short}[r1]
40326 \end_layout
40327
40328 \begin_layout Standard
40329
40330 \size footnotesize
40331 Sample.c(18:32:36:1:1) iTemp17 [lr23:38]{int}[r7 r0]= iTemp17 [lr23:38]{int}[r7
40332  r0]- 0x3 {short}
40333 \end_layout
40334
40335 \begin_layout Standard
40336
40337 \size footnotesize
40338 Sample.c(18:33:37:1) _gint [lr0:0]{int} = _gint [lr0:0]{int} + iTemp17 [lr23:38]{
40339 int}[r7 r0]
40340 \end_layout
40341
40342 \begin_layout Standard
40343
40344 \size footnotesize
40345 Sample.c(15:36:42:1) iTemp21 [lr21:38]{short}[r4] = iTemp21 [lr21:38]{short}[r4]
40346  + 0x1 {short}
40347 \end_layout
40348
40349 \begin_layout Standard
40350
40351 \size footnotesize
40352 Sample.c(15:37:45:1) iTemp23 [lr22:38]{int}[r5 r6]= iTemp23 [lr22:38]{int}[r5
40353  r6]- 0x1 {short}
40354 \end_layout
40355
40356 \begin_layout Standard
40357
40358 \size footnotesize
40359 Sample.c(19:38:47:1) goto _forcond_0($4)
40360 \end_layout
40361
40362 \begin_layout Standard
40363
40364 \size footnotesize
40365 Sample.c(19:39:48:0)_forbreak_0($7) :
40366 \end_layout
40367
40368 \begin_layout Standard
40369
40370 \size footnotesize
40371 Sample.c(20:40:49:0) iTemp24 [lr40:41]{short}[DPTR] = iTemp2 [lr18:40]{short}[r2]
40372  + ITemp11 [lr19:40]{short}[r3]
40373 \end_layout
40374
40375 \begin_layout Standard
40376
40377 \size footnotesize
40378 Sample.c(20:41:50:0) ret iTemp24 [lr40:41]{short}
40379 \end_layout
40380
40381 \begin_layout Standard
40382
40383 \size footnotesize
40384 Sample.c(20:42:51:0)_return($8) :
40385 \end_layout
40386
40387 \begin_layout Standard
40388
40389 \size footnotesize
40390 Sample.c(20:43:52:0) eproc _function [lr0:0]{ ia0 re0 rm0}{function short}
40391 \size default
40392
40393 \newline
40394
40395 \newline
40396 Finally the code generated for this function:
40397 \newline
40398
40399 \end_layout
40400
40401 \begin_layout Standard
40402
40403 \size footnotesize
40404 .area DSEG (DATA)
40405 \end_layout
40406
40407 \begin_layout Standard
40408
40409 \size footnotesize
40410 _p::
40411 \end_layout
40412
40413 \begin_layout Standard
40414
40415 \size footnotesize
40416 \InsetSpace ~
40417 \InsetSpace ~
40418 .ds 2
40419 \end_layout
40420
40421 \begin_layout Standard
40422
40423 \size footnotesize
40424 _gint::
40425 \end_layout
40426
40427 \begin_layout Standard
40428
40429 \size footnotesize
40430 \InsetSpace ~
40431 \InsetSpace ~
40432 .ds 2
40433 \end_layout
40434
40435 \begin_layout Standard
40436
40437 \size footnotesize
40438 ; sample.c 5
40439 \end_layout
40440
40441 \begin_layout Standard
40442
40443 \size footnotesize
40444 ; ----------------------------------------------
40445 \end_layout
40446
40447 \begin_layout Standard
40448
40449 \size footnotesize
40450 ; function function
40451 \end_layout
40452
40453 \begin_layout Standard
40454
40455 \size footnotesize
40456 ; ----------------------------------------------
40457 \end_layout
40458
40459 \begin_layout Standard
40460
40461 \size footnotesize
40462 _function:
40463 \end_layout
40464
40465 \begin_layout Standard
40466
40467 \size footnotesize
40468 ; iTemp0 [lr3:5]{_near * int}[r2] = recv 
40469 \end_layout
40470
40471 \begin_layout Standard
40472
40473 \size footnotesize
40474 \InsetSpace ~
40475 \InsetSpace ~
40476 mov r2,dpl
40477 \end_layout
40478
40479 \begin_layout Standard
40480
40481 \size footnotesize
40482 ; iTemp6 [lr5:16]{_near * int}[r0] := iTemp0 [lr3:5]{_near * int}[r2]
40483 \end_layout
40484
40485 \begin_layout Standard
40486
40487 \size footnotesize
40488 \InsetSpace ~
40489 \InsetSpace ~
40490 mov ar0,r2
40491 \end_layout
40492
40493 \begin_layout Standard
40494
40495 \size footnotesize
40496 ;_whilecontinue_0($1) :
40497 \end_layout
40498
40499 \begin_layout Standard
40500
40501 \size footnotesize
40502 00101$:
40503 \end_layout
40504
40505 \begin_layout Standard
40506
40507 \size footnotesize
40508 ; iTemp4 [lr7:8]{int}[r2 r3] = @[iTemp6 [lr5:16]{_near * int}[r0]]
40509 \end_layout
40510
40511 \begin_layout Standard
40512
40513 \size footnotesize
40514 ; if iTemp4 [lr7:8]{int}[r2 r3] == 0 goto _whilebreak_0($3)
40515 \end_layout
40516
40517 \begin_layout Standard
40518
40519 \size footnotesize
40520 \InsetSpace ~
40521 \InsetSpace ~
40522 mov ar2,@r0
40523 \end_layout
40524
40525 \begin_layout Standard
40526
40527 \size footnotesize
40528 \InsetSpace ~
40529 \InsetSpace ~
40530 inc r0
40531 \end_layout
40532
40533 \begin_layout Standard
40534
40535 \size footnotesize
40536 \InsetSpace ~
40537 \InsetSpace ~
40538 mov ar3,@r0
40539 \end_layout
40540
40541 \begin_layout Standard
40542
40543 \size footnotesize
40544 \InsetSpace ~
40545 \InsetSpace ~
40546 dec r0
40547 \end_layout
40548
40549 \begin_layout Standard
40550
40551 \size footnotesize
40552 \InsetSpace ~
40553 \InsetSpace ~
40554 mov a,r2
40555 \end_layout
40556
40557 \begin_layout Standard
40558
40559 \size footnotesize
40560 \InsetSpace ~
40561 \InsetSpace ~
40562 orl a,r3
40563 \end_layout
40564
40565 \begin_layout Standard
40566
40567 \size footnotesize
40568 \InsetSpace ~
40569 \InsetSpace ~
40570 jz 00103$
40571 \end_layout
40572
40573 \begin_layout Standard
40574
40575 \size footnotesize
40576 00114$:
40577 \end_layout
40578
40579 \begin_layout Standard
40580
40581 \size footnotesize
40582 ; iTemp7 [lr9:13]{_far * int}[DPTR] := _p [lr0:0]{_far * int}
40583 \end_layout
40584
40585 \begin_layout Standard
40586
40587 \size footnotesize
40588 \InsetSpace ~
40589 \InsetSpace ~
40590 mov dpl,_p
40591 \end_layout
40592
40593 \begin_layout Standard
40594
40595 \size footnotesize
40596 \InsetSpace ~
40597 \InsetSpace ~
40598 mov dph,(_p + 1)
40599 \end_layout
40600
40601 \begin_layout Standard
40602
40603 \size footnotesize
40604 ; _p [lr0:0]{_far * int} = _p [lr0:0]{_far * int} + 0x2 {short}
40605 \end_layout
40606
40607 \begin_layout Standard
40608
40609 \size footnotesize
40610 \InsetSpace ~
40611 \InsetSpace ~
40612 mov a,#0x02
40613 \end_layout
40614
40615 \begin_layout Standard
40616
40617 \size footnotesize
40618 \InsetSpace ~
40619 \InsetSpace ~
40620 add a,_p
40621 \end_layout
40622
40623 \begin_layout Standard
40624
40625 \size footnotesize
40626 \InsetSpace ~
40627 \InsetSpace ~
40628 mov _p,a
40629 \end_layout
40630
40631 \begin_layout Standard
40632
40633 \size footnotesize
40634 \InsetSpace ~
40635 \InsetSpace ~
40636 clr a
40637 \end_layout
40638
40639 \begin_layout Standard
40640
40641 \size footnotesize
40642 \InsetSpace ~
40643 \InsetSpace ~
40644 addc a,(_p + 1)
40645 \end_layout
40646
40647 \begin_layout Standard
40648
40649 \size footnotesize
40650 \InsetSpace ~
40651 \InsetSpace ~
40652 mov (_p + 1),a
40653 \end_layout
40654
40655 \begin_layout Standard
40656
40657 \size footnotesize
40658 ; iTemp10 [lr13:14]{int}[r2 r3] = @[iTemp7 [lr9:13]{_far * int}[DPTR]]
40659 \end_layout
40660
40661 \begin_layout Standard
40662
40663 \size footnotesize
40664 \InsetSpace ~
40665 \InsetSpace ~
40666 movx a,@dptr
40667 \end_layout
40668
40669 \begin_layout Standard
40670
40671 \size footnotesize
40672 \InsetSpace ~
40673 \InsetSpace ~
40674 mov r2,a
40675 \end_layout
40676
40677 \begin_layout Standard
40678
40679 \size footnotesize
40680 \InsetSpace ~
40681 \InsetSpace ~
40682 inc dptr
40683 \end_layout
40684
40685 \begin_layout Standard
40686
40687 \size footnotesize
40688 \InsetSpace ~
40689 \InsetSpace ~
40690 movx a,@dptr
40691 \end_layout
40692
40693 \begin_layout Standard
40694
40695 \size footnotesize
40696 \InsetSpace ~
40697 \InsetSpace ~
40698 mov r3,a
40699 \end_layout
40700
40701 \begin_layout Standard
40702
40703 \size footnotesize
40704 ; *(iTemp6 [lr5:16]{_near * int}[r0]) := iTemp10 [lr13:14]{int}[r2 r3]
40705 \end_layout
40706
40707 \begin_layout Standard
40708
40709 \size footnotesize
40710 \InsetSpace ~
40711 \InsetSpace ~
40712 mov @r0,ar2
40713 \end_layout
40714
40715 \begin_layout Standard
40716
40717 \size footnotesize
40718 \InsetSpace ~
40719 \InsetSpace ~
40720 inc r0
40721 \end_layout
40722
40723 \begin_layout Standard
40724
40725 \size footnotesize
40726 \InsetSpace ~
40727 \InsetSpace ~
40728 mov @r0,ar3
40729 \end_layout
40730
40731 \begin_layout Standard
40732
40733 \size footnotesize
40734 ; iTemp6 [lr5:16]{_near * int}[r0] = 
40735 \end_layout
40736
40737 \begin_layout Standard
40738
40739 \size footnotesize
40740 ; iTemp6 [lr5:16]{_near * int}[r0] + 
40741 \end_layout
40742
40743 \begin_layout Standard
40744
40745 \size footnotesize
40746 ; 0x2 {short}
40747 \end_layout
40748
40749 \begin_layout Standard
40750
40751 \size footnotesize
40752 \InsetSpace ~
40753 \InsetSpace ~
40754 inc r0
40755 \end_layout
40756
40757 \begin_layout Standard
40758
40759 \size footnotesize
40760 ; goto _whilecontinue_0($1)
40761 \end_layout
40762
40763 \begin_layout Standard
40764
40765 \size footnotesize
40766 \InsetSpace ~
40767 \InsetSpace ~
40768 sjmp 00101$
40769 \end_layout
40770
40771 \begin_layout Standard
40772
40773 \size footnotesize
40774 ; _whilebreak_0($3) :
40775 \end_layout
40776
40777 \begin_layout Standard
40778
40779 \size footnotesize
40780 00103$:
40781 \end_layout
40782
40783 \begin_layout Standard
40784
40785 \size footnotesize
40786 ; iTemp2 [lr18:40]{short}[r2] := 0x0 {short}
40787 \end_layout
40788
40789 \begin_layout Standard
40790
40791 \size footnotesize
40792 \InsetSpace ~
40793 \InsetSpace ~
40794 mov r2,#0x00
40795 \end_layout
40796
40797 \begin_layout Standard
40798
40799 \size footnotesize
40800 ; iTemp11 [lr19:40]{short}[r3] := 0x0 {short}
40801 \end_layout
40802
40803 \begin_layout Standard
40804
40805 \size footnotesize
40806 \InsetSpace ~
40807 \InsetSpace ~
40808 mov r3,#0x00
40809 \end_layout
40810
40811 \begin_layout Standard
40812
40813 \size footnotesize
40814 ; iTemp21 [lr21:38]{short}[r4] := 0x0 {short}
40815 \end_layout
40816
40817 \begin_layout Standard
40818
40819 \size footnotesize
40820 \InsetSpace ~
40821 \InsetSpace ~
40822 mov r4,#0x00
40823 \end_layout
40824
40825 \begin_layout Standard
40826
40827 \size footnotesize
40828 ; iTemp23 [lr22:38]{int}[r5 r6] := 0xa {int}
40829 \end_layout
40830
40831 \begin_layout Standard
40832
40833 \size footnotesize
40834 \InsetSpace ~
40835 \InsetSpace ~
40836 mov r5,#0x0A
40837 \end_layout
40838
40839 \begin_layout Standard
40840
40841 \size footnotesize
40842 \InsetSpace ~
40843 \InsetSpace ~
40844 mov r6,#0x00
40845 \end_layout
40846
40847 \begin_layout Standard
40848
40849 \size footnotesize
40850 ; iTemp17 [lr23:38]{int}[r7 r0] := 0x1e {int}
40851 \end_layout
40852
40853 \begin_layout Standard
40854
40855 \size footnotesize
40856 \InsetSpace ~
40857 \InsetSpace ~
40858 mov r7,#0x1E
40859 \end_layout
40860
40861 \begin_layout Standard
40862
40863 \size footnotesize
40864 \InsetSpace ~
40865 \InsetSpace ~
40866 mov r0,#0x00
40867 \end_layout
40868
40869 \begin_layout Standard
40870
40871 \size footnotesize
40872 ; _forcond_0($4) :
40873 \end_layout
40874
40875 \begin_layout Standard
40876
40877 \size footnotesize
40878 00104$:
40879 \end_layout
40880
40881 \begin_layout Standard
40882
40883 \size footnotesize
40884 ; iTemp13 [lr25:26]{char}[CC] = iTemp21 [lr21:38]{short}[r4] < 0xa {short}
40885 \end_layout
40886
40887 \begin_layout Standard
40888
40889 \size footnotesize
40890 ; if iTemp13 [lr25:26]{char}[CC] == 0 goto _forbreak_0($7)
40891 \end_layout
40892
40893 \begin_layout Standard
40894
40895 \size footnotesize
40896 \InsetSpace ~
40897 \InsetSpace ~
40898 clr c
40899 \end_layout
40900
40901 \begin_layout Standard
40902
40903 \size footnotesize
40904 \InsetSpace ~
40905 \InsetSpace ~
40906 mov a,r4
40907 \end_layout
40908
40909 \begin_layout Standard
40910
40911 \size footnotesize
40912 \InsetSpace ~
40913 \InsetSpace ~
40914 xrl a,#0x80
40915 \end_layout
40916
40917 \begin_layout Standard
40918
40919 \size footnotesize
40920 \InsetSpace ~
40921 \InsetSpace ~
40922 subb a,#0x8a
40923 \end_layout
40924
40925 \begin_layout Standard
40926
40927 \size footnotesize
40928 \InsetSpace ~
40929 \InsetSpace ~
40930 jnc 00107$
40931 \end_layout
40932
40933 \begin_layout Standard
40934
40935 \size footnotesize
40936 00115$:
40937 \end_layout
40938
40939 \begin_layout Standard
40940
40941 \size footnotesize
40942 ; iTemp2 [lr18:40]{short}[r2] = iTemp2 [lr18:40]{short}[r2] + 
40943 \end_layout
40944
40945 \begin_layout Standard
40946
40947 \size footnotesize
40948 ; iTemp21 [lr21:38]{short}[r4]
40949 \end_layout
40950
40951 \begin_layout Standard
40952
40953 \size footnotesize
40954 \InsetSpace ~
40955 \InsetSpace ~
40956 mov a,r4
40957 \end_layout
40958
40959 \begin_layout Standard
40960
40961 \size footnotesize
40962 \InsetSpace ~
40963 \InsetSpace ~
40964 add a,r2
40965 \end_layout
40966
40967 \begin_layout Standard
40968
40969 \size footnotesize
40970 \InsetSpace ~
40971 \InsetSpace ~
40972 mov r2,a
40973 \end_layout
40974
40975 \begin_layout Standard
40976
40977 \size footnotesize
40978 ; iTemp15 [lr29:30]{short}[r1] = iTemp21 [lr21:38]{short}[r4] * 0x3 {short}
40979 \end_layout
40980
40981 \begin_layout Standard
40982
40983 \size footnotesize
40984 \InsetSpace ~
40985 \InsetSpace ~
40986 mov b,#0x03
40987 \end_layout
40988
40989 \begin_layout Standard
40990
40991 \size footnotesize
40992 \InsetSpace ~
40993 \InsetSpace ~
40994 mov a,r4
40995 \end_layout
40996
40997 \begin_layout Standard
40998
40999 \size footnotesize
41000 \InsetSpace ~
41001 \InsetSpace ~
41002 mul ab
41003 \end_layout
41004
41005 \begin_layout Standard
41006
41007 \size footnotesize
41008 \InsetSpace ~
41009 \InsetSpace ~
41010 mov r1,a
41011 \end_layout
41012
41013 \begin_layout Standard
41014
41015 \size footnotesize
41016 ; iTemp11 [lr19:40]{short}[r3] = iTemp11 [lr19:40]{short}[r3] + 
41017 \end_layout
41018
41019 \begin_layout Standard
41020
41021 \size footnotesize
41022 ; iTemp15 [lr29:30]{short}[r1]
41023 \end_layout
41024
41025 \begin_layout Standard
41026
41027 \size footnotesize
41028 \InsetSpace ~
41029 \InsetSpace ~
41030 add a,r3
41031 \end_layout
41032
41033 \begin_layout Standard
41034
41035 \size footnotesize
41036 \InsetSpace ~
41037 \InsetSpace ~
41038 mov r3,a
41039 \end_layout
41040
41041 \begin_layout Standard
41042
41043 \size footnotesize
41044 ; iTemp17 [lr23:38]{int}[r7 r0]= iTemp17 [lr23:38]{int}[r7 r0]- 0x3 {short}
41045 \end_layout
41046
41047 \begin_layout Standard
41048
41049 \size footnotesize
41050 \InsetSpace ~
41051 \InsetSpace ~
41052 mov a,r7
41053 \end_layout
41054
41055 \begin_layout Standard
41056
41057 \size footnotesize
41058 \InsetSpace ~
41059 \InsetSpace ~
41060 add a,#0xfd
41061 \end_layout
41062
41063 \begin_layout Standard
41064
41065 \size footnotesize
41066 \InsetSpace ~
41067 \InsetSpace ~
41068 mov r7,a
41069 \end_layout
41070
41071 \begin_layout Standard
41072
41073 \size footnotesize
41074 \InsetSpace ~
41075 \InsetSpace ~
41076 mov a,r0
41077 \end_layout
41078
41079 \begin_layout Standard
41080
41081 \size footnotesize
41082 \InsetSpace ~
41083 \InsetSpace ~
41084 addc a,#0xff
41085 \end_layout
41086
41087 \begin_layout Standard
41088
41089 \size footnotesize
41090 \InsetSpace ~
41091 \InsetSpace ~
41092 mov r0,a
41093 \end_layout
41094
41095 \begin_layout Standard
41096
41097 \size footnotesize
41098 ; _gint [lr0:0]{int} = _gint [lr0:0]{int} + iTemp17 [lr23:38]{int}[r7 r0]
41099 \end_layout
41100
41101 \begin_layout Standard
41102
41103 \size footnotesize
41104 \InsetSpace ~
41105 \InsetSpace ~
41106 mov a,r7
41107 \end_layout
41108
41109 \begin_layout Standard
41110
41111 \size footnotesize
41112 \InsetSpace ~
41113 \InsetSpace ~
41114 add a,_gint
41115 \end_layout
41116
41117 \begin_layout Standard
41118
41119 \size footnotesize
41120 \InsetSpace ~
41121 \InsetSpace ~
41122 mov _gint,a
41123 \end_layout
41124
41125 \begin_layout Standard
41126
41127 \size footnotesize
41128 \InsetSpace ~
41129 \InsetSpace ~
41130 mov a,r0
41131 \end_layout
41132
41133 \begin_layout Standard
41134
41135 \size footnotesize
41136 \InsetSpace ~
41137 \InsetSpace ~
41138 addc a,(_gint + 1)
41139 \end_layout
41140
41141 \begin_layout Standard
41142
41143 \size footnotesize
41144 \InsetSpace ~
41145 \InsetSpace ~
41146 mov (_gint + 1),a
41147 \end_layout
41148
41149 \begin_layout Standard
41150
41151 \size footnotesize
41152 ; iTemp21 [lr21:38]{short}[r4] = iTemp21 [lr21:38]{short}[r4] + 0x1 {short}
41153 \end_layout
41154
41155 \begin_layout Standard
41156
41157 \size footnotesize
41158 \InsetSpace ~
41159 \InsetSpace ~
41160 inc r4
41161 \end_layout
41162
41163 \begin_layout Standard
41164
41165 \size footnotesize
41166 ; iTemp23 [lr22:38]{int}[r5 r6]= iTemp23 [lr22:38]{int}[r5 r6]- 0x1 {short}
41167 \end_layout
41168
41169 \begin_layout Standard
41170
41171 \size footnotesize
41172 \InsetSpace ~
41173 \InsetSpace ~
41174 dec r5
41175 \end_layout
41176
41177 \begin_layout Standard
41178
41179 \size footnotesize
41180 \InsetSpace ~
41181 \InsetSpace ~
41182 cjne r5,#0xff,00104$
41183 \end_layout
41184
41185 \begin_layout Standard
41186
41187 \size footnotesize
41188 \InsetSpace ~
41189 \InsetSpace ~
41190 dec r6
41191 \end_layout
41192
41193 \begin_layout Standard
41194
41195 \size footnotesize
41196 ; goto _forcond_0($4)
41197 \end_layout
41198
41199 \begin_layout Standard
41200
41201 \size footnotesize
41202 \InsetSpace ~
41203 \InsetSpace ~
41204 sjmp 00104$
41205 \end_layout
41206
41207 \begin_layout Standard
41208
41209 \size footnotesize
41210 ; _forbreak_0($7) :
41211 \end_layout
41212
41213 \begin_layout Standard
41214
41215 \size footnotesize
41216 00107$:
41217 \end_layout
41218
41219 \begin_layout Standard
41220
41221 \size footnotesize
41222 ; ret iTemp24 [lr40:41]{short}
41223 \end_layout
41224
41225 \begin_layout Standard
41226
41227 \size footnotesize
41228 \InsetSpace ~
41229 \InsetSpace ~
41230 mov a,r3
41231 \end_layout
41232
41233 \begin_layout Standard
41234
41235 \size footnotesize
41236 \InsetSpace ~
41237 \InsetSpace ~
41238 add a,r2
41239 \end_layout
41240
41241 \begin_layout Standard
41242
41243 \size footnotesize
41244 \InsetSpace ~
41245 \InsetSpace ~
41246 mov dpl,a
41247 \end_layout
41248
41249 \begin_layout Standard
41250
41251 \size footnotesize
41252 ; _return($8) :
41253 \end_layout
41254
41255 \begin_layout Standard
41256
41257 \size footnotesize
41258 00108$:
41259 \end_layout
41260
41261 \begin_layout Standard
41262
41263 \size footnotesize
41264 \InsetSpace ~
41265 \InsetSpace ~
41266 ret
41267 \newline
41268
41269 \end_layout
41270
41271 \begin_layout Section
41272 A few words about basic block successors, predecessors and dominators
41273 \end_layout
41274
41275 \begin_layout Standard
41276 Successors are basic blocks
41277 \begin_inset LatexCommand \index{Basic blocks}
41278
41279 \end_inset
41280
41281  that might execute after this basic block.
41282 \newline
41283 Predecessors are basic blocks
41284  that might execute before reaching this basic block.
41285 \newline
41286 Dominators are basic
41287  blocks that WILL execute before reaching this basic block.
41288 \newline
41289
41290 \end_layout
41291
41292 \begin_layout Standard
41293 [basic block 1]
41294 \end_layout
41295
41296 \begin_layout Standard
41297 if (something)
41298 \end_layout
41299
41300 \begin_layout Standard
41301 \InsetSpace ~
41302 \InsetSpace ~
41303 \InsetSpace ~
41304 \InsetSpace ~
41305 [basic block 2]
41306 \end_layout
41307
41308 \begin_layout Standard
41309 else
41310 \end_layout
41311
41312 \begin_layout Standard
41313 \InsetSpace ~
41314 \InsetSpace ~
41315 \InsetSpace ~
41316 \InsetSpace ~
41317 [basic block 3]
41318 \end_layout
41319
41320 \begin_layout Standard
41321 [basic block 4]
41322 \newline
41323
41324 \end_layout
41325
41326 \begin_layout Standard
41327 a) succList of [BB2] = [BB4], of [BB3] = [BB4], of [BB1] = [BB2,BB3]
41328 \end_layout
41329
41330 \begin_layout Standard
41331 b) predList of [BB2] = [BB1], of [BB3] = [BB1], of [BB4] = [BB2,BB3]
41332 \end_layout
41333
41334 \begin_layout Standard
41335 c) domVect of [BB4] = BB1 ...
41336  here we are not sure if BB2 or BB3 was executed but we are SURE that BB1
41337  was executed.
41338 \end_layout
41339
41340 \begin_layout Chapter
41341 Acknowledgments
41342 \end_layout
41343
41344 \begin_layout Standard
41345 \begin_inset LatexCommand \url{http://sdcc.sourceforge.net/#Who}
41346
41347 \end_inset
41348
41349
41350 \newline
41351
41352 \newline
41353
41354 \emph on
41355 Thanks to all the other volunteer developers who have helped with coding,
41356  testing, web-page creation, distribution sets, etc.
41357  You know who you are :-)
41358 \emph default
41359
41360 \newline
41361
41362 \newline
41363
41364 \emph on
41365 Thanks to Sourceforge 
41366 \begin_inset LatexCommand \url{http://www.sf.net}
41367
41368 \end_inset
41369
41370  which has hosted the project since 1999 and donates significant download
41371  bandwidth.
41372 \emph default
41373
41374 \newline
41375
41376 \newline
41377
41378 \emph on
41379 Also thanks to all SDCC Distributed Compile Farm members for donating CPU
41380  cycles and bandwidth for snapshot builds.
41381 \newline
41382
41383 \end_layout
41384
41385 \begin_layout Standard
41386 This document was initially written by Sandeep Dutta
41387 \end_layout
41388
41389 \begin_layout Standard
41390 All product names mentioned herein may be trademarks
41391 \begin_inset LatexCommand \index{Trademarks}
41392
41393 \end_inset
41394
41395  of their respective companies.
41396  
41397 \end_layout
41398
41399 \begin_layout Section*
41400 Alphabetical index
41401 \end_layout
41402
41403 \begin_layout Standard
41404 To avoid confusion, the installation and building options for SDCC itself
41405  (chapter 2) are not part of the index.
41406 \end_layout
41407
41408 \begin_layout Standard
41409 \begin_inset LatexCommand \printindex{}
41410
41411 \end_inset
41412
41413
41414 \end_layout
41415
41416 \end_body
41417 \end_document