+Segments may be placed anywhere in the 4 meg address space using the usual
+ -
+\begin_inset ERT
+status Collapsed
+
+\layout Standard
+
+\backslash
+/
+\end_inset
+
+-*-loc options.
+ Note that if any segments are located above 64K, the -r flag must be passed
+ to the linker to generate the proper segment relocations, and the Intel
+ HEX output format must be used.
+ The -r flag can be passed to the linker by using the option
+\emph on
+-Wl-r
+\emph default
+ on the sdcc command line.
+ However, currently the linker can not handle code segments > 64k.
+\layout Subsection
+
+Defines Created by the Compiler
+\begin_inset LatexCommand \index{Defines created by the compiler}
+
+\end_inset
+
+
+\layout Standard
+
+The compiler creates the following #defines
+\begin_inset LatexCommand \index{\#defines}
+
+\end_inset
+
+.
+\layout Itemize
+
+SDCC
+\begin_inset LatexCommand \index{SDCC}
+
+\end_inset
+
+ - this Symbol is always defined.
+\layout Itemize
+
+SDCC_mcs51
+\begin_inset LatexCommand \index{SDCC\_mcs51}
+
+\end_inset
+
+ or SDCC_ds390
+\begin_inset LatexCommand \index{SDCC\_ds390}
+
+\end_inset
+
+ or SDCC_z80
+\begin_inset LatexCommand \index{SDCC\_z80}
+
+\end_inset
+
+, etc - depending on the model used (e.g.: -mds390)
+\layout Itemize
+
+__mcs51
+\begin_inset LatexCommand \index{\_\_mcs51}
+
+\end_inset
+
+ or __ds390
+\begin_inset LatexCommand \index{\_\_ds390}
+
+\end_inset
+
+ or __z80
+\begin_inset LatexCommand \index{\_\_z80}
+
+\end_inset
+
+, etc - depending on the model used (e.g.
+ -mz80)
+\layout Itemize
+
+SDCC_STACK_AUTO
+\begin_inset LatexCommand \index{SDCC\_STACK\_AUTO}
+
+\end_inset
+
+ - this symbol is defined when
+\emph on
+-
+\begin_inset ERT
+status Collapsed
+
+\layout Standard
+
+\backslash
+/
+\end_inset
+
+-stack-auto
+\emph default
+ option is used.
+\layout Itemize
+
+SDCC_MODEL_SMALL
+\begin_inset LatexCommand \index{SDCC\_MODEL\_SMALL}
+
+\end_inset
+
+ - when
+\emph on
+-
+\begin_inset ERT
+status Collapsed
+
+\layout Standard
+
+\backslash
+/
+\end_inset
+
+-model-small
+\emph default
+ is used.
+\layout Itemize
+
+SDCC_MODEL_LARGE
+\begin_inset LatexCommand \index{SDCC\_MODEL\_LARGE}
+
+\end_inset
+
+ - when
+\emph on
+-
+\begin_inset ERT
+status Collapsed
+
+\layout Standard
+
+\backslash
+/
+\end_inset
+
+-model-large
+\emph default
+ is used.
+\layout Itemize
+
+SDCC_USE_XSTACK
+\begin_inset LatexCommand \index{SDCC\_USE\_XSTACK}
+
+\end_inset
+
+ - when
+\emph on
+-
+\begin_inset ERT
+status Collapsed
+
+\layout Standard
+
+\backslash
+/
+\end_inset
+
+-xstack
+\emph default
+ option is used.
+\layout Itemize
+
+SDCC_STACK_TENBIT
+\begin_inset LatexCommand \index{SDCC\_STACK\_TENBIT}
+
+\end_inset
+
+ - when
+\emph on
+-mds390
+\emph default
+ is used
+\layout Itemize
+
+SDCC_MODEL_FLAT24
+\begin_inset LatexCommand \index{SDCC\_MODEL\_FLAT24}
+
+\end_inset
+
+ - when
+\emph on
+-mds390
+\emph default
+ is used
+\layout Subsection
+
+Redirecting output on Windows Shells
+\layout Standard
+
+SDCC writes it's error messages to
+\begin_inset Quotes sld
+\end_inset
+
+standard error
+\begin_inset Quotes srd
+\end_inset
+
+.
+ The windows 95/98/me shell (command or cmd) can't redirect it to a file.
+ The solution is to use a reasonable shell or a helper program like redir.exe:
+\layout Standard
+
+
+\begin_inset LatexCommand \url{http://www.cygwin.com/ml/cygwin/1999-02/msg00603.html}
+
+\end_inset
+
+
+\layout Standard
+
+
+\begin_inset LatexCommand \url{ftp://ftp.xraylith.wisc.edu/pub/khan/gnu-win32/mingw32/misc/redir.zip}
+
+\end_inset
+
+
+\layout Standard
+
+
+\begin_inset LatexCommand \url{ftp://ftp.xraylith.wisc.edu/pub/khan/gnu-win32/mingw32/misc/README.redir}
+
+\end_inset
+
+
+\newline
+
+\newline
+If you are using a windows NT/2K/XP shell, you can redirect the
+\begin_inset Quotes sld
+\end_inset
+
+standard error
+\begin_inset Quotes srd
+\end_inset
+
+ output to a file using
+\begin_inset Quotes sld
+\end_inset
+
+2>
+\begin_inset Quotes srd
+\end_inset
+
+.
+ For example:
+\newline
+
+\series bold
+
+\newline
+sdcc -c foo.c 2> foo.err
+\newline
+
+\newline
+
+\series default
+To append the
+\begin_inset Quotes sld
+\end_inset
+
+standard error
+\begin_inset Quotes srd
+\end_inset
+
+ output of SDCC to a file you can use
+\begin_inset Quotes sld
+\end_inset
+
+2>>
+\begin_inset Quotes srd
+\end_inset
+
+.
+ I you happen to have visual studio installed in your windows machine, you
+ can use it to compile your sources using a custom build and the SDCC -
+\emph on
+
+\begin_inset ERT
+status Collapsed
+
+\layout Standard
+
+\backslash
+/
+\end_inset
+
+
+\emph default
+-vc option.
+ Something like this should work:
+\newline
+
+\newline
+
+\series bold
+c:
+\backslash
+sdcc
+\backslash
+bin
+\backslash
+sdcc.exe -
+\series default
+\emph on
+
+\begin_inset ERT
+status Collapsed
+
+\layout Standard
+
+\backslash
+/
+\end_inset
+
+
+\series bold
+\emph default
+-vc -
+\series default
+\emph on
+
+\begin_inset ERT
+status Collapsed
+
+\layout Standard
+
+\backslash
+/
+\end_inset
+
+
+\series bold
+\emph default
+-model-large -c $(InputPath)
+\layout Section
+\pagebreak_top
+SDCC Technical Data
+\layout Subsection
+
+Optimizations
+\begin_inset LatexCommand \index{Optimizations}
+
+\end_inset
+
+
+\layout Standard
+
+SDCC performs a host of standard optimizations in addition to some MCU specific
+ optimizations.
+
+\layout Subsubsection
+
+Sub-expression Elimination
+\begin_inset LatexCommand \index{Subexpression elimination}
+
+\end_inset
+
+
+\layout Standard
+
+The compiler does local and global common subexpression elimination, e.g.:
+
+\layout Verse
+
+
+\family typewriter
+i = x + y + 1;
+\newline
+j = x + y;
+\layout Standard
+
+will be translated to
+\layout Verse
+
+
+\family typewriter
+iTemp = x + y
+\newline
+i = iTemp + 1
+\newline
+j = iTemp
+\layout Standard
+
+Some subexpressions are not as obvious as the above example, e.g.:
+\layout Verse
+
+
+\family typewriter
+a->b[i].c = 10;
+\newline
+a->b[i].d = 11;
+\layout Standard
+
+In this case the address arithmetic a->b[i] will be computed only once;
+ the equivalent code in C would be.
+\layout Verse
+
+
+\family typewriter
+iTemp = a->b[i];
+\newline
+iTemp.c = 10;
+\newline
+iTemp.d = 11;
+\layout Standard
+
+The compiler will try to keep these temporary variables in registers.
+\layout Subsubsection
+
+Dead-Code Elimination
+\begin_inset LatexCommand \index{Dead-code elimination}
+
+\end_inset
+
+
+\layout Verse
+
+
+\family typewriter
+int global;
+\newline
+void f () {
+\newline
+\SpecialChar ~
+\SpecialChar ~
+int i;
+\newline
+\SpecialChar ~
+\SpecialChar ~
+i = 1; \SpecialChar ~
+/* dead store */
+\newline
+\SpecialChar ~
+\SpecialChar ~
+global = 1;\SpecialChar ~
+/* dead store */
+\newline
+\SpecialChar ~
+\SpecialChar ~
+global = 2;
+\newline
+\SpecialChar ~
+\SpecialChar ~
+return;
+\newline
+\SpecialChar ~
+\SpecialChar ~
+global = 3;\SpecialChar ~
+/* unreachable */
+\newline
+}
+\layout Standard
+
+will be changed to
+\layout Verse
+
+
+\family typewriter
+int global; void f ()
+\newline
+{
+\newline
+\SpecialChar ~
+\SpecialChar ~
+global = 2;
+\newline
+\SpecialChar ~
+\SpecialChar ~
+return;
+\newline
+}
+\layout Subsubsection
+
+Copy-Propagation
+\begin_inset LatexCommand \index{Copy propagation}
+
+\end_inset
+
+
+\layout Verse
+
+
+\family typewriter
+int f() {
+\newline
+\SpecialChar ~
+\SpecialChar ~
+int i, j;
+\newline
+\SpecialChar ~
+\SpecialChar ~
+i = 10;
+\newline
+\SpecialChar ~
+\SpecialChar ~
+j = i;
+\newline
+\SpecialChar ~
+\SpecialChar ~
+return j;
+\newline
+}
+\layout Standard
+
+will be changed to
+\layout Verse
+
+
+\family typewriter
+int f() {
+\newline
+\SpecialChar ~
+ \SpecialChar ~
+ int i,j;
+\newline
+\SpecialChar ~
+ \SpecialChar ~
+ i = 10;
+\newline
+\SpecialChar ~
+ \SpecialChar ~
+ j = 10;
+\newline
+\SpecialChar ~
+ \SpecialChar ~
+ return 10;
+\newline
+}
+\layout Standard
+
+Note: the dead stores created by this copy propagation will be eliminated
+ by dead-code elimination.
+\layout Subsubsection
+
+Loop Optimizations
+\begin_inset LatexCommand \index{Loop optimization}
+
+\end_inset
+
+
+\layout Standard
+
+Two types of loop optimizations are done by SDCC loop invariant lifting
+ and strength reduction of loop induction variables.
+ In addition to the strength reduction the optimizer marks the induction
+ variables and the register allocator tries to keep the induction variables
+ in registers for the duration of the loop.
+ Because of this preference of the register allocator
+\begin_inset LatexCommand \index{Register allocation}
+
+\end_inset
+
+, loop induction optimization causes an increase in register pressure, which
+ may cause unwanted spilling of other temporary variables into the stack
+\begin_inset LatexCommand \index{stack}
+
+\end_inset
+
+ / data space.
+ The compiler will generate a warning message when it is forced to allocate
+ extra space either on the stack or data space.
+ If this extra space allocation is undesirable then induction optimization
+ can be eliminated either for the entire source file (with -
+\begin_inset ERT
+status Collapsed
+
+\layout Standard
+
+\backslash
+/
+\end_inset
+
+-noinduction option) or for a given function only using #pragma\SpecialChar ~
+NOINDUCTION
+\begin_inset LatexCommand \index{\#pragma NOINDUCTION}
+
+\end_inset
+
+.
+\newline
+
+\newline
+Loop Invariant:
+\layout Verse
+
+
+\family typewriter
+for (i = 0 ; i < 100 ; i ++)
+\newline
+ \SpecialChar ~
+ \SpecialChar ~
+f += k + l;
+\layout Standard
+
+changed to
+\layout Verse
+
+
+\family typewriter
+itemp = k + l;
+\newline
+for (i = 0; i < 100; i++)
+\newline
+\SpecialChar ~
+\SpecialChar ~
+f += itemp;
+\layout Standard
+
+As mentioned previously some loop invariants are not as apparent, all static
+ address computations are also moved out of the loop.
+\newline
+
+\newline
+Strength Reduction
+\begin_inset LatexCommand \index{Strength reduction}
+
+\end_inset
+
+, this optimization substitutes an expression by a cheaper expression:
+\layout Verse
+
+
+\family typewriter
+for (i=0;i < 100; i++)
+\newline
+\SpecialChar ~
+\SpecialChar ~
+ar[i*5] = i*3;
+\layout Standard
+
+changed to
+\layout Verse
+
+
+\family typewriter
+itemp1 = 0;
+\newline
+itemp2 = 0;
+\newline
+for (i=0;i< 100;i++) {
+\newline
+ \SpecialChar ~
+ \SpecialChar ~
+ar[itemp1] = itemp2;
+\newline
+ \SpecialChar ~
+ \SpecialChar ~
+itemp1 += 5;
+\newline
+ \SpecialChar ~
+ \SpecialChar ~
+itemp2 += 3;
+\newline
+}
+\layout Standard
+
+The more expensive multiplication
+\begin_inset LatexCommand \index{Multiplication}
+
+\end_inset
+
+ is changed to a less expensive addition.
+\layout Subsubsection
+
+Loop Reversing
+\begin_inset LatexCommand \index{Loop reversing}
+
+\end_inset
+
+
+\layout Standard
+
+This optimization is done to reduce the overhead of checking loop boundaries
+ for every iteration.
+ Some simple loops can be reversed and implemented using a
+\begin_inset Quotes eld
+\end_inset
+
+decrement and jump if not zero
+\begin_inset Quotes erd
+\end_inset
+
+ instruction.
+ SDCC checks for the following criterion to determine if a loop is reversible
+ (note: more sophisticated compilers use data-dependency analysis to make
+ this determination, SDCC uses a more simple minded analysis).
+\layout Itemize
+
+The 'for' loop is of the form
+\newline
+
+\newline
+
+\family typewriter
+for(<symbol> = <expression>; <sym> [< | <=] <expression>; [<sym>++ | <sym>
+ += 1])
+\newline
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+<for body>
+\layout Itemize
+
+The <for body> does not contain
+\begin_inset Quotes eld
+\end_inset
+
+continue
+\begin_inset Quotes erd
+\end_inset
+
+ or 'break
+\begin_inset Quotes erd
+\end_inset
+
+.
+\layout Itemize
+
+All goto's are contained within the loop.
+\layout Itemize
+
+No function calls within the loop.
+\layout Itemize
+
+The loop control variable <sym> is not assigned any value within the loop
+\layout Itemize
+
+The loop control variable does NOT participate in any arithmetic operation
+ within the loop.
+\layout Itemize
+
+There are NO switch statements in the loop.
+\layout Subsubsection
+
+Algebraic Simplifications
+\layout Standard
+
+SDCC does numerous algebraic simplifications, the following is a small sub-set
+ of these optimizations.
+\layout Verse
+
+
+\family typewriter
+i = j + 0 ; /* changed to */ i = j;
+\newline
+i /= 2; /* changed to */ i >>= 1;
+\newline
+i = j - j ; /* changed to */ i = 0;
+\newline
+i = j / 1 ; /* changed to */ i = j;
+\layout Standard
+
+Note the subexpressions
+\begin_inset LatexCommand \index{Subexpression}
+
+\end_inset
+
+ given above are generally introduced by macro expansions or as a result
+ of copy/constant propagation.
+\layout Subsubsection
+
+'switch' Statements
+\begin_inset LatexCommand \index{switch statement}
+
+\end_inset
+
+
+\layout Standard
+
+SDCC changes switch statements to jump tables
+\begin_inset LatexCommand \index{jump tables}
+
+\end_inset
+
+ when the following conditions are true.
+
+\layout Itemize
+
+The case labels are in numerical sequence, the labels need not be in order,
+ and the starting number need not be one or zero.
+\begin_deeper
+\layout Verse
+
+
+\family typewriter
+switch(i) {\SpecialChar ~
+ \SpecialChar ~
+ \SpecialChar ~
+ \SpecialChar ~
+ \SpecialChar ~
+ \SpecialChar ~
+ \SpecialChar ~
+ \SpecialChar ~
+ \SpecialChar ~
+ \SpecialChar ~
+ \SpecialChar ~
+ \SpecialChar ~
+ \SpecialChar ~
+switch (i) {
+\newline
+case 4:...
+ \SpecialChar ~
+ \SpecialChar ~
+ \SpecialChar ~
+ \SpecialChar ~
+ \SpecialChar ~
+ \SpecialChar ~
+ \SpecialChar ~
+ \SpecialChar ~
+ \SpecialChar ~
+ \SpecialChar ~
+ \SpecialChar ~
+ \SpecialChar ~
+ \SpecialChar ~
+case 1: ...
+
+\newline
+case 5:...
+ \SpecialChar ~
+ \SpecialChar ~
+ \SpecialChar ~
+ \SpecialChar ~
+ \SpecialChar ~
+ \SpecialChar ~
+ \SpecialChar ~
+ \SpecialChar ~
+ \SpecialChar ~
+ \SpecialChar ~
+ \SpecialChar ~
+ \SpecialChar ~
+ \SpecialChar ~
+case 2: ...
+
+\newline
+case 3:...
+ \SpecialChar ~
+ \SpecialChar ~
+ \SpecialChar ~
+ \SpecialChar ~
+ \SpecialChar ~
+ \SpecialChar ~
+ \SpecialChar ~
+ \SpecialChar ~
+ \SpecialChar ~
+ \SpecialChar ~
+ \SpecialChar ~
+ \SpecialChar ~
+ \SpecialChar ~
+case 3: ...
+
+\newline
+case 6:...
+ \SpecialChar ~
+ \SpecialChar ~
+ \SpecialChar ~
+ \SpecialChar ~
+ \SpecialChar ~
+ \SpecialChar ~
+ \SpecialChar ~
+ \SpecialChar ~
+ \SpecialChar ~
+ \SpecialChar ~
+ \SpecialChar ~
+ \SpecialChar ~
+ \SpecialChar ~
+case 4: ...
+
+\newline
+}\SpecialChar ~
+ \SpecialChar ~
+ \SpecialChar ~
+ \SpecialChar ~
+ \SpecialChar ~
+ \SpecialChar ~
+ \SpecialChar ~
+ \SpecialChar ~
+ \SpecialChar ~
+ \SpecialChar ~
+ \SpecialChar ~
+ \SpecialChar ~
+ \SpecialChar ~
+ \SpecialChar ~
+ \SpecialChar ~
+ \SpecialChar ~
+ \SpecialChar ~
+ \SpecialChar ~
+}
+\layout Standard
+
+Both the above switch statements will be implemented using a jump-table.
+\end_deeper
+\layout Itemize
+
+The number of case labels is at least three, since it takes two conditional
+ statements to handle the boundary conditions.
+\layout Itemize
+
+The number of case labels is less than 84, since each label takes 3 bytes
+ and a jump-table can be utmost 256 bytes long.
+
+\layout Standard
+
+Switch statements which have gaps in the numeric sequence or those that
+ have more that 84 case labels can be split into more than one switch statement
+ for efficient code generation, e.g.:
+\layout Verse
+
+
+\family typewriter
+switch (i) {
+\newline
+\SpecialChar ~
+\SpecialChar ~
+case 1: ...
+
+\newline
+\SpecialChar ~
+\SpecialChar ~
+case 2: ...
+
+\newline
+\SpecialChar ~
+\SpecialChar ~
+case 3: ...
+
+\newline
+\SpecialChar ~
+\SpecialChar ~
+case 4: ...
+
+\newline
+\SpecialChar ~
+\SpecialChar ~
+case 9: ...
+
+\newline
+\SpecialChar ~
+\SpecialChar ~
+case 10: ...
+
+\newline
+\SpecialChar ~
+\SpecialChar ~
+case 11: ...
+
+\newline
+\SpecialChar ~
+\SpecialChar ~
+case 12: ...
+
+\newline
+}
+\layout Standard
+
+If the above switch statement is broken down into two switch statements
+\layout Verse
+
+
+\family typewriter
+switch (i) {
+\newline
+\SpecialChar ~
+\SpecialChar ~
+case 1: ...
+
+\newline
+\SpecialChar ~
+\SpecialChar ~
+case 2: ...
+
+\newline
+\SpecialChar ~
+\SpecialChar ~
+case 3: ...
+
+\newline
+\SpecialChar ~
+\SpecialChar ~
+case 4: ...
+
+\newline
+}
+\layout Standard
+
+and
+\layout Verse
+
+
+\family typewriter
+switch (i) {
+\newline
+\SpecialChar ~
+\SpecialChar ~
+case 9: \SpecialChar ~
+...
+
+\newline
+\SpecialChar ~
+\SpecialChar ~
+case 10: ...
+
+\newline
+\SpecialChar ~
+\SpecialChar ~
+case 11: ...
+
+\newline
+\SpecialChar ~
+\SpecialChar ~
+case 12:\SpecialChar ~
+...
+
+\newline
+}
+\layout Standard
+
+then both the switch statements will be implemented using jump-tables whereas
+ the unmodified switch statement will not be.
+\layout Subsubsection
+
+Bit-shifting Operations
+\begin_inset LatexCommand \index{Bit shifting}
+
+\end_inset
+
+.
+\layout Standard
+
+Bit shifting is one of the most frequently used operation in embedded programmin
+g.
+ SDCC tries to implement bit-shift operations in the most efficient way
+ possible, e.g.:
+\layout Verse
+
+
+\family typewriter
+unsigned char i;
+\newline
+...
+
+\newline
+i>>= 4;
+\newline
+...
+\layout Standard
+
+generates the following code:
+\layout Verse
+
+
+\family typewriter
+mov a,_i
+\newline
+swap a
+\newline
+anl a,#0x0f
+\newline
+mov _i,a
+\layout Standard
+
+In general SDCC will never setup a loop if the shift count is known.
+ Another example:
+\layout Verse
+
+
+\family typewriter
+unsigned int i;
+\newline
+...
+
+\newline
+i >>= 9;
+\newline
+...
+\layout Standard
+
+will generate:
+\layout Verse
+
+
+\family typewriter
+mov a,(_i + 1)
+\newline
+mov (_i + 1),#0x00
+\newline
+clr c
+\newline
+rrc a
+\newline
+mov _i,a
+\layout Standard
+
+Note that SDCC stores numbers in little-endian format (i.e.
+ lowest order first).
+\layout Subsubsection
+
+Bit-rotation
+\begin_inset LatexCommand \index{Bit rotation}
+
+\end_inset
+
+
+\layout Standard
+
+A special case of the bit-shift operation is bit rotation, SDCC recognizes
+ the following expression to be a left bit-rotation:
+\layout Verse
+
+
+\family typewriter
+unsigned char i;
+\newline
+...
+
+\newline
+i = ((i << 1) | (i >> 7));
+\family default
+
+\newline
+
+\family typewriter
+...
+\layout Standard
+
+will generate the following code:
+\layout Verse
+
+
+\family typewriter
+mov a,_i
+\newline
+rl a
+\newline
+mov _i,a
+\layout Standard
+
+SDCC uses pattern matching on the parse tree to determine this operation.Variatio
+ns of this case will also be recognized as bit-rotation, i.e.:
+\layout Verse
+
+
+\family typewriter
+i = ((i >> 7) | (i << 1)); /* left-bit rotation */
+\layout Subsubsection
+
+Highest Order Bit
+\begin_inset LatexCommand \index{Highest Order Bit}
+
+\end_inset
+
+
+\layout Standard
+
+It is frequently required to obtain the highest order bit of an integral
+ type (long, int, short or char types).
+ SDCC recognizes the following expression to yield the highest order bit
+ and generates optimized code for it, e.g.:
+\layout Verse
+
+
+\family typewriter
+unsigned int gint;
+\newline
+
+\newline
+foo () {
+\newline
+unsigned char hob;
+\newline
+\SpecialChar ~
+\SpecialChar ~
+...
+
+\newline
+\SpecialChar ~
+\SpecialChar ~
+hob = (gint >> 15) & 1;
+\newline
+\SpecialChar ~
+\SpecialChar ~
+..
+
+\newline
+}
+\layout Standard
+
+will generate the following code:
+\layout Verse
+
+
+\family typewriter
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+ 61 ;\SpecialChar ~
+ hob.c 7
+\newline
+000A E5*01\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+ 62\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+ mov\SpecialChar ~
+ a,(_gint + 1)
+\newline
+000C 33\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+ 63\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+ rlc\SpecialChar ~
+ a
+\newline
+000D E4\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+ 64\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+ clr\SpecialChar ~
+ a
+\newline
+000E 13\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+ 65\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+ rrc\SpecialChar ~
+ a
+\newline
+000F F5*02\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+ 66\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+ mov\SpecialChar ~
+ _foo_hob_1_1,a
+\layout Standard
+
+Variations of this case however will
+\emph on
+not
+\emph default
+ be recognized.
+ It is a standard C expression, so I heartily recommend this be the only
+ way to get the highest order bit, (it is portable).
+ Of course it will be recognized even if it is embedded in other expressions,
+ e.g.:
+\layout Verse
+
+
+\family typewriter
+xyz = gint + ((gint >> 15) & 1);
+\layout Standard
+
+will still be recognized.
+\layout Subsubsection
+
+Peephole Optimizer
+\begin_inset LatexCommand \index{Peephole optimizer}
+
+\end_inset
+
+
+\layout Standard
+
+The compiler uses a rule based, pattern matching and re-writing mechanism
+ for peep-hole optimization.
+ It is inspired by
+\emph on
+copt
+\emph default
+ a peep-hole optimizer by Christopher W.
+ Fraser (cwfraser@microsoft.com).
+ A default set of rules are compiled into the compiler, additional rules
+ may be added with the
+\emph on
+-
+\begin_inset ERT
+status Collapsed
+
+\layout Standard
+
+\backslash
+/
+\end_inset
+
+-peep-file
+\begin_inset LatexCommand \index{-\/-peep-file}
+
+\end_inset
+
+ <filename>
+\emph default
+ option.
+ The rule language is best illustrated with examples.
+\layout Verse
+
+
+\family typewriter
+replace {
+\newline
+\SpecialChar ~
+\SpecialChar ~
+mov %1,a
+\newline
+\SpecialChar ~
+\SpecialChar ~
+mov a,%1
+\newline
+} by {
+\newline
+\SpecialChar ~
+\SpecialChar ~
+mov %1,a
+\newline
+}
+\layout Standard
+
+The above rule will change the following assembly
+\begin_inset LatexCommand \index{Assembler routines}
+
+\end_inset
+
+ sequence:
+\layout Verse
+
+
+\family typewriter
+mov r1,a
+\newline
+mov a,r1
+\layout Standard
+
+to
+\layout Verse
+
+
+\family typewriter
+mov r1,a
+\layout Standard
+
+Note: All occurrences of a
+\emph on
+%n
+\emph default
+ (pattern variable) must denote the same string.
+ With the above rule, the assembly sequence:
+\layout Verse
+
+
+\family typewriter
+mov r1,a
+\newline
+mov a,r2
+\layout Standard
+
+will remain unmodified.
+\newline
+
+\newline
+Other special case optimizations may be added by the user (via
+\emph on
+-
+\begin_inset ERT
+status Collapsed
+
+\layout Standard
+
+\backslash
+/
+\end_inset
+
+-peep-file option
+\emph default
+).
+ E.g.
+ some variants of the 8051 MCU allow only
+\family typewriter
+ajmp
+\family default
+ and
+\family typewriter
+acall
+\family default
+.
+ The following two rules will change all
+\family typewriter
+ljmp
+\family default
+ and
+\family typewriter
+lcall
+\family default
+ to
+\family typewriter
+ajmp
+\family default
+ and
+\family typewriter
+acall
+\layout Verse
+
+
+\family typewriter
+replace { lcall %1 } by { acall %1 }
+\newline
+replace { ljmp %1 } by { ajmp %1 }
+\layout Standard
+
+The
+\emph on
+inline-assembler code
+\emph default
+ is also passed through the peep hole optimizer, thus the peephole optimizer
+ can also be used as an assembly level macro expander.
+ The rules themselves are MCU dependent whereas the rule language infra-structur
+e is MCU independent.
+ Peephole optimization rules for other MCU can be easily programmed using
+ the rule language.
+\newline
+
+\newline
+The syntax for a rule is as follows:
+\layout Verse
+
+
+\family typewriter
+rule := replace [ restart ] '{' <assembly sequence> '
+\backslash
+n'
+\newline
+\SpecialChar ~
+ \SpecialChar ~
+ \SpecialChar ~
+ \SpecialChar ~
+ \SpecialChar ~
+ \SpecialChar ~
+ \SpecialChar ~
+ \SpecialChar ~
+ \SpecialChar ~
+ \SpecialChar ~
+ \SpecialChar ~
+ \SpecialChar ~
+ \SpecialChar ~
+ \SpecialChar ~
+ '}' by '{' '
+\backslash
+n'
+\newline
+\SpecialChar ~
+ \SpecialChar ~
+ \SpecialChar ~
+ \SpecialChar ~
+ \SpecialChar ~
+ \SpecialChar ~
+ \SpecialChar ~
+ \SpecialChar ~
+ \SpecialChar ~
+ \SpecialChar ~
+ \SpecialChar ~
+ \SpecialChar ~
+ \SpecialChar ~
+ \SpecialChar ~
+ \SpecialChar ~
+ \SpecialChar ~
+ <assembly sequence> '
+\backslash
+n'
+\newline
+\SpecialChar ~
+ \SpecialChar ~
+ \SpecialChar ~
+ \SpecialChar ~
+ \SpecialChar ~
+ \SpecialChar ~
+ \SpecialChar ~
+ \SpecialChar ~
+ \SpecialChar ~
+ \SpecialChar ~
+ \SpecialChar ~
+ \SpecialChar ~
+ \SpecialChar ~
+ \SpecialChar ~
+ '}' [if <functionName> ] '
+\backslash
+n'
+\layout Standard
+
+<assembly sequence> := assembly instruction (each instruction including
+ labels must be on a separate line).
+\newline
+
+\newline
+The optimizer will apply to the rules one by one from the top in the sequence
+ of their appearance, it will terminate when all rules are exhausted.
+ If the 'restart' option is specified, then the optimizer will start matching
+ the rules again from the top, this option for a rule is expensive (performance)
+, it is intended to be used in situations where a transformation will trigger
+ the same rule again.
+ An example of this (not a good one, it has side effects) is the following
+ rule:
+\layout Verse
+
+
+\family typewriter
+replace restart {
+\newline
+\SpecialChar ~
+\SpecialChar ~
+pop %1
+\newline
+\SpecialChar ~
+\SpecialChar ~
+push %1 } by {
+\newline
+\SpecialChar ~
+\SpecialChar ~
+; nop
+\newline
+}
+\layout Standard
+
+Note that the replace pattern cannot be a blank, but can be a comment line.
+ Without the 'restart' option only the inner most 'pop' 'push' pair would
+ be eliminated, i.e.:
+\layout Verse
+
+
+\family typewriter
+pop ar1
+\newline
+pop ar2
+\newline
+push ar2
+\newline
+push ar1
+\layout Standard
+
+would result in:
+\layout Verse
+
+
+\family typewriter
+pop ar1
+\newline
+; nop
+\newline
+push ar1
+\layout Standard
+
+
+\emph on
+with
+\emph default
+ the restart option the rule will be applied again to the resulting code
+ and then all the pop-push pairs will be eliminated to yield:
+\layout Verse
+
+
+\family typewriter
+; nop
+\newline
+; nop
+\layout Standard
+
+A conditional function can be attached to a rule.
+ Attaching rules are somewhat more involved, let me illustrate this with
+ an example.
+\layout Verse
+
+
+\family typewriter
+replace {
+\newline
+\SpecialChar ~
+ \SpecialChar ~
+ \SpecialChar ~
+ljmp %5
+\newline
+%2:
+\newline
+} by {
+\newline
+\SpecialChar ~
+ \SpecialChar ~
+ \SpecialChar ~
+sjmp %5
+\newline
+%2:
+\newline
+} if labelInRange
+\layout Standard
+
+The optimizer does a look-up of a function name table defined in function
+
+\emph on
+callFuncByName
+\emph default
+ in the source file SDCCpeeph.c, with the name
+\emph on
+labelInRange
+\emph default
+.
+ If it finds a corresponding entry the function is called.
+ Note there can be no parameters specified for these functions, in this
+ case the use of
+\emph on
+%5
+\emph default
+ is crucial, since the function
+\emph on
+labelInRange
+\emph default
+ expects to find the label in that particular variable (the hash table containin
+g the variable bindings is passed as a parameter).
+ If you want to code more such functions, take a close look at the function
+ labelInRange and the calling mechanism in source file SDCCpeeph.c.
+ I know this whole thing is a little kludgey, but maybe some day we will
+ have some better means.
+ If you are looking at this file, you will also see the default rules that
+ are compiled into the compiler, you can add your own rules in the default
+ set there if you get tired of specifying the -
+\begin_inset ERT
+status Collapsed
+
+\layout Standard
+
+\backslash
+/
+\end_inset
+
+-peep-file option.
+\layout Subsection
+
+Pragmas
+\begin_inset LatexCommand \index{Pragmas}
+
+\end_inset
+
+
+\layout Standard
+
+SDCC supports the following #pragma directives.
+\layout Itemize
+
+SAVE
+\begin_inset LatexCommand \index{\#pragma SAVE}
+
+\end_inset
+
+ - this will save all current options to the SAVE/RESTORE stack.
+ See RESTORE.
+\layout Itemize
+
+RESTORE
+\begin_inset LatexCommand \index{\#pragma RESTORE}
+
+\end_inset
+
+ - will restore saved options from the last save.
+ SAVEs & RESTOREs can be nested.
+ SDCC uses a SAVE/RESTORE stack: SAVE pushes current options to the stack,
+ RESTORE pulls current options from the stack.
+ See SAVE.
+\layout Itemize
+
+NOGCSE
+\begin_inset LatexCommand \index{\#pragma NOGCSE}
+
+\end_inset
+
+ - will stop global subexpression elimination.
+\layout Itemize
+
+NOINDUCTION
+\begin_inset LatexCommand \index{\#pragma NOINDUCTION}
+
+\end_inset
+
+ - will stop loop induction optimizations.
+\layout Itemize
+
+NOJTBOUND
+\begin_inset LatexCommand \index{\#pragma NOJTBOUND}
+
+\end_inset
+
+ - will not generate code for boundary value checking, when switch statements
+ are turned into jump-tables.
+\layout Itemize
+
+NOOVERLAY
+\begin_inset LatexCommand \index{\#pragma NOOVERLAY}
+
+\end_inset
+
+ - the compiler will not overlay the parameters and local variables of a
+ function.
+\layout Itemize
+
+LESS_PEDANTIC
+\begin_inset LatexCommand \index{\#pragma LESS\_PEDANTIC}
+
+\end_inset
+
+ - the compiler will not warn you anymore for obvious mistakes, you'r on
+ your own now ;-(
+\layout Itemize
+
+NOLOOPREVERSE
+\begin_inset LatexCommand \index{\#pragma NOLOOPREVERSE}
+
+\end_inset
+
+ - Will not do loop reversal optimization
+\layout Itemize
+
+EXCLUDE
+\begin_inset LatexCommand \index{\#pragma EXCLUDE}
+
+\end_inset
+
+ NONE | {acc[,b[,dpl[,dph]]] - The exclude pragma disables generation of
+ pair of push/pop
+\begin_inset LatexCommand \index{push/pop}
+
+\end_inset
+
+ instruction in ISR function (using interrupt
+\begin_inset LatexCommand \index{interrupt}
+
+\end_inset
+
+ keyword).
+ The directive should be placed immediately before the ISR function definition
+ and it affects ALL ISR functions following it.
+ To enable the normal register saving for ISR functions use #pragma\SpecialChar ~
+EXCLUDE\SpecialChar ~
+none
+\begin_inset LatexCommand \index{\#pragma EXCLUDE}
+
+\end_inset
+
+.
+\layout Itemize
+
+NOIV
+\begin_inset LatexCommand \index{\#pragma NOIV}
+
+\end_inset
+
+ - Do not generate interrupt vector table entries for all ISR functions
+ defined after the pragma.
+ This is useful in cases where the interrupt vector table must be defined
+ manually, or when there is a secondary, manually defined interrupt vector
+ table (e.g.
+ for the autovector feature of the Cypress EZ-USB FX2).
+\layout Itemize
+
+CALLEE-SAVES
+\begin_inset LatexCommand \index{\#pragma CALLEE-SAVES}
+
+\end_inset
+
+
+\begin_inset LatexCommand \index{function prologue}
+
+\end_inset
+
+ function1[,function2[,function3...]] - The compiler by default uses a caller
+ saves convention for register saving across function calls, however this
+ can cause unnecessary register pushing & popping when calling small functions
+ from larger functions.
+ This option can be used to switch off the register saving convention for
+ the function names specified.
+ The compiler will not save registers when calling these functions, extra
+ code need to be manually inserted at the entry & exit for these functions
+ to save & restore the registers used by these functions, this can SUBSTANTIALLY
+ reduce code & improve run time performance of the generated code.
+ In the future the compiler (with inter procedural analysis) may be able
+ to determine the appropriate scheme to use for each function call.
+ If -
+\begin_inset ERT
+status Collapsed
+
+\layout Standard
+
+\backslash
+/
+\end_inset
+
+-callee-saves command line option is used, the function names specified
+ in #pragma\SpecialChar ~
+CALLEE-SAVES
+\begin_inset LatexCommand \index{\#pragma CALLEE-SAVES}
+
+\end_inset
+
+ is appended to the list of functions specified in the command line.
+\layout Standard
+
+The pragma's are intended to be used to turn-off certain optimizations which
+ might cause the compiler to generate extra stack / data space to store
+ compiler generated temporary variables.
+ This usually happens in large functions.
+ Pragma directives should be used as shown in the following example, they
+ are used to control options & optimizations for a given function; pragmas
+ should be placed before and/or after a function, placing pragma's inside
+ a function body could have unpredictable results.
+\layout Verse
+
+
+\family typewriter
+#pragma SAVE
+\begin_inset LatexCommand \index{\#pragma SAVE}
+
+\end_inset
+
+ /* save the current settings */
+\newline
+#pragma NOGCSE
+\begin_inset LatexCommand \index{\#pragma NOGCSE}
+
+\end_inset
+
+ /* turnoff global subexpression elimination */
+\newline
+#pragma NOINDUCTION
+\begin_inset LatexCommand \index{\#pragma NOINDUCTION}
+
+\end_inset
+
+ /* turn off induction optimizations */
+\newline
+int foo ()
+\newline
+{
+\newline
+\SpecialChar ~
+ \SpecialChar ~
+ ...
+
+\newline
+\SpecialChar ~
+ \SpecialChar ~
+ /* large code */
+\newline
+\SpecialChar ~
+ \SpecialChar ~
+ ...
+
+\newline
+}
+\newline
+#pragma RESTORE
+\begin_inset LatexCommand \index{\#pragma RESTORE}
+
+\end_inset
+
+ /* turn the optimizations back on */
+\layout Standard
+
+The compiler will generate a warning message when extra space is allocated.
+ It is strongly recommended that the SAVE and RESTORE pragma's be used when
+ changing options for a function.
+\layout Subsection
+
+Library Routines
+\emph on
+ <pending: this is messy and incomplete>
+\emph default
+
+\layout Enumerate
+
+Compiler support routines (_gptrget, _mulint etc)
+\layout Enumerate
+
+Stdclib functions (puts, printf, strcat etc)
+\layout Enumerate
+
+Math functions (sin, pow, sqrt etc)
+\layout Comment
+
+license statements for the libraries are missing
+\layout Subsection
+
+Interfacing with Assembly Routines
+\begin_inset LatexCommand \index{Assembler routines}
+
+\end_inset
+
+
+\layout Subsubsection
+
+Global Registers used for Parameter Passing
+\begin_inset LatexCommand \index{Parameter passing}
+
+\end_inset
+
+
+\layout Standard
+
+The compiler always uses the global registers
+\emph on
+DPL, DPH
+\begin_inset LatexCommand \index{DPTR, DPH, DPL}
+
+\end_inset
+
+, B
+\begin_inset LatexCommand \index{B (register)}
+
+\end_inset
+
+
+\emph default
+and
+\emph on
+ ACC
+\begin_inset LatexCommand \index{ACC}
+
+\end_inset
+
+
+\emph default
+ to pass the first parameter to a routine.
+ The second parameter onwards is either allocated on the stack (for reentrant
+ routines or if -
+\begin_inset ERT
+status Collapsed
+
+\layout Standard
+
+\backslash
+/
+\end_inset
+
+-stack-auto is used) or in the internal / external ram (depending on the
+ memory model).
+
+\layout Subsubsection
+
+Assembler Routine(non-reentrant
+\begin_inset LatexCommand \index{reentrant}
+
+\end_inset
+
+)
+\begin_inset LatexCommand \index{Assembler routines (non-reentrant)}
+
+\end_inset
+
+
+\layout Standard
+
+In the following example the function c_func calls an assembler routine
+ asm_func, which takes two parameters.
+\layout Verse
+
+
+\family typewriter
+extern int asm_func(unsigned char, unsigned char);
+\newline
+
+\newline
+int c_func (unsigned char i, unsigned char j)
+\newline
+{
+\newline
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+return asm_func(i,j);
+\newline
+}
+\newline
+
+\newline
+int main()
+\newline
+{
+\newline
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+return c_func(10,9);
+\newline
+}
+\layout Standard
+
+The corresponding assembler function is:
+\layout Verse
+
+
+\family typewriter
+.globl _asm_func_PARM_2
+\newline
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+.globl _asm_func
+\newline
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+.area OSEG
+\newline
+_asm_func_PARM_2:
+\newline
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+.ds 1
+\newline
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+.area CSEG
+\newline
+_asm_func:
+\newline
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+mov a,dpl
+\newline
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+add a,_asm_func_PARM_2
+\newline
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+mov dpl,a
+\newline
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+mov\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+dpl
+\begin_inset LatexCommand \index{DPTR, DPH, DPL}
+
+\end_inset
+
+,#0x00
+\newline
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+ret
+\layout Standard
+
+Note here that the return values are placed in 'dpl' - One byte return value,
+ 'dpl' LSB & 'dph' MSB for two byte values.
+ 'dpl', 'dph' and 'b' for three byte values (generic pointers) and 'dpl','dph','
+b' & 'acc' for four byte values.
+\layout Standard
+
+The parameter naming convention is _<function_name>_PARM_<n>, where n is
+ the parameter number starting from 1, and counting from the left.
+ The first parameter is passed in
+\begin_inset Quotes eld
+\end_inset
+
+dpl
+\begin_inset Quotes erd
+\end_inset
+
+ for One bye parameter,
+\begin_inset Quotes eld
+\end_inset
+
+dptr
+\begin_inset Quotes erd
+\end_inset
+
+ if two bytes,
+\begin_inset Quotes eld
+\end_inset
+
+b,dptr
+\begin_inset Quotes erd
+\end_inset
+
+ for three bytes and
+\begin_inset Quotes eld
+\end_inset
+
+acc,b,dptr
+\begin_inset Quotes erd
+\end_inset
+
+ for four bytes, the variable name for the second parameter will be _<function_n
+ame>_PARM_2.
+\newline
+
+\newline
+Assemble the assembler routine with the following command:
+\newline
+
+\newline
+
+\family sans
+\series bold
+asx8051 -losg asmfunc.asm
+\newline
+
+\newline
+
+\family default
+\series default
+Then compile and link the assembler routine to the C source file with the
+ following command:
+\newline
+
+\newline
+
+\family sans
+\series bold
+sdcc cfunc.c asmfunc.rel
+\layout Subsubsection
+
+Assembler Routine(reentrant
+\begin_inset LatexCommand \index{reentrant}
+
+\end_inset
+
+)
+\begin_inset LatexCommand \index{Assembler routines (reentrant)}
+
+\end_inset
+
+
+\layout Standard
+
+In this case the second parameter onwards will be passed on the stack, the
+ parameters are pushed from right to left i.e.
+ after the call the left most parameter will be on the top of the stack.
+ Here is an example:
+\layout Verse