X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=doc%2Fsdccman.lyx;h=111f2884d525beae04600bffda09f1b4cf83a199;hb=dbbb3782a55a92fbaeb4e53d16f08cc255472e50;hp=772e52a5f074918bea929580aed27c770476f9b3;hpb=69e754f12a02df9b381d11f0b7a1d31434e90ad5;p=fw%2Fsdcc diff --git a/doc/sdccman.lyx b/doc/sdccman.lyx index 772e52a5..111f2884 100644 --- a/doc/sdccman.lyx +++ b/doc/sdccman.lyx @@ -82,7 +82,7 @@ SDCC Compiler User Guide \size normal -SDCC 2.5.1 +SDCC 2.5.4 \size footnotesize \newline @@ -245,6 +245,7 @@ status Collapsed \newline SDCC also comes with a companion source level debugger SDCDB, the debugger currently uses ucSim a freeware simulator for 8051 and other micro-controllers. + SDCDB and ucSim are currently not available on Win32 platforms. \newline @@ -557,8 +558,8 @@ char KernelFunction3(char p) at 0x340; \family typewriter -code banking -\begin_inset LatexCommand \index{code banking (not supported)} +better code banking +\begin_inset LatexCommand \index{code banking (limited support)} \end_inset @@ -3268,8 +3269,10 @@ bin before running SDCC. \newline WARNING: Visual studio is very picky with line terminations; it expects the 0x0d, 0x0a DOS style line endings, not the 0x0a Unix style line endings. - If you are getting a message such as "This makefile was not generated by - Developer Studio etc. + When using the CVS repository it's easiest to configure the cvs client + to convert automatically for you. + If however you are getting a message such as "This makefile was not generated + by Developer Studio etc. etc. \begin_inset Quotes srd \end_inset @@ -4118,9 +4121,11 @@ link-gbz80 - The Z80 and GameBoy Z80 linkers. \layout Itemize s51 - The ucSim 8051 simulator. + Not available on Win32 platforms. \layout Itemize sdcdb - The source debugger. + Not available on Win32 platforms. \layout Itemize packihx - A tool to pack (compress) Intel hex files. @@ -4204,6 +4209,7 @@ S51 . It currently supports the core mcs51, the Dallas DS80C390 and the Phillips XA51 family. + S51 is currently not available on Win32 platfors. \layout Subsection sdcdb - Source Level Debugger @@ -4227,7 +4233,7 @@ Sdcdb \end_inset , but can be easily changed to use other simulators. - + Sdcdb is currently not available on Win32 platfors. \layout Chapter Using SDCC @@ -5735,6 +5741,61 @@ status Collapsed \labelwidthstring 00.00.0000 +\series bold +- +\begin_inset ERT +status Collapsed + +\layout Standard + +\backslash +/ +\end_inset + +-xstack-loc +\series default + +\begin_inset LatexCommand \index{-\/-xstack-loc } + +\end_inset + +\SpecialChar ~ + By default the external stack +\begin_inset LatexCommand \index{xstack} + +\end_inset + + is placed after the pdata segment. + Using this option the xstack can be placed anywhere in the external memory + space of the 8051. + The value entered can be in Hexadecimal or Decimal format, e.g. + - +\begin_inset ERT +status Collapsed + +\layout Standard + +\backslash +/ +\end_inset + +-xstack-loc 0x8000 or - +\begin_inset ERT +status Collapsed + +\layout Standard + +\backslash +/ +\end_inset + +-stack-loc 32768. + The provided value should not overlap any other memory areas such as the + pdata or xdata segment and with enough space for the current application. +\layout List +\labelwidthstring 00.00.0000 + + \series bold - \begin_inset ERT @@ -6043,6 +6104,33 @@ Generate code for Small Model programs, see section Memory Models for more \labelwidthstring 00.00.0000 +\series bold +- +\begin_inset ERT +status Collapsed + +\layout Standard + +\backslash +/ +\end_inset + +-model-medium +\begin_inset LatexCommand \index{-\/-model-medium} + +\end_inset + + +\series default + Generate code for Medium model programs, see section Memory Models for + more details. + If this option is used all source files in the project have to be compiled + with this option. + It must also be used when invoking the linker. +\layout List +\labelwidthstring 00.00.0000 + + \series bold - \begin_inset ERT @@ -6065,6 +6153,7 @@ status Collapsed details. If this option is used all source files in the project have to be compiled with this option. + It must also be used when invoking the linker. \layout List \labelwidthstring 00.00.0000 @@ -7796,6 +7885,74 @@ status Collapsed \labelwidthstring 00.00.0000 +\series bold +- +\begin_inset ERT +status Collapsed + +\layout Standard + +\backslash +/ +\end_inset + +-codeseg +\series default + +\begin_inset LatexCommand \index{-\/-codeseg } + +\end_inset + +\SpecialChar ~ + The name to be used for the code +\begin_inset LatexCommand \index{code} + +\end_inset + + segment, default CSEG. + This is useful if you need to tell the compiler to put the code in a special + segment so you can later on tell the linker to put this segment in a special + place in memory. + Can be used for instance when using bank switching to put the code in a + bank. +\layout List +\labelwidthstring 00.00.0000 + + +\series bold +- +\begin_inset ERT +status Collapsed + +\layout Standard + +\backslash +/ +\end_inset + +-constseg +\series default + +\begin_inset LatexCommand \index{-\/-constseg } + +\end_inset + +\SpecialChar ~ + The name to be used for the const +\begin_inset LatexCommand \index{code} + +\end_inset + + segment, default CONST. + This is useful if you need to tell the compiler to put the const data in + a special segment so you can later on tell the linker to put this segment + in a special place in memory. + Can be used for instance when using bank switching to put the const data + in a bank. +\layout List +\labelwidthstring 00.00.0000 + + \series bold more-pedantic \series default @@ -8699,6 +8856,11 @@ Paged xdata access is just as straightforward as using the other addressing \end_inset ). + This is the +\series bold +default +\series default + storage class for the Medium Memory model, e.g.: \layout Verse @@ -10331,6 +10493,13 @@ Parameters , (storage classes for parameters will be ignored), their allocation is governed by the memory model in use, and the reentrancy options. +\layout Standard + +It is however allowed to use bit parameters in reentrant functions and also + non-static local bit variables are supported. + Efficient use is limited to 8 semi-bitregisters in bit space. + They are pushed and popped to stack as a single byte just like the normal + registers. \layout Section Overlaying @@ -10773,7 +10942,13 @@ nooverlay if it is not reentrant. Furthermore nonreentrant functions should not be called from the main program while the interrupt service routine might be active. - + They also must not be called from low priority interrupt service routines + while a high priority interrupt service routine might be active. You could use + semaphores or make the function +\emph on + critical +\emph default + if all parameters are passed in registers. \newline \newline @@ -14653,12 +14828,12 @@ MCS51 Memory Models \layout Subsubsection -Small and Large +Small, Medium and Large \layout Standard -SDCC allows two memory models for MCS51 code, +SDCC allows three memory models for MCS51 code, \shape slanted -small +small, medium \shape default and \shape slanted @@ -14670,16 +14845,15 @@ large never \emph default be combined together or the results would be unpredictable. - The library routines supplied with the compiler are compiled as both small - and large. - The compiled library modules are contained in separate directories as small - and large so that you can link to either set. - + The library routines supplied with the compiler are compiled as small, + medium and large. + The compiled library modules are contained in separate directories as small, + medium and large so that you can link to the appropriate set. \layout Standard -When the large model is used all variables declared without a storage class - will be allocated into the external ram, this includes all parameters and - local variables (for non-reentrant +When the medium or large model is used all variables declared without a + storage class will be allocated into the external ram, this includes all + parameters and local variables (for non-reentrant \begin_inset LatexCommand \index{reentrant} \end_inset @@ -15217,6 +15391,24 @@ std_c99 - Follow the C99 standard and disable SDCC features that conflict with the standard (incomplete support). +\layout Itemize + +codeseg +\begin_inset LatexCommand \index{\#pragma codeseg} + +\end_inset + +- Use this name (max. + 8 characters) for the code segment. +\layout Itemize + +constseg +\begin_inset LatexCommand \index{\#pragma constseg} + +\end_inset + +- Use this name (max. + 8 characters) for the const segment. \layout Standard SDCPP supports the following #pragma directives: @@ -15329,7 +15521,7 @@ The compiler creates the following #defines \begin_inset Tabular - + @@ -15530,6 +15722,43 @@ status Collapsed \layout Standard +SDCC_MODEL_MEDIUM +\begin_inset LatexCommand \index{SDCC\_MODEL\_MEDIUM} + +\end_inset + + +\end_inset + + +\begin_inset Text + +\layout Standard + +when +\emph on +- +\begin_inset ERT +status Collapsed + +\layout Standard + +\backslash +/ +\end_inset + +-model-medium +\emph default + is used +\end_inset + + + + +\begin_inset Text + +\layout Standard + SDCC_MODEL_LARGE \begin_inset LatexCommand \index{SDCC\_MODEL\_LARGE} @@ -16007,7 +16236,7 @@ $(PRJ).hex: $(OBJS) \SpecialChar ~ \SpecialChar ~ \SpecialChar ~ -gplink -m -s $(PRJ).lkr -o $(PRJ).hex $(OBJS) +gplink -m -s $(PRJ).lkr -o $(PRJ).hex $(OBJS) libsdcc.lib \layout Standard Here is a @@ -16053,7 +16282,7 @@ $(PRJ).hex: $(OBJS) \SpecialChar ~ \SpecialChar ~ \SpecialChar ~ -mplink /v $(PRJ).lkr /m $(PRJ).map /o $(PRJ).hex $(OBJS) +mplink /v $(PRJ).lkr /m $(PRJ).map /o $(PRJ).hex $(OBJS) libsdcc.lib \layout Standard Please note that indentations within a @@ -16061,85 +16290,210 @@ Please note that indentations within a Makefile \family default have to be done with a tabulator character. -\layout Section +\layout Subsection -The PIC16 -\begin_inset LatexCommand \index{PIC16} +Command-line options +\layout Standard -\end_inset +Besides the switches common to all SDCC backends, the PIC14 port accepts + the following options (for an updated list see sdcc - +\begin_inset ERT +status Collapsed - port \layout Standard -The PIC16 -\begin_inset LatexCommand \index{PIC16} - +\backslash +/ \end_inset - port is the portion of SDCC that is responsible to produce code for the - Microchip -\begin_inset LatexCommand \index{Microchip} +-help): +\layout List +\labelwidthstring 00.00.0000 -\end_inset +- +\begin_inset ERT +status Collapsed -(TM) microcontrollers with 16 bit core. - Currently this family of microcontrollers contains the PIC18Fxxx and PIC18Fxxxx. - Currently supported devices are: \layout Standard -\align center -\begin_inset Tabular - - - - - - - - - - -\begin_inset Text +\backslash +/ +\end_inset -\layout Standard +-debug-extra emit debug info in assembly output +\layout List +\labelwidthstring 00.00.0000 -18F242 -\end_inset - - -\begin_inset Text +- +\begin_inset ERT +status Collapsed \layout Standard -18F248 +\backslash +/ \end_inset - - -\begin_inset Text -\layout Standard +-no-pcode-opt disable (slightly faulty) optimization on pCode +\layout Subsection -18F252 -\end_inset - - -\begin_inset Text +The library +\layout Subsubsection -\layout Standard +error: missing definition for symbol +\begin_inset Quotes sld +\end_inset -18F258 +__gptrget1 +\begin_inset Quotes srd \end_inset - - -\begin_inset Text + \layout Standard -18F442 -\end_inset - - -\begin_inset Text +The PIC14 port uses library routines to provide more complex operations + like multiplication, division/modulus and (generic) pointer dereferencing. + In order to add these routines to your project, you must link with PIC14's + +\family typewriter +libsdcc.lib +\family default +. + For single source file projects this is done automatically, more complex + projects must add +\family typewriter +libsdcc.lib +\family default + to the linker's arguments. + Make sure you also add an include path for the library (using the -I switch + to the linker)! +\layout Subsubsection + +Processor mismatch in file +\begin_inset Quotes sld +\end_inset + +XXX +\begin_inset Quotes srd +\end_inset + +. +\layout Standard + +This warning can usually be ignored due to the very good compatibility amongst + 14 bit PIC devices. +\layout Standard + +You might also consider recompiling the library for your specific device + by changing the ARCH=p16f877 (default target) entry in +\family typewriter +device/lib/pic/Makefile.in +\family default + and +\family typewriter +device/lib/pic/Makefile +\family default + to reflect your device. + This might even improve performance for smaller devices as unneccesary + BANKSELs migth be removed. +\layout Subsection + +Known bugs +\layout Subsubsection + +initialized data +\layout Standard + +Currently, data can only be initialized if it resides in the source file + together with +\emph on +main() +\emph default +. + Data in other source files will silently +\series bold +not +\series default + be initialized. +\layout Section + +The PIC16 +\begin_inset LatexCommand \index{PIC16} + +\end_inset + + port +\layout Standard + +The PIC16 +\begin_inset LatexCommand \index{PIC16} + +\end_inset + + port is the portion of SDCC that is responsible to produce code for the + Microchip +\begin_inset LatexCommand \index{Microchip} + +\end_inset + +(TM) microcontrollers with 16 bit core. + Currently this family of microcontrollers contains the PIC18Fxxx and PIC18Fxxxx. + Currently supported devices are: +\layout Standard +\align center + +\begin_inset Tabular + + + + + + + + + + +\begin_inset Text + +\layout Standard + +18F242 +\end_inset + + +\begin_inset Text + +\layout Standard + +18F248 +\end_inset + + +\begin_inset Text + +\layout Standard + +18F252 +\end_inset + + +\begin_inset Text + +\layout Standard + +18F258 +\end_inset + + +\begin_inset Text + +\layout Standard + +18F442 +\end_inset + + +\begin_inset Text \layout Standard @@ -16536,6 +16890,20 @@ status Collapsed / \end_inset +-optimize-df Analyze the dataflow of the generated code and improve it. +\layout List +\labelwidthstring 00.00.0000 + +- +\begin_inset ERT +status Collapsed + +\layout Standard + +\backslash +/ +\end_inset + -obanksel=nn Set optimization level for inserting BANKSELs. \newline @@ -19751,7 +20119,7 @@ on, which also builds and installs the debugger in the target directory specified during configuration. The debugger allows you debug BOTH at the C source and at the ASM source level. - Sdcdb is available on Unix platforms only. + Sdcdb is currently not available on Win32 platforms. \layout Section Compiling for Debugging @@ -19850,7 +20218,7 @@ foo.ihx - the Intel hex format object file. \layout Section -Command Line Options. +Command Line Options \layout Itemize - @@ -19917,15 +20285,15 @@ status Collapsed -k passed to simulator see the simulator docs for details. \layout Section -Debugger Commands. +Debugger Commands \layout Standard As mentioned earlier the command interface for the debugger has been deliberatel y kept as close the GNU debugger gdb, as possible. This will help the integration with existing graphical user interfaces (like ddd, xxgdb or xemacs) existing for the GNU debugger. - If you use a graphical user interface for the debugger you can skip the - next sections. + If you use a graphical user interface for the debugger you can skip this + section. \layout Subsubsection* break [line | file:line | function | file:function] @@ -20068,6 +20436,91 @@ quit My name is Bobby Brown" \layout Section +Interfacing with DDD +\layout Comment + +The screenshot was converted from png to eps with: +\begin_inset Quotes sld +\end_inset + +bmeps -c -e8f -p3 ddd_example.png >ddd_example.eps +\begin_inset Quotes srd +\end_inset + + which produces a pretty compact eps file which is free from compression + artifacts. +\layout Comment + +The screenshot was included in sdccman.lyx cvs version 1.120 but later removed + as this broke the build system on Sourceforge (pdf-file was broken). +\layout Standard + +The .eps File +\size footnotesize + +\begin_inset LatexCommand \url{http://cvs.sourceforge.net/viewcvs.py/*checkout*/sdcc/sdcc/doc/figures/ddd_example.eps} + +\end_inset + + +\size default + shows a screenshot of a debugging session with DDD +\begin_inset LatexCommand \index{DDD (debugger)} + +\end_inset + + (Unix only) on a simulated 8032. + The debugging session might not run as smoothly as the screenshot suggests. + The debugger allows setting of breakpoints, displaying and changing variables, + single stepping through C and assembler code. + +\newline +The source was compiled with +\family sans +\series bold + +\newline + +\newline +sdcc - +\family default +\series default + +\begin_inset ERT +status Collapsed + +\layout Standard + +\backslash +/ +\end_inset + + +\family sans +\series bold +-debug ddd_example.c +\family default +\series default + +\family sans +\series bold + +\newline + +\family default +\series default + +\newline +and DDD was invoked with +\family sans +\series bold + +\newline + +\newline +ddd -debugger 'sdcdb -cpu 8032 ddd_example' +\layout Section + Interfacing with XEmacs \begin_inset LatexCommand \index{XEmacs} @@ -20078,7 +20531,7 @@ Interfacing with XEmacs \end_inset -. + \layout Standard Two files (in emacs lisp) are provided for the interfacing with XEmacs, @@ -24282,6 +24735,11 @@ so little-endian is the more efficient byte order. Highest Order Bit \begin_inset LatexCommand \index{Highest Order Bit} +\end_inset + + / Any Order Bit +\begin_inset LatexCommand \index{Any Order Bit} + \end_inset @@ -24289,7 +24747,8 @@ Highest Order Bit 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 + Also obtaining any other order bit is not uncommon. + SDCC recognizes the following expressions to yield the highest order bit and generates optimized code for it, e.g.: \layout Verse @@ -24303,7 +24762,11 @@ foo () { \newline \SpecialChar ~ \SpecialChar ~ -unsigned char hob; +unsigned char hob1, aob1; +\newline +\SpecialChar ~ +\SpecialChar ~ +bit hob2, hob3, aob2, aob3; \newline \SpecialChar ~ \SpecialChar ~ @@ -24312,7 +24775,27 @@ unsigned char hob; \newline \SpecialChar ~ \SpecialChar ~ -hob = (gint >> 15) & 1; +hob1 = (gint >> 15) & 1; +\newline +\SpecialChar ~ +\SpecialChar ~ +hob2 = (gint >> 15) & 1; +\newline +\SpecialChar ~ +\SpecialChar ~ +hob3 = gint & 0x8000; +\newline +\SpecialChar ~ +\SpecialChar ~ +aob1 = (gint >> 9) & 1; +\newline +\SpecialChar ~ +\SpecialChar ~ +aob2 = (gint >> 8) & 1; +\newline +\SpecialChar ~ +\SpecialChar ~ +aob3 = gint & 0x0800; \newline \SpecialChar ~ \SpecialChar ~ @@ -24465,45 +24948,949 @@ will generate the following code: \SpecialChar ~ mov\SpecialChar ~ \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 Subsection - -Peephole Optimizer -\begin_inset LatexCommand \label{sub:Peephole-Optimizer} - -\end_inset - - -\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 + _foo_hob1_1_1,a +\newline +\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 ~ + 66 ;\SpecialChar ~ + hob.c 8 +\newline +0011 E5*01\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ + 67\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ + mov\SpecialChar ~ +\SpecialChar ~ + a,(_gint + 1) +\newline +0013 33\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ + 68\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ + rlc\SpecialChar ~ +\SpecialChar ~ + a +\newline +0014 92*00\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ + 69\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ + mov\SpecialChar ~ +\SpecialChar ~ + _foo_hob2_1_1,c +\newline +\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 ~ + 66 ;\SpecialChar ~ + hob.c 9 +\newline +0016 E5*01\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ + 67\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ + mov\SpecialChar ~ +\SpecialChar ~ + a,(_gint + 1) +\newline +0018 33\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ + 68\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ + rlc\SpecialChar ~ +\SpecialChar ~ + a +\newline +0019 92*01\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ + 69\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ + mov\SpecialChar ~ +\SpecialChar ~ + _foo_hob3_1_1,c +\newline +\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 ~ + 70 ;\SpecialChar ~ + hob.c 10 +\newline +001B E5*01\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ + 71\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ + mov\SpecialChar ~ +\SpecialChar ~ + a,(_gint + 1) +\newline +001D 03\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ + 72\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ + rr\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ + a +\newline +001E 54 01\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ + 73\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ + anl\SpecialChar ~ +\SpecialChar ~ + a,#0x01 +\newline +0020 F5*03\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ + 74\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ + mov\SpecialChar ~ +\SpecialChar ~ + _foo_aob1_1_1,a +\newline +\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 ~ + 75 ;\SpecialChar ~ + hob.c 11 +\newline +0022 E5*01\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ + 76\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ + mov\SpecialChar ~ +\SpecialChar ~ + a,(_gint + 1) +\newline +0024 13\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ + 77\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ + rrc\SpecialChar ~ +\SpecialChar ~ + a +\newline +0025 92*02\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ + 78\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ + mov\SpecialChar ~ +\SpecialChar ~ + _foo_aob2_1_1,c +\newline +\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 ~ + 79 ;\SpecialChar ~ + hob.c 12 +\newline +0027 E5*01\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ + 80\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ + mov\SpecialChar ~ +\SpecialChar ~ + a,(_gint + 1) +\newline +0029 A2 E3\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ + 81\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ + mov\SpecialChar ~ +\SpecialChar ~ + c,acc[3] +\newline +002B 92*03\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ + 82\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ + mov\SpecialChar ~ +\SpecialChar ~ + _foo_aob3_1_1,c +\layout Standard + +Other variations of these cases however will +\emph on +not +\emph default + be recognized. + They are standard C expressions, so I heartily recommend these 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 Subsection + +Higher Order Byte +\begin_inset LatexCommand \index{Higher Order Byte} + +\end_inset + + / Higher Order Word +\begin_inset LatexCommand \index{Higher Order Word} + +\end_inset + + +\layout Standard + +It is also frequently required to obtain a higher order byte or word of + a larger integral type (long, int or short types). + SDCC recognizes the following expressions to yield the higher order byte + or word and generates optimized code for it, e.g.: +\layout Verse + + +\family typewriter +unsigned int gint; +\newline +unsigned long int glong; +\newline + +\newline +foo () { +\newline +\SpecialChar ~ +\SpecialChar ~ +unsigned char hob1, hob2; +\newline +\SpecialChar ~ +\SpecialChar ~ +unsigned int how1, how2; +\newline +\SpecialChar ~ +\SpecialChar ~ +... + +\newline +\SpecialChar ~ +\SpecialChar ~ +hob1 = (gint >> 8) & 0xFF; +\newline +\SpecialChar ~ +\SpecialChar ~ +hob2 = glong >> 24; +\newline +\SpecialChar ~ +\SpecialChar ~ +how1 = (glong >> 16) & 0xFFFF; +\newline +\SpecialChar ~ +\SpecialChar ~ +how2 = glong >> 8; +\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 ~ + 91 ;\SpecialChar ~ + hob.c 15 +\newline +0037 85*01*06\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ + 92\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ + mov\SpecialChar ~ +\SpecialChar ~ + _foo_hob1_1_1,(_gint + 1) +\newline +\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 ~ + 93 ;\SpecialChar ~ + hob.c 16 +\newline +003A 85*05*07\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ + 94\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ + mov\SpecialChar ~ +\SpecialChar ~ + _foo_hob2_1_1,(_glong + 3) +\newline +\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 ~ + 95 ;\SpecialChar ~ + hob.c 17 +\newline +003D 85*04*08\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ + 96\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ + mov\SpecialChar ~ +\SpecialChar ~ + _foo_how1_1_1,(_glong + 2) +\newline +0040 85*05*09\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ + 97\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ + mov\SpecialChar ~ +\SpecialChar ~ + (_foo_how1_1_1 + 1),(_glong + 3) +\newline +0043 85*03*0A\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ + 98\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ + mov\SpecialChar ~ +\SpecialChar ~ + _foo_how2_1_1,(_glong + 1) +\newline +0046 85*04*0B\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ + 99\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ +\SpecialChar ~ + mov\SpecialChar ~ +\SpecialChar ~ + (_foo_how2_1_1 + 1),(_glong + 2) +\layout Standard + +Again, variations of these cases may +\emph on +not +\emph default + be recognized. + They are standard C expressions, so I heartily recommend these be the only + way to get the higher order byte/word, (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 >> 8) & 0xFF); +\layout Standard + +will still be recognized. +\layout Subsection + +Peephole Optimizer +\begin_inset LatexCommand \label{sub:Peephole-Optimizer} + +\end_inset + + +\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. @@ -24998,6 +26385,18 @@ return rets;/* is invalid in SDCC although allowed in ANSI */ \end_deeper \layout Itemize +initialization of structure arrays must be fully braced. +\begin_deeper +\layout Verse + + +\family typewriter +struct s { char x } a[] = {1, 2}; /* invalid in SDCC */ +\newline +struct s { char x } a[] = {{1}, {2}}; /* OK */ +\end_deeper +\layout Itemize + 'long long \begin_inset LatexCommand \index{long long (not supported)} @@ -25024,19 +26423,6 @@ return rets;/* is invalid in SDCC although allowed in ANSI */ not supported. \layout Itemize -No support for setjmp -\begin_inset LatexCommand \index{setjmp (not supported)} - -\end_inset - - and longjmp -\begin_inset LatexCommand \index{longjmp (not supported)} - -\end_inset - - (for now). -\layout Itemize - Old K&R style \begin_inset LatexCommand \index{K\&R style} @@ -25065,6 +26451,26 @@ int i,j; /* are valid in ANSI but not valid in SDCC */ \end_deeper \layout Itemize +Most enhancements in C99 are not supported, f.e.: +\begin_deeper +\layout Verse + + +\family typewriter +\series bold +inline +\series default + int increment (int a) { return a+1; } /* is invalid in SDCC although allowed + in C99 */ +\newline +for ( +\series bold +int +\series default + i=0; i<10; i++) /* is invalid in SDCC although allowed in C99 */ +\end_deeper +\layout Itemize + Certain words that are valid identifiers in the standard may be reserved words in SDCC unless the \series bold