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