* Changed banked for nonbanked
[fw/sdcc] / doc / SDCCUdoc.lyx
1 #This file was created by <sandeep> Sun Mar 26 12:40:23 2000
2 #LyX 1.0 (C) 1995-1999 Matthias Ettrich and the LyX Team
3 \lyxformat 2.15
4 \textclass linuxdoc
5 \language english
6 \inputencoding default
7 \fontscheme default
8 \graphics default
9 \paperfontsize default
10 \spacing single 
11 \papersize Default
12 \paperpackage a4
13 \use_geometry 0
14 \use_amsmath 0
15 \paperorientation portrait
16 \secnumdepth 3
17 \tocdepth 3
18 \paragraph_separation indent
19 \defskip medskip
20 \quotes_language english
21 \quotes_times 2
22 \papercolumns 1
23 \papersides 1
24 \paperpagestyle default
25
26 \layout Title
27
28 SDCC Compiler User Guide
29 \layout Author
30
31 Sandeep Dutta (sandeep.dutta@usa.net)
32 \layout Section
33
34 Introduction
35 \layout Standard
36
37 SDCC is a Free ware , retargettable, optimizing ANSI-C compiler.
38  The current version targets Intel 8051 based MCUs, it can be retargetted
39  for other 8 bit MCUs or PICs.
40  The entire source code for the compiler is distributed under GPL.
41  SDCC used ASXXXX & ASLINK a Free ware, retargettable assembler & linker.
42  SDCC has extensive MCU (8051) specific language extensions, which lets
43  it utilize the underlying hardware effectively.
44  The front-end (parser) will be enhanced to handle language extensions for
45  other MCUs as and when they are targetted.
46  In addition to the MCU Specific optimizations SDCC also does a host of
47  standard optimizations like
48 \emph on 
49  global sub expression elimination, loop optimizations (loop invariant,
50  strength reduction of induction variables and loop reversing), constant
51  folding & propagation, copy propagation, dead code elimination and jumptables
52  for 'switch' statements.
53  
54 \emph default 
55 For the back-end SDCC uses a global register allocation scheme which should
56  be well suited for other 8 bit MCUs , the peep hole optimizer uses a rule
57  based substitution mechanism which is MCU independent.
58  Supported data-types are 
59 \emph on 
60 short (8 bits, 1 byte), char (8 bits, 1 byte), int (16 bits, 2 bytes ),
61  long (32 bit, 4 bytes) & float (4 byte IEEE).
62  
63 \emph default 
64 The compiler also allows 
65 \emph on 
66 inline assembler code
67 \emph default 
68  to be embedded anywhere in a function.
69  In addition routines developed in assembly can also be called.
70  SDCC also provides an option to report the relative complexity of a function,
71  these functions can then be further optimized , or hand coded in assembly
72  if need be.
73  SDCC also comes with a companion source level debugger SDCDB, the debugger
74  currently uses S51 a freeware simulator for 8051, it can be easily modified
75  to use other simulators.
76  The latest version can be downloaded from 
77 \series bold 
78 http://www.geocities.com/ResearchTriangle/Forum/1353
79 \layout Standard
80
81 All packages used in this compiler system are 
82 \emph on 
83 opensource
84 \emph default 
85  (freeware); source code for all the sub-packages ( asxxxx assembler/linker
86  , pre-processor and
87 \emph on 
88  gc
89 \emph default 
90  a conservative garbage collector) are distributed with the package.
91  Documentation was created using a freeware word processor (LyX).
92  
93 \layout Standard
94
95 This program is free software; you can redistribute it and/or modify it
96  under the terms of the GNU General Public License as published by the Free
97  Software Foundation; either version 2, or (at your option) any later version.
98  This program is distributed in the hope that it will be useful, but WITHOUT
99  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
100  FOR A PARTICULAR PURPOSE.
101  See the GNU General Public License for more details.
102  You should have received a copy of the GNU General Public License along
103  with this program; if not, write to the Free Software Foundation, 59 Temple
104  Place - Suite 330, Boston, MA 02111-1307, USA.
105  In other words, you are welcome to use, share and improve this program.
106  You are forbidden to forbid anyone else to use, share and improve what
107  you give them.
108  Help stamp out software-hoarding! 
109 \layout Section
110
111 Installation 
112 \begin_inset LatexCommand \label{Installation}
113
114 \end_inset 
115
116
117 \layout Standard
118
119 What you need before you start installation of SDCC ? A C Compiler, not
120  just any C Compiler, gcc to be exact, you can get adventurous and try another
121  compiler , I HAVEN'T tried it.
122  GCC is free , and is available for almost all major platforms, if you are
123  using 
124 \emph on 
125 linux
126 \emph default 
127  you probably already have it, if you are using 
128 \emph on 
129 Windows 95/NT
130 \emph default 
131  go to 
132 \emph on 
133 www.cygnus.com
134 \emph default 
135  and download 
136 \emph on 
137 CYGWIN32
138 \emph default 
139  you will need the full development version of their tool (
140 \emph on 
141 full.exe)
142 \emph default 
143 , follow their instructions for installation (this is also free and is very
144  easy to install), 
145 \emph on 
146 Windows
147 \emph default 
148  
149 \emph on 
150 95/NT 
151 \emph default 
152 users be aware that the compiler runs substantially slower on the Windows
153  platform, I am not sure why.
154 \layout Standard
155
156 After you have installed 
157 \emph on 
158 gcc
159 \emph default 
160  you are ready to build the compiler (sorry no binary distributions yet).
161  SDCC is native to Linux but can be ported to any platform on which GCC
162  is available .
163  Extract the source file package (
164 \emph on 
165 .zip
166 \emph default 
167  or 
168 \emph on 
169 .tar.gz
170 \emph default 
171 ) into some directory , which we shall refer to as 
172 \emph on 
173 SDCCDIR
174 \emph default 
175  from now on.
176 \layout Subsection
177
178 Components of SDCC
179 \begin_inset LatexCommand \label{Components}
180
181 \end_inset 
182
183
184 \layout Subsubsection
185
186 gc ( a conservative garbage collector)
187 \layout Standard
188
189 SDCC relies on this component to do all the memory management, this excellent
190  package is copyrighted by 
191 \emph on 
192 Jans J Boehm(boehm@sgi.com) and Alan J Demers
193 \emph default 
194  but can be used with minimum restrictions.
195  The GC source will be extracted into the directory 
196 \emph on 
197 SDCCDIR/gc.
198
199 \emph default 
200  
201 \layout Subsubsection
202
203 cpp ( C-Preprocessor)
204 \layout Standard
205
206 The preprocessor is extracted into the directory 
207 \emph on 
208 SDCCDIR/cpp
209 \emph default 
210 , it is a modified version of the GNU preprocessor.
211 \layout Subsubsection
212
213 asxxxx & aslink ( The assembler and Linkage Editor)
214 \layout Standard
215
216 This is retargettable assembler & linkage editor, it was developed by Alan
217  Baldwin, John Hartman created the version for 8051, and I (Sandeep) have
218  some enhancements and bug fixes for it to work properly with the SDCC.
219  This component is extracted into the directory 
220 \emph on 
221 SDCCDIR/asxxxx.
222 \layout Subsubsection
223
224 SDCC - The compiler.
225 \layout Standard
226
227 This is the actual compiler, it uses 
228 \emph on 
229 gc
230 \emph default 
231  and invokes the assembler and linkage editor.
232  All files with the prefix 
233 \emph on 
234 SDCC 
235 \emph default 
236 are part of the compiler and is extracted into the the directory 
237 \emph on 
238 SDCCDIR.
239 \layout Subsubsection
240
241 S51 - Simulator
242 \layout Standard
243
244 Version 2.1.8 onwards contains s51 a freeware , opensource simulator developed
245  by Daniel Drotos <drdani@mazsola.iit.uni-miskolc.hu>.
246  The executable is built as part of build process, for more information
247  visit Daniel's website at <http://mazsola.iit.uni-miskolc.hu/~drdani/embedded/s51/
248 >.
249 \layout Subsubsection
250
251 SDCDB - Source level Debugger.
252 \layout Standard
253
254 SDCDB is the companion source level debugger .
255  The current version of the debugger uses Daniel's Simulator S51, but can
256  be easily changed to use other simulators.
257 \layout Subsection
258
259 Installation for Version <= 2.1.7
260 \layout Standard
261
262 After the package is extracted (
263 \emph on 
264 Windows 95/NT
265 \emph default 
266  users start 
267 \emph on 
268 CYGWIN shell)
269 \emph default 
270 , change to the directory where you extracted the package and give the command.
271 \layout Verbatim
272
273 ./sdccbuild.sh
274 \layout Standard
275
276 This is a 
277 \emph on 
278 bash
279 \emph default 
280  shell script, it will compile all the above mentioned components and install
281  the executables into the directory 
282 \emph on 
283 SDCCDIR/bin
284 \emph default 
285  make sure you add this directory to your 
286 \emph on 
287 PATH
288 \emph default 
289  environment variable.
290  This script will also compile all the support routines ( library routines
291  ) using SDCC.
292  The support routines are all developed in C and need to be compiled.
293 \layout Subsection
294
295 Installation for Version >= 2.1.8a
296 \layout Standard
297
298 The distribution method from Version 2.1.8a has been changed to be conforment
299  with the 
300 \begin_inset Quotes eld
301 \end_inset 
302
303 autoconf
304 \begin_inset Quotes erd
305 \end_inset 
306
307  utility.
308  The source is now distributed as 
309 \series bold 
310 \size large 
311 \emph on 
312 sdcc-<version number>.tar.gz format
313 \series default 
314 \size default 
315 \emph default 
316  , instead of the older .zip format.
317  The steps for installation are as follows.
318 \layout Subsubsection
319
320 Unpack the sources.
321 \layout Standard
322
323 This is usually done by the following command 
324 \begin_inset Quotes eld
325 \end_inset 
326
327
328 \series bold 
329 \size large 
330 \emph on 
331 gunzip -c sdcc-<version number>.tar.gz | tar -xv -
332 \series default 
333 \size default 
334 \emph default 
335
336 \begin_inset Quotes eld
337 \end_inset 
338
339
340 \layout Subsubsection
341
342 Change to the main source directory (usually sdcc or sdcc-<version number>)
343 \layout Subsubsection
344
345 Issue command to configure your system
346 \layout Standard
347
348 The configure command has several options the most commonly used option
349  is --prefix=<directory name>, where <directory name> is the final location
350  for the sdcc executables and libraries, (default location is /usr/local).
351  The installation process will create the following directory structure
352  under the <directory name> specified.
353 \layout Verbatim
354
355 bin/ - binary exectables (add to PATH environment variable) 
356 \newline 
357 share/ 
358 \newline 
359
360 \protected_separator 
361
362 \protected_separator 
363
364 \protected_separator 
365
366 \protected_separator 
367
368 \protected_separator 
369
370 \protected_separator 
371 sdcc51inc/ - include header files 
372 \newline 
373
374 \protected_separator 
375
376 \protected_separator 
377
378 \protected_separator 
379
380 \protected_separator 
381
382 \protected_separator 
383
384 \protected_separator 
385 sdcc51lib/ - 
386 \newline 
387
388 \protected_separator 
389
390 \protected_separator 
391
392 \protected_separator 
393
394 \protected_separator 
395
396 \protected_separator 
397
398 \protected_separator 
399
400 \protected_separator 
401
402 \protected_separator 
403
404 \protected_separator 
405
406 \protected_separator 
407
408 \protected_separator 
409
410 \protected_separator 
411
412 \protected_separator 
413 small/ - Object & Library files for small model library 
414 \newline 
415
416 \protected_separator 
417
418 \protected_separator 
419
420 \protected_separator 
421
422 \protected_separator 
423
424 \protected_separator 
425
426 \protected_separator 
427
428 \protected_separator 
429
430 \protected_separator 
431
432 \protected_separator 
433
434 \protected_separator 
435
436 \protected_separator 
437
438 \protected_separator 
439
440 \protected_separator 
441 large/ - Object & library files for large model library
442 \layout Standard
443
444 The command 
445 \layout Standard
446
447
448 \series bold 
449 \size large 
450 \bar under 
451 './configure --prefix=/usr/local
452 \begin_inset Quotes erd
453 \end_inset 
454
455  
456 \layout Standard
457
458 will create configure the compiler to be installed in directory /usr/local/bin.
459 \layout Subsubsection
460
461 make
462 \layout Standard
463
464 After configuration step issue the command 
465 \layout Standard
466
467
468 \series bold 
469 \size large 
470 \bar under 
471
472 \begin_inset Quotes eld
473 \end_inset 
474
475 make
476 \begin_inset Quotes erd
477 \end_inset 
478
479
480 \layout Standard
481
482 This will compile the compiler
483 \layout Subsubsection
484
485
486 \begin_inset Quotes eld
487 \end_inset 
488
489 make install
490 \begin_inset Quotes erd
491 \end_inset 
492
493
494 \layout Standard
495
496 Will install the compiler and libraries in the appropriate directories.
497 \layout Subsubsection
498
499 Special Notes for Windows Users.
500  Provided by Michael Jamet[ mjamet@computer.org] 
501 \layout Standard
502
503
504 \protected_separator 
505
506 \layout Standard
507
508
509 \protected_separator 
510  How to install SDCC from source on a Windows 95 or Windows NT 4 system
511  
512 \layout Standard
513
514
515 \protected_separator 
516
517 \layout Standard
518
519
520 \protected_separator 
521  This document describes how to install SDCC on a Win 95 or Win NT 4 system.
522  
523 \layout Standard
524
525
526 \protected_separator 
527  These instructions probably work for Win 98 as well, but have not been
528  
529 \layout Standard
530
531
532 \protected_separator 
533  tested on that platform.
534  
535 \layout Standard
536
537
538 \protected_separator 
539
540 \layout Standard
541
542
543 \protected_separator 
544  There are lots of little differences between UNIX and the Win32 Cygnus
545  
546 \layout Standard
547
548
549 \protected_separator 
550  environment which make porting more difficult than it should be.
551 \protected_separator 
552  If 
553 \layout Standard
554
555
556 \protected_separator 
557  you want the details, please contact me.
558 \protected_separator 
559  Otherwise just follow these 
560 \layout Standard
561
562
563 \protected_separator 
564  instructions.
565  
566 \layout Standard
567
568
569 \protected_separator 
570
571 \layout Standard
572
573
574 \protected_separator 
575  1.
576  Install the Cygnus Software 
577 \layout Standard
578
579
580 \protected_separator 
581  Go to http://sourceware.cygnus.com/cygwin.
582 \protected_separator 
583  Cygnus provides a UNIX like 
584 \layout Standard
585
586
587 \protected_separator 
588  environment for Win 32 systems.
589 \protected_separator 
590  Download "full.exe" and install.
591 \protected_separator 
592  You 
593 \layout Standard
594
595
596 \protected_separator 
597  MUST install it on your C drive.
598 \protected_separator 
599  "full.exe" contains a shell AND many 
600 \layout Standard
601
602
603 \protected_separator 
604  common UNIX utilities.
605  
606 \layout Standard
607
608
609 \protected_separator 
610
611 \layout Standard
612
613
614 \protected_separator 
615  2.
616  Download and Extract the Latest SDCC 
617 \layout Standard
618
619
620 \protected_separator 
621  The latest version can be found at 
622 \layout Standard
623
624
625 \protected_separator 
626
627 \protected_separator 
628  www.geocities.com/ResearchTriange/Forum/1353.
629  
630 \layout Standard
631
632
633 \protected_separator 
634  It can be uncompressed with winzip.
635  
636 \layout Standard
637
638
639 \protected_separator 
640
641 \layout Standard
642
643
644 \protected_separator 
645  3.
646 \protected_separator 
647  Start a Cygnus Shell 
648 \layout Standard
649
650
651 \protected_separator 
652  There should be an entry in the Start Menu for Cygnus.
653 \protected_separator 
654  Invoke the shell.
655  
656 \layout Standard
657
658
659 \protected_separator 
660  This gives you a UNIX like environment.
661 \protected_separator 
662  FROM THIS POINT ON, DIRECTORIES 
663 \layout Standard
664
665
666 \protected_separator 
667  MUST BE SPECIFIED WITH FORWARD SLASHES (/) NOT THE DOS STYLE BACK 
668 \layout Standard
669
670
671 \protected_separator 
672  SLASHES (
673 \backslash 
674 ) BECAUSE THIS IS WHAT UNIX EXPECTS.
675 \protected_separator 
676  - 
677 \layout Standard
678
679
680 \protected_separator 
681
682 \protected_separator 
683  ex.
684  "
685 \backslash 
686 winnt" would be "/winnt" under the shell.
687  
688 \layout Standard
689
690
691 \protected_separator 
692
693 \layout Standard
694
695
696 \protected_separator 
697  4.
698  Change Directory to Where SDCC was extracted (referred to as INSTALLDIR)
699  
700 \layout Standard
701
702
703 \protected_separator 
704
705 \layout Standard
706
707
708 \protected_separator 
709  ex.
710  cd /sdcc218Da.
711 \protected_separator 
712  If you extracted to a drive OTHER THAN C, the drive 
713 \layout Standard
714
715
716 \protected_separator 
717  must be specified as part of the path.
718  For example, if you extracted to 
719 \layout Standard
720
721
722 \protected_separator 
723  your "g drive", type the following: "cd //g/mydir".
724 \protected_separator 
725  You must use "//" 
726 \layout Standard
727
728
729 \protected_separator 
730  to specify the drive.
731  
732 \layout Standard
733
734
735 \protected_separator 
736
737 \layout Standard
738
739
740 \protected_separator 
741  5.
742  Make Dirs Which are Automatically Made During the UNIX Installation 
743 \layout Standard
744
745
746 \protected_separator 
747  From the INSTALLDIR, 
748 \layout Standard
749
750
751 \protected_separator 
752
753 \layout Standard
754
755
756 \protected_separator 
757
758 \protected_separator 
759  mkdir -p bin
760 \protected_separator 
761
762 \protected_separator 
763  (not a typo, just "bin") 
764 \layout Standard
765
766
767 \protected_separator 
768
769 \protected_separator 
770  mkdir -p /bin 
771 \layout Standard
772
773
774 \protected_separator 
775
776 \protected_separator 
777  mkdir -p /usr/local/bin 
778 \layout Standard
779
780
781 \protected_separator 
782
783 \protected_separator 
784  mkdir -p /usr/local/share 
785 \layout Standard
786
787
788 \protected_separator 
789
790 \protected_separator 
791  mkdir -p /usr/local/share/sdcc51lib 
792 \layout Standard
793
794
795 \protected_separator 
796
797 \protected_separator 
798  mkdir -p /usr/local/share/sdcc51inc 
799 \layout Standard
800
801
802 \protected_separator 
803
804 \protected_separator 
805  mkdir -p /tmp 
806 \layout Standard
807
808
809 \protected_separator 
810
811 \layout Standard
812
813
814 \protected_separator 
815  (When a path from the root directory is specified WITHOUT a drive, the
816  
817 \layout Standard
818
819
820 \protected_separator 
821  drive defaults to c.
822 \protected_separator 
823  For example /michael/newuser => c:
824 \backslash 
825 michael
826 \backslash 
827 newuser) 
828 \layout Standard
829
830
831 \protected_separator 
832
833 \layout Standard
834
835
836 \protected_separator 
837  6.
838 \protected_separator 
839  Add Programs to /bin Expected by the Installation Process 
840 \layout Standard
841
842
843 \protected_separator 
844
845 \protected_separator 
846  - Look at your path: echo $PATH 
847 \layout Standard
848
849
850 \protected_separator 
851
852 \protected_separator 
853
854 \protected_separator 
855
856 \protected_separator 
857  One of the fields is the diretory with the CYGNUS programs.
858  
859 \layout Standard
860
861
862 \protected_separator 
863
864 \protected_separator 
865
866 \protected_separator 
867  ex.
868  /CYGNUS/CYGWIN~1/H-I586/BIN 
869 \layout Standard
870
871
872 \protected_separator 
873
874 \layout Standard
875
876
877 \protected_separator 
878
879 \protected_separator 
880  - cd to the directory found above.
881 \protected_separator 
882  You may have to fiddle with the 
883 \layout Standard
884
885
886 \protected_separator 
887
888 \protected_separator 
889
890 \protected_separator 
891
892 \protected_separator 
893  case (upper or lower) here because the PATH is SHOWN as all upper 
894 \layout Standard
895
896
897 \protected_separator 
898
899 \protected_separator 
900
901 \protected_separator 
902
903 \protected_separator 
904  case, but is actually mixed.
905 \protected_separator 
906  To help you along, you may type 
907 \layout Standard
908
909
910 \protected_separator 
911
912 \protected_separator 
913
914 \protected_separator 
915
916 \protected_separator 
917  a letter or 2 followed by the escape key.
918 \protected_separator 
919  The shell will fill 
920 \layout Standard
921
922
923 \protected_separator 
924
925 \protected_separator 
926
927 \protected_separator 
928
929 \protected_separator 
930  out the remaining letters IF THEY describe a unique directory.
931  
932 \layout Standard
933
934
935 \protected_separator 
936
937 \protected_separator 
938
939 \protected_separator 
940
941 \protected_separator 
942  If you have problems here, cd one directory and type "ls".
943 \protected_separator 
944  "ls" 
945 \layout Standard
946
947
948 \protected_separator 
949
950 \protected_separator 
951
952 \protected_separator 
953
954 \protected_separator 
955  is the equivalent of "dir/w".
956  
957 \layout Standard
958
959
960 \protected_separator 
961
962 \layout Standard
963
964
965 \protected_separator 
966
967 \protected_separator 
968  - Copy the following: 
969 \layout Standard
970
971
972 \protected_separator 
973
974 \protected_separator 
975
976 \protected_separator 
977  cp sh.exe /bin 
978 \layout Standard
979
980
981 \protected_separator 
982
983 \protected_separator 
984
985 \protected_separator 
986  cp pwd.exe /bin 
987 \layout Standard
988
989
990 \protected_separator 
991
992 \protected_separator 
993
994 \protected_separator 
995  cp echo.exe /bin 
996 \layout Standard
997
998
999 \protected_separator 
1000
1001 \layout Standard
1002
1003
1004 \protected_separator 
1005  7.
1006  Go back to the INSTALLDIR 
1007 \layout Standard
1008
1009
1010 \protected_separator 
1011
1012 \protected_separator 
1013  cd INSTALLDIR 
1014 \layout Standard
1015
1016
1017 \protected_separator 
1018  ex.
1019  cd //d/sdcc218Da 
1020 \layout Standard
1021
1022
1023 \protected_separator 
1024
1025 \layout Standard
1026
1027
1028 \protected_separator 
1029  8.
1030  Run the configure Program 
1031 \layout Standard
1032
1033
1034 \protected_separator 
1035
1036 \protected_separator 
1037  ./configure 
1038 \layout Standard
1039
1040
1041 \protected_separator 
1042  The "./" is important because your current directory is NOT in your path.
1043  
1044 \layout Standard
1045
1046
1047 \protected_separator 
1048  Under DOS, your current directory was implicitly always the first entry
1049  
1050 \layout Standard
1051
1052
1053 \protected_separator 
1054  in your path.
1055  
1056 \layout Standard
1057
1058
1059 \protected_separator 
1060
1061 \layout Standard
1062
1063
1064 \protected_separator 
1065  9.
1066  Run make 
1067 \layout Standard
1068
1069
1070 \protected_separator 
1071
1072 \protected_separator 
1073  make 
1074 \layout Standard
1075
1076
1077 \protected_separator 
1078
1079 \layout Standard
1080
1081
1082 \protected_separator 
1083  This process takes quite some time under Win 32.
1084  
1085 \layout Standard
1086
1087
1088 \protected_separator 
1089
1090 \layout Standard
1091
1092
1093 \protected_separator 
1094  10.
1095  Install the Newly Built Software 
1096 \layout Standard
1097
1098
1099 \protected_separator 
1100
1101 \protected_separator 
1102  make install 
1103 \layout Standard
1104
1105
1106 \protected_separator 
1107
1108 \layout Standard
1109
1110
1111 \protected_separator 
1112  This will partially install the software into the /usr/local directories
1113  
1114 \layout Standard
1115
1116
1117 \protected_separator 
1118  created in step 5.
1119 \protected_separator 
1120  What it actually doing is copying the .c, .h and 
1121 \layout Standard
1122
1123
1124 \protected_separator 
1125  library files to directories under /usr/local/share.
1126  
1127 \layout Standard
1128
1129
1130 \protected_separator 
1131
1132 \layout Standard
1133
1134
1135 \protected_separator 
1136  It will NOT be able to install the actual programs (binaries) because 
1137 \layout Standard
1138
1139
1140 \protected_separator 
1141  it does not know programs on Win32 systems have ".exe" extensions.
1142  
1143 \layout Standard
1144
1145
1146 \protected_separator 
1147  For example, it tries to install sdcc instead of sdcc.exe.
1148  
1149 \layout Standard
1150
1151
1152 \protected_separator 
1153
1154 \layout Standard
1155
1156
1157 \protected_separator 
1158  After the automated part is finished, you must manually copy the binaries:
1159  
1160 \layout Standard
1161
1162
1163 \protected_separator 
1164
1165 \protected_separator 
1166  cd bin
1167 \protected_separator 
1168  (This is the bin directory in your INSTALLDIR) 
1169 \layout Standard
1170
1171
1172 \protected_separator 
1173
1174 \protected_separator 
1175  cp * /usr/local/bin 
1176 \layout Standard
1177
1178
1179 \protected_separator 
1180
1181 \layout Standard
1182
1183
1184 \protected_separator 
1185  11.
1186  Make sure /usr/local/bin is in Your PATH 
1187 \layout Standard
1188
1189
1190 \protected_separator 
1191  You may add c:
1192 \backslash 
1193 usr
1194 \backslash 
1195 local
1196 \backslash 
1197 bin to your path however your Win32 system allows.
1198 \protected_separator 
1199  For 
1200 \layout Standard
1201
1202
1203 \protected_separator 
1204  example you may add it to the PATH statement in autoexec.bat.
1205  
1206 \layout Standard
1207
1208
1209 \protected_separator 
1210
1211 \layout Standard
1212
1213
1214 \protected_separator 
1215  Good luck.
1216 \protected_separator 
1217  If you have any questions send them to me or post them 
1218 \layout Standard
1219
1220
1221 \protected_separator 
1222  to the list.
1223  
1224 \layout Section
1225
1226 Compiling.
1227 \begin_inset LatexCommand \label{Compiling}
1228
1229 \end_inset 
1230
1231
1232 \layout Subsection
1233
1234 Single Source file projects.
1235 \begin_inset LatexCommand \label{One Source File}
1236
1237 \end_inset 
1238
1239
1240 \layout Standard
1241
1242 For single source file projects the process is very simple.
1243  Compile your programs with the following command
1244 \layout Verbatim
1245
1246
1247 \size footnotesize 
1248 sdcc sourcefile.c
1249 \layout Standard
1250
1251 The above command will compile ,assemble and link your source file.
1252  Output files are as follows.
1253 \layout Itemize
1254
1255
1256 \size footnotesize 
1257 sourcefile.asm - Assembler source file created by the compiler
1258 \layout Itemize
1259
1260
1261 \size footnotesize 
1262 sourcefile.lst - Assembler listing file created by the Assembler
1263 \layout Itemize
1264
1265
1266 \size footnotesize 
1267 sourcefile.rst - Assembler listing file updated with linkedit information
1268  , created by linkage editor
1269 \layout Itemize
1270
1271
1272 \size footnotesize 
1273 sourcefile.sym - symbol listing for the sourcefile, created by the assembler.
1274 \layout Itemize
1275
1276
1277 \size footnotesize 
1278 sourcefile.rel - Object file created by the assembler, input to Linkage editor.
1279 \layout Itemize
1280
1281
1282 \size footnotesize 
1283 sourcefile.map - The memory map for the load module, created by the Linker.
1284 \layout Itemize
1285
1286
1287 \size footnotesize 
1288 sourcefile.<ihx | s19> - The load module : ihx - Intel hex format (default
1289  ), s19 - Motorola S19 format when compiler option --out-fmt-s19 is used.
1290 \layout Subsection
1291
1292 Projects with multiple source files.
1293 \layout Standard
1294
1295 SDCC can compile only ONE file at a time.
1296  Let us for example assume that you have a project containing the following
1297  files.
1298 \layout Verbatim
1299
1300
1301 \size footnotesize 
1302 foo1.c ( contains some functions )
1303 \layout Verbatim
1304
1305
1306 \size footnotesize 
1307 foo2.c (contains some more functions)
1308 \layout Verbatim
1309
1310
1311 \size footnotesize 
1312 foomain.c (contains more functions and the function main)
1313 \layout Standard
1314
1315 The first two files will need to be compiled separately with the commands
1316 \layout Verbatim
1317
1318
1319 \size footnotesize 
1320 sdcc -c foo1.c
1321 \layout Verbatim
1322
1323
1324 \size footnotesize 
1325 sdcc -c foo2.c
1326 \layout Standard
1327
1328 Then compile the source file containing main and link the other files together
1329  with the following command.
1330 \layout Verbatim
1331
1332
1333 \size footnotesize 
1334 sdcc foomain.c foo1.rel foo2.rel
1335 \layout Standard
1336
1337 Alternatively 
1338 \emph on 
1339 foomain.c
1340 \emph default 
1341  can be separately compiled as well
1342 \layout Verbatim
1343
1344
1345 \size footnotesize 
1346 sdcc -c foomain.c 
1347 \layout Verbatim
1348
1349
1350 \size footnotesize 
1351 sdcc foomain.rel foo1.rel foo2.rel
1352 \layout Standard
1353
1354 The file containing the main function MUST be the FIRST file specified in
1355  the command line , since the linkage editor processes file in the order
1356  they are presented to it.
1357 \layout Subsection
1358
1359 Projects with additional libraries.
1360 \layout Standard
1361
1362 Some reusable routines may be compiled into a library, see the documentation
1363  for the assembler and linkage editor in the directory 
1364 \emph on 
1365 SDCCDIR/asxxxx/asxhtm.htm 
1366 \emph default 
1367 this describes how to create a 
1368 \emph on 
1369 .lib
1370 \emph default 
1371  library file, the libraries created in this manner may be included using
1372  the command line, make sure you include the -L <library-path> option to
1373  tell the linker where to look for these files.
1374  Here is an example, assuming you have the source file 
1375 \emph on 
1376 'foomain.c
1377 \emph default 
1378 ' and a library
1379 \emph on 
1380  'foolib.lib'
1381 \emph default 
1382  in the directory 
1383 \emph on 
1384 'mylib'
1385 \emph default 
1386 .
1387 \layout Verbatim
1388
1389
1390 \size footnotesize 
1391 sdcc foomain.c foolib.lib -L mylib
1392 \layout Standard
1393
1394 Note here that 
1395 \emph on 
1396 'mylib
1397 \emph default 
1398 ' must be an absolute path name.
1399 \layout Standard
1400
1401 The view of the way the linkage editor processes the library files, it is
1402  recommended that you put each source routine in a separate file and combine
1403  them using the .lib file.
1404  For an example see the standard library file 'libsdcc.lib' in the directory
1405  SDCCDIR/sdcc51lib.
1406 \layout Section
1407
1408 Command Line options
1409 \begin_inset LatexCommand \label{Command Line Options}
1410
1411 \end_inset 
1412
1413
1414 \layout Itemize
1415
1416
1417 \series bold 
1418 \size large 
1419 --model-large
1420 \emph on 
1421
1422 \begin_inset LatexCommand \label{--model-large}
1423
1424 \end_inset 
1425
1426
1427 \series default 
1428 \size default 
1429 \emph default 
1430  Generate code for Large model programs see section Memory Models for more
1431  details.
1432  If this option is used all source files in the project should be compiled
1433  with this option.
1434  In addition the standard library routines are compiled with small model
1435  , they will need to be recompiled.
1436 \layout Itemize
1437
1438
1439 \series bold 
1440 \size large 
1441 \bar under 
1442 --model-small
1443 \series default 
1444 \emph on 
1445 \bar default 
1446  
1447 \size default 
1448 \emph default 
1449
1450 \begin_inset LatexCommand \label{--model-small}
1451
1452 \end_inset 
1453
1454 Generate code for Small Model programs see section Memory Models for more
1455  details.
1456  This is the default model.
1457 \layout Itemize
1458
1459
1460 \series bold 
1461 \size large 
1462 \bar under 
1463 --model-flat24
1464 \series default 
1465 \emph on 
1466 \bar default 
1467  
1468 \size default 
1469 \emph default 
1470
1471 \begin_inset LatexCommand \ref[--model-flat24]{--model-flat24}
1472
1473 \end_inset 
1474
1475 Generate code for Small Model programs see section Memory Models for more
1476  details.
1477  This is the default model.
1478 \layout Itemize
1479
1480
1481 \series bold 
1482 \size large 
1483 \bar under 
1484 --stack-
1485 \emph on 
1486 auto
1487 \series default 
1488 \bar default 
1489  
1490 \size default 
1491 \emph default 
1492
1493 \begin_inset LatexCommand \label{--stack-auto}
1494
1495 \end_inset 
1496
1497 All functions in the source file will be compiled as 
1498 \emph on 
1499 reentrant
1500 \emph default 
1501 , i.e.
1502  the parameters and local variables will be allocated on the stack.
1503  see section Parameters and Local Variables for more details.
1504  If this option is used all source files in the project should be compiled
1505  with this option.
1506  
1507 \layout Itemize
1508
1509
1510 \series bold 
1511 \size large 
1512 \bar under 
1513 --xstack
1514 \series default 
1515 \size default 
1516 \bar default 
1517
1518 \begin_inset LatexCommand \label{--xstack}
1519
1520 \end_inset 
1521
1522  Uses a pseudo stack in the first 256 bytes in the external ram for allocating
1523  variables and passing parameters.
1524  See section on external stack for more details.
1525 \layout Itemize
1526
1527
1528 \series bold 
1529 \size large 
1530 \bar under 
1531 --nogcse
1532 \series default 
1533 \size default 
1534 \bar default 
1535
1536 \begin_inset LatexCommand \label{--nogcse}
1537
1538 \end_inset 
1539
1540  Will not do global subexpression elimination, this option may be used when
1541  the compiler creates undesirably large stack/data spaces to store compiler
1542  temporaries.
1543  A warning message will be generated when this happens and the compiler
1544  will indicate the number of extra bytes it allocated.
1545  It recommended that this option NOT be used , #pragma NOGCSE can be used
1546  to turn off global subexpression elimination for a given function only.
1547 \layout Itemize
1548
1549
1550 \series bold 
1551 \size large 
1552 \bar under 
1553 --noinvariant
1554 \series default 
1555 \size default 
1556 \bar default 
1557
1558 \begin_inset LatexCommand \label{--noinvariant}
1559
1560 \end_inset 
1561
1562  Will not do loop invariant optimizations, this may be turned off for reasons
1563  explained for the previous option .
1564  For more details of loop optimizations performed see section Loop Invariants.It
1565  recommended that this option NOT be used , #pragma NOINVARIANT can be used
1566  to turn off invariant optimizations for a given function only.
1567 \layout Itemize
1568
1569
1570 \series bold 
1571 \size large 
1572 \bar under 
1573 --noinduction
1574 \series default 
1575 \size default 
1576 \bar default 
1577
1578 \begin_inset LatexCommand \label{--noinduction}
1579
1580 \end_inset 
1581
1582  Will not do loop induction optimizations, see section Strength reduction
1583  for more details.It recommended that this option NOT be used , #pragma NOINDUCTI
1584 ON can be used to turn off induction optimizations for given function only.
1585 \layout Itemize
1586
1587
1588 \series bold 
1589 \size large 
1590 \bar under 
1591 --nojtbound 
1592 \series default 
1593 \size default 
1594 \bar default 
1595
1596 \begin_inset LatexCommand \label{--nojtbound}
1597
1598 \end_inset 
1599
1600  Will not generate boundary condition check when switch statements are implement
1601 ed using jump-tables.
1602  See section Switch Statements for more details.It recommended that this
1603  option NOT be used , #pragma NOJTBOUND can be used to turn off boundary
1604  checking for jump tables for a given function only.
1605 \layout Itemize
1606
1607
1608 \series bold 
1609 \size large 
1610 \bar under 
1611 --noloopreverse
1612 \series default 
1613 \bar default 
1614  
1615 \size default 
1616
1617 \begin_inset LatexCommand \label{--noloopreverse}
1618
1619 \end_inset 
1620
1621 Will not do loop reversal optimization
1622 \layout Itemize
1623
1624
1625 \series bold 
1626 \size large 
1627 \bar under 
1628 --noregparms
1629 \series default 
1630 \size default 
1631 \bar default 
1632
1633 \begin_inset LatexCommand \label{--noregparms}
1634
1635 \end_inset 
1636
1637  By default the first parameter is passed using global registers (DPL,DPH,B,ACC).
1638  This option will disable parameter passing using registers.
1639  NOTE: if your program uses the 16/32 bit support routines (for multiplication/d
1640 ivision) these library routines will need to be recompiled with the --noregparms
1641  option as well.
1642 \layout Itemize
1643
1644
1645 \series bold 
1646 \size large 
1647 \bar under 
1648 --callee-saves function1[,function2][,function3]....
1649
1650 \series default 
1651 \size default 
1652 \bar default 
1653  
1654 \begin_inset LatexCommand \label{--callee-saves}
1655
1656 \end_inset 
1657
1658 The compiler by default uses a caller saves convention for register saving
1659  across function calls, however this can cause unneccessary register pushing
1660  & popping when calling small functions from larger functions.
1661  This option can be used to switch the register saving convention for the
1662  function names specified.
1663  The compiler will not save registers when calling these functions, extra
1664  code will be generated at the entry & exit for these functions to save
1665  & restore the registers used by these functions, this can SUBSTANTIALLY
1666  reduce code & improve run time performance of the generated code.
1667  In future the compiler (with interprocedural analysis) will be able to
1668  determine the appropriate scheme to use for each function call.
1669  DO NOT use this option for built-in functions such as _muluint..., if this
1670  option is used for a library function the appropriate library function
1671  needs to be recompiled with the same option.
1672  If the project consists of multiple source files then all the source file
1673  should be compiled with the same --callee-saves option string.
1674  Also see Pragma Directive
1675 \begin_inset LatexCommand \ref{Pragmaa}
1676
1677 \end_inset 
1678
1679  CALLEE-SAVES.
1680 \begin_inset LatexCommand \ref{pragma callee-saves}
1681
1682 \end_inset 
1683
1684  .
1685 \layout Itemize
1686
1687
1688 \series bold 
1689 \bar under 
1690 --debug 
1691 \series default 
1692 \bar default 
1693
1694 \begin_inset LatexCommand \label{--debug}
1695
1696 \end_inset 
1697
1698 When this option is used the compiler will generate debug information ,
1699  that can be used with the SDCDB.
1700  The debug information is collected in a file with .cdb extension.
1701  For more information see documentation for SDCDB.
1702 \layout Itemize
1703
1704
1705 \series bold 
1706 \size large 
1707 \bar under 
1708 --regextend
1709 \size default 
1710  
1711 \series default 
1712 \bar default 
1713
1714 \begin_inset LatexCommand \label{--regextend}
1715
1716 \end_inset 
1717
1718  This option will cause the compiler to define pseudo registers , if this
1719  option is used, all source files in the project should be compiled with
1720  this option.
1721  See section Register Extension for more details.
1722 \layout Itemize
1723
1724
1725 \series bold 
1726 \size large 
1727 \bar under 
1728 --compile-only
1729 \series default 
1730 \bar default 
1731 (-c) 
1732 \size default 
1733
1734 \begin_inset LatexCommand \label{--compile-only}
1735
1736 \end_inset 
1737
1738  will compile and assemble the source only, will not call the linkage editor.
1739 \layout Itemize
1740
1741
1742 \series bold 
1743 \size large 
1744 \bar under 
1745 --xram-loc 
1746 \series default 
1747 \size default 
1748 \bar default 
1749
1750 \begin_inset LatexCommand \label{--xram-loc}
1751
1752 \end_inset 
1753
1754 <Value> The start location of the external ram, default value is 0.
1755  The value entered can be in Hexadecimal or Decimal format .eg.
1756  --xram-loc 0x8000 or --xram-loc 32768.
1757 \layout Itemize
1758
1759
1760 \series bold 
1761 \size large 
1762 \bar under 
1763 --code-loc
1764 \size default 
1765  
1766 \series default 
1767 \bar default 
1768
1769 \begin_inset LatexCommand \label{--code-loc}
1770
1771 \end_inset 
1772
1773 <Value> The start location of the code segment , default value 0.
1774  Note when this option is used the interrupt vector table is also relocated
1775  to the given address.
1776  The value entered can be in Hexadecimal or Decimal format .eg.
1777  --code-loc 0x8000 or --code-loc 32768.
1778 \layout Itemize
1779
1780
1781 \series bold 
1782 \size large 
1783 \bar under 
1784 --stack-loc
1785 \series default 
1786 \size default 
1787 \bar default 
1788
1789 \begin_inset LatexCommand \label{--stack-loc}
1790
1791 \end_inset 
1792
1793 <Value> The initial value of the stack pointer.
1794  The default value of the stack pointer is 0x07 if only register bank 0
1795  is used, if other register banks are used then the stack pointer is initialized
1796  to the location above the highest register bank used.
1797  eg.
1798  if register banks 1 & 2 are used the stack pointer will default to location
1799  0x18.
1800  The value entered can be in Hexadecimal or Decimal format .eg.
1801  --stack-loc 0x20 or --stack-loc 32.
1802  If all four register banks are used the stack will be placed after the
1803  data segment (equivalent to --stack-after-data)
1804 \layout Itemize
1805
1806
1807 \series bold 
1808 \size large 
1809 \bar under 
1810 --stack-after-data
1811 \series default 
1812 \size default 
1813 \bar default 
1814
1815 \begin_inset LatexCommand \label{--stack-after-data}
1816
1817 \end_inset 
1818
1819 This option will cause the stack to be located in the internal ram after
1820  the data segment.
1821 \layout Itemize
1822
1823
1824 \series bold 
1825 \size large 
1826 \bar under 
1827 --data-loc
1828 \series default 
1829 \bar default 
1830  
1831 \size default 
1832
1833 \begin_inset LatexCommand \label{--data-loc}
1834
1835 \end_inset 
1836
1837 <Value> The start location of the internal ram data segment, the default
1838  value is 0x30.The value entered can be in Hexadecimal or Decimal format
1839  .eg.
1840  --data-loc 0x20 or --data-loc 32.
1841 \layout Itemize
1842
1843
1844 \series bold 
1845 \size large 
1846 \bar under 
1847 --idata-loc
1848 \series default 
1849 \size default 
1850 \bar default 
1851
1852 \begin_inset LatexCommand \label{--idata-loc}
1853
1854 \end_inset 
1855
1856 <Value> The start location of the indirectly addressable internal ram, default
1857  value is 0x80.
1858  The value entered can be in Hexadecimal or Decimal format .eg.
1859  --idata-loc 0x88 or --idata-loc 136.
1860 \layout Itemize
1861
1862
1863 \series bold 
1864 \size large 
1865 \bar under 
1866 --peep-file
1867 \size default 
1868
1869 \begin_inset LatexCommand \label{--peep-file}
1870
1871 \end_inset 
1872
1873  
1874 \series default 
1875 \bar default 
1876 <filename> This option can be used to use additional rules to be used by
1877  the peep hole optimizer.
1878  See section Peep Hole optimizations for details on how to write these rules.
1879 \layout Itemize
1880
1881
1882 \series bold 
1883 \size large 
1884 \bar under 
1885 --lib-path (-L)
1886 \size default 
1887  
1888 \series default 
1889 \bar default 
1890
1891 \begin_inset LatexCommand \label{--lib-path}
1892
1893 \end_inset 
1894
1895 <absolute path to additional libraries> This option is passed to the linkage
1896  editor, additional libraries search path.
1897  The path name must be absolute.
1898  Additional library files may be specified in the command line .
1899  See section Compiling programs for more details.
1900 \layout Itemize
1901
1902
1903 \series bold 
1904 \bar under 
1905 -I <path>
1906 \begin_inset LatexCommand \label{-I}
1907
1908 \end_inset 
1909
1910
1911 \series default 
1912 \bar default 
1913  The additional location where the pre processor will look for <..h> or 
1914 \begin_inset Quotes eld
1915 \end_inset 
1916
1917 ..h
1918 \begin_inset Quotes erd
1919 \end_inset 
1920
1921  files.
1922 \layout Itemize
1923
1924
1925 \series bold 
1926 \size large 
1927 \bar under 
1928 -D<macro[=value]>
1929 \series default 
1930 \size default 
1931 \bar default 
1932  
1933 \begin_inset LatexCommand \label{-D}
1934
1935 \end_inset 
1936
1937 Command line definition of macros.
1938  Passed to the pre processor.
1939 \layout Itemize
1940
1941
1942 \series bold 
1943 \size large 
1944 \bar under 
1945 -E
1946 \series default 
1947 \size default 
1948 \bar default 
1949
1950 \begin_inset LatexCommand \label{-E}
1951
1952 \end_inset 
1953
1954  Run only the C preprocessor.
1955  Preprocess all the C source files specified and output the results to standard
1956  output.
1957 \layout Itemize
1958
1959
1960 \series bold 
1961 \size large 
1962 \bar under 
1963 -M
1964 \bar default 
1965
1966 \begin_inset LatexCommand \label{-M}
1967
1968 \end_inset 
1969
1970
1971 \series default 
1972 \size default 
1973  Tell the preprocessor to output a rule suitable for make describing the
1974  dependencies of each object file.
1975  For each source file, the preprocessor outputs one make-rule whose target
1976  is the object file name for that source file and whose dependencies are
1977  all the files `#include'd in it.
1978  This rule may be a single line or may be continued with `
1979 \backslash 
1980 '-newline if it is long.
1981  The list of rules is printed on standard output instead of the preprocessed
1982  C program.
1983  `-M' implies `-E'.
1984 \layout Itemize
1985
1986
1987 \series bold 
1988 \size large 
1989 \bar under 
1990 -C
1991 \series default 
1992 \size default 
1993 \bar default 
1994  
1995 \begin_inset LatexCommand \label{-C}
1996
1997 \end_inset 
1998
1999 Tell the preprocessor not to discard comments.
2000  Used with the `-E' option.
2001 \layout Itemize
2002
2003
2004 \series bold 
2005 \size large 
2006 \bar under 
2007 -MM 
2008 \series default 
2009 \size default 
2010 \bar default 
2011
2012 \begin_inset LatexCommand \label{-MM}
2013
2014 \end_inset 
2015
2016 Like `-M' but the output mentions only the user header files included with
2017  `#include file"'.
2018  System header files included with `#include <file>' are omitted.
2019 \layout Itemize
2020
2021
2022 \series bold 
2023 \size large 
2024 \bar under 
2025 -Aquestion(answer)
2026 \series default 
2027 \size default 
2028 \bar default 
2029
2030 \begin_inset LatexCommand \label{-Aquestion(answer)}
2031
2032 \end_inset 
2033
2034  Assert the answer answer for question, in case it is tested with a preprocessor
2035  conditional such as `#if #question(answer)'.
2036  `-A-' disables the standard asser- tions that normally describe the target
2037  machine.
2038 \layout Itemize
2039
2040
2041 \series bold 
2042 \size large 
2043 \bar under 
2044 -Aquestion
2045 \series default 
2046 \size default 
2047 \bar default 
2048
2049 \begin_inset LatexCommand \label{-Aquestion}
2050
2051 \end_inset 
2052
2053  (answer) Assert the answer answer for question, in case it is tested with
2054  a preprocessor conditional such as `#if #question(answer)'.
2055  `-A-' disables the standard assertions that normally describe the target
2056  machine.
2057 \layout Itemize
2058
2059
2060 \series bold 
2061 \size large 
2062 \bar under 
2063 -Umacro
2064 \series default 
2065 \size default 
2066 \bar default 
2067
2068 \begin_inset LatexCommand \label{-Umacro}
2069
2070 \end_inset 
2071
2072  Undefine macro macro.
2073  `-U' options are evaluated after all `-D' options, but before any `-include'
2074  and `-imac- ros' options.
2075 \layout Itemize
2076
2077
2078 \series bold 
2079 \size large 
2080 \bar under 
2081 -dM
2082 \series default 
2083 \size default 
2084 \bar default 
2085
2086 \begin_inset LatexCommand \label{-dM}
2087
2088 \end_inset 
2089
2090  Tell the preprocessor to output only a list of the mac- ro definitions
2091  that are in effect at the end of prepro- cessing.
2092  Used with the `-E' option.
2093 \layout Itemize
2094
2095
2096 \series bold 
2097 \size large 
2098 \bar under 
2099 -dD
2100 \series default 
2101 \size default 
2102 \bar default 
2103  
2104 \begin_inset LatexCommand \label{-dD}
2105
2106 \end_inset 
2107
2108 Tell the preprocessor to pass all macro definitions into the output, in
2109  their proper sequence in the rest of the output.
2110 \layout Itemize
2111
2112
2113 \series bold 
2114 \size large 
2115 \bar under 
2116 -dN 
2117 \series default 
2118 \size default 
2119 \bar default 
2120
2121 \begin_inset LatexCommand \label{-dN}
2122
2123 \end_inset 
2124
2125 Like `-dD' except that the macro arguments and contents are omitted.
2126  Only `#define name' is included in the output.
2127 \layout Itemize
2128
2129
2130 \series bold 
2131 \size large 
2132 \bar under 
2133 -S 
2134 \series default 
2135 \size default 
2136 \bar default 
2137
2138 \begin_inset LatexCommand \label{-S}
2139
2140 \end_inset 
2141
2142 Stop after the stage of compilation proper; do not as- semble.
2143  The output is an assembler code file for the input file specified.
2144 \layout Itemize
2145
2146
2147 \series bold 
2148 \bar under 
2149 -Wa asmOption[,asmOption]
2150 \series default 
2151 \bar default 
2152 ...
2153  Pass the asmOption to the assembler
2154 \layout Itemize
2155
2156
2157 \series bold 
2158 \bar under 
2159 -Wl linkOption[,linkOption]
2160 \series default 
2161 \bar default 
2162  ..
2163  Pass the linkOption to the linker.
2164 \layout Itemize
2165
2166
2167 \series bold 
2168 \size large 
2169 \bar under 
2170 --int-long-reent
2171 \series default 
2172 \bar default 
2173  
2174 \size default 
2175
2176 \begin_inset LatexCommand \label{--int-long-rent}
2177
2178 \end_inset 
2179
2180  Integer (16 bit) and long (32 bit) libraries have been compiled as reentrant.
2181  Note by default these libraries are compiled as non-reentrant.
2182  See section Installation for more details.
2183 \layout Itemize
2184
2185
2186 \series bold 
2187 \size large 
2188 \bar under 
2189 --cyclomatic
2190 \size default 
2191  
2192 \series default 
2193 \bar default 
2194
2195 \begin_inset LatexCommand \label{--cyclomatic}
2196
2197 \end_inset 
2198
2199 This option will cause the compiler to generate an information message for
2200  each function in the source file.
2201  The message contains some 
2202 \emph on 
2203 important
2204 \emph default 
2205  information about the function.
2206  The number of edges and nodes the compiler detected in the control flow
2207  graph of the function, and most importantly the 
2208 \emph on 
2209 cyclomatic complexity
2210 \emph default 
2211  see section on Cyclomatic Complexity for more details.
2212 \layout Itemize
2213
2214
2215 \series bold 
2216 \size large 
2217 \bar under 
2218 --float-reent
2219 \size default 
2220  
2221 \series default 
2222 \bar default 
2223
2224 \begin_inset LatexCommand \label{--float-reent}
2225
2226 \end_inset 
2227
2228  Floating point library is compiled as reentrant.See section Installation
2229  for more details.
2230 \layout Itemize
2231
2232
2233 \series bold 
2234 \size large 
2235 \bar under 
2236 --out-fmt-ihx
2237 \size default 
2238
2239 \begin_inset LatexCommand \label{--out-fmt-ihx}
2240
2241 \end_inset 
2242
2243  
2244 \series default 
2245 \bar default 
2246 The linker output (final object code) is in Intel Hex format.
2247  (This is the default option).
2248 \layout Itemize
2249
2250
2251 \series bold 
2252 \size large 
2253 \bar under 
2254 --out-fmt-s19
2255 \size default 
2256  
2257 \series default 
2258 \bar default 
2259
2260 \begin_inset LatexCommand \label{--out-fmt-s19}
2261
2262 \end_inset 
2263
2264 The linker output (final object code) is in Motorola S19 format.
2265 \layout Itemize
2266
2267
2268 \series bold 
2269 \size large 
2270 \bar under 
2271 --nooverlay
2272 \series default 
2273 \size default 
2274 \bar default 
2275  
2276 \begin_inset LatexCommand \label{--nooverlay}
2277
2278 \end_inset 
2279
2280  The compiler will not overlay parameters and local variables of any function,
2281  see section Parameters and local variables for more details.
2282 \layout Itemize
2283
2284
2285 \series bold 
2286 \size large 
2287 \bar under 
2288 --main-return
2289 \series default 
2290 \size default 
2291 \bar default 
2292
2293 \begin_inset LatexCommand \label{--main-return}
2294
2295 \end_inset 
2296
2297  This option can be used when the code generated is called by a monitor
2298  program.
2299  The compiler will generate a 'ret' upon return from the 'main' function.
2300  The default option is to lock up i.e.
2301  generate a 'ljmp .' .
2302 \layout Itemize
2303
2304
2305 \series bold 
2306 \size large 
2307 \bar under 
2308 --no-peep
2309 \series default 
2310 \size default 
2311 \bar default 
2312  
2313 \begin_inset LatexCommand \label{--no-peep}
2314
2315 \end_inset 
2316
2317  Disable peep-hole optimization.
2318 \layout Itemize
2319
2320
2321 \series bold 
2322 \size large 
2323 \bar under 
2324 --peep-asm
2325 \series default 
2326 \size default 
2327 \bar default 
2328  
2329 \begin_inset LatexCommand \label{--peep-asm}
2330
2331 \end_inset 
2332
2333  Pass the inline assembler code through the peep hole optimizer.
2334  Can cause unexpected changes to inline assembler code , please go through
2335  the peephole optimizer rules defnied in file 'SDCCpeeph.def' before using
2336  this option.
2337 \layout Itemize
2338
2339
2340 \series bold 
2341 \size large 
2342 \bar under 
2343 --iram-size
2344 \series default 
2345 \size default 
2346 \bar default 
2347
2348 \begin_inset LatexCommand \label{--iram-size}
2349
2350 \end_inset 
2351
2352  <Value> Causes the linker to check if the interal ram usage is within limits
2353  of the given value.
2354 \layout Standard
2355
2356 The following options are provided for the purpose of retargetting and debugging
2357  the compiler .
2358  These provided a means to dump the intermediate code (iCode) generated
2359  by the compiler in human readable form at various stages of the compilation
2360  process.
2361  
2362 \layout Itemize
2363
2364
2365 \series bold 
2366 \size large 
2367 \bar under 
2368 --dumpraw 
2369 \series default 
2370 \size default 
2371 \bar default 
2372
2373 \begin_inset LatexCommand \label{--dumpraw}
2374
2375 \end_inset 
2376
2377 .
2378  This option will cause the compiler to dump the intermediate code into
2379  a file of named 
2380 \emph on 
2381 <source filename>.dumpraw
2382 \emph default 
2383  just after the intermediate code has been generated for a function , i.e.
2384  before any optimizations are done.
2385  The basic blocks at this stage ordered in the depth first number, so they
2386  may not be in sequence of execution.
2387 \layout Itemize
2388
2389
2390 \series bold 
2391 \size large 
2392 \bar under 
2393 --dumpgcse
2394 \series default 
2395 \bar default 
2396 .
2397 \size default 
2398
2399 \begin_inset LatexCommand \label{--dumpgcse}
2400
2401 \end_inset 
2402
2403  Will create a dump if iCode, after global subexpression elimination, into
2404  a file named 
2405 \emph on 
2406 <source filename>.dumpgcse.
2407 \layout Itemize
2408
2409
2410 \series bold 
2411 \size large 
2412 \bar under 
2413 --dumpdeadcode 
2414 \series default 
2415 \size default 
2416 \bar default 
2417
2418 \begin_inset LatexCommand \label{--dumpdeadcode}
2419
2420 \end_inset 
2421
2422 .Will create a dump if iCode, after deadcode elimination, into a file named
2423  
2424 \emph on 
2425 <source filename>.dumpdeadcode.
2426 \layout Itemize
2427
2428
2429 \series bold 
2430 \size large 
2431 \bar under 
2432 --dumploop.
2433
2434 \series default 
2435 \bar default 
2436  
2437 \size default 
2438
2439 \begin_inset LatexCommand \label{--dumploop}
2440
2441 \end_inset 
2442
2443 Will create a dump if iCode, after loop optimizations, into a file named
2444  
2445 \emph on 
2446 <source filename>.dumploop.
2447 \layout Itemize
2448
2449
2450 \series bold 
2451 \size large 
2452 \bar under 
2453 --dumprange.
2454
2455 \series default 
2456 \bar default 
2457  
2458 \size default 
2459
2460 \begin_inset LatexCommand \label{--dump-range}
2461
2462 \end_inset 
2463
2464 Will create a dump if iCode, after live range analysis, into a file named
2465  
2466 \emph on 
2467 <source filename>.dumprange.
2468 \layout Itemize
2469
2470
2471 \series bold 
2472 \size large 
2473 \bar under 
2474 --dumpregassign.
2475
2476 \size default 
2477  
2478 \series default 
2479 \bar default 
2480
2481 \begin_inset LatexCommand \label{--dumpregassign}
2482
2483 \end_inset 
2484
2485 Will create a dump if iCode, after register assignment , into a file named
2486  
2487 \emph on 
2488 <source filename>.dumprassgn.
2489 \layout Itemize
2490
2491
2492 \series bold 
2493 \size large 
2494 \bar under 
2495 --dumpall.
2496  
2497 \series default 
2498 \size default 
2499 \bar default 
2500
2501 \begin_inset LatexCommand \label{--dumpall}
2502
2503 \end_inset 
2504
2505 Will cause all the above mentioned dumps to be created.
2506 \layout Standard
2507
2508 Note that the files created for the dump are appended to each time.
2509  So the files should be deleted manually , before each dump is created.
2510  
2511 \layout Standard
2512
2513 When reporting bugs, it will be very helpful if you could include these
2514  dumps along with the portion of the code that is causing the problem.
2515 \layout Section
2516
2517 Language Extensions
2518 \begin_inset LatexCommand \label{Language Extension}
2519
2520 \end_inset 
2521
2522
2523 \layout Subsection
2524
2525 Storage Classes.
2526 \begin_inset LatexCommand \label{Storage Classes}
2527
2528 \end_inset 
2529
2530
2531 \layout Standard
2532
2533 In addition to the ANSI storage classes SDCC allows the following 8051 specific
2534  storage classes.
2535 \layout Subsubsection
2536
2537 xdata.
2538 \begin_inset LatexCommand \label{xdata}
2539
2540 \end_inset 
2541
2542
2543 \layout Standard
2544
2545 Variables declared with this storage class will be placed in the extern
2546  RAM.
2547  This is the 
2548 \series bold 
2549 default
2550 \series default 
2551  storage class for Large Memory model .
2552 \layout Standard
2553
2554
2555 \size footnotesize 
2556 eg.
2557  
2558 \emph on 
2559 xdata unsigned char xduc;
2560 \layout Subsubsection
2561
2562 data
2563 \begin_inset LatexCommand \label{data}
2564
2565 \end_inset 
2566
2567
2568 \layout Standard
2569
2570 This is the 
2571 \series bold 
2572 default
2573 \series default 
2574  storage class for Small Memory model.
2575  Variables declared with this storage class will be allocated in the internal
2576  RAM.
2577 \layout Standard
2578
2579
2580 \size footnotesize 
2581 eg.
2582
2583 \emph on 
2584  data int iramdata;
2585 \layout Subsubsection
2586
2587 idata
2588 \begin_inset LatexCommand \label{idata}
2589
2590 \end_inset 
2591
2592
2593 \layout Standard
2594
2595 Variables declared with this storage class will be allocated into the indirectly
2596  addressable portion of the internal ram of a 8051 .
2597 \layout Standard
2598
2599
2600 \size footnotesize 
2601 eg.
2602 \emph on 
2603 idata int idi;
2604 \layout Subsubsection
2605
2606 bit
2607 \begin_inset LatexCommand \label{bit}
2608
2609 \end_inset 
2610
2611
2612 \layout Standard
2613
2614 This is a data-type and a storage class specifier.
2615  When a variable is declared as a bit , it is allocated into the bit addressable
2616  memory of 8051.
2617 \layout Standard
2618
2619 eg.
2620 \emph on 
2621 bit iFlag;
2622 \layout Subsubsection
2623
2624 sfr / sbit
2625 \begin_inset LatexCommand \label{sfr / sbit}
2626
2627 \end_inset 
2628
2629
2630 \layout Standard
2631
2632 Like the bit keyword, 
2633 \emph on 
2634 sfr / sbit 
2635 \emph default 
2636 signifies both a data-type and storage class, they are used to describe
2637  the special function registers and special bit variables of a 8051.
2638  
2639 \layout Standard
2640
2641 eg.
2642
2643 \emph on 
2644  
2645 \layout Standard
2646
2647
2648 \emph on 
2649 sfr at 0x80 P0; 
2650 \emph default 
2651 \noun on 
2652 /* special function register P0 at location 0x80 */
2653 \layout Standard
2654
2655
2656 \emph on 
2657 sbit at 0xd7 CY; /* 
2658 \noun on 
2659 CY (Carry Flag) */
2660 \layout Section
2661
2662 Optimizations
2663 \begin_inset LatexCommand \label{Optimizations}
2664
2665 \end_inset 
2666
2667
2668 \layout Standard
2669
2670 SDCC performs a a host of standard optimizations in addition to some MCU
2671  specific optimizations.
2672  
2673 \layout Subsection
2674
2675 Sub-expression elimination
2676 \begin_inset LatexCommand \label{Sub-expression Elimination}
2677
2678 \end_inset 
2679
2680
2681 \layout Standard
2682
2683 The compiler does 
2684 \emph on 
2685 local and global 
2686 \emph default 
2687 common subexpression elimination.
2688 \layout Standard
2689
2690
2691 \family typewriter 
2692 \size scriptsize 
2693 eg.
2694  
2695 \layout Verbatim
2696
2697
2698 \size small 
2699 i = x + y + 1; 
2700 \size default 
2701
2702 \newline 
2703
2704 \size small 
2705 = x + y;
2706 \layout Standard
2707
2708 will be translated to
2709 \layout Verbatim
2710
2711
2712 \size small 
2713 iTemp = x + y 
2714 \newline 
2715 i = iTemp + 1 
2716 \newline 
2717 j = iTemp
2718 \layout Standard
2719
2720 Some subexpressions are not as obvious as the above example.
2721 \layout Standard
2722
2723 eg.
2724 \layout Verbatim
2725
2726
2727 \size small 
2728 a->b[i].c = 10; 
2729 \newline 
2730 a->b[i].d = 11;
2731 \layout Standard
2732
2733 In this case the address arithmetic 
2734 \emph on 
2735 a->b[i] 
2736 \emph default 
2737 will be computed only once; the equivalent code in C would be.
2738 \layout Verbatim
2739
2740
2741 \size small 
2742 iTemp = a->b[i]; 
2743 \newline 
2744 iTemp.c = 10; 
2745 \newline 
2746 iTemp.d = 11;
2747 \layout Standard
2748
2749 The compiler will try to keep these temporary variables in registers.
2750 \layout Subsection
2751
2752 Dead-Code elimination.
2753 \begin_inset LatexCommand \label{Dead-code elimination}
2754
2755 \end_inset 
2756
2757
2758 \layout Standard
2759
2760 eg.
2761 \layout Verbatim
2762
2763
2764 \size small 
2765 int global; 
2766 \newline 
2767 void f () { 
2768 \newline 
2769
2770 \protected_separator 
2771
2772 \protected_separator 
2773 int i; 
2774 \newline 
2775
2776 \protected_separator 
2777
2778 \protected_separator 
2779 i = 1; 
2780 \protected_separator 
2781
2782 \protected_separator 
2783
2784 \protected_separator 
2785 /* dead store */ 
2786 \newline 
2787
2788 \protected_separator 
2789
2790 \protected_separator 
2791 global = 1; /* dead store */ 
2792 \newline 
2793
2794 \protected_separator 
2795
2796 \protected_separator 
2797 global = 2; 
2798 \newline 
2799
2800 \protected_separator 
2801
2802 \protected_separator 
2803 return; 
2804 \newline 
2805
2806 \protected_separator 
2807
2808 \protected_separator 
2809 global = 3; /* unreachable */ 
2810 \newline 
2811 }
2812 \layout Standard
2813
2814 will be changed to
2815 \layout Verbatim
2816
2817
2818 \size footnotesize 
2819 int global; void f () 
2820 \newline 
2821
2822 \protected_separator 
2823  
2824 \protected_separator 
2825  
2826 \newline 
2827
2828 \protected_separator 
2829 global = 2; 
2830 \protected_separator 
2831  
2832 \protected_separator 
2833  
2834 \newline 
2835
2836 \protected_separator 
2837 return; 
2838 \newline 
2839 }
2840 \layout Subsection
2841
2842 Copy-Propagation:
2843 \begin_inset LatexCommand \label{Copy-Propagation}
2844
2845 \end_inset 
2846
2847
2848 \layout Standard
2849
2850 eg.
2851 \layout Verbatim
2852
2853
2854 \size footnotesize 
2855 int f() { 
2856 \newline 
2857
2858 \protected_separator 
2859
2860 \protected_separator 
2861
2862 \protected_separator 
2863 int i, j; 
2864 \newline 
2865
2866 \protected_separator 
2867
2868 \protected_separator 
2869
2870 \protected_separator 
2871 i = 10; 
2872 \newline 
2873
2874 \protected_separator 
2875
2876 \protected_separator 
2877
2878 \protected_separator 
2879 j = i; 
2880 \newline 
2881
2882 \protected_separator 
2883
2884 \protected_separator 
2885
2886 \protected_separator 
2887 return j; 
2888 \newline 
2889 }
2890 \layout Standard
2891
2892 will be changed to 
2893 \layout Verbatim
2894
2895
2896 \size small 
2897 int f() { 
2898 \newline 
2899
2900 \protected_separator 
2901  
2902 \protected_separator 
2903  int i,j; 
2904 \newline 
2905
2906 \protected_separator 
2907  
2908 \protected_separator 
2909  i = 10; 
2910 \newline 
2911
2912 \protected_separator 
2913  
2914 \protected_separator 
2915  j = 10; 
2916 \newline 
2917
2918 \protected_separator 
2919  
2920 \protected_separator 
2921  return 10; 
2922 \newline 
2923 }
2924 \layout Standard
2925
2926 Note: the dead stores created by this copy propagation will be eliminated
2927  by dead-code elimination .
2928 \layout Subsection
2929
2930 Loop optimizations
2931 \begin_inset LatexCommand \label{Loop Optimizations}
2932
2933 \end_inset 
2934
2935
2936 \layout Standard
2937
2938 Two types of loop optimizations are done by SDCC loop invariant lifting
2939  and strength reduction of loop induction variables.In addition to the strength
2940  reduction the optimizer marks the induction variables and the register
2941  allocator tries to keep the induction variables in registers for the duration
2942  of the loop.
2943  Because of this preference of the register allocator , loop induction optimizat
2944 ion causes an increase in register pressure, which may cause unwanted spilling
2945  of other temporary variables into the stack / data space .
2946  The compiler will generate a warning message when it is forced to allocate
2947  extra space either on the stack or data space.
2948  If this extra space allocation is undesirable then induction optimization
2949  can be eliminated either for the entire source file ( with --noinduction
2950  option) or for a given function only (#pragma NOINDUCTION).
2951 \layout Subsubsection
2952
2953 Loop Invariant:
2954 \begin_inset LatexCommand \label{Loop Invariant}
2955
2956 \end_inset 
2957
2958
2959 \layout Standard
2960
2961 eg
2962 \layout Verbatim
2963
2964
2965 \size small 
2966 for (i = 0 ; i < 100 ; i ++) 
2967 \newline 
2968
2969 \protected_separator 
2970  
2971 \protected_separator 
2972  
2973 \protected_separator 
2974 f += k + l;
2975 \layout Standard
2976
2977 changed to
2978 \layout Verbatim
2979
2980
2981 \size small 
2982 itemp = k + l; 
2983 \newline 
2984 for ( i = 0; i < 100; i++ ) f += itemp;
2985 \layout Standard
2986
2987 As mentioned previously some loop invariants are not as apparent, all static
2988  address computations are also moved out of the loop.
2989 \layout Subsubsection
2990
2991 Strength reduction :
2992 \begin_inset LatexCommand \label{Strength Reduction}
2993
2994 \end_inset 
2995
2996
2997 \layout Standard
2998
2999 This optimization substitutes an expression by a cheaper expression.
3000 \layout Standard
3001
3002 eg.
3003 \layout Verbatim
3004
3005
3006 \size small 
3007 for (i=0;i < 100; i++) ar[i*5] = i*3;
3008 \layout Standard
3009
3010 changed to
3011 \layout Verbatim
3012
3013
3014 \size small 
3015 itemp1 = 0; 
3016 \newline 
3017 itemp2 = 0; 
3018 \newline 
3019 for (i=0;i< 100;i++) { 
3020 \newline 
3021
3022 \protected_separator 
3023  
3024 \protected_separator 
3025  
3026 \protected_separator 
3027 ar[itemp1] = itemp2; 
3028 \newline 
3029
3030 \protected_separator 
3031  
3032 \protected_separator 
3033  
3034 \protected_separator 
3035 itemp1 += 5; 
3036 \newline 
3037
3038 \protected_separator 
3039  
3040 \protected_separator 
3041  
3042 \protected_separator 
3043 itemp2 += 3; 
3044 \newline 
3045 }
3046 \layout Standard
3047
3048 The more expensive multiplication is changed to a less expensive addition.
3049 \layout Subsubsection
3050
3051 Loop reversing:
3052 \begin_inset LatexCommand \label{Loop reversing}
3053
3054 \end_inset 
3055
3056
3057 \layout Standard
3058
3059 This optimization is done to reduce the overhead of checking loop boundaries
3060  for every iteration.
3061  Some simple loops can be reversed and implemented using a 
3062 \begin_inset Quotes eld
3063 \end_inset 
3064
3065 decrement and jump if not zero
3066 \begin_inset Quotes erd
3067 \end_inset 
3068
3069  instruction.
3070  SDCC checks for the following criterion to determine if a loop is reversible
3071  (note: more sophisticated compiers use data-dependency analysis to make
3072  this determination, SDCC uses a more simple minded analysis).
3073 \layout Itemize
3074
3075 The 'for' loop is of the form 
3076 \newline 
3077
3078 \begin_inset Quotes eld
3079 \end_inset 
3080
3081 for ( <symbol> = <expression> ; <sym> [< | <=] <expression> ; [<sym>++ |
3082  <sym> += 1])
3083 \newline 
3084
3085 \protected_separator 
3086
3087 \protected_separator 
3088
3089 \protected_separator 
3090
3091 \protected_separator 
3092
3093 \protected_separator 
3094
3095 \protected_separator 
3096
3097 \protected_separator 
3098 <for body>
3099 \begin_inset Quotes erd
3100 \end_inset 
3101
3102
3103 \layout Itemize
3104
3105 The <for body> does not contain 
3106 \begin_inset Quotes eld
3107 \end_inset 
3108
3109 continue
3110 \begin_inset Quotes erd
3111 \end_inset 
3112
3113  or 'break
3114 \begin_inset Quotes erd
3115 \end_inset 
3116
3117 .
3118 \layout Itemize
3119
3120 All goto's are contained within the loop.
3121 \layout Itemize
3122
3123 No function calls within the loop.
3124 \layout Itemize
3125
3126 The loop control variable <sym> is not assigned any value within the loop
3127 \layout Itemize
3128
3129 The loop control variable does NOT participate in any arithmetic operation
3130  within the loop.
3131 \layout Itemize
3132
3133 There are NO switch statements in the loop.
3134 \layout Standard
3135
3136 Note djnz instruction can be used for 8-bit values ONLY, therefore it is
3137  advantageous to declare loop control symbols as either 'char' or 'short',
3138  ofcourse this may not be possible on all situations.
3139 \layout Subsection
3140
3141 Algebraic simplifications:
3142 \begin_inset LatexCommand \label{Algebraic Simplifications}
3143
3144 \end_inset 
3145
3146
3147 \layout Standard
3148
3149 SDCC does numerous algebraic simplifications, the following is a small sub-set
3150  of these optimizations.
3151 \layout Verbatim
3152
3153
3154 \size small 
3155 eg
3156 \emph on 
3157  
3158 \emph default 
3159
3160 \newline 
3161 i = j + 0 ; /* changed to */ i = j; 
3162 \newline 
3163 i /= 2; /* changed to */ i >>= 1; 
3164 \newline 
3165 i = j - j ; /* changed to */ i = 0; 
3166 \newline 
3167 i = j / 1 ; /* changed to */ i = j;
3168 \layout Standard
3169
3170 Note the subexpressions given above are generally introduced by macro expansions
3171  or as a result of copy/constant propagation.
3172 \layout Subsection
3173
3174 'switch' statements.
3175 \begin_inset LatexCommand \label{Switch Statement}
3176
3177 \end_inset 
3178
3179
3180 \layout Standard
3181
3182 SDCC changes switch statements to jump tables when the following conditions
3183  are true.
3184  
3185 \layout Itemize
3186
3187 The case labels are in numerical sequence , the labels need not be in order,
3188  and the starting number need not be one or zero.
3189 \layout Standard
3190
3191 eg 
3192 \layout Verbatim
3193
3194
3195 \size small 
3196 switch(i) {
3197 \protected_separator 
3198  
3199 \protected_separator 
3200  
3201 \protected_separator 
3202  
3203 \protected_separator 
3204  
3205 \protected_separator 
3206  
3207 \protected_separator 
3208  
3209 \protected_separator 
3210  
3211 \protected_separator 
3212  
3213 \protected_separator 
3214  
3215 \protected_separator 
3216  
3217 \protected_separator 
3218  
3219 \protected_separator 
3220  
3221 \protected_separator 
3222 switch (i) { 
3223 \newline 
3224 case 4:...
3225  
3226 \protected_separator 
3227  
3228 \protected_separator 
3229  
3230 \protected_separator 
3231  
3232 \protected_separator 
3233  
3234 \protected_separator 
3235  
3236 \protected_separator 
3237  
3238 \protected_separator 
3239  
3240 \protected_separator 
3241  
3242 \protected_separator 
3243  
3244 \protected_separator 
3245  
3246 \protected_separator 
3247  
3248 \protected_separator 
3249  
3250 \protected_separator 
3251 case 1: ...
3252  
3253 \newline 
3254 case 5:...
3255  
3256 \protected_separator 
3257  
3258 \protected_separator 
3259  
3260 \protected_separator 
3261  
3262 \protected_separator 
3263  
3264 \protected_separator 
3265  
3266 \protected_separator 
3267  
3268 \protected_separator 
3269  
3270 \protected_separator 
3271  
3272 \protected_separator 
3273  
3274 \protected_separator 
3275  
3276 \protected_separator 
3277  
3278 \protected_separator 
3279  
3280 \protected_separator 
3281 case 2: ...
3282  
3283 \newline 
3284 case 3:...
3285  
3286 \protected_separator 
3287  
3288 \protected_separator 
3289  
3290 \protected_separator 
3291  
3292 \protected_separator 
3293  
3294 \protected_separator 
3295  
3296 \protected_separator 
3297  
3298 \protected_separator 
3299  
3300 \protected_separator 
3301  
3302 \protected_separator 
3303  
3304 \protected_separator 
3305  
3306 \protected_separator 
3307  
3308 \protected_separator 
3309  
3310 \protected_separator 
3311 case 3: ...
3312  
3313 \newline 
3314 case 6:...
3315  
3316 \protected_separator 
3317  
3318 \protected_separator 
3319  
3320 \protected_separator 
3321  
3322 \protected_separator 
3323  
3324 \protected_separator 
3325  
3326 \protected_separator 
3327  
3328 \protected_separator 
3329  
3330 \protected_separator 
3331  
3332 \protected_separator 
3333  
3334 \protected_separator 
3335  
3336 \protected_separator 
3337  
3338 \protected_separator 
3339  
3340 \protected_separator 
3341 case 4: ...
3342  
3343 \newline 
3344 }
3345 \protected_separator 
3346  
3347 \protected_separator 
3348  
3349 \protected_separator 
3350  
3351 \protected_separator 
3352  
3353 \protected_separator 
3354  
3355 \protected_separator 
3356  
3357 \protected_separator 
3358  
3359 \protected_separator 
3360  
3361 \protected_separator 
3362  
3363 \protected_separator 
3364  
3365 \protected_separator 
3366  
3367 \protected_separator 
3368  
3369 \protected_separator 
3370  
3371 \protected_separator 
3372  
3373 \protected_separator 
3374  
3375 \protected_separator 
3376  
3377 \protected_separator 
3378  
3379 \protected_separator 
3380 }
3381 \layout Standard
3382
3383 Both the above switch statements will be implemented using a jump-table.
3384 \layout Itemize
3385
3386 The number of case labels is at least three, since it takes two conditional
3387  statements to handle the boundary conditions.
3388 \layout Itemize
3389
3390 The number of case labels is less than 84, since each label takes 3 bytes
3391  and a jump-table can be utmost 256 bytes long.
3392  
3393 \layout Standard
3394
3395 Switch statements which have gaps in the numeric sequence or those that
3396  have more that 84 case labels can be split into more than one switch statement
3397  for efficient code generation.
3398 \layout Standard
3399
3400 eg
3401 \layout Verbatim
3402
3403
3404 \size small 
3405 switch (i) { 
3406 \newline 
3407 case 1: ...
3408  
3409 \newline 
3410 case 2: ...
3411  
3412 \newline 
3413 case 3: ...
3414  
3415 \newline 
3416 case 4: ...
3417  
3418 \newline 
3419 case 9: ...
3420  
3421 \newline 
3422 case 10: ...
3423  
3424 \newline 
3425 case 11: ...
3426  
3427 \newline 
3428 case 12: ...
3429  
3430 \newline 
3431 }
3432 \layout Standard
3433
3434 If the above switch statement is broken down into two switch statements
3435 \layout Verbatim
3436
3437
3438 \size small 
3439 switch (i) { 
3440 \newline 
3441 case 1: ...
3442  
3443 \newline 
3444 case 2: ...
3445  
3446 \newline 
3447 case 3: ...
3448  
3449 \newline 
3450 case 4: ...
3451  
3452 \newline 
3453 }
3454 \layout Verbatim
3455
3456
3457 \size small 
3458 switch (i) { 
3459 \newline 
3460 case 9: ...
3461  
3462 \newline 
3463 case 10: ...
3464  
3465 \newline 
3466 case 11: ...
3467  
3468 \newline 
3469 case 12:...
3470  
3471 \newline 
3472 }
3473 \layout Standard
3474
3475 then both the switch statements will be implemented using jump-tables whereas
3476  the unmodified switch statement will not be .
3477 \layout Subsection
3478
3479 bit-shifting operations.
3480 \begin_inset LatexCommand \label{bit shifting}
3481
3482 \end_inset 
3483
3484
3485 \layout Standard
3486
3487 Bit shifting is one of the most frequently used operation in embedded programmin
3488 g .
3489  SDCC tries to implement bit-shift operations in the most efficient way
3490  possible.
3491 \layout Standard
3492
3493 eg.
3494 \layout Verbatim
3495
3496
3497 \size small 
3498 unsigned short i;
3499 \layout Verbatim
3500
3501
3502 \size small 
3503 ...
3504  
3505 \newline 
3506 i>>= 4; 
3507 \newline 
3508 ..
3509 \layout Standard
3510
3511 generates the following code.
3512 \layout Verbatim
3513
3514
3515 \size small 
3516 mov a,_i 
3517 \newline 
3518 swap a 
3519 \newline 
3520 anl a,#0x0f 
3521 \newline 
3522 mov _i,a
3523 \layout Standard
3524
3525 In general SDCC will never setup a loop if the shift count is known.
3526  Another example
3527 \layout Verbatim
3528
3529
3530 \size small 
3531 unsigned int i; 
3532 \newline 
3533 ...
3534  
3535 \newline 
3536 i >>= 9; 
3537 \newline 
3538 ...
3539 \layout Standard
3540
3541 will generate
3542 \layout Verbatim
3543
3544
3545 \size small 
3546 mov a,(_i + 1) 
3547 \newline 
3548 mov (_i + 1),#0x00 
3549 \newline 
3550 clr c 
3551 \newline 
3552 rrc a 
3553 \newline 
3554 mov _i,a
3555 \layout Standard
3556
3557 Note that SDCC stores numbers in 
3558 \noun on 
3559 little-endian 
3560 \noun default 
3561 format (i.e.
3562  lowest order first)
3563 \layout Subsubsection
3564
3565 Bit-rotation:
3566 \begin_inset LatexCommand \label{bit rotation}
3567
3568 \end_inset 
3569
3570
3571 \layout Standard
3572
3573 A special case of the bit-shift operation is bit rotation, SDCC recognizes
3574  the following expression to be a left bit-rotation.
3575 \layout Verbatim
3576
3577
3578 \size small 
3579 unsigned char i; 
3580 \newline 
3581 ...
3582  
3583 \newline 
3584 i = ( ( i << 1) | ( i >> 7)); 
3585 \newline 
3586 ...
3587 \layout Standard
3588
3589 will generate the following code.
3590 \layout Verbatim
3591
3592
3593 \size small 
3594 mov a,_i 
3595 \newline 
3596 rl a 
3597 \newline 
3598 mov _i,a
3599 \layout Standard
3600
3601 SDCC uses pattern matching on the parse tree to determine this operation
3602  .Variations of this case will also be recognized as bit-rotation i.e
3603 \emph on 
3604  i = ((i >> 7) | (i << 1)); 
3605 \emph default 
3606 /* left-bit rotation */
3607 \layout Subsection
3608
3609 Highest Order Bit.
3610 \begin_inset LatexCommand \label{Highest Order Bit}
3611
3612 \end_inset 
3613
3614
3615 \layout Standard
3616
3617 It is frequently required to obtain the highest order bit of an integral
3618  type (int,long,short or char types).
3619  SDCC recognizes the following expression to yield the highest order bit
3620  and generates optimized code for it.
3621 \layout Verbatim
3622
3623
3624 \size small 
3625 eg 
3626 \newline 
3627 unsigned int gint; 
3628 \newline 
3629 foo () { 
3630 \newline 
3631 unsigned char hob; 
3632 \newline 
3633
3634 \protected_separator 
3635
3636 \protected_separator 
3637
3638 \protected_separator 
3639 ...
3640  
3641 \newline 
3642
3643 \protected_separator 
3644
3645 \protected_separator 
3646
3647 \protected_separator 
3648 hob = (gint >> 15) & 1; 
3649 \newline 
3650
3651 \protected_separator 
3652
3653 \protected_separator 
3654
3655 \protected_separator 
3656 ..
3657  
3658 \newline 
3659 }
3660 \layout Standard
3661
3662 Will generate the following code.
3663 \layout Verbatim
3664
3665
3666 \size small 
3667
3668 \protected_separator 
3669
3670 \protected_separator 
3671
3672 \protected_separator 
3673
3674 \protected_separator 
3675
3676 \protected_separator 
3677
3678 \protected_separator 
3679
3680 \protected_separator 
3681
3682 \protected_separator 
3683
3684 \protected_separator 
3685
3686 \protected_separator 
3687
3688 \protected_separator 
3689
3690 \protected_separator 
3691
3692 \protected_separator 
3693
3694 \protected_separator 
3695
3696 \protected_separator 
3697
3698 \protected_separator 
3699
3700 \protected_separator 
3701
3702 \protected_separator 
3703
3704 \protected_separator 
3705
3706 \protected_separator 
3707
3708 \protected_separator 
3709
3710 \protected_separator 
3711
3712 \protected_separator 
3713
3714 \protected_separator 
3715
3716 \protected_separator 
3717
3718 \protected_separator 
3719
3720 \protected_separator 
3721
3722 \protected_separator 
3723  61 ;
3724 \protected_separator 
3725  hob.c 7 
3726 \newline 
3727
3728 \protected_separator 
3729
3730 \protected_separator 
3731  000A E5*01
3732 \protected_separator 
3733
3734 \protected_separator 
3735
3736 \protected_separator 
3737
3738 \protected_separator 
3739
3740 \protected_separator 
3741
3742 \protected_separator 
3743
3744 \protected_separator 
3745
3746 \protected_separator 
3747
3748 \protected_separator 
3749
3750 \protected_separator 
3751
3752 \protected_separator 
3753
3754 \protected_separator 
3755
3756 \protected_separator 
3757
3758 \protected_separator 
3759
3760 \protected_separator 
3761  62
3762 \protected_separator 
3763
3764 \protected_separator 
3765
3766 \protected_separator 
3767
3768 \protected_separator 
3769
3770 \protected_separator 
3771
3772 \protected_separator 
3773
3774 \protected_separator 
3775
3776 \protected_separator 
3777  mov
3778 \protected_separator 
3779  a,(_gint + 1) 
3780 \newline 
3781
3782 \protected_separator 
3783
3784 \protected_separator 
3785  000C 33
3786 \protected_separator 
3787
3788 \protected_separator 
3789
3790 \protected_separator 
3791
3792 \protected_separator 
3793
3794 \protected_separator 
3795
3796 \protected_separator 
3797
3798 \protected_separator 
3799
3800 \protected_separator 
3801
3802 \protected_separator 
3803
3804 \protected_separator 
3805
3806 \protected_separator 
3807
3808 \protected_separator 
3809
3810 \protected_separator 
3811
3812 \protected_separator 
3813
3814 \protected_separator 
3815
3816 \protected_separator 
3817
3818 \protected_separator 
3819
3820 \protected_separator 
3821  63
3822 \protected_separator 
3823
3824 \protected_separator 
3825
3826 \protected_separator 
3827
3828 \protected_separator 
3829
3830 \protected_separator 
3831
3832 \protected_separator 
3833
3834 \protected_separator 
3835
3836 \protected_separator 
3837  rlc
3838 \protected_separator 
3839  a 
3840 \newline 
3841
3842 \protected_separator 
3843
3844 \protected_separator 
3845  000D E4
3846 \protected_separator 
3847
3848 \protected_separator 
3849
3850 \protected_separator 
3851
3852 \protected_separator 
3853
3854 \protected_separator 
3855
3856 \protected_separator 
3857
3858 \protected_separator 
3859
3860 \protected_separator 
3861
3862 \protected_separator 
3863
3864 \protected_separator 
3865
3866 \protected_separator 
3867
3868 \protected_separator 
3869
3870 \protected_separator 
3871
3872 \protected_separator 
3873
3874 \protected_separator 
3875
3876 \protected_separator 
3877
3878 \protected_separator 
3879
3880 \protected_separator 
3881  64
3882 \protected_separator 
3883
3884 \protected_separator 
3885
3886 \protected_separator 
3887
3888 \protected_separator 
3889
3890 \protected_separator 
3891
3892 \protected_separator 
3893
3894 \protected_separator 
3895
3896 \protected_separator 
3897  clr
3898 \protected_separator 
3899  a 
3900 \newline 
3901
3902 \protected_separator 
3903
3904 \protected_separator 
3905  000E 13
3906 \protected_separator 
3907
3908 \protected_separator 
3909
3910 \protected_separator 
3911
3912 \protected_separator 
3913
3914 \protected_separator 
3915
3916 \protected_separator 
3917
3918 \protected_separator 
3919
3920 \protected_separator 
3921
3922 \protected_separator 
3923
3924 \protected_separator 
3925
3926 \protected_separator 
3927
3928 \protected_separator 
3929
3930 \protected_separator 
3931
3932 \protected_separator 
3933
3934 \protected_separator 
3935
3936 \protected_separator 
3937
3938 \protected_separator 
3939
3940 \protected_separator 
3941  65
3942 \protected_separator 
3943
3944 \protected_separator 
3945
3946 \protected_separator 
3947
3948 \protected_separator 
3949
3950 \protected_separator 
3951
3952 \protected_separator 
3953
3954 \protected_separator 
3955
3956 \protected_separator 
3957  rrc
3958 \protected_separator 
3959  a 
3960 \newline 
3961
3962 \protected_separator 
3963
3964 \protected_separator 
3965  000F F5*02
3966 \protected_separator 
3967
3968 \protected_separator 
3969
3970 \protected_separator 
3971
3972 \protected_separator 
3973
3974 \protected_separator 
3975
3976 \protected_separator 
3977
3978 \protected_separator 
3979
3980 \protected_separator 
3981
3982 \protected_separator 
3983
3984 \protected_separator 
3985
3986 \protected_separator 
3987
3988 \protected_separator 
3989
3990 \protected_separator 
3991
3992 \protected_separator 
3993
3994 \protected_separator 
3995  66
3996 \protected_separator 
3997
3998 \protected_separator 
3999
4000 \protected_separator 
4001
4002 \protected_separator 
4003
4004 \protected_separator 
4005
4006 \protected_separator 
4007
4008 \protected_separator 
4009
4010 \protected_separator 
4011  mov
4012 \protected_separator 
4013  _foo_hob_1_1,a
4014 \layout Standard
4015
4016 Variations of this case however will NOT be recognized .
4017  It is a standard C expression , so I heartily recommend this be the only
4018  way to get the highest order bit, (it is portable).
4019  Of course it will be recognized even if it is embedded in other expressions.
4020 \layout Verbatim
4021
4022
4023 \size small 
4024 eg.
4025 \layout Verbatim
4026
4027
4028 \size small 
4029 xyz = gint + ((gint >> 15) & 1);
4030 \layout Standard
4031
4032 will still be recognized.
4033 \layout Subsection
4034
4035 Peep-hole optimizer.
4036 \begin_inset LatexCommand \label{Peep-Hole}
4037
4038 \end_inset 
4039
4040
4041 \layout Standard
4042
4043 The compiler uses a rule based , pattern matching and re-writing mechanism
4044  for peep-hole optimization .
4045  It is inspired by '
4046 \emph on 
4047 copt'
4048 \emph default 
4049  a peep-hole optimizer by Christopher W.
4050  Fraser (cwfraser@microsoft.com).
4051  A default set of rules are compiled into the compiler, additional rules
4052  may be added with the --peep-file <filename> option.
4053  The rule language is best illustrated with examples.
4054 \layout Verbatim
4055
4056
4057 \size small 
4058 replace { 
4059 \newline 
4060 mov %1,a 
4061 \newline 
4062 mov a,%1 } by { mov %1,a }
4063 \layout Standard
4064
4065 The above rule will the following assembly sequence
4066 \layout Verbatim
4067
4068
4069 \size small 
4070 mov r1,a 
4071 \newline 
4072 mov a,r1
4073 \layout Standard
4074
4075 to
4076 \layout Verbatim
4077
4078
4079 \size small 
4080 mov r1,a
4081 \layout Standard
4082
4083 Note: All occurrences of a '%n' ( pattern variable ) must denote the same
4084  string.
4085  With the above rule, the assembly sequence
4086 \layout Verbatim
4087
4088
4089 \size small 
4090 mov r1,a 
4091 \newline 
4092 mov a,r2
4093 \layout Standard
4094
4095 will remain unmodified.
4096  Other special case optimizations may be added by the user (via --peep-file
4097  option), eg.
4098  some variants of the 8051 MCU allow only 'AJMP' and 'ACALL' , the following
4099  two rules will change all 'LJMP' & 'LCALL' to 'AJMP' & 'ACALL'.
4100 \layout Verbatim
4101
4102
4103 \size small 
4104 replace { lcall %1 } by { acall %1 } 
4105 \newline 
4106 replace { ljmp %1 } by { ajmp %1 }
4107 \layout Standard
4108
4109 The inline-assembler' code is also passed through the peep hole optimizer,
4110  thus the peephole optimizer can also be used as an assembly level macro
4111  expander.
4112  The rules themselves are MCU dependent whereas the rule language infra-structur
4113 e is MCU independent.
4114  Peephole optimization rules for other MCU can be easily programmed using
4115  the rule language.
4116 \layout Standard
4117
4118 The syntax for a rule is as follows ,
4119 \layout Verbatim
4120
4121
4122 \size small 
4123 rule := replace [ restart ] '{' <assembly sequence> '
4124 \backslash 
4125 n' 
4126 \newline 
4127
4128 \protected_separator 
4129  
4130 \protected_separator 
4131  
4132 \protected_separator 
4133  
4134 \protected_separator 
4135  
4136 \protected_separator 
4137  
4138 \protected_separator 
4139  
4140 \protected_separator 
4141  
4142 \protected_separator 
4143  
4144 \protected_separator 
4145  
4146 \protected_separator 
4147  
4148 \protected_separator 
4149  
4150 \protected_separator 
4151  
4152 \protected_separator 
4153  
4154 \protected_separator 
4155  '}' by '{' '
4156 \backslash 
4157 n' 
4158 \newline 
4159
4160 \protected_separator 
4161  
4162 \protected_separator 
4163  
4164 \protected_separator 
4165  
4166 \protected_separator 
4167  
4168 \protected_separator 
4169  
4170 \protected_separator 
4171  
4172 \protected_separator 
4173  
4174 \protected_separator 
4175  
4176 \protected_separator 
4177  
4178 \protected_separator 
4179  
4180 \protected_separator 
4181  
4182 \protected_separator 
4183  
4184 \protected_separator 
4185  
4186 \protected_separator 
4187  
4188 \protected_separator 
4189  
4190 \protected_separator 
4191  <assembly sequence> '
4192 \backslash 
4193 n' 
4194 \newline 
4195
4196 \protected_separator 
4197  
4198 \protected_separator 
4199  
4200 \protected_separator 
4201  
4202 \protected_separator 
4203  
4204 \protected_separator 
4205  
4206 \protected_separator 
4207  
4208 \protected_separator 
4209  
4210 \protected_separator 
4211  
4212 \protected_separator 
4213  
4214 \protected_separator 
4215  
4216 \protected_separator 
4217  
4218 \protected_separator 
4219  
4220 \protected_separator 
4221  
4222 \protected_separator 
4223  '}' [if <functionName> ] '
4224 \backslash 
4225 n' 
4226 \newline 
4227 <assembly sequence> := assembly instruction (each instruction including
4228  labels must be on a separate line).
4229 \protected_separator 
4230  
4231 \protected_separator 
4232
4233 \layout Standard
4234
4235 The optimizer will apply to the rules one by one from the top in the sequence
4236  of their appearance, it will terminate when all rules are exhausted.
4237  If the '
4238 \emph on 
4239 restart
4240 \emph default 
4241 ' option is specified, then the optimizer will start matching the rules
4242  again from the top, this option for a rule is expensive (performance),
4243  it is intended to be used in situations where a transformation will trigger
4244  the same rule again.
4245  A good example of this the following rule.
4246 \layout Verbatim
4247
4248
4249 \size small 
4250 replace restart { 
4251 \newline 
4252 pop %1 
4253 \newline 
4254 push %1 } by { 
4255 \newline 
4256 ; nop 
4257 \newline 
4258 }
4259 \layout Standard
4260
4261 Note that the replace pattern cannot be a blank, but can be a comment line.
4262  Without the '
4263 \emph on 
4264 restart
4265 \emph default 
4266 ' option only the inner most 'pop' 'push' pair would be eliminated.
4267  i.e.
4268 \layout Verbatim
4269
4270
4271 \size small 
4272 pop ar1 
4273 \newline 
4274 pop ar2 
4275 \newline 
4276 push ar2 
4277 \newline 
4278 push ar1
4279 \layout Standard
4280
4281 would result in
4282 \layout Verbatim
4283
4284
4285 \size small 
4286 pop ar1 
4287 \newline 
4288 ; nop 
4289 \newline 
4290 push ar1
4291 \layout Standard
4292
4293 with the '
4294 \emph on 
4295 restart
4296 \emph default 
4297 ' option the rule will be applied again to the resulting code and the all
4298  the '
4299 \emph on 
4300 pop' 'push'
4301 \emph default 
4302  pairs will be eliminated to yield
4303 \layout Verbatim
4304
4305
4306 \size small 
4307 ; nop 
4308 \newline 
4309 ; nop
4310 \layout Standard
4311
4312 A conditional function can be attached to a rule.
4313  Attaching rules are somewhat more involved, let me illustrate this with
4314  an example.
4315 \layout Verbatim
4316
4317
4318 \size small 
4319 replace { 
4320 \newline 
4321
4322 \protected_separator 
4323  
4324 \protected_separator 
4325  
4326 \protected_separator 
4327 ljmp %5 
4328 \newline 
4329 %2:} by { 
4330 \newline 
4331
4332 \protected_separator 
4333  
4334 \protected_separator 
4335  
4336 \protected_separator 
4337 sjmp %5 
4338 \newline 
4339 %2:} if labelInRange
4340 \layout Standard
4341
4342 The optimizer does a look-up of a function name table defined in function
4343  '
4344 \emph on 
4345 callFuncByName'
4346 \emph default 
4347  in the source file 
4348 \emph on 
4349 SDCCpeeph.c
4350 \emph default 
4351  , with the name 
4352 \emph on 
4353 'labelInRange
4354 \emph default 
4355 ', if it finds a corresponding entry the function is called.
4356  Note there can be no parameters specified for these functions, in this
4357  case the use of 
4358 \emph on 
4359 '%5
4360 \emph default 
4361 ' is crucial, since the function 
4362 \emph on 
4363 labelInRange
4364 \emph default 
4365  expects to find the label in that particular variable (the hash table containin
4366 g the variable bindings is passed as a parameter).
4367  If you want to code more such functions , take a close look at the function
4368  
4369 \emph on 
4370 labelInRange
4371 \emph default 
4372  and the calling mechanism in source file 
4373 \emph on 
4374 SDCCpeeph.c
4375 \emph default 
4376 .
4377  I know this whole thing is a little kludgey , may be some day we will have
4378  some better means.
4379  If you are looking at this file, you will also see the default rules that
4380  are compiled into the compiler, you can your own rules in the default set
4381  there if you get tired of specifying the 
4382 \emph on 
4383 --peep-file
4384 \emph default 
4385  option.
4386 \layout Section
4387
4388 Pointers
4389 \begin_inset LatexCommand \label{Pointers}
4390
4391 \end_inset 
4392
4393
4394 \layout Standard
4395
4396 SDCC allows (via language extensions) pointers to explicitly point to any
4397  of the memory spaces of the 8051.
4398  In addition to the explicit pointers, the compiler also allows a 
4399 \emph on 
4400 _generic
4401 \emph default 
4402  class of pointers which can be used to point to any of the memory spaces.
4403  
4404 \layout Standard
4405
4406 Pointer declaration examples.
4407 \layout Verbatim
4408
4409
4410 \size small 
4411 /* pointer physically in xternal ram pointing to object in internal ram
4412  */ 
4413 \newline 
4414 data unsigned char * xdata p;
4415 \newline 
4416
4417 \layout Verbatim
4418
4419
4420 \size small 
4421 /* pointer physically in code rom pointing to data in xdata space */ 
4422 \newline 
4423 xdata unsigned char * code p;
4424 \newline 
4425
4426 \layout Verbatim
4427
4428
4429 \size small 
4430 /* pointer physically in code space pointing to data in code space */ 
4431 \newline 
4432 code unsigned char * code p;
4433 \newline 
4434
4435 \newline 
4436 /* the folowing is a generic pointer physically located in xdata space */
4437 \newline 
4438 char * xdata p;
4439 \layout Standard
4440
4441 Well you get the idea.
4442  For compatibility with the previous version of the compiler, the following
4443  syntax for pointer declaration is also supported.
4444  Note the above examples will be portable to other commercially available
4445  compilers.
4446 \layout Verbatim
4447
4448
4449 \size small 
4450 unsigned char _xdata *ucxdp; /* pointer to data in external ram */ 
4451 \newline 
4452 unsigned char _data 
4453 \protected_separator 
4454 *ucdp ; /* pointer to data in internal ram */ 
4455 \newline 
4456 unsigned char _code 
4457 \protected_separator 
4458 *uccp ; /* pointer to data in R/O code space */
4459 \newline 
4460 unsigned char _idata *uccp; 
4461 \protected_separator 
4462 /* pointer to upper 128 bytes of ram */
4463 \layout Standard
4464
4465 All unqualified pointers are treated as 3 - byte '_generic' pointers.
4466  These type of pointers can also to be explicitly declared.
4467 \layout Verbatim
4468
4469
4470 \size small 
4471 unsigned char _generic *ucgp;
4472 \layout Standard
4473
4474 The highest order byte of the generic pointers contains the data space informati
4475 on.
4476  Assembler support routines are called whenever data is stored or retrieved
4477  using _generic pointers.
4478  These are useful for developing reusable library routines.
4479  Explicitly specifying the pointer type will generate the most efficient
4480  code.
4481  Pointers declared using a mixture of OLD/NEW style could have unpredictable
4482  results.
4483 \layout Section
4484
4485 Parameters & Local Variables
4486 \begin_inset LatexCommand \label{Auto Variables}
4487
4488 \end_inset 
4489
4490
4491 \layout Standard
4492
4493 Automatic (local) variables and parameters to functions can either be placed
4494  on the stack or in data-space.
4495  The default action of the compiler is to place these variables in the internal
4496  RAM ( for small model) or external RAM (for Large model).
4497  They can be placed on the stack either by using the
4498 \emph on 
4499  --stack-auto
4500 \emph default 
4501  compiler option or by using the 'reentrant' keyword in the function declaration.
4502 \layout Standard
4503
4504
4505 \family typewriter 
4506 \size scriptsize 
4507 eg
4508 \layout Verbatim
4509
4510
4511 \size small 
4512 unsigned short foo( short i) reentrant { 
4513 \newline 
4514 ...
4515  
4516 \newline 
4517 }
4518 \layout Standard
4519
4520 Note that when the parameters & local variables are declared in the internal/ext
4521 ernal ram the functions are non-reentrant.
4522  Since stack space on 8051 is limited the 
4523 \emph on 
4524 'reentrant' 
4525 \emph default 
4526 keyword or the
4527 \emph on 
4528  --stack-auto
4529 \emph default 
4530  option should be used sparingly.
4531  Note the reentrant keyword just means that the parameters & local variables
4532  will be allocated to the stack, it DOES NOT mean that the function is register
4533  bank independent.
4534 \layout Standard
4535
4536 When compiled with the default option (i.e.
4537  non-reentrant ), local variables can be assigned storage classes and absolute
4538  addresses.
4539  
4540 \layout Standard
4541
4542
4543 \family typewriter 
4544 \size scriptsize 
4545 eg
4546 \layout Verbatim
4547
4548
4549 \size small 
4550 unsigned short foo() { 
4551 \newline 
4552
4553 \protected_separator 
4554  
4555 \protected_separator 
4556 xdata unsigned short i; 
4557 \newline 
4558
4559 \protected_separator 
4560  
4561 \protected_separator 
4562 bit bvar; 
4563 \newline 
4564
4565 \protected_separator 
4566  
4567 \protected_separator 
4568 data at 0x31 unsiged short j; 
4569 \newline 
4570 ...
4571  
4572 \newline 
4573 }
4574 \layout Standard
4575
4576 In the above example the variable 
4577 \emph on 
4578 i
4579 \emph default 
4580  will be allocated in the external ram, 
4581 \emph on 
4582 bvar
4583 \emph default 
4584  in bit addressable space and
4585 \emph on 
4586  j
4587 \emph default 
4588  in internal ram.
4589  When compiled with the 
4590 \emph on 
4591 --stack-auto
4592 \emph default 
4593  or when a function is declared as 
4594 \emph on 
4595 'reentrant'
4596 \emph default 
4597  local variables cannot be assigned storage classes or absolute addresses.
4598 \layout Standard
4599
4600 Parameters however are not allowed any storage class, (storage classes for
4601  parameters will be ignored), their allocation is governed by the memory
4602  model in use , and the reentrancy options.
4603 \layout Subsection
4604
4605 Overlaying
4606 \begin_inset LatexCommand \label{Overlaying}
4607
4608 \end_inset 
4609
4610
4611 \layout Standard
4612
4613 For non-reentrant functions SDCC will try to reduce internal ram space usage
4614  by overlaying parameters and local variables of a function (if possible).
4615  Parameters and local variables of a function will be allocated to an overlayabl
4616 e segment if the function has 
4617 \emph on 
4618 no other function calls and the function is non-reentrant and the memory
4619  model is small.
4620
4621 \emph default 
4622  If an explicit storage class is specified for a local variable , it will
4623  NOT be overplayed.
4624 \layout Standard
4625
4626 Note that the compiler (not the linkage editor) makes the decision for overlayin
4627 g the data items.
4628  Functions that are called from an interrupt service routine should be preceded
4629  by a #pragma NOOVERLAY if they are not reentrant Along the same lines the
4630  compiler does not do any processing with the inline assembler code so the
4631  compiler might incorrectly assign local variables and parameters of a function
4632  into the overlay segment if the only function call from a function is from
4633  inline assembler code, it is safe to use the #pragma NOOVERLAY for functions
4634  which call other functions using inline assembler code.
4635 \layout Standard
4636
4637 Parameters and Local variables of functions that contain 16 or 32 bit multiplica
4638 tion or division will NOT be overlayed since these are implemented using
4639  external functions.
4640 \layout Standard
4641
4642 eg.
4643 \layout Verbatim
4644
4645
4646 \size small 
4647 #pragma SAVE 
4648 \newline 
4649 #pragma NOOVERLAY 
4650 \newline 
4651 void set_error( unsigned short errcd) 
4652 \newline 
4653
4654 \newline 
4655
4656 \protected_separator 
4657  
4658 \protected_separator 
4659  P3 = errcd; 
4660 \newline 
4661
4662 \newline 
4663 #pragma RESTORE 
4664 \newline 
4665 void some_isr () interrupt 2 using 1 
4666 \newline 
4667
4668 \newline 
4669
4670 \protected_separator 
4671  
4672 \protected_separator 
4673  ...
4674  
4675 \newline 
4676
4677 \protected_separator 
4678  
4679 \protected_separator 
4680  set_error(10); 
4681 \newline 
4682
4683 \protected_separator 
4684  
4685 \protected_separator 
4686  ...
4687  
4688 \newline 
4689 }
4690 \layout Standard
4691
4692 In the above example the parameter 
4693 \emph on 
4694 errcd
4695 \emph default 
4696  for the function 
4697 \emph on 
4698 set_error
4699 \emph default 
4700  would be assigned to the overlayable segment (if the #pragma NOOVERLAY
4701  was not present) , this could cause unpredictable runtime behavior.
4702  The pragma NOOVERLAY ensures that the parameters and local variables for
4703  the function are NOT overlayed.
4704 \layout Section
4705
4706 critical Functions.
4707 \begin_inset LatexCommand \label{Critical}
4708
4709 \end_inset 
4710
4711
4712 \layout Standard
4713
4714 A special keyword may be associated with a function declaring it as '
4715 \emph on 
4716 critical
4717 \emph default 
4718 '.
4719  SDCC will generate code to disable all interrupts upon entry to a critical
4720  function and enable them back before returning .
4721  Note that nesting critical functions may cause unpredictable results.
4722 \layout Standard
4723
4724 eg
4725 \layout Verbatim
4726
4727
4728 \size small 
4729 int foo () critical 
4730 \newline 
4731
4732 \newline 
4733 ...
4734  
4735 \newline 
4736 ...
4737  
4738 \newline 
4739 }
4740 \layout Standard
4741
4742 The critical attribute maybe used with other attributes like 
4743 \emph on 
4744 reentrant.
4745 \layout Section
4746
4747 Absolute addressing.
4748 \begin_inset LatexCommand \label{Absolute Addressing}
4749
4750 \end_inset 
4751
4752
4753 \layout Standard
4754
4755 Data items can be assigned an absolute address with the 
4756 \emph on 
4757 at <address>
4758 \emph default 
4759  keyword, in addition to a storage class.
4760 \layout Verbatim
4761
4762 eg.
4763  
4764 \layout Verbatim
4765
4766
4767 \size small 
4768 xdata at 0x8000 unsigned char PORTA_8255 ;
4769 \layout Standard
4770
4771 In the above example the 
4772 \emph on 
4773 PORTA_8255
4774 \emph default 
4775  will be allocated to the location 0x8000 of the external ram.
4776  
4777 \layout Standard
4778
4779 Note that is this feature is provided to give the programmer access to 
4780 \emph on 
4781 memory mapped
4782 \emph default 
4783  devices attached to the controller.
4784  The compiler does not actually reserve any space for variables declared
4785  in this way (they are implemented with an equate in the assembler), thus
4786  it is left to the programmer to make sure there are no overlaps with other
4787  variables that are declared without the absolute address, the assembler
4788  listing file (.lst) and the linker output files (<filename>.rst) and (<filename>.m
4789 ap) are a good places to look for such overlaps.
4790 \layout Standard
4791
4792 Absolute address can be specified for variables in all storage classes.
4793 \layout Verbatim
4794
4795
4796 \size small 
4797 eg.
4798 \layout Verbatim
4799
4800
4801 \size small 
4802 bit at 0x02 bvar;
4803 \layout Standard
4804
4805 The above example will allocate the variable at offset 0x02 in the bit-addressab
4806 le space.
4807  There is no real advantage to assigning absolute addresses to variables
4808  in this manner , unless you want strict control over all the variables
4809  allocated.
4810 \layout Section
4811
4812 Interrupt Service Routines
4813 \begin_inset LatexCommand \label{Interrupt Service Rouines}
4814
4815 \end_inset 
4816
4817
4818 \layout Standard
4819
4820 SDCC allows interrupt service routines to be coded in C, with some extended
4821  keywords.
4822 \layout Verbatim
4823
4824
4825 \size small 
4826 void timer_isr (void) interrupt 2 using 1 
4827 \newline 
4828
4829 \newline 
4830 ..
4831  
4832 \newline 
4833 }
4834 \layout Standard
4835
4836 The number following the 'interrupt' keyword is the interrupt number this
4837  routine will service.
4838  The compiler will insert a call to this routine in the interrupt vector
4839  table for the interrupt number specified.
4840  The 'using' keyword is used to tell the compiler to use the specified register
4841  bank (8051 specific) when generating code for this function.
4842  Note that when some function is called from an interrupt service routine
4843  it should be preceded by a #pragma NOOVERLAY (if it is not reentrant) .
4844  A special note here, int (16 bit) and long (32 bit) integer division, multiplic
4845 ation & modulus operations are implemented using external support routines
4846  developed in ANSI-C, if an interrupt service routine needs to do any of
4847  these operations then the support routines (as mentioned in a following
4848  section) will have to recompiled using the --stack-auto option and the
4849  source file will need to be compiled using the --int-long-rent compiler
4850  option.
4851 \layout Standard
4852
4853 If you have multiple source files in your project, interrupt service routines
4854  can be present in any of them, but a prototype of the isr MUST be present
4855  in the file that contains the function 
4856 \emph on 
4857 'main'
4858 \emph default 
4859 .
4860 \layout Standard
4861
4862 Interrupt Numbers and the corresponding address & descriptions for the Standard
4863  8051 are listed below.
4864  SDCC will automatically adjust the interrupt vector table to the maximum
4865  interrupt number specified.
4866 \layout Verbatim
4867
4868 Interrupt # 
4869 \protected_separator 
4870
4871 \protected_separator 
4872
4873 \protected_separator 
4874
4875 \protected_separator 
4876
4877 \protected_separator 
4878
4879 \protected_separator 
4880
4881 \protected_separator 
4882
4883 \protected_separator 
4884 Description 
4885 \protected_separator 
4886
4887 \protected_separator 
4888
4889 \protected_separator 
4890
4891 \protected_separator 
4892
4893 \protected_separator 
4894
4895 \protected_separator 
4896
4897 \protected_separator 
4898
4899 \protected_separator 
4900
4901 \protected_separator 
4902
4903 \protected_separator 
4904 Vector Address 
4905 \newline 
4906
4907 \protected_separator 
4908
4909 \protected_separator 
4910
4911 \protected_separator 
4912
4913 \protected_separator 
4914
4915 \protected_separator 
4916
4917 \protected_separator 
4918
4919 \protected_separator 
4920
4921 \protected_separator 
4922
4923 \protected_separator 
4924
4925 \protected_separator 
4926
4927 \protected_separator 
4928
4929 \protected_separator 
4930
4931 \protected_separator 
4932
4933 \protected_separator 
4934
4935 \protected_separator 
4936
4937 \protected_separator 
4938
4939 \protected_separator 
4940
4941 \protected_separator 
4942 External 0
4943 \protected_separator 
4944
4945 \protected_separator 
4946
4947 \protected_separator 
4948
4949 \protected_separator 
4950
4951 \protected_separator 
4952
4953 \protected_separator 
4954
4955 \protected_separator 
4956
4957 \protected_separator 
4958
4959 \protected_separator 
4960
4961 \protected_separator 
4962
4963 \protected_separator 
4964
4965 \protected_separator 
4966 0x0003 
4967 \newline 
4968
4969 \protected_separator 
4970
4971 \protected_separator 
4972
4973 \protected_separator 
4974
4975 \protected_separator 
4976
4977 \protected_separator 
4978
4979 \protected_separator 
4980
4981 \protected_separator 
4982
4983 \protected_separator 
4984
4985 \protected_separator 
4986
4987 \protected_separator 
4988
4989 \protected_separator 
4990
4991 \protected_separator 
4992
4993 \protected_separator 
4994
4995 \protected_separator 
4996
4997 \protected_separator 
4998
4999 \protected_separator 
5000
5001 \protected_separator 
5002
5003 \protected_separator 
5004 Timer 0
5005 \protected_separator 
5006
5007 \protected_separator 
5008
5009 \protected_separator 
5010
5011 \protected_separator 
5012
5013 \protected_separator 
5014
5015 \protected_separator 
5016
5017 \protected_separator 
5018
5019 \protected_separator 
5020
5021 \protected_separator 
5022
5023 \protected_separator 
5024
5025 \protected_separator 
5026
5027 \protected_separator 
5028
5029 \protected_separator 
5030
5031 \protected_separator 
5032
5033 \protected_separator 
5034 0x000B 
5035 \newline 
5036
5037 \protected_separator 
5038
5039 \protected_separator 
5040
5041 \protected_separator 
5042
5043 \protected_separator 
5044
5045 \protected_separator 
5046
5047 \protected_separator 
5048
5049 \protected_separator 
5050
5051 \protected_separator 
5052
5053 \protected_separator 
5054
5055 \protected_separator 
5056
5057 \protected_separator 
5058
5059 \protected_separator 
5060
5061 \protected_separator 
5062
5063 \protected_separator 
5064
5065 \protected_separator 
5066
5067 \protected_separator 
5068
5069 \protected_separator 
5070
5071 \protected_separator 
5072 External 1
5073 \protected_separator 
5074
5075 \protected_separator 
5076
5077 \protected_separator 
5078
5079 \protected_separator 
5080
5081 \protected_separator 
5082
5083 \protected_separator 
5084
5085 \protected_separator 
5086
5087 \protected_separator 
5088
5089 \protected_separator 
5090
5091 \protected_separator 
5092
5093 \protected_separator 
5094
5095 \protected_separator 
5096 0x0013 
5097 \newline 
5098
5099 \protected_separator 
5100
5101 \protected_separator 
5102
5103 \protected_separator 
5104
5105 \protected_separator 
5106
5107 \protected_separator 
5108
5109 \protected_separator 
5110
5111 \protected_separator 
5112
5113 \protected_separator 
5114
5115 \protected_separator 
5116
5117 \protected_separator 
5118
5119 \protected_separator 
5120
5121 \protected_separator 
5122
5123 \protected_separator 
5124
5125 \protected_separator 
5126
5127 \protected_separator 
5128
5129 \protected_separator 
5130
5131 \protected_separator 
5132
5133 \protected_separator 
5134 Timer 1 
5135 \protected_separator 
5136
5137 \protected_separator 
5138
5139 \protected_separator 
5140
5141 \protected_separator 
5142
5143 \protected_separator 
5144
5145 \protected_separator 
5146
5147 \protected_separator 
5148
5149 \protected_separator 
5150
5151 \protected_separator 
5152
5153 \protected_separator 
5154
5155 \protected_separator 
5156
5157 \protected_separator 
5158
5159 \protected_separator 
5160
5161 \protected_separator 
5162 0x001B 
5163 \newline 
5164
5165 \protected_separator 
5166
5167 \protected_separator 
5168
5169 \protected_separator 
5170
5171 \protected_separator 
5172
5173 \protected_separator 
5174
5175 \protected_separator 
5176
5177 \protected_separator 
5178
5179 \protected_separator 
5180
5181 \protected_separator 
5182
5183 \protected_separator 
5184
5185 \protected_separator 
5186
5187 \protected_separator 
5188
5189 \protected_separator 
5190
5191 \protected_separator 
5192
5193 \protected_separator 
5194
5195 \protected_separator 
5196
5197 \protected_separator 
5198
5199 \protected_separator 
5200 Serial 
5201 \protected_separator 
5202
5203 \protected_separator 
5204
5205 \protected_separator 
5206
5207 \protected_separator 
5208
5209 \protected_separator 
5210
5211 \protected_separator 
5212
5213 \protected_separator 
5214
5215 \protected_separator 
5216
5217 \protected_separator 
5218
5219 \protected_separator 
5220
5221 \protected_separator 
5222
5223 \protected_separator 
5224
5225 \protected_separator 
5226
5227 \protected_separator 
5228
5229 \protected_separator 
5230 0x0023
5231 \layout Standard
5232
5233 If the interrupt service routine is defined without a register bank or with
5234  register bank 0 (using 0), the compiler will save the registers used by
5235  itself on the stack (upon entry and restore them at exit), however if such
5236  an interrupt service routine calls another function then the entire register
5237  bank will be saved on the stack.
5238  This scheme may be advantageous for small interrupt service routines which
5239  have low register usage.
5240 \layout Standard
5241
5242 If the interrupt service routine is defined to be using a specific register
5243  bank then only 
5244 \begin_inset Quotes eld
5245 \end_inset 
5246
5247 a
5248 \begin_inset Quotes erd
5249 \end_inset 
5250
5251 ,
5252 \begin_inset Quotes erd
5253 \end_inset 
5254
5255 b
5256 \begin_inset Quotes erd
5257 \end_inset 
5258
5259  & 
5260 \begin_inset Quotes eld
5261 \end_inset 
5262
5263 dptr
5264 \begin_inset Quotes erd
5265 \end_inset 
5266
5267  are save and restored, if such an interrupt service routine calls another
5268  function (using another register bank) then the entire register bank of
5269  the called function will be saved on the stack.
5270  This scheme is recommended for larger interrupt service routines.
5271 \layout Standard
5272
5273 Calling other functions from an interrupt service routine is not recommended
5274  avoid it if possible.
5275 \layout Section
5276
5277 Startup Code
5278 \begin_inset LatexCommand \label{Startup}
5279
5280 \end_inset 
5281
5282
5283 \layout Standard
5284
5285 The compiler inserts a jump to the C routine 
5286 \series bold 
5287 _sdcc__external__startup() 
5288 \series default 
5289 at the start of the CODE area.
5290  This routine can be found in the file 
5291 \series bold 
5292 SDCCDIR/sdcc51lib/_startup.c
5293 \series default 
5294  , by default this routine returns 0, if this routine returns a non-zero
5295  value , the static & global variable initialization will be skipped and
5296  the function main will be invoked, other wise static & global variables
5297  will be initialized before the function main is invoked.
5298 \layout Section
5299
5300 Inline assembler code.
5301 \begin_inset LatexCommand \label{Inline}
5302
5303 \end_inset 
5304
5305
5306 \layout Standard
5307
5308 SDCC allows the use of in-line assembler with a few restriction as regards
5309  labels.
5310  All labels defined within inline assembler code HAS TO BE of the 
5311 \emph on 
5312 form nnnnn$
5313 \emph default 
5314  where nnnn is a number less than 100 (which implies a limit of utmost 100
5315  inline assembler labels 
5316 \noun on 
5317 per function)
5318 \noun default 
5319 .
5320  It is strongly recommended that each assembly instruction (including labels)
5321  be placed in a separate line ( as the example shows).
5322  When the 
5323 \series bold 
5324 \bar under 
5325 --peep-asm
5326 \series default 
5327 \bar default 
5328  command line option is used, the inline assembler code will be passed through
5329  the peephole optimizer, this might cause some unexpected changes in the
5330  inline assembler code, please go throught the peephole optimizer rules
5331  defined in file 'SDCCpeeph.def' carefully before using this option.
5332 \layout Verbatim
5333
5334
5335 \size small 
5336 eg
5337 \layout Verbatim
5338
5339
5340 \size small 
5341 _asm 
5342 \newline 
5343
5344 \protected_separator 
5345  
5346 \protected_separator 
5347  
5348 \protected_separator 
5349  
5350 \protected_separator 
5351  
5352 \protected_separator 
5353 mov b,#10 
5354 \newline 
5355 00001$: 
5356 \newline 
5357
5358 \protected_separator 
5359  
5360 \protected_separator 
5361  
5362 \protected_separator 
5363  
5364 \protected_separator 
5365  
5366 \protected_separator 
5367 djnz b,00001$ 
5368 \newline 
5369 _endasm ;
5370 \layout Standard
5371
5372 The inline assembler code can contain any valid code understood by the assembler
5373  (this includes any assembler directives and comment lines ) .
5374  The compiler does not do any validation of the code within the 
5375 \emph on 
5376 _asm ...
5377  _endasm;
5378 \emph default 
5379  keyword pair.
5380  
5381 \layout Standard
5382
5383 Inline assembler code cannot reference any C-Labels however it can reference
5384  labels defined by the inline assembler.
5385 \layout Verbatim
5386
5387
5388 \size small 
5389 eg
5390 \layout Verbatim
5391
5392
5393 \size small 
5394 foo() { 
5395 \newline 
5396 ...
5397  /* some c code */ 
5398 \newline 
5399 _asm 
5400 \newline 
5401
5402 \protected_separator 
5403  
5404 \protected_separator 
5405  
5406 \protected_separator 
5407 ; some assembler code 
5408 \newline 
5409
5410 \protected_separator 
5411  
5412 \protected_separator 
5413  ljmp $0003 
5414 \newline 
5415 _endasm ; 
5416 \newline 
5417 ...
5418  /* some more c code */ 
5419 \newline 
5420 clabel: 
5421 \protected_separator 
5422  /* inline assembler cannot reference this label */ 
5423 \newline 
5424 _asm 
5425 \newline 
5426
5427 \protected_separator 
5428  
5429 \protected_separator 
5430 $0003: ;label (can be reference by inline assembler only) 
5431 \newline 
5432 _endasm ; 
5433 \newline 
5434 ...
5435  
5436 \newline 
5437 }
5438 \layout Standard
5439
5440 In other words inline assembly code can access labels defined in inline
5441  assembly.
5442  The same goes the other way, ie.
5443  labels defines in inline assembly CANNOT be accessed by C statements.
5444 \layout Section
5445
5446 int (16 bit) and long (32 bit ) support.
5447 \begin_inset LatexCommand \label{int and long}
5448
5449 \end_inset 
5450
5451
5452 \layout Standard
5453
5454 For signed & unsigned int (16 bit) and long (32 bit) variables, division,
5455  multiplication and modulus operations are implemented by support routines.
5456  These support routines are all developed in ANSI-C to facilitate porting
5457  to other MCUs.
5458  The following files contain the described routine, all of them can be found
5459  in the directory SDCCDIR/sdcc51lib
5460 \layout Itemize
5461
5462
5463 \size footnotesize 
5464 _mulsint.c - signed 16 bit multiplication (calls _muluint)
5465 \layout Itemize
5466
5467
5468 \size footnotesize 
5469 _muluint.c - unsigned 16 bit multiplication
5470 \layout Itemize
5471
5472
5473 \size footnotesize 
5474 _divsint.c - signed 16 bit division (calls _divuint)
5475 \layout Itemize
5476
5477
5478 \size footnotesize 
5479 _divuint.c - unsigned 16 bit division.
5480 \layout Itemize
5481
5482
5483 \size footnotesize 
5484 _modsint.c - signed 16 bit modulus (call _moduint)
5485 \layout Itemize
5486
5487
5488 \size footnotesize 
5489 _moduint.c - unsigned 16 bit modulus.
5490 \layout Itemize
5491
5492
5493 \size footnotesize 
5494 _mulslong.c - signed 32 bit multiplication (calls _mululong)
5495 \layout Itemize
5496
5497
5498 \size footnotesize 
5499 _mululong.c - unsigned32 bit multiplication.
5500 \layout Itemize
5501
5502
5503 \size footnotesize 
5504 _divslong.c - signed 32 division (calls _divulong)
5505 \layout Itemize
5506
5507
5508 \size footnotesize 
5509 _divulong.c - unsigned 32 division.
5510 \layout Itemize
5511
5512
5513 \size footnotesize 
5514 _modslong.c - signed 32 bit modulus (calls _modulong).
5515 \layout Itemize
5516
5517
5518 \size footnotesize 
5519 _modulong.c - unsigned 32 bit modulus.
5520 \layout Standard
5521
5522 All these routines are compiled as non-reentrant and small model.
5523  Since they are compiled as non-reentrant, interrupt service routines should
5524  not do any of the above operations, if this unavoidable then the above
5525  routines will need to ne compiled with the --stack-auto option, after which
5526  the source program will have to be compiled with --int-long-rent option.
5527 \layout Section
5528
5529 Floating point support
5530 \begin_inset LatexCommand \label{Float}
5531
5532 \end_inset 
5533
5534
5535 \layout Standard
5536
5537 SDCC supports IEEE (single precision 4bytes) floating point numbers.The floating
5538  point support routines are derived from gcc's floatlib.c and consists of
5539  the following routines.
5540  
5541 \layout Itemize
5542
5543
5544 \size footnotesize 
5545 _fsadd.c - add floating point numbers.
5546 \layout Itemize
5547
5548
5549 \size footnotesize 
5550 _fssub.c - subtract floating point numbers
5551 \layout Itemize
5552
5553
5554 \size footnotesize 
5555 _fsdiv.c - divide floating point numbers
5556 \layout Itemize
5557
5558
5559 \size footnotesize 
5560 _fsmul.c - multiply floating point numbers
5561 \layout Itemize
5562
5563
5564 \size footnotesize 
5565 _fs2uchar.c - convert floating point to unsigned char
5566 \layout Itemize
5567
5568
5569 \size footnotesize 
5570 _fs2char.c - convert floating point to signed char.
5571 \layout Itemize
5572
5573
5574 \size footnotesize 
5575 _fs2uint.c - convert floating point to unsigned int.
5576 \layout Itemize
5577
5578
5579 \size footnotesize 
5580 _fs2int.c - convert floating point to signed int.
5581 \layout Itemize
5582
5583
5584 \size footnotesize 
5585 _fs2ulong.c - convert floating point to unsigned long.
5586 \layout Itemize
5587
5588
5589 \size footnotesize 
5590 _fs2long.c - convert floating point to signed long.
5591 \layout Itemize
5592
5593
5594 \size footnotesize 
5595 _uchar2fs.c - convert unsigned char to floating point
5596 \layout Itemize
5597
5598
5599 \size footnotesize 
5600 _char2fs.c - convert char to floating point number
5601 \layout Itemize
5602
5603
5604 \size footnotesize 
5605 _uint2fs.c - convert unsigned int to floating point
5606 \layout Itemize
5607
5608
5609 \size footnotesize 
5610 _int2fs.c - convert int to floating point numbers
5611 \layout Itemize
5612
5613
5614 \size footnotesize 
5615 _ulong2fs.c - convert unsigned long to floating point number
5616 \layout Itemize
5617
5618
5619 \size footnotesize 
5620 _long2fs.c - convert long to floating point number.
5621 \layout Standard
5622
5623 Note if all these routines are used simultaneously the data space might
5624  overflow.
5625  For serious floating point usage it is strongly recommended that the Large
5626  model be used (in which case the floating point routines mentioned above
5627  will need to recompiled with the --model-Large option)
5628 \layout Section
5629
5630 Memory Models
5631 \begin_inset LatexCommand \label{Memory Models}
5632
5633 \end_inset 
5634
5635
5636 \layout Standard
5637
5638 SDCC allows two memory models, modules compiled with different memory models
5639  should be combined together, the results would be unpredictable.
5640  The support routines supplied with the compiler are compiled in small-model
5641  by default, and will need to be recompiled using the large model if the
5642  large model is used.
5643  In general the use of the large model is discouraged.
5644 \layout Standard
5645
5646 When the large model is used all variables declared without a storage class
5647  will be allocated into the external ram, this includes all parameters and
5648  local variables (for non-reentrant functions).
5649  When the small model is used variables without storage class are allocated
5650  in the internal ram.
5651 \layout Standard
5652
5653 Judicious usage of the processor specific storage classes and the 'reentrant'
5654  function type will yield much more efficient code, than using the large-model.
5655  Several optimizations are disabled when the program is compiled using the
5656  large model, it is therefore strongly recommdended that the small model
5657  be used unless absolutely required.
5658 \layout Section
5659
5660 Flat 24 bit addressing model.
5661 \begin_inset LatexCommand \label{--model-flat24}
5662
5663 \end_inset 
5664
5665
5666 \layout Standard
5667
5668 This option generates code for the 24 bit contiguous addressing mode of
5669  the Dallas DS80C390 part.
5670  In this mode, up to four meg of external RAM or code space can be directly
5671  addressed.
5672  See the data sheets at www.dalsemi.com for further information on this part.
5673 \layout Standard
5674
5675 Note that the compiler does not generate any code to place the processor
5676  into this mode (it defaults to 8051 compatible mode).
5677  Boot loader or similar code must ensure that the processor is in 24 bit
5678  contiguous addressing mode before calling the SDCC startup code.
5679 \layout Standard
5680
5681 Like the --model-large option, variables will by default be placed into
5682  the XDATA segment.
5683  However, a current limitation is that the compiler will spill variables
5684  into the DATA segment when it runs out of registers.
5685  This means that compiling complex code can rapidly fill up the DATA segment.
5686  This limitation is being worked on, and should be addressed in the next
5687  release of sdcc.
5688 \layout Standard
5689
5690 Segments may be placed anywhere in the 4 meg address space using the usual
5691  --*-loc options.
5692  Note that if any segments are located above 64K, the -r flag must be passed
5693  to the linker to generate the proper segment relocations, and the Intel
5694  HEX output format must be used.
5695  The -r flag can be passed to the linker by using the option -Wl-r on the
5696  sdcc command line.
5697 \layout Standard
5698
5699 --stack-10bit:
5700 \layout Standard
5701
5702 This option generates code for the 10 bit stack mode of the Dallas DS80C390
5703  part.
5704  In this mode, the stack is located in the lower 1K of the internal RAM,
5705  which is mapped to 0x400000.
5706 \layout Standard
5707
5708 With this option, sdcc will generate the proper addressing for stack variables.
5709 \layout Standard
5710
5711 Note that the support is incomplete, since it still uses a single byte as
5712  the stack pointer.
5713  This means that only the lower 256 bytes of the potential 1K stack space
5714  can actually be used.
5715  However, this does allow you to reclaim the precious 256 bytes of low RAM
5716  for use for the DATA and IDATA segments.
5717 \layout Standard
5718
5719 The compiler will not generate any code to put the processor into 10 bit
5720  stack mode.
5721  It is important to ensure that the processor is in this mode before calling
5722  any re-entrant functions compiled with this option.
5723 \layout Standard
5724
5725 In principle, this should work with the --stack-auto option, but that has
5726  not been tested.
5727  It is incompatible with the --xstack option.
5728  It also only makes sense if the processor is in 24 bit contiguous addressing
5729  mode (see the --model-flat24 option).
5730 \layout Section
5731
5732 Defines created by the compiler.
5733 \begin_inset LatexCommand \label{Defines.}
5734
5735 \end_inset 
5736
5737
5738 \layout Standard
5739
5740 The compiler creates the following #defines .
5741 \layout Itemize
5742
5743 SDCC - this Symbol is always defined.
5744 \layout Itemize
5745
5746 SDCC_STACK_AUTO - this symbol is defined when --stack-auto option is used.
5747 \layout Itemize
5748
5749 SDCC_MODEL_SMALL - when small model is used.
5750 \layout Itemize
5751
5752 SDCC_MODEL_LARGE - when --model-large is used.
5753 \layout Itemize
5754
5755 SDCC_USE_XSTACK - when --xstack option is used.
5756 \layout Section
5757
5758 Pragmas
5759 \begin_inset LatexCommand \label{Pragmaa}
5760
5761 \end_inset 
5762
5763
5764 \layout Standard
5765
5766 SDCC supports the following 
5767 \emph on 
5768 #pragma 
5769 \emph default 
5770 directives.
5771  This directives are applicable only at a function level.
5772 \layout Itemize
5773
5774
5775 \series bold 
5776 SAVE
5777 \series default 
5778
5779 \begin_inset LatexCommand \label{pragma save}
5780
5781 \end_inset 
5782
5783  - this will save all the current options .
5784 \layout Itemize
5785
5786
5787 \series bold 
5788 RESTORE 
5789 \series default 
5790
5791 \begin_inset LatexCommand \label{pragma restore}
5792
5793 \end_inset 
5794
5795 - will restore the saved options from the last save.
5796  Note that SAVES & RESTOREs cannot be nested.
5797  SDCC uses the same buffer to save the options each time a SAVE is called.
5798 \layout Itemize
5799
5800
5801 \series bold 
5802 NOGCSE
5803 \series default 
5804
5805 \begin_inset LatexCommand \label{pragma nogcse}
5806
5807 \end_inset 
5808
5809  - will stop global subexpression elimination.
5810 \layout Itemize
5811
5812
5813 \series bold 
5814 NOINDUCTION
5815 \series default 
5816  
5817 \begin_inset LatexCommand \label{pragma noinduction}
5818
5819 \end_inset 
5820
5821 - will stop loop induction optimizations .
5822 \layout Itemize
5823
5824
5825 \series bold 
5826 NOJTBOUND
5827 \series default 
5828  
5829 \begin_inset LatexCommand \label{pragma nojtbound}
5830
5831 \end_inset 
5832
5833 - will not generate code for boundary value checking , when switch statements
5834  are turned into jump-tables.
5835 \layout Itemize
5836
5837
5838 \series bold 
5839 NOOVERLAY 
5840 \series default 
5841
5842 \begin_inset LatexCommand \label{pragma nooverlay}
5843
5844 \end_inset 
5845
5846 - the compiler will not overlay the parameters and local variables of a
5847  function.
5848 \layout Itemize
5849
5850
5851 \series bold 
5852 NOLOOPREVERSE
5853 \series default 
5854  
5855 \begin_inset LatexCommand \label{pragma noloopreverse}
5856
5857 \end_inset 
5858
5859 - Will not do loop reversal optimization
5860 \layout Itemize
5861
5862
5863 \series bold 
5864 EXCLUDE NONE | {acc[,b[,dpl[,dph]]]
5865 \series default 
5866
5867 \begin_inset LatexCommand \label{pragma exclude}
5868
5869 \end_inset 
5870
5871  - The exclude pragma disables generation of pair of push/pop instruction
5872  in ISR function (using interrupt keyword).
5873  The directive should be placed immediately before the ISR function definition
5874  and it affects ALL ISR functions following it.
5875  To enable the normal register saving for ISR functions use 
5876 \begin_inset Quotes eld
5877 \end_inset 
5878
5879 #pragma EXCLUDE none
5880 \begin_inset Quotes erd
5881 \end_inset 
5882
5883
5884 \layout Itemize
5885
5886
5887 \series bold 
5888 CALLEE-SAVES function1[,function2[,function3...]]
5889 \series default 
5890
5891 \begin_inset LatexCommand \label{pragma callee-saves}
5892
5893 \end_inset 
5894
5895  - The compiler by default uses a caller saves convention for register saving
5896  across function calls, however this can cause unneccessary register pushing
5897  & popping when calling small functions from larger functions.
5898  This option can be used to switch the register saving convention for the
5899  function names specified.
5900  The compiler will not save registers when calling these functions, extra
5901  code will be generated at the entry & exit for these functions to save
5902  & restore the registers used by these functions, this can SUBSTANTIALLY
5903  reduce code & improve run time performance of the generated code.
5904  In future the compiler (with interprocedural analysis) will be able to
5905  determine the appropriate scheme to use for each function call.
5906  If --callee-saves
5907 \begin_inset LatexCommand \ref{--callee-saves}
5908
5909 \end_inset 
5910
5911  command line option is used, the function names specified in #pragma CALLEE-SAV
5912 ES is appended to the list of functions specified inthe command line.
5913 \layout Standard
5914
5915 The pragma's are intended to be used to turn-off certain optimizations which
5916  might cause the compiler to generate extra stack / data space to store
5917  compiler generated temporary variables.
5918  This usually happens in large functions.
5919  Pragma directives should be used as shown in the following example, they
5920  are used to control options & optimizations for a given function; pragmas
5921  should be placed 
5922 \noun on 
5923 before
5924 \noun default 
5925  and/or 
5926 \noun on 
5927 after
5928 \noun default 
5929  a function, placing pragma's inside a function body could have unpredictable
5930  results.
5931 \layout Verbatim
5932
5933
5934 \size scriptsize 
5935 eg
5936 \layout Verbatim
5937
5938
5939 \size scriptsize 
5940 #pragma SAVE 
5941 \protected_separator 
5942  /* save the current settings */ 
5943 \newline 
5944 #pragma NOGCSE /* turnoff global subexpression elimination */ 
5945 \newline 
5946 #pragma NOINDUCTION /* turn off induction optimizations */ 
5947 \newline 
5948 int foo () 
5949 \newline 
5950
5951 \newline 
5952
5953 \protected_separator 
5954  
5955 \protected_separator 
5956  ...
5957  
5958 \newline 
5959
5960 \protected_separator 
5961  
5962 \protected_separator 
5963  /* large code */ 
5964 \newline 
5965
5966 \protected_separator 
5967  
5968 \protected_separator 
5969  ...
5970  
5971 \newline 
5972
5973 \newline 
5974 #pragma RESTORE /* turn the optimizations back on */
5975 \layout Standard
5976
5977 The compiler will generate a warning message when extra space is allocated.
5978  It is strongly recommended that the SAVE and RESTORE pragma's be used when
5979  changing options for a function.
5980 \layout Section
5981
5982 Library routines.
5983 \begin_inset LatexCommand \label{Library}
5984
5985 \end_inset 
5986
5987
5988 \layout Standard
5989
5990 The following library routines are provided for your convenience.
5991 \layout Standard
5992
5993
5994 \series bold 
5995 \size large 
5996 stdio.h 
5997 \series default 
5998 \size default 
5999 - Contains the following functions printf & sprintf these routines are developed
6000  by 
6001 \emph on 
6002 Martijn van Balen <balen@natlab.research.philips.com>.
6003  
6004 \layout Verbatim
6005
6006
6007 \size scriptsize 
6008 %[flags][width][b|B|l|L]type
6009 \layout Verbatim
6010
6011
6012 \size scriptsize 
6013
6014 \protected_separator 
6015
6016 \protected_separator 
6017
6018 \protected_separator 
6019
6020 \protected_separator 
6021
6022 \protected_separator 
6023
6024 \protected_separator 
6025
6026 \protected_separator 
6027
6028 \protected_separator 
6029
6030 \protected_separator 
6031
6032 \protected_separator 
6033  flags: -
6034 \protected_separator 
6035
6036 \protected_separator 
6037
6038 \protected_separator 
6039
6040 \protected_separator 
6041
6042 \protected_separator 
6043
6044 \protected_separator 
6045
6046 \protected_separator 
6047  left justify output in specified field width 
6048 \newline 
6049
6050 \protected_separator 
6051
6052 \protected_separator 
6053
6054 \protected_separator 
6055
6056 \protected_separator 
6057
6058 \protected_separator 
6059
6060 \protected_separator 
6061
6062 \protected_separator 
6063
6064 \protected_separator 
6065
6066 \protected_separator 
6067
6068 \protected_separator 
6069
6070 \protected_separator 
6071
6072 \protected_separator 
6073
6074 \protected_separator 
6075
6076 \protected_separator 
6077
6078 \protected_separator 
6079
6080 \protected_separator 
6081  +
6082 \protected_separator 
6083
6084 \protected_separator 
6085
6086 \protected_separator 
6087
6088 \protected_separator 
6089
6090 \protected_separator 
6091
6092 \protected_separator 
6093
6094 \protected_separator 
6095  prefix output with +/- sign if output is signed type 
6096 \newline 
6097
6098 \protected_separator 
6099
6100 \protected_separator 
6101
6102 \protected_separator 
6103
6104 \protected_separator 
6105
6106 \protected_separator 
6107
6108 \protected_separator 
6109
6110 \protected_separator 
6111
6112 \protected_separator 
6113
6114 \protected_separator 
6115
6116 \protected_separator 
6117
6118 \protected_separator 
6119
6120 \protected_separator 
6121
6122 \protected_separator 
6123
6124 \protected_separator 
6125
6126 \protected_separator 
6127
6128 \protected_separator 
6129  space
6130 \protected_separator 
6131
6132 \protected_separator 
6133
6134 \protected_separator 
6135  prefix output with a blank if it's a signed positive value 
6136 \newline 
6137
6138 \protected_separator 
6139
6140 \protected_separator 
6141
6142 \protected_separator 
6143
6144 \protected_separator 
6145
6146 \protected_separator 
6147
6148 \protected_separator 
6149
6150 \protected_separator 
6151
6152 \protected_separator 
6153
6154 \protected_separator 
6155  width:
6156 \protected_separator 
6157
6158 \protected_separator 
6159
6160 \protected_separator 
6161
6162 \protected_separator 
6163
6164 \protected_separator 
6165
6166 \protected_separator 
6167
6168 \protected_separator 
6169
6170 \protected_separator 
6171
6172 \protected_separator 
6173  specifies minimum number of characters outputted for numbers 
6174 \newline 
6175
6176 \protected_separator 
6177
6178 \protected_separator 
6179
6180 \protected_separator 
6181
6182 \protected_separator 
6183
6184 \protected_separator 
6185
6186 \protected_separator 
6187
6188 \protected_separator 
6189
6190 \protected_separator 
6191
6192 \protected_separator 
6193
6194 \protected_separator 
6195
6196 \protected_separator 
6197
6198 \protected_separator 
6199
6200 \protected_separator 
6201
6202 \protected_separator 
6203
6204 \protected_separator 
6205
6206 \protected_separator 
6207
6208 \protected_separator 
6209
6210 \protected_separator 
6211
6212 \protected_separator 
6213
6214 \protected_separator 
6215
6216 \protected_separator 
6217
6218 \protected_separator 
6219
6220 \protected_separator 
6221
6222 \protected_separator 
6223
6224 \protected_separator 
6225  or strings.
6226  
6227 \newline 
6228
6229 \protected_separator 
6230
6231 \protected_separator 
6232
6233 \protected_separator 
6234
6235 \protected_separator 
6236
6237 \protected_separator 
6238
6239 \protected_separator 
6240
6241 \protected_separator 
6242
6243 \protected_separator 
6244
6245 \protected_separator 
6246
6247 \protected_separator 
6248
6249 \protected_separator 
6250
6251 \protected_separator 
6252
6253 \protected_separator 
6254
6255 \protected_separator 
6256
6257 \protected_separator 
6258
6259 \protected_separator 
6260
6261 \protected_separator 
6262
6263 \protected_separator 
6264
6265 \protected_separator 
6266
6267 \protected_separator 
6268
6269 \protected_separator 
6270
6271 \protected_separator 
6272
6273 \protected_separator 
6274
6275 \protected_separator 
6276
6277 \protected_separator 
6278  - For numbers, spaces are added on the left when needed.
6279  
6280 \newline 
6281
6282 \protected_separator 
6283
6284 \protected_separator 
6285
6286 \protected_separator 
6287
6288 \protected_separator 
6289
6290 \protected_separator 
6291
6292 \protected_separator 
6293
6294 \protected_separator 
6295
6296 \protected_separator 
6297
6298 \protected_separator 
6299
6300 \protected_separator 
6301
6302 \protected_separator 
6303
6304 \protected_separator 
6305
6306 \protected_separator 
6307
6308 \protected_separator 
6309
6310 \protected_separator 
6311
6312 \protected_separator 
6313
6314 \protected_separator 
6315
6316 \protected_separator 
6317
6318 \protected_separator 
6319
6320 \protected_separator 
6321
6322 \protected_separator 
6323
6324 \protected_separator 
6325
6326 \protected_separator 
6327
6328 \protected_separator 
6329
6330 \protected_separator 
6331
6332 \protected_separator 
6333
6334 \protected_separator 
6335  If width starts with a zero character, zeroes and used 
6336 \newline 
6337
6338 \protected_separator 
6339
6340 \protected_separator 
6341
6342 \protected_separator 
6343
6344 \protected_separator 
6345
6346 \protected_separator 
6347
6348 \protected_separator 
6349
6350 \protected_separator 
6351
6352 \protected_separator 
6353
6354 \protected_separator 
6355
6356 \protected_separator 
6357
6358 \protected_separator 
6359
6360 \protected_separator 
6361
6362 \protected_separator 
6363
6364 \protected_separator 
6365
6366 \protected_separator 
6367
6368 \protected_separator 
6369
6370 \protected_separator 
6371
6372 \protected_separator 
6373
6374 \protected_separator 
6375
6376 \protected_separator 
6377
6378 \protected_separator 
6379
6380 \protected_separator 
6381
6382 \protected_separator 
6383
6384 \protected_separator 
6385
6386 \protected_separator 
6387
6388 \protected_separator 
6389
6390 \protected_separator 
6391  instead of spaces.
6392  
6393 \newline 
6394
6395 \protected_separator 
6396
6397 \protected_separator 
6398
6399 \protected_separator 
6400
6401 \protected_separator 
6402
6403 \protected_separator 
6404
6405 \protected_separator 
6406
6407 \protected_separator 
6408
6409 \protected_separator 
6410
6411 \protected_separator 
6412
6413 \protected_separator 
6414
6415 \protected_separator 
6416
6417 \protected_separator 
6418
6419 \protected_separator 
6420
6421 \protected_separator 
6422
6423 \protected_separator 
6424
6425 \protected_separator 
6426
6427 \protected_separator 
6428
6429 \protected_separator 
6430
6431 \protected_separator 
6432
6433 \protected_separator 
6434
6435 \protected_separator 
6436
6437 \protected_separator 
6438
6439 \protected_separator 
6440
6441 \protected_separator 
6442
6443 \protected_separator 
6444  - For strings, spaces are are added on the left or right (when 
6445 \newline 
6446
6447 \protected_separator 
6448
6449 \protected_separator 
6450
6451 \protected_separator 
6452
6453 \protected_separator 
6454
6455 \protected_separator 
6456
6457 \protected_separator 
6458
6459 \protected_separator 
6460
6461 \protected_separator 
6462
6463 \protected_separator 
6464
6465 \protected_separator 
6466
6467 \protected_separator 
6468
6469 \protected_separator 
6470
6471 \protected_separator 
6472
6473 \protected_separator 
6474
6475 \protected_separator 
6476
6477 \protected_separator 
6478
6479 \protected_separator 
6480
6481 \protected_separator 
6482
6483 \protected_separator 
6484
6485 \protected_separator 
6486
6487 \protected_separator 
6488
6489 \protected_separator 
6490
6491 \protected_separator 
6492
6493 \protected_separator 
6494
6495 \protected_separator 
6496
6497 \protected_separator 
6498
6499 \protected_separator 
6500  flag '-' is used) when needed.
6501  
6502 \newline 
6503
6504 \protected_separator 
6505
6506 \protected_separator 
6507
6508 \protected_separator 
6509
6510 \protected_separator 
6511
6512 \protected_separator 
6513
6514 \protected_separator 
6515
6516 \protected_separator 
6517
6518 \protected_separator 
6519
6520 \protected_separator 
6521
6522 \protected_separator 
6523
6524 \protected_separator 
6525
6526 \protected_separator 
6527
6528 \protected_separator 
6529
6530 \protected_separator 
6531
6532 \protected_separator 
6533
6534 \protected_separator 
6535
6536 \protected_separator 
6537
6538 \protected_separator 
6539
6540 \protected_separator 
6541
6542 \protected_separator 
6543
6544 \protected_separator 
6545
6546 \protected_separator 
6547
6548 \protected_separator 
6549
6550 \protected_separator 
6551
6552 \protected_separator 
6553  
6554 \newline 
6555
6556 \protected_separator 
6557
6558 \protected_separator 
6559
6560 \protected_separator 
6561
6562 \protected_separator 
6563
6564 \protected_separator 
6565
6566 \protected_separator 
6567
6568 \protected_separator 
6569
6570 \protected_separator 
6571
6572 \protected_separator 
6573  b/B:
6574 \protected_separator 
6575
6576 \protected_separator 
6577
6578 \protected_separator 
6579
6580 \protected_separator 
6581
6582 \protected_separator 
6583
6584 \protected_separator 
6585
6586 \protected_separator 
6587
6588 \protected_separator 
6589
6590 \protected_separator 
6591
6592 \protected_separator 
6593
6594 \protected_separator 
6595  byte argument (used by d, u, o, x, X) 
6596 \newline 
6597
6598 \protected_separator 
6599
6600 \protected_separator 
6601
6602 \protected_separator 
6603
6604 \protected_separator 
6605
6606 \protected_separator 
6607
6608 \protected_separator 
6609
6610 \protected_separator 
6611
6612 \protected_separator 
6613
6614 \protected_separator 
6615  l/L:
6616 \protected_separator 
6617
6618 \protected_separator 
6619
6620 \protected_separator 
6621
6622 \protected_separator 
6623
6624 \protected_separator 
6625
6626 \protected_separator 
6627
6628 \protected_separator 
6629
6630 \protected_separator 
6631
6632 \protected_separator 
6633
6634 \protected_separator 
6635
6636 \protected_separator 
6637  long argument (used by d, u, o, x, X)
6638 \newline 
6639
6640 \protected_separator 
6641
6642 \protected_separator 
6643
6644 \protected_separator 
6645
6646 \protected_separator 
6647
6648 \protected_separator 
6649
6650 \protected_separator 
6651
6652 \protected_separator 
6653
6654 \protected_separator 
6655
6656 \protected_separator 
6657  type:
6658 \protected_separator 
6659  d
6660 \protected_separator 
6661
6662 \protected_separator 
6663
6664 \protected_separator 
6665
6666 \protected_separator 
6667
6668 \protected_separator 
6669
6670 \protected_separator 
6671
6672 \protected_separator 
6673  decimal number 
6674 \newline 
6675
6676 \protected_separator 
6677
6678 \protected_separator 
6679
6680 \protected_separator 
6681
6682 \protected_separator 
6683
6684 \protected_separator 
6685
6686 \protected_separator 
6687
6688 \protected_separator 
6689
6690 \protected_separator 
6691
6692 \protected_separator 
6693
6694 \protected_separator 
6695
6696 \protected_separator 
6697
6698 \protected_separator 
6699
6700 \protected_separator 
6701
6702 \protected_separator 
6703
6704 \protected_separator 
6705
6706 \protected_separator 
6707  u
6708 \protected_separator 
6709
6710 \protected_separator 
6711
6712 \protected_separator 
6713
6714 \protected_separator 
6715
6716 \protected_separator 
6717
6718 \protected_separator 
6719
6720 \protected_separator 
6721  unsigned decimal number 
6722 \newline 
6723
6724 \protected_separator 
6725
6726 \protected_separator 
6727
6728 \protected_separator 
6729
6730 \protected_separator 
6731
6732 \protected_separator 
6733
6734 \protected_separator 
6735
6736 \protected_separator 
6737
6738 \protected_separator 
6739
6740 \protected_separator 
6741
6742 \protected_separator 
6743
6744 \protected_separator 
6745
6746 \protected_separator 
6747
6748 \protected_separator 
6749
6750 \protected_separator 
6751
6752 \protected_separator 
6753
6754 \protected_separator 
6755  o
6756 \protected_separator 
6757
6758 \protected_separator 
6759
6760 \protected_separator 
6761
6762 \protected_separator 
6763
6764 \protected_separator 
6765
6766 \protected_separator 
6767
6768 \protected_separator 
6769  unsigned octal number 
6770 \newline 
6771
6772 \protected_separator 
6773
6774 \protected_separator 
6775
6776 \protected_separator 
6777
6778 \protected_separator 
6779
6780 \protected_separator 
6781
6782 \protected_separator 
6783
6784 \protected_separator 
6785
6786 \protected_separator 
6787
6788 \protected_separator 
6789
6790 \protected_separator 
6791
6792 \protected_separator 
6793
6794 \protected_separator 
6795
6796 \protected_separator 
6797
6798 \protected_separator 
6799
6800 \protected_separator 
6801
6802 \protected_separator 
6803  x
6804 \protected_separator 
6805
6806 \protected_separator 
6807
6808 \protected_separator 
6809
6810 \protected_separator 
6811
6812 \protected_separator 
6813
6814 \protected_separator 
6815
6816 \protected_separator 
6817  unsigned hexadecimal number (0-9, a-f) 
6818 \newline 
6819
6820 \protected_separator 
6821
6822 \protected_separator 
6823
6824 \protected_separator 
6825
6826 \protected_separator 
6827
6828 \protected_separator 
6829
6830 \protected_separator 
6831
6832 \protected_separator 
6833
6834 \protected_separator 
6835
6836 \protected_separator 
6837
6838 \protected_separator 
6839
6840 \protected_separator 
6841
6842 \protected_separator 
6843
6844 \protected_separator 
6845
6846 \protected_separator 
6847
6848 \protected_separator 
6849
6850 \protected_separator 
6851  X
6852 \protected_separator 
6853
6854 \protected_separator 
6855
6856 \protected_separator 
6857
6858 \protected_separator 
6859
6860 \protected_separator 
6861
6862 \protected_separator 
6863
6864 \protected_separator 
6865  unsigned hexadecimal number (0-9, A-F) 
6866 \newline 
6867
6868 \protected_separator 
6869
6870 \protected_separator 
6871
6872 \protected_separator 
6873
6874 \protected_separator 
6875
6876 \protected_separator 
6877
6878 \protected_separator 
6879
6880 \protected_separator 
6881
6882 \protected_separator 
6883
6884 \protected_separator 
6885
6886 \protected_separator 
6887
6888 \protected_separator 
6889
6890 \protected_separator 
6891
6892 \protected_separator 
6893
6894 \protected_separator 
6895
6896 \protected_separator 
6897
6898 \protected_separator 
6899  c
6900 \protected_separator 
6901
6902 \protected_separator 
6903
6904 \protected_separator 
6905
6906 \protected_separator 
6907
6908 \protected_separator 
6909
6910 \protected_separator 
6911
6912 \protected_separator 
6913  character 
6914 \newline 
6915
6916 \protected_separator 
6917
6918 \protected_separator 
6919
6920 \protected_separator 
6921
6922 \protected_separator 
6923
6924 \protected_separator 
6925
6926 \protected_separator 
6927
6928 \protected_separator 
6929
6930 \protected_separator 
6931
6932 \protected_separator 
6933
6934 \protected_separator 
6935
6936 \protected_separator 
6937
6938 \protected_separator 
6939
6940 \protected_separator 
6941
6942 \protected_separator 
6943
6944 \protected_separator 
6945
6946 \protected_separator 
6947  s
6948 \protected_separator 
6949
6950 \protected_separator 
6951
6952 \protected_separator 
6953
6954 \protected_separator 
6955
6956 \protected_separator 
6957
6958 \protected_separator 
6959
6960 \protected_separator 
6961  string (generic pointer) 
6962 \newline 
6963
6964 \protected_separator 
6965
6966 \protected_separator 
6967
6968 \protected_separator 
6969
6970 \protected_separator 
6971
6972 \protected_separator 
6973
6974 \protected_separator 
6975
6976 \protected_separator 
6977
6978 \protected_separator 
6979
6980 \protected_separator 
6981
6982 \protected_separator 
6983
6984 \protected_separator 
6985
6986 \protected_separator 
6987
6988 \protected_separator 
6989
6990 \protected_separator 
6991
6992 \protected_separator 
6993
6994 \protected_separator 
6995  p
6996 \protected_separator 
6997
6998 \protected_separator 
6999
7000 \protected_separator 
7001
7002 \protected_separator 
7003
7004 \protected_separator 
7005
7006 \protected_separator 
7007
7008 \protected_separator 
7009  generic pointer (I:data/idata, C:code, X:xdata, P:paged) 
7010 \newline 
7011
7012 \protected_separator 
7013
7014 \protected_separator 
7015
7016 \protected_separator 
7017
7018 \protected_separator 
7019
7020 \protected_separator 
7021
7022 \protected_separator 
7023
7024 \protected_separator 
7025
7026 \protected_separator 
7027
7028 \protected_separator 
7029
7030 \protected_separator 
7031
7032 \protected_separator 
7033
7034 \protected_separator 
7035
7036 \protected_separator 
7037
7038 \protected_separator 
7039
7040 \protected_separator 
7041
7042 \protected_separator 
7043  f
7044 \protected_separator 
7045
7046 \protected_separator 
7047
7048 \protected_separator 
7049
7050 \protected_separator 
7051
7052 \protected_separator 
7053
7054 \protected_separator 
7055
7056 \protected_separator 
7057  float (still to be implemented)
7058 \layout Standard
7059
7060 Also contains a very simple version of printf (
7061 \series bold 
7062 printf_small
7063 \series default 
7064 ).
7065  This simplified version of printf supports only the following formats.
7066 \layout Verbatim
7067
7068
7069 \size scriptsize 
7070 \bar under 
7071 format
7072 \protected_separator 
7073
7074 \protected_separator 
7075
7076 \protected_separator 
7077
7078 \protected_separator 
7079
7080 \protected_separator 
7081 output
7082 \protected_separator 
7083 type
7084 \protected_separator 
7085
7086 \protected_separator 
7087
7088 \protected_separator 
7089
7090 \protected_separator 
7091
7092 \protected_separator 
7093 argument-type
7094 \bar default 
7095  
7096 \series bold 
7097 \size default 
7098
7099 \newline 
7100
7101 \series default 
7102 \size scriptsize 
7103 %d 
7104 \protected_separator 
7105
7106 \protected_separator 
7107
7108 \protected_separator 
7109
7110 \protected_separator 
7111
7112 \protected_separator 
7113
7114 \protected_separator 
7115
7116 \protected_separator 
7117
7118 \protected_separator 
7119 decimal 
7120 \protected_separator 
7121
7122 \protected_separator 
7123
7124 \protected_separator 
7125
7126 \protected_separator 
7127
7128 \protected_separator 
7129  int 
7130 \newline 
7131 %ld
7132 \protected_separator 
7133
7134 \protected_separator 
7135
7136 \protected_separator 
7137
7138 \protected_separator 
7139
7140 \protected_separator 
7141
7142 \protected_separator 
7143
7144 \protected_separator 
7145
7146 \protected_separator 
7147 decimal
7148 \protected_separator 
7149
7150 \protected_separator 
7151
7152 \protected_separator 
7153
7154 \protected_separator 
7155
7156 \protected_separator 
7157
7158 \protected_separator 
7159
7160 \protected_separator 
7161 long 
7162 \newline 
7163 %hd
7164 \protected_separator 
7165
7166 \protected_separator 
7167
7168 \protected_separator 
7169
7170 \protected_separator 
7171
7172 \protected_separator 
7173
7174 \protected_separator 
7175
7176 \protected_separator 
7177
7178 \protected_separator 
7179 decimal
7180 \protected_separator 
7181
7182 \protected_separator 
7183
7184 \protected_separator 
7185
7186 \protected_separator 
7187
7188 \protected_separator 
7189
7190 \protected_separator 
7191
7192 \protected_separator 
7193 short/char 
7194 \newline 
7195 %x
7196 \protected_separator 
7197
7198 \protected_separator 
7199
7200 \protected_separator 
7201
7202 \protected_separator 
7203
7204 \protected_separator 
7205
7206 \protected_separator 
7207
7208 \protected_separator 
7209
7210 \protected_separator 
7211 hexadecimal
7212 \protected_separator 
7213
7214 \protected_separator 
7215
7216 \protected_separator 
7217
7218 \protected_separator 
7219 int 
7220 \newline 
7221 %lx
7222 \protected_separator 
7223
7224 \protected_separator 
7225
7226 \protected_separator 
7227
7228 \protected_separator 
7229
7230 \protected_separator 
7231
7232 \protected_separator 
7233
7234 \protected_separator 
7235 hexadecimal
7236 \protected_separator 
7237
7238 \protected_separator 
7239
7240 \protected_separator 
7241
7242 \protected_separator 
7243 long 
7244 \newline 
7245 %hx
7246 \protected_separator 
7247
7248 \protected_separator 
7249
7250 \protected_separator 
7251
7252 \protected_separator 
7253
7254 \protected_separator 
7255
7256 \protected_separator 
7257
7258 \protected_separator 
7259 hexadecimal
7260 \protected_separator 
7261
7262 \protected_separator 
7263
7264 \protected_separator 
7265
7266 \protected_separator 
7267 short/char 
7268 \newline 
7269 %o
7270 \protected_separator 
7271
7272 \protected_separator 
7273
7274 \protected_separator 
7275
7276 \protected_separator 
7277
7278 \protected_separator 
7279
7280 \protected_separator 
7281
7282 \protected_separator 
7283
7284 \protected_separator 
7285
7286 \protected_separator 
7287 octal
7288 \protected_separator 
7289
7290 \protected_separator 
7291
7292 \protected_separator 
7293
7294 \protected_separator 
7295
7296 \protected_separator 
7297
7298 \protected_separator 
7299
7300 \protected_separator 
7301
7302 \protected_separator 
7303
7304 \protected_separator 
7305 int 
7306 \newline 
7307 %lo
7308 \protected_separator 
7309
7310 \protected_separator 
7311
7312 \protected_separator 
7313
7314 \protected_separator 
7315
7316 \protected_separator 
7317
7318 \protected_separator 
7319
7320 \protected_separator 
7321
7322 \protected_separator 
7323 octal
7324 \protected_separator 
7325
7326 \protected_separator 
7327
7328 \protected_separator 
7329
7330 \protected_separator 
7331
7332 \protected_separator 
7333
7334 \protected_separator 
7335
7336 \protected_separator 
7337
7338 \protected_separator 
7339
7340 \protected_separator 
7341 long 
7342 \newline 
7343 %ho
7344 \protected_separator 
7345
7346 \protected_separator 
7347
7348 \protected_separator 
7349
7350 \protected_separator 
7351
7352 \protected_separator 
7353
7354 \protected_separator 
7355
7356 \protected_separator 
7357
7358 \protected_separator 
7359 octal
7360 \protected_separator 
7361
7362 \protected_separator 
7363
7364 \protected_separator 
7365
7366 \protected_separator 
7367
7368 \protected_separator 
7369
7370 \protected_separator 
7371
7372 \protected_separator 
7373
7374 \protected_separator 
7375
7376 \protected_separator 
7377 short/char 
7378 \newline 
7379 %c
7380 \protected_separator 
7381
7382 \protected_separator 
7383
7384 \protected_separator 
7385
7386 \protected_separator 
7387
7388 \protected_separator 
7389
7390 \protected_separator 
7391
7392 \protected_separator 
7393
7394 \protected_separator 
7395 character
7396 \protected_separator 
7397
7398 \protected_separator 
7399
7400 \protected_separator 
7401
7402 \protected_separator 
7403
7404 \protected_separator 
7405
7406 \protected_separator 
7407 char/short 
7408 \newline 
7409 %s
7410 \protected_separator 
7411
7412 \protected_separator 
7413
7414 \protected_separator 
7415
7416 \protected_separator 
7417
7418 \protected_separator 
7419
7420 \protected_separator 
7421
7422 \protected_separator 
7423
7424 \protected_separator 
7425 character
7426 \protected_separator 
7427
7428 \protected_separator 
7429
7430 \protected_separator 
7431
7432 \protected_separator 
7433
7434 \protected_separator 
7435 _generic pointer
7436 \begin_deeper 
7437 \layout Standard
7438
7439 The routine is 
7440 \series bold 
7441 very stack intesive 
7442 \series default 
7443 , --stack-after-data parameter should be used when using this routine, the
7444  routine also takes about 1K of code space .It also expects an external function
7445  named 
7446 \emph on 
7447 putchar(char )
7448 \emph default 
7449  to be present (this can be changed).
7450  When using the %s format the string / pointer should be cast to a generic
7451  pointer.
7452  eg.
7453 \layout Verbatim
7454
7455
7456 \size scriptsize 
7457 printf_small(
7458 \begin_inset Quotes eld
7459 \end_inset 
7460
7461 my str %s, my int %d
7462 \backslash 
7463 n
7464 \begin_inset Quotes erd
7465 \end_inset 
7466
7467 ,(char _generic *)mystr,myint);
7468 \end_deeper 
7469 \layout Itemize
7470
7471
7472 \series bold 
7473 \size large 
7474 stdarg.h 
7475 \series default 
7476 \size default 
7477 - contains definition for the following macros to be used for variable parameter
7478  list, note that a function can have a variable parameter list if and only
7479  if it is 'reentrant'
7480 \begin_deeper 
7481 \layout Standard
7482
7483
7484 \size small 
7485 va_list, va_start, va_arg, va_end.
7486 \end_deeper 
7487 \layout Itemize
7488
7489
7490 \series bold 
7491 \size large 
7492 setjmp.h 
7493 \series default 
7494 \size default 
7495 - contains defintion for ANSI
7496 \series bold 
7497  setjmp 
7498 \series default 
7499
7500 \series bold 
7501 longjmp
7502 \series default 
7503  routines.
7504  Note in this case setjmp & longjmp can be used between functions executing
7505  within the same register bank, if long jmp is executed from a function
7506  that is using a different register bank from the function issuing the setjmp
7507  function, the results may be unpredictable.
7508  The jump buffer requires 3 bytes of data (the stack pointer & a 16 byte
7509  return address), and can be placed in any address space.
7510 \layout Itemize
7511
7512
7513 \series bold 
7514 \size large 
7515 stdlib.h
7516 \series default 
7517 \size default 
7518  - contains the following functions.
7519 \begin_deeper 
7520 \layout Standard
7521
7522
7523 \size footnotesize 
7524 atoi, atol.
7525 \end_deeper 
7526 \layout Itemize
7527
7528
7529 \series bold 
7530 \size large 
7531 string.h 
7532 \series default 
7533 \size default 
7534 - contains the following functions.
7535 \begin_deeper 
7536 \layout Standard
7537
7538
7539 \size footnotesize 
7540 strcpy, strncpy, strcat, strncat, strcmp, strncmp, strchr, strrchr, strspn,
7541  strcspn, strpbrk, strstr, strlen, strtok, memcpy, memcmp, memset.
7542 \end_deeper 
7543 \layout Itemize
7544
7545
7546 \series bold 
7547 \size large 
7548 ctype.h
7549 \series default 
7550 \size default 
7551  - contains the following routines.
7552 \begin_deeper 
7553 \layout Standard
7554
7555
7556 \size footnotesize 
7557 iscntrl, isdigit, isgraph, islower, isupper, isprint, ispunct, isspace,
7558  isxdigit, isalnum, isalpha.
7559 \end_deeper 
7560 \layout Itemize
7561
7562
7563 \series bold 
7564 \size large 
7565 malloc.h
7566 \series default 
7567 \size default 
7568  - The malloc routines are developed by Dmitry S.
7569  Obukhov (dso@usa.net).
7570  These routines will allocate memory from the external ram.
7571  Here is a description on how to use them (as described by the author).
7572 \begin_deeper 
7573 \layout Verbatim
7574
7575
7576 \size scriptsize 
7577 //Example: 
7578 \newline 
7579
7580 \protected_separator 
7581
7582 \protected_separator 
7583
7584 \protected_separator 
7585
7586 \protected_separator 
7587  //
7588 \protected_separator 
7589
7590 \protected_separator 
7591
7592 \protected_separator 
7593
7594 \protected_separator 
7595  #define DYNAMIC_MEMORY_SIZE 0x2000 
7596 \newline 
7597
7598 \protected_separator 
7599
7600 \protected_separator 
7601
7602 \protected_separator 
7603
7604 \protected_separator 
7605  //
7606 \protected_separator 
7607
7608 \protected_separator 
7609
7610 \protected_separator 
7611
7612 \protected_separator 
7613  .....
7614  
7615 \newline 
7616
7617 \protected_separator 
7618
7619 \protected_separator 
7620
7621 \protected_separator 
7622
7623 \protected_separator 
7624  //
7625 \protected_separator 
7626
7627 \protected_separator 
7628
7629 \protected_separator 
7630
7631 \protected_separator 
7632  unsigned char xdata dynamic_memory_pool[DYNAMIC_MEMORY_SIZE]; 
7633 \newline 
7634
7635 \protected_separator 
7636
7637 \protected_separator 
7638
7639 \protected_separator 
7640
7641 \protected_separator 
7642  //
7643 \protected_separator 
7644
7645 \protected_separator 
7646
7647 \protected_separator 
7648
7649 \protected_separator 
7650  unsigned char xdata * current_buffer; 
7651 \newline 
7652
7653 \protected_separator 
7654
7655 \protected_separator 
7656
7657 \protected_separator 
7658
7659 \protected_separator 
7660  //
7661 \protected_separator 
7662
7663 \protected_separator 
7664
7665 \protected_separator 
7666
7667 \protected_separator 
7668  .....
7669  
7670 \newline 
7671
7672 \protected_separator 
7673
7674 \protected_separator 
7675
7676 \protected_separator 
7677
7678 \protected_separator 
7679  //
7680 \protected_separator 
7681
7682 \protected_separator 
7683
7684 \protected_separator 
7685
7686 \protected_separator 
7687  void main(void) 
7688 \newline 
7689
7690 \protected_separator 
7691
7692 \protected_separator 
7693
7694 \protected_separator 
7695
7696 \protected_separator 
7697  //
7698 \protected_separator 
7699
7700 \protected_separator 
7701
7702 \protected_separator 
7703
7704 \protected_separator 
7705  { 
7706 \newline 
7707
7708 \protected_separator 
7709
7710 \protected_separator 
7711
7712 \protected_separator 
7713
7714 \protected_separator 
7715  //
7716 \protected_separator 
7717
7718 \protected_separator 
7719
7720 \protected_separator 
7721
7722 \protected_separator 
7723
7724 \protected_separator 
7725
7726 \protected_separator 
7727
7728 \protected_separator 
7729
7730 \protected_separator 
7731  ...
7732  
7733 \newline 
7734
7735 \protected_separator 
7736
7737 \protected_separator 
7738
7739 \protected_separator 
7740
7741 \protected_separator 
7742
7743 \protected_separator 
7744 //
7745 \protected_separator 
7746
7747 \protected_separator 
7748
7749 \protected_separator 
7750
7751 \protected_separator 
7752
7753 \protected_separator 
7754
7755 \protected_separator 
7756
7757 \protected_separator 
7758
7759 \protected_separator 
7760  init_dynamic_memory(dynamic_memory_pool,DYNAMIC_MEMORY_SIZE); 
7761 \newline 
7762
7763 \protected_separator 
7764
7765 \protected_separator 
7766
7767 \protected_separator 
7768
7769 \protected_separator 
7770  //
7771 \protected_separator 
7772
7773 \protected_separator 
7774
7775 \protected_separator 
7776
7777 \protected_separator 
7778
7779 \protected_separator 
7780
7781 \protected_separator 
7782
7783 \protected_separator 
7784
7785 \protected_separator 
7786  //Now it's possible to use malloc.
7787  
7788 \newline 
7789
7790 \protected_separator 
7791
7792 \protected_separator 
7793
7794 \protected_separator 
7795
7796 \protected_separator 
7797  //
7798 \protected_separator 
7799
7800 \protected_separator 
7801
7802 \protected_separator 
7803
7804 \protected_separator 
7805
7806 \protected_separator 
7807
7808 \protected_separator 
7809
7810 \protected_separator 
7811
7812 \protected_separator 
7813  ...
7814  
7815 \newline 
7816
7817 \protected_separator 
7818
7819 \protected_separator 
7820
7821 \protected_separator 
7822
7823 \protected_separator 
7824  //
7825 \protected_separator 
7826
7827 \protected_separator 
7828
7829 \protected_separator 
7830
7831 \protected_separator 
7832
7833 \protected_separator 
7834
7835 \protected_separator 
7836
7837 \protected_separator 
7838
7839 \protected_separator 
7840  current_buffer = malloc(0x100); 
7841 \newline 
7842
7843 \protected_separator 
7844
7845 \protected_separator 
7846
7847 \protected_separator 
7848
7849 \protected_separator 
7850  //
7851 \end_deeper 
7852 \layout Itemize
7853
7854
7855 \series bold 
7856 \size large 
7857 serial.h
7858 \series default 
7859 \size default 
7860  - Serial IO routines are also developed by Dmitry S.
7861  Obukhov (dso@usa.net).
7862  These routines are interrupt driven with a 256 byte circular buffer, they
7863  also expect external ram to be present.
7864  Please see documentation in file SDCCDIR/sdcc51lib/serial.c .
7865  Note the header file 
7866 \begin_inset Quotes eld
7867 \end_inset 
7868
7869 serial.h
7870 \begin_inset Quotes erd
7871 \end_inset 
7872
7873  MUST be included in the file containing the 'main' function.
7874 \layout Itemize
7875
7876
7877 \series bold 
7878 \size large 
7879 ser.h 
7880 \series default 
7881 \size default 
7882 - Alternate serial routine provided by Wolfgang Esslinger <wolfgang@WiredMinds.co
7883 m> these routines are more compact and faster.
7884  Please see documentation in file SDCCDIR/sdcc51lib/ser.c
7885 \layout Itemize
7886
7887
7888 \series bold 
7889 \size large 
7890 ser_ir.h 
7891 \series default 
7892 \size default 
7893 - Another alternate set of serial routines provided by Josef Wolf <jw@raven.inka.d
7894 e> , these routines do not use the external ram.
7895 \layout Itemize
7896
7897
7898 \series bold 
7899 \size large 
7900 reg51.h
7901 \series default 
7902 \size default 
7903  - contains register definitions for a standard 8051
7904 \layout Itemize
7905
7906
7907 \series bold 
7908 \size large 
7909 reg552.h 
7910 \series default 
7911 \size default 
7912 - contains register definitions for 80C552.
7913 \layout Itemize
7914
7915
7916 \series bold 
7917 \size large 
7918 float.h
7919 \series default 
7920 \size default 
7921  - contains min, max and other floating point related stuff.
7922 \layout Standard
7923
7924 All library routines are compiled as --model-small , they are all non-reentrant,
7925  if you plan to use the large model or want to make these routines reentrant,
7926  then they will have to be recompiled with the appropriate compiler option.
7927 \layout Standard
7928
7929 Have not had time to do the more involved routines like printf, will get
7930  to them shortly.
7931 \layout Section
7932
7933 Interfacing with assembly routines.
7934 \begin_inset LatexCommand \label{Interface_asm}
7935
7936 \end_inset 
7937
7938
7939 \layout Subsection
7940
7941 Global registers used for parameter passing.
7942 \layout Standard
7943
7944 By default the compiler uses the global registers 
7945 \begin_inset Quotes eld
7946 \end_inset 
7947
7948 DPL,DPH,B,ACC
7949 \begin_inset Quotes erd
7950 \end_inset 
7951
7952  to pass the first parameter to a routine, the second parameter onwards
7953  is either allocated on the stack (for reentrant routines or --stack-auto
7954  is used) or in the internal / external ram (depending on the memory model).
7955  
7956 \layout Subsubsection
7957
7958 Assembler routine non-reentrant
7959 \layout Standard
7960
7961 In the following example the function
7962 \series bold 
7963  cfunc
7964 \series default 
7965  calls an assembler routine 
7966 \series bold 
7967 asm_func
7968 \series default 
7969 , which takes two parameters.
7970 \layout Standard
7971
7972
7973 \size footnotesize 
7974 extern int asm_func( unsigned short, unsigned short);
7975 \layout Verbatim
7976
7977
7978 \size footnotesize 
7979
7980 \protected_separator 
7981
7982 \newline 
7983 int c_func (unsigned short i, unsigned short j) 
7984 \newline 
7985
7986 \newline 
7987
7988 \protected_separator 
7989
7990 \protected_separator 
7991
7992 \protected_separator 
7993
7994 \protected_separator 
7995
7996 \protected_separator 
7997
7998 \protected_separator 
7999
8000 \protected_separator 
8001  return asm_func(i,j); 
8002 \newline 
8003 }
8004 \size default 
8005  
8006 \size scriptsize 
8007
8008 \newline 
8009 int main() 
8010 \newline 
8011
8012 \newline 
8013
8014 \protected_separator 
8015
8016 \protected_separator 
8017
8018 \protected_separator 
8019 return c_func(10,9); 
8020 \newline 
8021 }
8022 \layout Standard
8023
8024 The corresponding assembler function is:-
8025 \layout Verbatim
8026
8027
8028 \size scriptsize 
8029
8030 \protected_separator 
8031
8032 \protected_separator 
8033
8034 \protected_separator 
8035
8036 \protected_separator 
8037
8038 \protected_separator 
8039
8040 \protected_separator 
8041
8042 \protected_separator 
8043  .globl _asm_func_PARM_2 
8044 \newline 
8045
8046 \protected_separator 
8047
8048 \protected_separator 
8049
8050 \protected_separator 
8051
8052 \protected_separator 
8053
8054 \protected_separator 
8055
8056 \protected_separator 
8057
8058 \protected_separator 
8059  .globl _asm_func 
8060 \newline 
8061
8062 \protected_separator 
8063
8064 \protected_separator 
8065
8066 \protected_separator 
8067
8068 \protected_separator 
8069
8070 \protected_separator 
8071
8072 \protected_separator 
8073
8074 \protected_separator 
8075  .area OSEG 
8076 \newline 
8077 _asm_func_PARM_2:
8078 \protected_separator 
8079
8080 \protected_separator 
8081
8082 \protected_separator 
8083
8084 \protected_separator 
8085
8086 \protected_separator 
8087
8088 \protected_separator 
8089  .ds
8090 \protected_separator 
8091
8092 \protected_separator 
8093
8094 \protected_separator 
8095
8096 \protected_separator 
8097
8098 \protected_separator 
8099  1 
8100 \newline 
8101
8102 \protected_separator 
8103
8104 \protected_separator 
8105
8106 \protected_separator 
8107
8108 \protected_separator 
8109
8110 \protected_separator 
8111
8112 \protected_separator 
8113
8114 \protected_separator 
8115  .area CSEG 
8116 \newline 
8117 _asm_func: 
8118 \newline 
8119
8120 \protected_separator 
8121
8122 \protected_separator 
8123
8124 \protected_separator 
8125
8126 \protected_separator 
8127
8128 \protected_separator 
8129
8130 \protected_separator 
8131
8132 \protected_separator 
8133  mov
8134 \protected_separator 
8135
8136 \protected_separator 
8137
8138 \protected_separator 
8139
8140 \protected_separator 
8141  a,dpl 
8142 \newline 
8143
8144 \protected_separator 
8145
8146 \protected_separator 
8147
8148 \protected_separator 
8149
8150 \protected_separator 
8151
8152 \protected_separator 
8153
8154 \protected_separator 
8155
8156 \protected_separator 
8157  add
8158 \protected_separator 
8159
8160 \protected_separator 
8161
8162 \protected_separator 
8163
8164 \protected_separator 
8165  a,_asm_func_PARM_2 
8166 \newline 
8167
8168 \protected_separator 
8169
8170 \protected_separator 
8171
8172 \protected_separator 
8173
8174 \protected_separator 
8175
8176 \protected_separator 
8177
8178 \protected_separator 
8179
8180 \protected_separator 
8181  mov
8182 \protected_separator 
8183
8184 \protected_separator 
8185
8186 \protected_separator 
8187
8188 \protected_separator 
8189  dpl,a 
8190 \newline 
8191
8192 \protected_separator 
8193
8194 \protected_separator 
8195
8196 \protected_separator 
8197
8198 \protected_separator 
8199
8200 \protected_separator 
8201
8202 \protected_separator 
8203
8204 \protected_separator 
8205  mov
8206 \protected_separator 
8207
8208 \protected_separator 
8209
8210 \protected_separator 
8211
8212 \protected_separator 
8213  dpl,#0x00 
8214 \newline 
8215
8216 \protected_separator 
8217
8218 \protected_separator 
8219
8220 \protected_separator 
8221
8222 \protected_separator 
8223
8224 \protected_separator 
8225
8226 \protected_separator 
8227
8228 \protected_separator 
8229  ret
8230 \layout Standard
8231
8232 Note here that the return values are placed in 'dpl' - One byte return value,
8233  'dpl' LSB & 'dph' MSB for two byte values.
8234  'dpl', 'dph' and 'b' for three byte values (generic pointers) and 'dpl','dph','
8235 b' & 'acc' for four byte values.
8236 \layout Standard
8237
8238 The parameter naming convention is 
8239 \series bold 
8240 _<function_name>_PARM_<n>,
8241 \series default 
8242  where n is the parameter number starting from 1, and counting from the
8243  left.
8244  The first parameter is passed in 
8245 \begin_inset Quotes eld
8246 \end_inset 
8247
8248 dpl
8249 \begin_inset Quotes erd
8250 \end_inset 
8251
8252  for One bye parameter, 
8253 \begin_inset Quotes eld
8254 \end_inset 
8255
8256 dptr
8257 \begin_inset Quotes erd
8258 \end_inset 
8259
8260  if two bytes, 
8261 \begin_inset Quotes eld
8262 \end_inset 
8263
8264 b,dptr
8265 \begin_inset Quotes erd
8266 \end_inset 
8267
8268  for three bytes and 
8269 \begin_inset Quotes eld
8270 \end_inset 
8271
8272 acc,b,dptr
8273 \begin_inset Quotes erd
8274 \end_inset 
8275
8276  for four bytes, the 
8277 \family typewriter 
8278 \series bold 
8279 \size footnotesize 
8280 varaible name for the second parameter will be _<function_name>_PARM_2.
8281 \layout Standard
8282
8283 Assemble the assembler routine with the following command.
8284 \layout Verbatim
8285
8286 asx8051 -losg asmfunc.asm
8287 \layout Standard
8288
8289 Then compile and link the assembler routine to the C source file with the
8290  following command,
8291 \layout Verbatim
8292
8293 sdcc cfunc.c asmfunc.rel
8294 \layout Subsubsection
8295
8296 Assembler routine is reentrant
8297 \layout Standard
8298
8299 In this case the second parameter onwards will be passed on the stack ,
8300  the parameters are pushed from right to left i.e.
8301  after the call the left most parameter will be on the top of the stack.
8302  Here is an example.
8303 \layout Standard
8304
8305
8306 \size footnotesize 
8307 extern int asm_func( unsigned short, unsigned short);
8308 \layout Verbatim
8309
8310
8311 \size footnotesize 
8312
8313 \protected_separator 
8314
8315 \layout Verbatim
8316
8317
8318 \size footnotesize 
8319 int c_func (unsigned short i, unsigned short j) reentrant 
8320 \newline 
8321
8322 \newline 
8323
8324 \protected_separator 
8325
8326 \protected_separator 
8327
8328 \protected_separator 
8329
8330 \protected_separator 
8331
8332 \protected_separator 
8333
8334 \protected_separator 
8335
8336 \protected_separator 
8337  return asm_func(i,j); 
8338 \newline 
8339 }
8340 \size default 
8341  
8342 \size scriptsize 
8343
8344 \newline 
8345 int main() 
8346 \newline 
8347
8348 \newline 
8349
8350 \protected_separator 
8351
8352 \protected_separator 
8353
8354 \protected_separator 
8355 return c_func(10,9); 
8356 \newline 
8357 }
8358 \layout Standard
8359
8360 The corresponding assembler routine is.
8361 \layout Verbatim
8362
8363
8364 \size scriptsize 
8365
8366 \protected_separator 
8367
8368 \protected_separator 
8369
8370 \protected_separator 
8371
8372 \protected_separator 
8373
8374 \protected_separator 
8375
8376 \protected_separator 
8377
8378 \protected_separator 
8379  .globl _asm_func 
8380 \newline 
8381 _asm_func: 
8382 \newline 
8383
8384 \protected_separator 
8385
8386 \protected_separator 
8387
8388 \protected_separator 
8389
8390 \protected_separator 
8391
8392 \protected_separator 
8393
8394 \protected_separator 
8395
8396 \protected_separator 
8397  push
8398 \protected_separator 
8399  _bp 
8400 \newline 
8401
8402 \protected_separator 
8403
8404 \protected_separator 
8405
8406 \protected_separator 
8407
8408 \protected_separator 
8409
8410 \protected_separator 
8411
8412 \protected_separator 
8413
8414 \protected_separator 
8415  mov
8416 \protected_separator 
8417  _bp,sp 
8418 \newline 
8419
8420 \protected_separator 
8421
8422 \protected_separator 
8423
8424 \protected_separator 
8425
8426 \protected_separator 
8427
8428 \protected_separator 
8429
8430 \protected_separator 
8431
8432 \protected_separator 
8433
8434 \protected_separator 
8435 mov
8436 \protected_separator 
8437  r2,dpl
8438 \newline 
8439
8440 \protected_separator 
8441
8442 \protected_separator 
8443
8444 \protected_separator 
8445
8446 \protected_separator 
8447
8448 \protected_separator 
8449
8450 \protected_separator 
8451
8452 \protected_separator 
8453  mov
8454 \protected_separator 
8455  a,_bp 
8456 \newline 
8457
8458 \protected_separator 
8459
8460 \protected_separator 
8461
8462 \protected_separator 
8463
8464 \protected_separator 
8465
8466 \protected_separator 
8467
8468 \protected_separator 
8469
8470 \protected_separator 
8471  clr
8472 \protected_separator 
8473  c 
8474 \newline 
8475
8476 \protected_separator 
8477
8478 \protected_separator 
8479
8480 \protected_separator 
8481
8482 \protected_separator 
8483
8484 \protected_separator 
8485
8486 \protected_separator 
8487
8488 \protected_separator 
8489  add
8490 \protected_separator 
8491  a,#0xfd 
8492 \newline 
8493
8494 \protected_separator 
8495
8496 \protected_separator 
8497
8498 \protected_separator 
8499
8500 \protected_separator 
8501
8502 \protected_separator 
8503
8504 \protected_separator 
8505
8506 \protected_separator 
8507  mov
8508 \protected_separator 
8509  r0,a 
8510 \newline 
8511
8512 \protected_separator 
8513
8514 \protected_separator 
8515
8516 \protected_separator 
8517
8518 \protected_separator 
8519
8520 \protected_separator 
8521
8522 \protected_separator 
8523
8524 \protected_separator 
8525  add
8526 \protected_separator 
8527  a,#0xfc
8528 \newline 
8529
8530 \protected_separator 
8531
8532 \protected_separator 
8533
8534 \protected_separator 
8535
8536 \protected_separator 
8537
8538 \protected_separator 
8539
8540 \protected_separator 
8541
8542 \protected_separator 
8543  mov
8544 \protected_separator 
8545  r1,a 
8546 \newline 
8547
8548 \protected_separator 
8549
8550 \protected_separator 
8551
8552 \protected_separator 
8553
8554 \protected_separator 
8555
8556 \protected_separator 
8557
8558 \protected_separator 
8559
8560 \protected_separator 
8561  mov
8562 \protected_separator 
8563  a,@r0 
8564 \newline 
8565
8566 \protected_separator 
8567
8568 \protected_separator 
8569
8570 \protected_separator 
8571
8572 \protected_separator 
8573
8574 \protected_separator 
8575
8576 \protected_separator 
8577
8578 \protected_separator 
8579  add
8580 \protected_separator 
8581  a,r2
8582 \newline 
8583
8584 \protected_separator 
8585
8586 \protected_separator 
8587
8588 \protected_separator 
8589
8590 \protected_separator 
8591
8592 \protected_separator 
8593
8594 \protected_separator 
8595
8596 \protected_separator 
8597  mov
8598 \protected_separator 
8599  dpl,a 
8600 \newline 
8601
8602 \protected_separator 
8603
8604 \protected_separator 
8605
8606 \protected_separator 
8607
8608 \protected_separator 
8609
8610 \protected_separator 
8611
8612 \protected_separator 
8613
8614 \protected_separator 
8615  mov
8616 \protected_separator 
8617  dph,#0x00 
8618 \newline 
8619
8620 \protected_separator 
8621
8622 \protected_separator 
8623
8624 \protected_separator 
8625
8626 \protected_separator 
8627
8628 \protected_separator 
8629
8630 \protected_separator 
8631
8632 \protected_separator 
8633  mov
8634 \protected_separator 
8635  sp,_bp 
8636 \newline 
8637
8638 \protected_separator 
8639
8640 \protected_separator 
8641
8642 \protected_separator 
8643
8644 \protected_separator 
8645
8646 \protected_separator 
8647
8648 \protected_separator 
8649
8650 \protected_separator 
8651  pop
8652 \protected_separator 
8653  _bp 
8654 \newline 
8655
8656 \protected_separator 
8657
8658 \protected_separator 
8659
8660 \protected_separator 
8661
8662 \protected_separator 
8663
8664 \protected_separator 
8665
8666 \protected_separator 
8667
8668 \protected_separator 
8669  ret
8670 \layout Standard
8671
8672 The compiling and linking procedure remains the same, however note the extra
8673  entry & exit linkage required for the assembler code, _bp is the stack
8674  frame pointer and is used to compute the offset into the stack for parameters
8675  and local variables.
8676 \layout Subsection
8677
8678 With --noregparms option.
8679 \layout Standard
8680
8681 When the source is compiled with --noregparms option , space is allocated
8682  for each of the parameters passed to a routine.
8683 \layout Subsubsection
8684
8685 Assembler routine non-reentrant.
8686 \layout Standard
8687
8688 In the following example the function
8689 \series bold 
8690  cfunc
8691 \series default 
8692  calls an assembler routine 
8693 \series bold 
8694 asm_func
8695 \series default 
8696 , which takes two parameters.
8697 \layout Verbatim
8698
8699
8700 \size footnotesize 
8701 extern int asm_func( unsigned short, unsigned short);
8702 \layout Verbatim
8703
8704
8705 \size footnotesize 
8706
8707 \protected_separator 
8708
8709 \newline 
8710 int c_func (unsigned short i, unsigned short j) 
8711 \newline 
8712
8713 \newline 
8714
8715 \protected_separator 
8716
8717 \protected_separator 
8718
8719 \protected_separator 
8720
8721 \protected_separator 
8722
8723 \protected_separator 
8724
8725 \protected_separator 
8726
8727 \protected_separator 
8728  return asm_func(i,j); 
8729 \newline 
8730 }
8731 \size default 
8732  
8733 \size scriptsize 
8734
8735 \newline 
8736 int main() 
8737 \newline 
8738
8739 \newline 
8740
8741 \protected_separator 
8742
8743 \protected_separator 
8744
8745 \protected_separator 
8746 return c_func(10,9); 
8747 \newline 
8748 }
8749 \layout Standard
8750
8751 The corresponding assembler function is:-
8752 \layout Verbatim
8753
8754
8755 \size scriptsize 
8756
8757 \protected_separator 
8758
8759 \protected_separator 
8760
8761 \protected_separator 
8762
8763 \protected_separator 
8764
8765 \protected_separator 
8766
8767 \protected_separator 
8768
8769 \protected_separator 
8770  .globl _asm_func_PARM_1 
8771 \newline 
8772
8773 \protected_separator 
8774
8775 \protected_separator 
8776
8777 \protected_separator 
8778
8779 \protected_separator 
8780
8781 \protected_separator 
8782
8783 \protected_separator 
8784
8785 \protected_separator 
8786  .globl _asm_func_PARM_2 
8787 \newline 
8788
8789 \protected_separator 
8790
8791 \protected_separator 
8792
8793 \protected_separator 
8794
8795 \protected_separator 
8796
8797 \protected_separator 
8798
8799 \protected_separator 
8800
8801 \protected_separator 
8802  .globl _asm_func 
8803 \newline 
8804
8805 \protected_separator 
8806
8807 \protected_separator 
8808
8809 \protected_separator 
8810
8811 \protected_separator 
8812
8813 \protected_separator 
8814
8815 \protected_separator 
8816
8817 \protected_separator 
8818  .area OSEG 
8819 \newline 
8820 _asm_func_PARM_1:
8821 \protected_separator 
8822
8823 \protected_separator 
8824
8825 \protected_separator 
8826
8827 \protected_separator 
8828
8829 \protected_separator 
8830
8831 \protected_separator 
8832  .ds
8833 \protected_separator 
8834
8835 \protected_separator 
8836
8837 \protected_separator 
8838
8839 \protected_separator 
8840  1 
8841 \newline 
8842 _asm_func_PARM_2:
8843 \protected_separator 
8844
8845 \protected_separator 
8846
8847 \protected_separator 
8848
8849 \protected_separator 
8850
8851 \protected_separator 
8852
8853 \protected_separator 
8854  .ds
8855 \protected_separator 
8856
8857 \protected_separator 
8858
8859 \protected_separator 
8860
8861 \protected_separator 
8862
8863 \protected_separator 
8864  1 
8865 \newline 
8866
8867 \protected_separator 
8868
8869 \protected_separator 
8870
8871 \protected_separator 
8872
8873 \protected_separator 
8874
8875 \protected_separator 
8876
8877 \protected_separator 
8878
8879 \protected_separator 
8880  .area CSEG 
8881 \newline 
8882 _asm_func: 
8883 \newline 
8884
8885 \protected_separator 
8886
8887 \protected_separator 
8888
8889 \protected_separator 
8890
8891 \protected_separator 
8892
8893 \protected_separator 
8894
8895 \protected_separator 
8896
8897 \protected_separator 
8898  mov
8899 \protected_separator 
8900
8901 \protected_separator 
8902
8903 \protected_separator 
8904
8905 \protected_separator 
8906  a,_asm_func_PARM_1 
8907 \newline 
8908
8909 \protected_separator 
8910
8911 \protected_separator 
8912
8913 \protected_separator 
8914
8915 \protected_separator 
8916
8917 \protected_separator 
8918
8919 \protected_separator 
8920
8921 \protected_separator 
8922  add
8923 \protected_separator 
8924
8925 \protected_separator 
8926
8927 \protected_separator 
8928
8929 \protected_separator 
8930  a,_asm_func_PARM_2 
8931 \newline 
8932
8933 \protected_separator 
8934
8935 \protected_separator 
8936
8937 \protected_separator 
8938
8939 \protected_separator 
8940
8941 \protected_separator 
8942
8943 \protected_separator 
8944
8945 \protected_separator 
8946  mov
8947 \protected_separator 
8948
8949 \protected_separator 
8950
8951 \protected_separator 
8952
8953 \protected_separator 
8954  dpl,a 
8955 \newline 
8956
8957 \protected_separator 
8958
8959 \protected_separator 
8960
8961 \protected_separator 
8962
8963 \protected_separator 
8964
8965 \protected_separator 
8966
8967 \protected_separator 
8968
8969 \protected_separator 
8970  mov
8971 \protected_separator 
8972
8973 \protected_separator 
8974
8975 \protected_separator 
8976
8977 \protected_separator 
8978  dpl,#0x00 
8979 \newline 
8980
8981 \protected_separator 
8982
8983 \protected_separator 
8984
8985 \protected_separator 
8986
8987 \protected_separator 
8988
8989 \protected_separator 
8990
8991 \protected_separator 
8992
8993 \protected_separator 
8994  ret
8995 \layout Standard
8996
8997 Note here that the return values are placed in 'dpl' - One byte return value,
8998  'dpl' LSB & 'dph' MSB for two byte values.
8999  'dpl', 'dph' and 'b' for three byte values (generic pointers) and 'dpl','dph','
9000 b' & 'acc' for four byte values.
9001 \layout Standard
9002
9003 The parameter naming convention is 
9004 \series bold 
9005 _<function_name>_PARM_<n>,
9006 \series default 
9007  where n is the parameter number starting from 1, and counting from the
9008  left.
9009  i.e.
9010  the 
9011 \family typewriter 
9012 \series bold 
9013 \size footnotesize 
9014 left-most parameter name will be _<function_name>_PARM_1.
9015 \layout Standard
9016
9017 Assemble the assembler routine with the following command.
9018 \layout Verbatim
9019
9020 asx8051 -losg asmfunc.asm
9021 \layout Standard
9022
9023 Then compile and link the assembler routine to the C source file with the
9024  following command,
9025 \layout Verbatim
9026
9027 sdcc cfunc.c asmfunc.rel
9028 \layout Subsubsection
9029
9030 Assembler routine is reentrant.
9031 \layout Standard
9032
9033 In this case the parameters will be passed on the stack , the parameters
9034  are pushed from right to left i.e.
9035  after the call the left most parameter will be on the top of the stack.
9036  Here is an example.
9037 \layout Standard
9038
9039
9040 \size footnotesize 
9041 extern int asm_func( unsigned short, unsigned short);
9042 \layout Verbatim
9043
9044
9045 \size footnotesize 
9046
9047 \protected_separator 
9048
9049 \layout Verbatim
9050
9051
9052 \size footnotesize 
9053 int c_func (unsigned short i, unsigned short j) reentrant 
9054 \newline 
9055
9056 \newline 
9057
9058 \protected_separator 
9059
9060 \protected_separator 
9061
9062 \protected_separator 
9063
9064 \protected_separator 
9065
9066 \protected_separator 
9067
9068 \protected_separator 
9069
9070 \protected_separator 
9071  return asm_func(i,j); 
9072 \newline 
9073 }
9074 \size default 
9075  
9076 \size scriptsize 
9077
9078 \newline 
9079 int main() 
9080 \newline 
9081
9082 \newline 
9083
9084 \protected_separator 
9085
9086 \protected_separator 
9087
9088 \protected_separator 
9089 return c_func(10,9); 
9090 \newline 
9091 }
9092 \layout Standard
9093
9094 The corresponding assembler routine is.
9095 \layout Verbatim
9096
9097
9098 \size scriptsize 
9099
9100 \protected_separator 
9101
9102 \protected_separator 
9103
9104 \protected_separator 
9105
9106 \protected_separator 
9107
9108 \protected_separator 
9109
9110 \protected_separator 
9111
9112 \protected_separator 
9113  .globl _asm_func 
9114 \newline 
9115 _asm_func: 
9116 \newline 
9117
9118 \protected_separator 
9119
9120 \protected_separator 
9121
9122 \protected_separator 
9123
9124 \protected_separator 
9125
9126 \protected_separator 
9127
9128 \protected_separator 
9129
9130 \protected_separator 
9131  push
9132 \protected_separator 
9133  _bp 
9134 \newline 
9135
9136 \protected_separator 
9137
9138 \protected_separator 
9139
9140 \protected_separator 
9141
9142 \protected_separator 
9143
9144 \protected_separator 
9145
9146 \protected_separator 
9147
9148 \protected_separator 
9149  mov
9150 \protected_separator 
9151  _bp,sp 
9152 \newline 
9153
9154 \protected_separator 
9155
9156 \protected_separator 
9157
9158 \protected_separator 
9159
9160 \protected_separator 
9161
9162 \protected_separator 
9163
9164 \protected_separator 
9165
9166 \protected_separator 
9167  mov
9168 \protected_separator 
9169  a,_bp 
9170 \newline 
9171
9172 \protected_separator 
9173
9174 \protected_separator 
9175
9176 \protected_separator 
9177
9178 \protected_separator 
9179
9180 \protected_separator 
9181
9182 \protected_separator 
9183
9184 \protected_separator 
9185  clr
9186 \protected_separator 
9187  c 
9188 \newline 
9189
9190 \protected_separator 
9191
9192 \protected_separator 
9193
9194 \protected_separator 
9195
9196 \protected_separator 
9197
9198 \protected_separator 
9199
9200 \protected_separator 
9201
9202 \protected_separator 
9203  add
9204 \protected_separator 
9205  a,#0xfd 
9206 \newline 
9207
9208 \protected_separator 
9209
9210 \protected_separator 
9211
9212 \protected_separator 
9213
9214 \protected_separator 
9215
9216 \protected_separator 
9217
9218 \protected_separator 
9219
9220 \protected_separator 
9221  mov
9222 \protected_separator 
9223  r0,a 
9224 \newline 
9225
9226 \protected_separator 
9227
9228 \protected_separator 
9229
9230 \protected_separator 
9231
9232 \protected_separator 
9233
9234 \protected_separator 
9235
9236 \protected_separator 
9237
9238 \protected_separator 
9239  mov
9240 \protected_separator 
9241  a,_bp 
9242 \newline 
9243
9244 \protected_separator 
9245
9246 \protected_separator 
9247
9248 \protected_separator 
9249
9250 \protected_separator 
9251
9252 \protected_separator 
9253
9254 \protected_separator 
9255
9256 \protected_separator 
9257  clr
9258 \protected_separator 
9259  c 
9260 \newline 
9261
9262 \protected_separator 
9263
9264 \protected_separator 
9265
9266 \protected_separator 
9267
9268 \protected_separator 
9269
9270 \protected_separator 
9271
9272 \protected_separator 
9273
9274 \protected_separator 
9275  add
9276 \protected_separator 
9277  a,#0xfc 
9278 \newline 
9279
9280 \protected_separator 
9281
9282 \protected_separator 
9283
9284 \protected_separator 
9285
9286 \protected_separator 
9287
9288 \protected_separator 
9289
9290 \protected_separator 
9291
9292 \protected_separator 
9293  mov
9294 \protected_separator 
9295  r1,a 
9296 \newline 
9297
9298 \protected_separator 
9299
9300 \protected_separator 
9301
9302 \protected_separator 
9303
9304 \protected_separator 
9305
9306 \protected_separator 
9307
9308 \protected_separator 
9309
9310 \protected_separator 
9311  mov
9312 \protected_separator 
9313  a,@r0 
9314 \newline 
9315
9316 \protected_separator 
9317
9318 \protected_separator 
9319
9320 \protected_separator 
9321
9322 \protected_separator 
9323
9324 \protected_separator 
9325
9326 \protected_separator 
9327
9328 \protected_separator 
9329  add
9330 \protected_separator 
9331  a,@r1 
9332 \newline 
9333
9334 \protected_separator 
9335
9336 \protected_separator 
9337
9338 \protected_separator 
9339
9340 \protected_separator 
9341
9342 \protected_separator 
9343
9344 \protected_separator 
9345
9346 \protected_separator 
9347  mov
9348 \protected_separator 
9349  dpl,a 
9350 \newline 
9351
9352 \protected_separator 
9353
9354 \protected_separator 
9355
9356 \protected_separator 
9357
9358 \protected_separator 
9359
9360 \protected_separator 
9361
9362 \protected_separator 
9363
9364 \protected_separator 
9365  mov
9366 \protected_separator 
9367  dph,#0x00 
9368 \newline 
9369
9370 \protected_separator 
9371
9372 \protected_separator 
9373
9374 \protected_separator 
9375
9376 \protected_separator 
9377
9378 \protected_separator 
9379
9380 \protected_separator 
9381
9382 \protected_separator 
9383  mov
9384 \protected_separator 
9385  sp,_bp 
9386 \newline 
9387
9388 \protected_separator 
9389
9390 \protected_separator 
9391
9392 \protected_separator 
9393
9394 \protected_separator 
9395
9396 \protected_separator 
9397
9398 \protected_separator 
9399
9400 \protected_separator 
9401  pop
9402 \protected_separator 
9403  _bp 
9404 \newline 
9405
9406 \protected_separator 
9407
9408 \protected_separator 
9409
9410 \protected_separator 
9411
9412 \protected_separator 
9413
9414 \protected_separator 
9415
9416 \protected_separator 
9417
9418 \protected_separator 
9419  ret
9420 \layout Standard
9421
9422 The compiling and linking procedure remains the same, however note the extra
9423  entry & exit linkage required for the assembler code, _bp is the stack
9424  frame pointer and is used to compute the offset into the stack for parameters
9425  and local variables.
9426 \layout Section
9427
9428 External Stack.
9429 \begin_inset LatexCommand \label{xstack}
9430
9431 \end_inset 
9432
9433
9434 \layout Standard
9435
9436 The external stack is located at the start of the external ram segment ,
9437  and is 256 bytes in size.
9438  When --xstack option is used to compile the program , the parameters and
9439  local variables of all reentrant functions are allocated in this area.
9440  This option is provided for programs with large stack space requirements.
9441  When used with the --stack-auto option, all parameters and local variables
9442  are allocated on the external stack (note support libraries will need to
9443  be recompiled with the same options).
9444 \layout Standard
9445
9446 The compiler outputs the higher order address byte of the external ram segment
9447  into PORT P2, therefore when using the External Stack option, this port
9448  MAY NOT be used by the application program.
9449 \layout Section
9450
9451 ANSI-Compliance.
9452 \begin_inset LatexCommand \label{ANSI_Compliance}
9453
9454 \end_inset 
9455
9456
9457 \layout Standard
9458
9459 Deviations from the compliancy.
9460 \layout Enumerate
9461
9462 functions are not always reentrant.
9463 \layout Enumerate
9464
9465 structures cannot be assigned values directly, cannot be passed as function
9466  parameters or assigned to each other and cannot be a return value from
9467  a function.
9468 \begin_deeper 
9469 \layout Verbatim
9470
9471
9472 \size small 
9473 eg
9474 \end_deeper 
9475 \layout Verbatim
9476
9477
9478 \size small 
9479 struct s { ...
9480  }; 
9481 \newline 
9482 struct s s1, s2; 
9483 \newline 
9484 foo() 
9485 \newline 
9486
9487 \newline 
9488 ...
9489  
9490 \newline 
9491 s1 = s2 ; /* is invalid in SDCC although allowed in ANSI */ 
9492 \newline 
9493 ...
9494  
9495 \newline 
9496 }
9497 \layout Verbatim
9498
9499
9500 \size small 
9501 struct s foo1 (struct s parms) /* is invalid in SDCC although allowed in
9502  ANSI */ 
9503 \newline 
9504
9505 \newline 
9506 struct s rets; 
9507 \newline 
9508 ...
9509  
9510 \newline 
9511 return rets;/* is invalid in SDCC although allowed in ANSI */ 
9512 \newline 
9513 }
9514 \layout Enumerate
9515
9516 'long long' (64 bit integers) not supported.
9517 \layout Enumerate
9518
9519 'double' precision floating point not supported.
9520 \layout Enumerate
9521
9522 integral promotions are suppressed.
9523  What does this mean ? The compiler will not implicitly promote an integer
9524  expression to a higher order integer, exception is an assignment or parameter
9525  passing.
9526  
9527 \layout Enumerate
9528
9529 No support for 
9530 \emph on 
9531 setjmp
9532 \emph default 
9533  and 
9534 \emph on 
9535 longjmp
9536 \emph default 
9537  (for now).
9538 \layout Enumerate
9539
9540 Old K&R style function declarations are NOT allowed.
9541 \layout Verbatim
9542
9543
9544 \size footnotesize 
9545 foo( i,j) /* this old style of function declarations */ 
9546 \newline 
9547 int i,j; /* are valid in ANSI ..
9548  not valid in SDCC */ 
9549 \newline 
9550
9551 \newline 
9552 ...
9553  
9554 \newline 
9555 }
9556 \layout Enumerate
9557
9558 functions declared as pointers must be dereferenced during the call.
9559 \begin_deeper 
9560 \layout Verbatim
9561
9562
9563 \size small 
9564 int (*foo)();
9565 \end_deeper 
9566 \layout Verbatim
9567
9568
9569 \size small 
9570
9571 \protected_separator 
9572  
9573 \protected_separator 
9574 ...
9575  
9576 \newline 
9577
9578 \protected_separator 
9579  
9580 \protected_separator 
9581 /* has to be called like this */ 
9582 \newline 
9583
9584 \protected_separator 
9585  
9586 \protected_separator 
9587 (*foo)();/* ansi standard allows calls to be made like 'foo()' */
9588 \layout Section
9589
9590 Cyclomatic Complexity
9591 \begin_inset LatexCommand \label{Cyclomatic}
9592
9593 \end_inset 
9594
9595
9596 \layout Standard
9597
9598 Cyclomatic complexity of a function is defined as the number of independent
9599  paths the program can take during execution of the function.
9600  This is an important number since it defines the number test cases you
9601  have to generate to validate the function .
9602  The accepted industry standard for complexity number is 10, if the cyclomatic
9603  complexity reported by SDCC exceeds 10 you should think about simplification
9604  of the function logic.
9605 \layout Standard
9606
9607 Note that the complexity level is not related to the number of lines of
9608  code in a function.
9609  Large functions can have low complexity, and small functions can have large
9610  complexity levels.
9611  SDCC uses the following formula to compute the complexity.
9612 \layout Verbatim
9613
9614
9615 \size small 
9616 complexity = (number of edges in control flow graph) - 
9617 \newline 
9618
9619 \protected_separator 
9620  
9621 \protected_separator 
9622  
9623 \protected_separator 
9624  
9625 \protected_separator 
9626  
9627 \protected_separator 
9628  
9629 \protected_separator 
9630  
9631 \protected_separator 
9632 (number of nodes in control flow graph) + 2;
9633 \layout Standard
9634
9635 Having said that the industry standard is 10, you should be aware that in
9636  some cases it may unavoidable to have a complexity level of less than 10.
9637  For example if you have switch statement with more than 10 case labels,
9638  each case label adds one to the complexity level.
9639  The complexity level is by no means an absolute measure of the algorithmic
9640  complexity of the function, it does however provide a good starting point
9641  for which functions you might look at for further optimization.
9642 \layout Section
9643
9644 TIPS
9645 \begin_inset LatexCommand \label{Tips}
9646
9647 \end_inset 
9648
9649
9650 \layout Standard
9651
9652 Here are a few guide-lines that will help the compiler generate more efficient
9653  code, some of the tips are specific to this compiler others are generally
9654  good programming practice.
9655 \layout Itemize
9656
9657 Use the smallest data type to represent your data-value.
9658  If it is known in advance that the value is going to be less than 256 then
9659  use a 'short' or 'char' instead of an 'int'.
9660 \layout Itemize
9661
9662 Use unsigned when it is known in advance that the value is not going to
9663  be negative.
9664  This helps especially if you are doing division or multiplication.
9665 \layout Itemize
9666
9667 NEVER jump into a LOOP.
9668 \layout Itemize
9669
9670 Declare the variables to be local whenever possible, especially loop control
9671  variables (induction).
9672 \layout Itemize
9673
9674 Since the compiler does not do implicit integral promotion, the programmer
9675  should do an explicit cast when integral promotion is required.
9676 \layout Itemize
9677
9678 Reducing the size of division , multiplication & modulus operations can
9679  reduce code size substantially.
9680  Take the following code for example.
9681 \begin_deeper 
9682 \layout Verbatim
9683
9684
9685 \size footnotesize 
9686 foobar( unsigned int p1, unsigned char ch)
9687 \newline 
9688 {
9689 \newline 
9690
9691 \protected_separator 
9692
9693 \protected_separator 
9694
9695 \protected_separator 
9696
9697 \protected_separator 
9698 unsigned char ch1 = p1 % ch ;
9699 \newline 
9700
9701 \protected_separator 
9702
9703 \protected_separator 
9704
9705 \protected_separator 
9706
9707 \protected_separator 
9708 ....
9709 \protected_separator 
9710
9711 \protected_separator 
9712
9713 \protected_separator 
9714
9715 \protected_separator 
9716
9717 \newline 
9718 }
9719 \layout Standard
9720
9721 For the modulus operation the variable ch will be promoted to unsigned int
9722  first then the modulus operation will be performed (this will lead to a
9723  call to a support routine).
9724  If the code is changed to 
9725 \layout Verbatim
9726
9727
9728 \size footnotesize 
9729 foobar( unsigned int p1, unsigned char ch)
9730 \newline 
9731 {
9732 \newline 
9733
9734 \protected_separator 
9735
9736 \protected_separator 
9737
9738 \protected_separator 
9739
9740 \protected_separator 
9741 unsigned char ch1 = (unsigned char)p1 % ch ;
9742 \newline 
9743
9744 \protected_separator 
9745
9746 \protected_separator 
9747
9748 \protected_separator 
9749
9750 \protected_separator 
9751 ....
9752 \protected_separator 
9753
9754 \protected_separator 
9755
9756 \protected_separator 
9757
9758 \protected_separator 
9759
9760 \newline 
9761 }
9762 \layout Standard
9763
9764 It would substantially reduce the code generated (future versions of the
9765  compiler will be smart enough to detect such optimization oppurtunities).
9766 \end_deeper 
9767 \layout Standard
9768
9769
9770 \series bold 
9771 Notes from an USER ( Trefor@magera.freeserve.co.uk )
9772 \layout Standard
9773
9774 The 8051 family of micro controller have a minimum of 128 bytes of internal
9775  memory which is structured as follows
9776 \layout Standard
9777
9778 - Bytes 00-1F - 32 bytes to hold up to 4 banks of the registers R7 to R7
9779  
9780 \layout Standard
9781
9782 - Bytes 20-2F - 16 bytes to hold 128 bit variables and 
9783 \layout Standard
9784
9785 - Bytes 30-7F - 60 bytes for general purpose use.
9786 \layout Standard
9787
9788 Normally the SDCC compiler will only utilise the first bank of registers,
9789  but it is possible to specify that other banks of registers should be used
9790  in interrupt routines.
9791  By default, the compiler will place the stack after the last bank of used
9792  registers, i.e.
9793  if the first 2 banks of registers are used, it will position the base of
9794  the internal stack at address 16 (0X10).
9795  This implies that as the stack grows, it will use up the remaining register
9796  banks, and the 16 bytes used by the 128 bit variables, and 60 bytes for
9797  general purpose use.
9798 \layout Standard
9799
9800 By default, the compiler uses the 60 general purpose bytes to hold "near
9801  data".
9802  The compiler/optimiser may also declare some Local Variables in this area
9803  to hold local data.
9804  
9805 \layout Standard
9806
9807 If any of the 128 bit variables are used, or near data is being used then
9808  care needs to be taken to ensure that the stack does not grow so much that
9809  it starts to over write either your bit variables or "near data".
9810  There is no runtime checking to prevent this from happening.
9811 \layout Standard
9812
9813 The amount of stack being used is affected by the use of the "internal stack"
9814  to save registers before a subroutine call is made, - --stack-auto will
9815  declare parameters and local variables on the stack - the number of nested
9816  subroutines.
9817 \layout Standard
9818
9819 If you detect that the stack is over writing you data, then the following
9820  can be done.
9821  --xstack will cause an external stack to be used for saving registers and
9822  (if --stack-auto is being used) storing parameters and local variables.
9823  However this will produce more and code which will be slower to execute.
9824  
9825 \layout Standard
9826
9827 --stack-loc will allow you specify the start of the stack, i.e.
9828  you could start it after any data in the general purpose area.
9829  However this may waste the memory not used by the register banks and if
9830  the size of the "near data" increases, it may creep into the bottom of
9831  the stack.
9832 \layout Standard
9833
9834 --stack-after-data, similar to the --stack-loc, but it automatically places
9835  the stack after the end of the "near data".
9836  Again this could waste any spare register space.
9837 \layout Standard
9838
9839 --data-loc allows you to specify the start address of the near data.
9840  This could be used to move the "near data" further away from the stack
9841  giving it more room to grow.
9842  This will only work if no bit variables are being used and the stack can
9843  grow to use the bit variable space.
9844 \layout Standard
9845
9846 Conclusion.
9847 \layout Standard
9848
9849 If you find that the stack is over writing your bit variables or "near data"
9850  then the approach which best utilised the internal memory is to position
9851  the "near data" after the last bank of used registers or, if you use bit
9852  variables, after the last bit variable by using the --data-loc, e.g.
9853  if two register banks are being used and no data variables, --data-loc
9854  16, and - use the --stack-after-data option.
9855 \layout Standard
9856
9857 If bit variables are being used, another method would be to try and squeeze
9858  the data area in the unused register banks if it will fit, and start the
9859  stack after the last bit variable.
9860 \layout Section
9861
9862 Retargetting for other MCUs.
9863 \begin_inset LatexCommand \label{Retargetting}
9864
9865 \end_inset 
9866
9867
9868 \layout Standard
9869
9870 The issues for retargetting the compiler are far too numerous to be covered
9871  by this document.
9872  What follows is a brief description of each of the seven phases of the
9873  compiler and its MCU dependency.
9874 \layout Enumerate
9875
9876 Parsing the source and building the annotated parse tree.
9877  This phase is largely MCU independent (except for the language extensions).
9878  Syntax & semantic checks are also done in this phase , along with some
9879  initial optimizations like back patching labels and the pattern matching
9880  optimizations like bit-rotation etc.
9881 \layout Enumerate
9882
9883 The second phase involves generating an intermediate code which can be easy
9884  manipulated during the later phases.
9885  This phase is entirely MCU independent.
9886  The intermediate code generation assumes the target machine has unlimited
9887  number of registers, and designates them with the name iTemp.
9888  The compiler can be made to dump a human readable form of the code generated
9889  by using the --dumpraw option.
9890 \layout Enumerate
9891
9892 This phase does the bulk of the standard optimizations and is also MCU independe
9893 nt.
9894  This phase can be broken down into several sub-phases.
9895 \begin_deeper 
9896 \layout Itemize
9897
9898 Break down intermediate code (iCode) into basic blocks.
9899 \layout Itemize
9900
9901 Do control flow & data flow analysis on the basic blocks.
9902 \layout Itemize
9903
9904 Do local common subexpression elimination, then global subexpression elimination
9905 \layout Itemize
9906
9907 dead code elimination
9908 \layout Itemize
9909
9910 loop optimizations
9911 \layout Itemize
9912
9913 if loop optimizations caused any changes then do 'global subexpression eliminati
9914 on' and 'dead code elimination' again.
9915 \end_deeper 
9916 \layout Enumerate
9917
9918 This phase determines the live-ranges; by live range I mean those iTemp
9919  variables defined by the compiler that still survive after all the optimization
9920 s.
9921  Live range analysis is essential for register allocation, since these computati
9922 on determines which of these iTemps will be assigned to registers, and for
9923  how long.
9924 \layout Enumerate
9925
9926 Phase five is register allocation.
9927  There are two parts to this process .
9928 \begin_deeper 
9929 \layout Enumerate
9930
9931 The first part I call 'register packing' (for lack of a better term) .
9932  In this case several MCU specific expression folding is done to reduce
9933  register pressure.
9934 \layout Enumerate
9935
9936 The second part is more MCU independent and deals with allocating registers
9937  to the remaining live ranges.
9938  A lot of MCU specific code does creep into this phase because of the limited
9939  number of index registers available in the 8051.
9940 \end_deeper 
9941 \layout Enumerate
9942
9943 The Code generation phase is (unhappily), entirely MCU dependent and very
9944  little (if any at all) of this code can be reused for other MCU.
9945  However the scheme for allocating a homogenized assembler operand for each
9946  iCode operand may be reused.
9947 \layout Enumerate
9948
9949 As mentioned in the optimization section the peep-hole optimizer is rule
9950  based system, which can reprogrammed for other MCUs.
9951 \layout Section
9952
9953 Reporting Bugs
9954 \begin_inset LatexCommand \label{Bugs}
9955
9956 \end_inset 
9957
9958
9959 \layout Standard
9960
9961 Shoot of an email to 'sandeep.dutta@usa.net', as a matter of principle I always
9962  reply to all email's sent to me.
9963  Bugs will be fixed ASAP.
9964  When reporting a bug , it is useful to include a small snippet of code
9965  that is causing the problem, if possible compile your program with the
9966  --dumpall option and send the dump files along with the bug report.
9967 \layout Section
9968
9969 SDCDB - Source level debugger.
9970 \layout Standard
9971
9972 SDCC is distributed with a source level debugger.
9973  The debugger uses a command line interface, the command repertoire of the
9974  debugger has been kept as close to gdb ( the GNU debugger) as possible.
9975  The configuration and build process of the compiler see Installation 
9976 \begin_inset LatexCommand \ref{Installation}
9977
9978 \end_inset 
9979
9980  also builds and installs the debugger in the target directory specified
9981  during configuration.
9982  The debugger allows you debug BOTH at the C source and at the ASM source
9983  level.
9984 \layout Subsection
9985
9986 Compiling for debugging.
9987 \layout Standard
9988
9989 The 
9990 \emph on 
9991 --debug
9992 \emph default 
9993  option must be specified for all files for which debug information is to
9994  be generated.
9995  The complier generates a 
9996 \emph on 
9997 .cdb
9998 \emph default 
9999  file for each of these files.
10000  The linker updates the 
10001 \emph on 
10002 .cdb
10003 \emph default 
10004  file with the address information.
10005  This .cdb is used by the debugger .
10006 \layout Subsection
10007
10008 How the debugger works.
10009 \layout Standard
10010
10011 When the 
10012 \emph on 
10013 --debug
10014 \emph default 
10015  option is specified the compiler generates extra symbol information some
10016  of which are put into the the assembler source and some are put into the
10017  .cdb file, the linker updates the .cdb file with the address information
10018  for the symbols.
10019  The debugger reads the symbolic information generated by the compiler &
10020  the address information generated by the linker.
10021  It uses the SIMULATOR (Daniel's S51) to execute the program, the program
10022  execution is controlled by the debugger.
10023  When a command is issued for the debugger, it translates it into appropriate
10024  commands for the simulator .
10025 \layout Subsection
10026
10027 Starting the debugger.
10028 \layout Standard
10029
10030 The debugger can be started using the following command line.
10031  (Assume the file you are debugging has
10032 \layout Standard
10033
10034 the file name foo).
10035 \layout Verbatim
10036
10037 >sdcdb foo
10038 \layout Standard
10039
10040 The debugger will look for the following files.
10041 \layout Enumerate
10042
10043 foo.c - the source file.
10044 \layout Enumerate
10045
10046 foo.cdb - the debugger symbol information file.
10047 \layout Enumerate
10048
10049 foo.ihx - the intel hex format object file.
10050 \layout Subsection
10051
10052 Command line options.
10053 \layout Itemize
10054
10055 --directory=<source file directory> this option can used to specify the
10056  directory search list.
10057  The debugger will look into the directory list specified for source , cdb
10058  & ihx files.
10059  The items in the directory list must be separated by ':' , e.g.
10060  if the source files can be in the directories /home/src1 and /home/src2,
10061  the --directory option should be --directory=/home/src1:/home/src2 .
10062  Note there can be no spaces in the option.
10063  
10064 \layout Itemize
10065
10066 -cd <directory> - change to the <directory>.
10067 \layout Itemize
10068
10069 -fullname - used by GUI front ends.
10070 \layout Itemize
10071
10072 -cpu <cpu-type> - this argument is passed to the simulator please see the
10073  simulator docs for details.
10074 \layout Itemize
10075
10076 -X <Clock frequency > this options is passed to the simulator please see
10077  simulator docs for details.
10078 \layout Itemize
10079
10080 -s <serial port file> passed to simulator see simulator docs for details.
10081 \layout Itemize
10082
10083 -S <serial in,out> passed to simulator see simulator docs for details.
10084 \layout Subsection
10085
10086 Debugger Commands.
10087 \layout Standard
10088
10089 As mention earlier the command interface for the debugger has been deliberately
10090  kept as close the GNU debugger gdb , as possible, this will help int integratio
10091 n with existing graphical user interfaces (like ddd, xxgdb or xemacs) existing
10092  for the GNU debugger.
10093 \layout Subsubsection
10094
10095 break [line | file:line | function | file:function]
10096 \layout Standard
10097
10098 Set breakpoint at specified line or function.
10099 \layout Verbatim
10100
10101 sdcdb>break 100 
10102 \newline 
10103 sdcdb>break foo.c:100
10104 \newline 
10105 sdcdb>break funcfoo
10106 \newline 
10107 sdcdb>break foo.c:funcfoo
10108 \layout Subsubsection
10109
10110 clear [line | file:line | function | file:function ]
10111 \layout Standard
10112
10113 Clear breakpoint at specified line or function.
10114 \layout Verbatim
10115
10116 sdcdb>clear 100
10117 \newline 
10118 sdcdb>clear foo.c:100
10119 \newline 
10120 sdcdb>clear funcfoo
10121 \newline 
10122 sdcdb>clear foo.c:funcfoo
10123 \layout Subsubsection
10124
10125 continue
10126 \layout Standard
10127
10128 Continue program being debugged, after breakpoint.
10129 \layout Subsubsection
10130
10131 finish
10132 \layout Standard
10133
10134 Execute till the end of the current function.
10135 \layout Subsubsection
10136
10137 delete [n]
10138 \layout Standard
10139
10140 Delete breakpoint number 'n'.
10141  If used without any option clear ALL user defined break points.
10142 \layout Subsubsection
10143
10144 info [break | stack | frame | registers ]
10145 \layout Itemize
10146
10147 info break - list all breakpoints
10148 \layout Itemize
10149
10150 info stack - show the function call stack.
10151 \layout Itemize
10152
10153 info frame - show information about the current execution frame.
10154 \layout Itemize
10155
10156 info registers - show content of all registers.
10157 \layout Subsubsection
10158
10159 step
10160 \layout Standard
10161
10162 Step program until it reaches a different source line.
10163 \layout Subsubsection
10164
10165 next
10166 \layout Standard
10167
10168 Step program, proceeding through subroutine calls.
10169 \layout Subsubsection
10170
10171 run
10172 \layout Standard
10173
10174 Start debugged program.
10175 \layout Subsubsection
10176
10177 ptype variable 
10178 \layout Standard
10179
10180 Print type information of the variable.
10181 \layout Subsubsection
10182
10183 print variable
10184 \layout Standard
10185
10186 print value of variable.
10187 \layout Subsubsection
10188
10189 file filename
10190 \layout Standard
10191
10192 load the given file name.
10193  Note this is an alternate method of loading file for debugging.
10194 \layout Subsubsection
10195
10196 frame
10197 \layout Standard
10198
10199 print information about current frame.
10200 \layout Subsubsection
10201
10202 set srcmode
10203 \layout Standard
10204
10205 Toggle between C source & assembly source.
10206 \layout Subsubsection
10207
10208 ! simulator command
10209 \layout Standard
10210
10211 Send the string following '!' to the simulator, the simulator response is
10212  displayed.
10213  Note the debugger does not interpret the command being sent to the simulator,
10214  so if a command like 'go' is sent the debugger can loose its execution
10215  context and may display incorrect values.
10216 \layout Subsubsection
10217
10218 quit.
10219 \layout Standard
10220
10221 "Watch me now.
10222  Iam going Down.
10223  My name is Bobby Brown"
10224 \layout Subsection
10225
10226 Interfacing with XEmacs.
10227 \layout Standard
10228
10229 Two files are (in emacs lisp) are provided for the interfacing with XEmacs,
10230 \emph on 
10231  sdcdb.el
10232 \emph default 
10233  and 
10234 \emph on 
10235 sdcdbsrc.el
10236 \emph default 
10237 .
10238  These two files can be found in the $(prefix)/bin directory after the installat
10239 ion is complete.
10240  These files need to be loaded into XEmacs for the interface to work, this
10241  can be done at XEmacs startup time by inserting the following into your
10242  
10243 \emph on 
10244 '.xemacs'
10245 \emph default 
10246  file (which can be found in your HOME directory) 
10247 \emph on 
10248 (load-file sdcdbsrc.el) 
10249 \emph default 
10250 [ .xemacs is a lisp file so the () around the command is REQUIRED), the files
10251  can also be loaded dynamically while XEmacs is running, set the environment
10252  variable 
10253 \emph on 
10254 'EMACSLOADPATH' 
10255 \emph default 
10256 to the installation bin directory [$(prefix)/bin], then enter the following
10257  command 
10258 \emph on 
10259 ESC-x load-file sdcdbsrc .
10260  
10261 \emph default 
10262 To start the interface enter the following command 
10263 \emph on 
10264 ESC-x sdcdbsrc
10265 \emph default 
10266  , you will prompted to enter the file name to be debugged.
10267  
10268 \layout Standard
10269
10270 The command line options that are passed to the simulator directly are bound
10271  to default values in the file 
10272 \emph on 
10273 sdcdbsrc.el 
10274 \emph default 
10275 the variables are listed below these values maybe changed as required.
10276 \layout Itemize
10277
10278 sdcdbsrc-cpu-type '51
10279 \layout Itemize
10280
10281 sdcdbsrc-frequency '11059200
10282 \layout Itemize
10283
10284 sdcdbsrc-serial nil
10285 \layout Standard
10286
10287 The following is a list of key mapping for the debugger interface.
10288 \layout Verbatim
10289
10290
10291 \protected_separator 
10292
10293 \size scriptsize 
10294
10295 \newline 
10296 ;; Current Listing :: 
10297 \newline 
10298 ;;key
10299 \protected_separator 
10300
10301 \protected_separator 
10302
10303 \protected_separator 
10304
10305 \protected_separator 
10306
10307 \protected_separator 
10308
10309 \protected_separator 
10310
10311 \protected_separator 
10312
10313 \protected_separator 
10314
10315 \protected_separator 
10316
10317 \protected_separator 
10318
10319 \protected_separator 
10320
10321 \protected_separator 
10322
10323 \protected_separator 
10324
10325 \protected_separator 
10326
10327 \protected_separator 
10328 binding
10329 \protected_separator 
10330
10331 \protected_separator 
10332
10333 \protected_separator 
10334
10335 \protected_separator 
10336
10337 \protected_separator 
10338
10339 \protected_separator 
10340
10341 \protected_separator 
10342
10343 \protected_separator 
10344
10345 \protected_separator 
10346
10347 \protected_separator 
10348
10349 \protected_separator 
10350
10351 \protected_separator 
10352
10353 \protected_separator 
10354
10355 \protected_separator 
10356
10357 \protected_separator 
10358
10359 \protected_separator 
10360
10361 \protected_separator 
10362
10363 \protected_separator 
10364
10365 \protected_separator 
10366
10367 \protected_separator 
10368
10369 \protected_separator 
10370
10371 \protected_separator 
10372 Comment 
10373 \newline 
10374 ;;---
10375 \protected_separator 
10376
10377 \protected_separator 
10378
10379 \protected_separator 
10380
10381 \protected_separator 
10382
10383 \protected_separator 
10384
10385 \protected_separator 
10386
10387 \protected_separator 
10388
10389 \protected_separator 
10390
10391 \protected_separator 
10392
10393 \protected_separator 
10394
10395 \protected_separator 
10396
10397 \protected_separator 
10398
10399 \protected_separator 
10400
10401 \protected_separator 
10402
10403 \protected_separator 
10404 -------
10405 \protected_separator 
10406
10407 \protected_separator 
10408
10409 \protected_separator 
10410
10411 \protected_separator 
10412
10413 \protected_separator 
10414
10415 \protected_separator 
10416
10417 \protected_separator 
10418
10419 \protected_separator 
10420
10421 \protected_separator 
10422
10423 \protected_separator 
10424
10425 \protected_separator 
10426
10427 \protected_separator 
10428
10429 \protected_separator 
10430
10431 \protected_separator 
10432
10433 \protected_separator 
10434
10435 \protected_separator 
10436
10437 \protected_separator 
10438
10439 \protected_separator 
10440
10441 \protected_separator 
10442
10443 \protected_separator 
10444
10445 \protected_separator 
10446
10447 \protected_separator 
10448 ------- 
10449 \newline 
10450 ;; 
10451 \newline 
10452 ;; n
10453 \protected_separator 
10454
10455 \protected_separator 
10456
10457 \protected_separator 
10458
10459 \protected_separator 
10460
10461 \protected_separator 
10462
10463 \protected_separator 
10464
10465 \protected_separator 
10466
10467 \protected_separator 
10468
10469 \protected_separator 
10470
10471 \protected_separator 
10472
10473 \protected_separator 
10474
10475 \protected_separator 
10476
10477 \protected_separator 
10478
10479 \protected_separator 
10480  sdcdb-next-from-src
10481 \protected_separator 
10482
10483 \protected_separator 
10484
10485 \protected_separator 
10486
10487 \protected_separator 
10488
10489 \protected_separator 
10490
10491 \protected_separator 
10492
10493 \protected_separator 
10494
10495 \protected_separator 
10496
10497 \protected_separator 
10498
10499 \protected_separator 
10500 SDCDB next command 
10501 \newline 
10502 ;; b
10503 \protected_separator 
10504
10505 \protected_separator 
10506
10507 \protected_separator 
10508
10509 \protected_separator 
10510
10511 \protected_separator 
10512
10513 \protected_separator 
10514
10515 \protected_separator 
10516
10517 \protected_separator 
10518
10519 \protected_separator 
10520
10521 \protected_separator 
10522
10523 \protected_separator 
10524
10525 \protected_separator 
10526
10527 \protected_separator 
10528
10529 \protected_separator 
10530  sdcdb-back-from-src
10531 \protected_separator 
10532
10533 \protected_separator 
10534
10535 \protected_separator 
10536
10537 \protected_separator 
10538
10539 \protected_separator 
10540
10541 \protected_separator 
10542
10543 \protected_separator 
10544
10545 \protected_separator 
10546
10547 \protected_separator 
10548
10549 \protected_separator 
10550 SDCDB back command 
10551 \newline 
10552 ;; c
10553 \protected_separator 
10554
10555 \protected_separator 
10556
10557 \protected_separator 
10558
10559 \protected_separator 
10560
10561 \protected_separator 
10562
10563 \protected_separator 
10564
10565 \protected_separator 
10566
10567 \protected_separator 
10568
10569 \protected_separator 
10570
10571 \protected_separator 
10572
10573 \protected_separator 
10574
10575 \protected_separator 
10576
10577 \protected_separator 
10578
10579 \protected_separator 
10580  sdcdb-cont-from-src
10581 \protected_separator 
10582
10583 \protected_separator 
10584
10585 \protected_separator 
10586
10587 \protected_separator 
10588
10589 \protected_separator 
10590
10591 \protected_separator 
10592
10593 \protected_separator 
10594
10595 \protected_separator 
10596
10597 \protected_separator 
10598
10599 \protected_separator 
10600 SDCDB continue command
10601 \newline 
10602 ;; s
10603 \protected_separator 
10604
10605 \protected_separator 
10606
10607 \protected_separator 
10608
10609 \protected_separator 
10610
10611 \protected_separator 
10612
10613 \protected_separator 
10614
10615 \protected_separator 
10616
10617 \protected_separator 
10618
10619 \protected_separator 
10620
10621 \protected_separator 
10622
10623 \protected_separator 
10624
10625 \protected_separator 
10626
10627 \protected_separator 
10628
10629 \protected_separator 
10630  sdcdb-step-from-src
10631 \protected_separator 
10632
10633 \protected_separator 
10634
10635 \protected_separator 
10636
10637 \protected_separator 
10638
10639 \protected_separator 
10640
10641 \protected_separator 
10642
10643 \protected_separator 
10644
10645 \protected_separator 
10646
10647 \protected_separator 
10648
10649 \protected_separator 
10650 SDCDB step command 
10651 \newline 
10652 ;; ?
10653 \protected_separator 
10654
10655 \protected_separator 
10656
10657 \protected_separator 
10658
10659 \protected_separator 
10660
10661 \protected_separator 
10662
10663 \protected_separator 
10664
10665 \protected_separator 
10666
10667 \protected_separator 
10668
10669 \protected_separator 
10670
10671 \protected_separator 
10672
10673 \protected_separator 
10674
10675 \protected_separator 
10676
10677 \protected_separator 
10678
10679 \protected_separator 
10680  sdcdb-whatis-c-sexp
10681 \protected_separator 
10682
10683 \protected_separator 
10684
10685 \protected_separator 
10686
10687 \protected_separator 
10688
10689 \protected_separator 
10690
10691 \protected_separator 
10692
10693 \protected_separator 
10694
10695 \protected_separator 
10696
10697 \protected_separator 
10698
10699 \protected_separator 
10700 SDCDB ptypecommand for data at 
10701 \newline 
10702 ;;
10703 \protected_separator 
10704
10705 \protected_separator 
10706
10707 \protected_separator 
10708
10709 \protected_separator 
10710
10711 \protected_separator 
10712
10713 \protected_separator 
10714
10715 \protected_separator 
10716
10717 \protected_separator 
10718
10719 \protected_separator 
10720
10721 \protected_separator 
10722
10723 \protected_separator 
10724
10725 \protected_separator 
10726
10727 \protected_separator 
10728
10729 \protected_separator 
10730
10731 \protected_separator 
10732
10733 \protected_separator 
10734
10735 \protected_separator 
10736
10737 \protected_separator 
10738
10739 \protected_separator 
10740
10741 \protected_separator 
10742
10743 \protected_separator 
10744
10745 \protected_separator 
10746
10747 \protected_separator 
10748
10749 \protected_separator 
10750
10751 \protected_separator 
10752
10753 \protected_separator 
10754
10755 \protected_separator 
10756
10757 \protected_separator 
10758
10759 \protected_separator 
10760
10761 \protected_separator 
10762
10763 \protected_separator 
10764
10765 \protected_separator 
10766
10767 \protected_separator 
10768
10769 \protected_separator 
10770
10771 \protected_separator 
10772
10773 \protected_separator 
10774
10775 \protected_separator 
10776
10777 \protected_separator 
10778
10779 \protected_separator 
10780
10781 \protected_separator 
10782
10783 \protected_separator 
10784
10785 \protected_separator 
10786  buffer point 
10787 \newline 
10788 ;; x
10789 \protected_separator 
10790
10791 \protected_separator 
10792
10793 \protected_separator 
10794
10795 \protected_separator 
10796
10797 \protected_separator 
10798
10799 \protected_separator 
10800
10801 \protected_separator 
10802
10803 \protected_separator 
10804
10805 \protected_separator 
10806
10807 \protected_separator 
10808
10809 \protected_separator 
10810
10811 \protected_separator 
10812
10813 \protected_separator 
10814
10815 \protected_separator 
10816  sdcdbsrc-delete
10817 \protected_separator 
10818
10819 \protected_separator 
10820
10821 \protected_separator 
10822
10823 \protected_separator 
10824
10825 \protected_separator 
10826
10827 \protected_separator 
10828
10829 \protected_separator 
10830
10831 \protected_separator 
10832
10833 \protected_separator 
10834
10835 \protected_separator 
10836
10837 \protected_separator 
10838
10839 \protected_separator 
10840
10841 \protected_separator 
10842
10843 \protected_separator 
10844 SDCDB Delete all breakpoints if no arg 
10845 \newline 
10846 ;;
10847 \protected_separator 
10848
10849 \protected_separator 
10850
10851 \protected_separator 
10852
10853 \protected_separator 
10854
10855 \protected_separator 
10856
10857 \protected_separator 
10858
10859 \protected_separator 
10860
10861 \protected_separator 
10862
10863 \protected_separator 
10864
10865 \protected_separator 
10866
10867 \protected_separator 
10868
10869 \protected_separator 
10870
10871 \protected_separator 
10872
10873 \protected_separator 
10874
10875 \protected_separator 
10876
10877 \protected_separator 
10878
10879 \protected_separator 
10880
10881 \protected_separator 
10882
10883 \protected_separator 
10884
10885 \protected_separator 
10886
10887 \protected_separator 
10888
10889 \protected_separator 
10890
10891 \protected_separator 
10892
10893 \protected_separator 
10894
10895 \protected_separator 
10896
10897 \protected_separator 
10898
10899 \protected_separator 
10900
10901 \protected_separator 
10902
10903 \protected_separator 
10904
10905 \protected_separator 
10906
10907 \protected_separator 
10908
10909 \protected_separator 
10910
10911 \protected_separator 
10912
10913 \protected_separator 
10914
10915 \protected_separator 
10916
10917 \protected_separator 
10918
10919 \protected_separator 
10920
10921 \protected_separator 
10922
10923 \protected_separator 
10924
10925 \protected_separator 
10926
10927 \protected_separator 
10928
10929 \protected_separator 
10930
10931 \protected_separator 
10932
10933 \protected_separator 
10934
10935 \protected_separator 
10936
10937 \protected_separator 
10938 given or delete arg (C-u arg x) 
10939 \newline 
10940 ;; m
10941 \protected_separator 
10942
10943 \protected_separator 
10944
10945 \protected_separator 
10946
10947 \protected_separator 
10948
10949 \protected_separator 
10950
10951 \protected_separator 
10952
10953 \protected_separator 
10954
10955 \protected_separator 
10956
10957 \protected_separator 
10958
10959 \protected_separator 
10960
10961 \protected_separator 
10962
10963 \protected_separator 
10964
10965 \protected_separator 
10966
10967 \protected_separator 
10968  sdcdbsrc-frame
10969 \protected_separator 
10970
10971 \protected_separator 
10972
10973 \protected_separator 
10974
10975 \protected_separator 
10976
10977 \protected_separator 
10978
10979 \protected_separator 
10980
10981 \protected_separator 
10982
10983 \protected_separator 
10984
10985 \protected_separator 
10986
10987 \protected_separator 
10988
10989 \protected_separator 
10990
10991 \protected_separator 
10992
10993 \protected_separator 
10994
10995 \protected_separator 
10996
10997 \protected_separator 
10998 SDCDB Display current frame if no arg, 
10999 \newline 
11000 ;;
11001 \protected_separator 
11002
11003 \protected_separator 
11004
11005 \protected_separator 
11006
11007 \protected_separator 
11008
11009 \protected_separator 
11010
11011 \protected_separator 
11012
11013 \protected_separator 
11014
11015 \protected_separator 
11016
11017 \protected_separator 
11018
11019 \protected_separator 
11020
11021 \protected_separator 
11022
11023 \protected_separator 
11024
11025 \protected_separator 
11026
11027 \protected_separator 
11028
11029 \protected_separator 
11030
11031 \protected_separator 
11032
11033 \protected_separator 
11034
11035 \protected_separator 
11036
11037 \protected_separator 
11038
11039 \protected_separator 
11040
11041 \protected_separator 
11042
11043 \protected_separator 
11044
11045 \protected_separator 
11046
11047 \protected_separator 
11048
11049 \protected_separator 
11050
11051 \protected_separator 
11052
11053 \protected_separator 
11054
11055 \protected_separator 
11056
11057 \protected_separator 
11058
11059 \protected_separator 
11060
11061 \protected_separator 
11062
11063 \protected_separator 
11064
11065 \protected_separator 
11066
11067 \protected_separator 
11068
11069 \protected_separator 
11070
11071 \protected_separator 
11072
11073 \protected_separator 
11074
11075 \protected_separator 
11076
11077 \protected_separator 
11078
11079 \protected_separator 
11080
11081 \protected_separator 
11082
11083 \protected_separator 
11084
11085 \protected_separator 
11086
11087 \protected_separator 
11088
11089 \protected_separator 
11090
11091 \protected_separator 
11092 given or display frame arg 
11093 \newline 
11094 ;;
11095 \protected_separator 
11096
11097 \protected_separator 
11098
11099 \protected_separator 
11100
11101 \protected_separator 
11102
11103 \protected_separator 
11104
11105 \protected_separator 
11106
11107 \protected_separator 
11108
11109 \protected_separator 
11110
11111 \protected_separator 
11112
11113 \protected_separator 
11114
11115 \protected_separator 
11116
11117 \protected_separator 
11118
11119 \protected_separator 
11120
11121 \protected_separator 
11122
11123 \protected_separator 
11124
11125 \protected_separator 
11126
11127 \protected_separator 
11128
11129 \protected_separator 
11130
11131 \protected_separator 
11132
11133 \protected_separator 
11134
11135 \protected_separator 
11136
11137 \protected_separator 
11138
11139 \protected_separator 
11140
11141 \protected_separator 
11142
11143 \protected_separator 
11144
11145 \protected_separator 
11146
11147 \protected_separator 
11148
11149 \protected_separator 
11150
11151 \protected_separator 
11152
11153 \protected_separator 
11154
11155 \protected_separator 
11156
11157 \protected_separator 
11158
11159 \protected_separator 
11160
11161 \protected_separator 
11162
11163 \protected_separator 
11164
11165 \protected_separator 
11166
11167 \protected_separator 
11168
11169 \protected_separator 
11170
11171 \protected_separator 
11172
11173 \protected_separator 
11174
11175 \protected_separator 
11176
11177 \protected_separator 
11178
11179 \protected_separator 
11180
11181 \protected_separator 
11182
11183 \protected_separator 
11184 buffer point 
11185 \newline 
11186 ;; !
11187 \protected_separator 
11188
11189 \protected_separator 
11190
11191 \protected_separator 
11192
11193 \protected_separator 
11194
11195 \protected_separator 
11196
11197 \protected_separator 
11198
11199 \protected_separator 
11200
11201 \protected_separator 
11202
11203 \protected_separator 
11204
11205 \protected_separator 
11206
11207 \protected_separator 
11208
11209 \protected_separator 
11210
11211 \protected_separator 
11212
11213 \protected_separator 
11214  sdcdbsrc-goto-sdcdb
11215 \protected_separator 
11216
11217 \protected_separator 
11218
11219 \protected_separator 
11220
11221 \protected_separator 
11222
11223 \protected_separator 
11224
11225 \protected_separator 
11226
11227 \protected_separator 
11228
11229 \protected_separator 
11230
11231 \protected_separator 
11232
11233 \protected_separator 
11234 Goto the SDCDB output buffer 
11235 \newline 
11236 ;; p
11237 \protected_separator 
11238
11239 \protected_separator 
11240
11241 \protected_separator 
11242
11243 \protected_separator 
11244
11245 \protected_separator 
11246
11247 \protected_separator 
11248
11249 \protected_separator 
11250
11251 \protected_separator 
11252
11253 \protected_separator 
11254
11255 \protected_separator 
11256
11257 \protected_separator 
11258
11259 \protected_separator 
11260
11261 \protected_separator 
11262
11263 \protected_separator 
11264  sdcdb-print-c-sexp
11265 \protected_separator 
11266
11267 \protected_separator 
11268
11269 \protected_separator 
11270
11271 \protected_separator 
11272
11273 \protected_separator 
11274
11275 \protected_separator 
11276
11277 \protected_separator 
11278
11279 \protected_separator 
11280
11281 \protected_separator 
11282
11283 \protected_separator 
11284
11285 \protected_separator 
11286 SDCDB print command for data at 
11287 \newline 
11288 ;;
11289 \protected_separator 
11290
11291 \protected_separator 
11292
11293 \protected_separator 
11294
11295 \protected_separator 
11296
11297 \protected_separator 
11298
11299 \protected_separator 
11300
11301 \protected_separator 
11302
11303 \protected_separator 
11304
11305 \protected_separator 
11306
11307 \protected_separator 
11308
11309 \protected_separator 
11310
11311 \protected_separator 
11312
11313 \protected_separator 
11314
11315 \protected_separator 
11316
11317 \protected_separator 
11318
11319 \protected_separator 
11320
11321 \protected_separator 
11322
11323 \protected_separator 
11324
11325 \protected_separator 
11326
11327 \protected_separator 
11328
11329 \protected_separator 
11330
11331 \protected_separator 
11332
11333 \protected_separator 
11334
11335 \protected_separator 
11336
11337 \protected_separator 
11338
11339 \protected_separator 
11340
11341 \protected_separator 
11342
11343 \protected_separator 
11344
11345 \protected_separator 
11346
11347 \protected_separator 
11348
11349 \protected_separator 
11350
11351 \protected_separator 
11352
11353 \protected_separator 
11354
11355 \protected_separator 
11356
11357 \protected_separator 
11358
11359 \protected_separator 
11360
11361 \protected_separator 
11362
11363 \protected_separator 
11364
11365 \protected_separator 
11366
11367 \protected_separator 
11368
11369 \protected_separator 
11370
11371 \protected_separator 
11372  buffer point 
11373 \newline 
11374 ;; g
11375 \protected_separator 
11376
11377 \protected_separator 
11378
11379 \protected_separator 
11380
11381 \protected_separator 
11382
11383 \protected_separator 
11384
11385 \protected_separator 
11386
11387 \protected_separator 
11388
11389 \protected_separator 
11390
11391 \protected_separator 
11392
11393 \protected_separator 
11394
11395 \protected_separator 
11396
11397 \protected_separator 
11398
11399 \protected_separator 
11400
11401 \protected_separator 
11402  sdcdbsrc-goto-sdcdb
11403 \protected_separator 
11404
11405 \protected_separator 
11406
11407 \protected_separator 
11408
11409 \protected_separator 
11410
11411 \protected_separator 
11412
11413 \protected_separator 
11414
11415 \protected_separator 
11416
11417 \protected_separator 
11418
11419 \protected_separator 
11420
11421 \protected_separator 
11422 Goto the SDCDB output buffer 
11423 \newline 
11424 ;; t
11425 \protected_separator 
11426
11427 \protected_separator 
11428
11429 \protected_separator 
11430
11431 \protected_separator 
11432
11433 \protected_separator 
11434
11435 \protected_separator 
11436
11437 \protected_separator 
11438
11439 \protected_separator 
11440
11441 \protected_separator 
11442
11443 \protected_separator 
11444
11445 \protected_separator 
11446
11447 \protected_separator 
11448
11449 \protected_separator 
11450
11451 \protected_separator 
11452  sdcdbsrc-mode
11453 \protected_separator 
11454
11455 \protected_separator 
11456
11457 \protected_separator 
11458
11459 \protected_separator 
11460
11461 \protected_separator 
11462
11463 \protected_separator 
11464
11465 \protected_separator 
11466
11467 \protected_separator 
11468
11469 \protected_separator 
11470
11471 \protected_separator 
11472
11473 \protected_separator 
11474
11475 \protected_separator 
11476
11477 \protected_separator 
11478
11479 \protected_separator 
11480
11481 \protected_separator 
11482
11483 \protected_separator 
11484 Toggles Sdcdbsrc mode (turns it off) 
11485 \newline 
11486 ;; 
11487 \newline 
11488 ;; C-c C-f
11489 \protected_separator 
11490
11491 \protected_separator 
11492
11493 \protected_separator 
11494
11495 \protected_separator 
11496
11497 \protected_separator 
11498
11499 \protected_separator 
11500
11501 \protected_separator 
11502
11503 \protected_separator 
11504  sdcdb-finish-from-src
11505 \protected_separator 
11506
11507 \protected_separator 
11508
11509 \protected_separator 
11510
11511 \protected_separator 
11512
11513 \protected_separator 
11514
11515 \protected_separator 
11516
11517 \protected_separator 
11518
11519 \protected_separator 
11520 SDCDB finish command 
11521 \newline 
11522 ;; 
11523 \newline 
11524 ;; C-x SPC
11525 \protected_separator 
11526
11527 \protected_separator 
11528
11529 \protected_separator 
11530
11531 \protected_separator 
11532
11533 \protected_separator 
11534
11535 \protected_separator 
11536
11537 \protected_separator 
11538
11539 \protected_separator 
11540  sdcdb-break
11541 \protected_separator 
11542
11543 \protected_separator 
11544
11545 \protected_separator 
11546
11547 \protected_separator 
11548
11549 \protected_separator 
11550
11551 \protected_separator 
11552
11553 \protected_separator 
11554
11555 \protected_separator 
11556
11557 \protected_separator 
11558
11559 \protected_separator 
11560
11561 \protected_separator 
11562
11563 \protected_separator 
11564
11565 \protected_separator 
11566
11567 \protected_separator 
11568
11569 \protected_separator 
11570
11571 \protected_separator 
11572
11573 \protected_separator 
11574
11575 \protected_separator 
11576 Set break for line with point 
11577 \newline 
11578 ;; ESC t
11579 \protected_separator 
11580
11581 \protected_separator 
11582
11583 \protected_separator 
11584
11585 \protected_separator 
11586
11587 \protected_separator 
11588
11589 \protected_separator 
11590
11591 \protected_separator 
11592
11593 \protected_separator 
11594
11595 \protected_separator 
11596
11597 \protected_separator 
11598  sdcdbsrc-mode
11599 \protected_separator 
11600
11601 \protected_separator 
11602
11603 \protected_separator 
11604
11605 \protected_separator 
11606
11607 \protected_separator 
11608
11609 \protected_separator 
11610
11611 \protected_separator 
11612
11613 \protected_separator 
11614
11615 \protected_separator 
11616
11617 \protected_separator 
11618
11619 \protected_separator 
11620
11621 \protected_separator 
11622
11623 \protected_separator 
11624
11625 \protected_separator 
11626
11627 \protected_separator 
11628
11629 \protected_separator 
11630 Toggle Sdcdbsrc mode 
11631 \newline 
11632 ;; ESC m
11633 \protected_separator 
11634
11635 \protected_separator 
11636
11637 \protected_separator 
11638
11639 \protected_separator 
11640
11641 \protected_separator 
11642
11643 \protected_separator 
11644
11645 \protected_separator 
11646
11647 \protected_separator 
11648
11649 \protected_separator 
11650
11651 \protected_separator 
11652  sdcdbsrc-srcmode
11653 \protected_separator 
11654
11655 \protected_separator 
11656
11657 \protected_separator 
11658
11659 \protected_separator 
11660
11661 \protected_separator 
11662
11663 \protected_separator 
11664
11665 \protected_separator 
11666
11667 \protected_separator 
11668
11669 \protected_separator 
11670
11671 \protected_separator 
11672
11673 \protected_separator 
11674
11675 \protected_separator 
11676  Toggle list mode 
11677 \newline 
11678 ;; 
11679 \newline 
11680
11681 \layout Section
11682
11683 Conclusion
11684 \begin_inset LatexCommand \label{Conclusion}
11685
11686 \end_inset 
11687
11688
11689 \layout Standard
11690
11691 SDCC is a large project , the compiler alone (without the Assembler Package
11692  , Preprocessor & garbage collector) is about 40,000 lines of code (blank
11693  stripped).
11694  As with any project of this size there are bound to be bugs, I am more
11695  than willing to work to fix these bugs , of course all the source code
11696  is included with the package.
11697  
11698 \layout Standard
11699
11700 Where does it go from here ? I am planning to target the Atmel AVR 8-bit
11701  MCUs which seems to have a lot of users.
11702  I am also planning to include an alias analysis system with this compiler
11703  (it does not currently have one).
11704 \layout Section
11705
11706 Acknowledgments
11707 \begin_inset LatexCommand \label{Acknowledgements}
11708
11709 \end_inset 
11710
11711
11712 \layout Standard
11713
11714 Alan Baldwin (baldwin@shop-pdp.kent.edu) - Initial version of ASXXXX & ASLINK.
11715  
11716 \layout Standard
11717
11718 John Hartman (jhartman@compuserve.com) - Porting ASXXX & ASLINK for 8051
11719 \layout Standard
11720
11721 Dmitry S.
11722  Obukhov (dso@usa.net) - malloc & serial i/o routines.
11723  
11724 \layout Standard
11725
11726 Daniel Drotos <drdani@mazsola.iit.uni-miskolc.hu> - for his Freeware simulator
11727 \layout Standard
11728
11729 Jans J Boehm(boehm@sgi.com) and Alan J Demers - Conservative garbage collector
11730  for C & C++.
11731 \layout Standard
11732
11733 Malini Dutta(malini_dutta@hotmail.com) - my wife for her patience and support.
11734 \layout Standard
11735
11736 Unknown - for the GNU C - preprocessor.
11737 \layout Section
11738
11739 Appendix A: The Z80 and gbz80 port
11740 \layout Standard
11741
11742 2.2.0 can target both the Zilog Z80 and the Nintendo Gameboy's Z80-like gbz80.
11743  The port is incomplete - long support is incomplete (mul, div and mod are
11744  unimplimented), and both float and bitfield support is missing, but apart
11745  from that the code generated is correct.
11746 \layout Standard
11747
11748 As always, the code is the authoritave reference - see z80/ralloc.c and z80/gen.c.
11749  The stack frame is similar to that generated by the IAR Z80 compiler.
11750  IX is used as the base pointer, HL is used as a temporary register, and
11751  BC and DE are available for holding varibles.
11752  IY is currently unusued.
11753  Return values are stored in HL.
11754  One bad side effect of using IX as the base pointer is that a functions
11755  stack frame is limited to 127 bytes - this will be fixed in a later version.bc
11756 \layout Standard
11757
11758 9
11759 \layout Standard
11760
11761
11762 \begin_inset LatexCommand \index
11763
11764 \end_inset 
11765
11766
11767 \the_end