<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> <!--Converted with LaTeX2HTML 2008 (1.71) original version by: Nikos Drakos, CBLU, University of Leeds * revised and updated by: Marcus Hennecke, Ross Moore, Herb Swan * with significant contributions from: Jens Lippmann, Marek Rouchal, Martin Wilck and others --> <HTML> <HEAD> <TITLE>9.1 The anatomy of the compiler</TITLE> <META NAME="description" CONTENT="9.1 The anatomy of the compiler"> <META NAME="keywords" CONTENT="sdccman"> <META NAME="resource-type" CONTENT="document"> <META NAME="distribution" CONTENT="global"> <META NAME="Generator" CONTENT="LaTeX2HTML v2008"> <META HTTP-EQUIV="Content-Style-Type" CONTENT="text/css"> <LINK REL="STYLESHEET" HREF="sdccman.css"> <LINK REL="next" HREF="node188.html"> <LINK REL="previous" HREF="node186.html"> <LINK REL="up" HREF="node186.html"> <LINK REL="next" HREF="node188.html"> </HEAD> <BODY > <!--Navigation Panel--> <A NAME="tex2html3614" HREF="node188.html"> <IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next" SRC="next.png"></A> <A NAME="tex2html3608" HREF="node186.html"> <IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up" SRC="up.png"></A> <A NAME="tex2html3602" HREF="node186.html"> <IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous" SRC="prev.png"></A> <A NAME="tex2html3610" HREF="node1.html"> <IMG WIDTH="65" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="contents" SRC="contents.png"></A> <A NAME="tex2html3612" HREF="node191.html"> <IMG WIDTH="43" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="index" SRC="index.png"></A> <BR> <B> Next:</B> <A NAME="tex2html3615" HREF="node188.html">9.2 A few words</A> <B> Up:</B> <A NAME="tex2html3609" HREF="node186.html">9. Compiler internals</A> <B> Previous:</B> <A NAME="tex2html3603" HREF="node186.html">9. Compiler internals</A> <B> <A NAME="tex2html3611" HREF="node1.html">Contents</A></B> <B> <A NAME="tex2html3613" HREF="node191.html">Index</A></B> <BR> <BR> <!--End of Navigation Panel--> <H1><A NAME="SECTION001010000000000000000"></A><A NAME="sub:The-anatomy-of"></A> <BR> 9.1 The anatomy of the compiler </H1> <P> <I>This is an excerpt from an article published in Circuit Cellar Magazine in</I> <B><I>August 2000</I></B><I>. It's a little outdated (the compiler is much more efficient now and user/developer friendly), but pretty well exposes the guts of it all.</I> <BR> <BR> The current version of SDCC can generate code for Intel 8051 and Z80 MCU. It is fairly easy to retarget for other 8-bit MCU. Here we take a look at some of the internals of the compiler. <P> <H4><A NAME="SECTION001010010000000000000"></A><A NAME="4516"></A> <BR> Parsing </H4> <P> Parsing the input source file and creating an AST (Annotated Syntax Tree<A NAME="4517"></A>). This phase also involves propagating types (annotating each node of the parse tree with type information) and semantic analysis. There are some MCU specific parsing rules. For example the storage classes, the extended storage classes are MCU specific while there may be a xdata storage class for 8051 there is no such storage class for z80. SDCC allows MCU specific storage class extensions, i.e. xdata will be treated as a storage class specifier when parsing 8051 C code but will be treated as a C identifier when parsing z80 code. <P> <H4><A NAME="SECTION001010020000000000000"></A><A NAME="4518"></A> <BR> Generating iCode </H4> <P> Intermediate code generation. In this phase the AST is broken down into three-operand form (iCode). These three operand forms are represented as doubly linked lists. ICode is the term given to the intermediate form generated by the compiler. ICode example section shows some examples of iCode generated for some simple C source functions. <P> <H4><A NAME="SECTION001010030000000000000"></A><A NAME="4519"></A> <BR> Optimizations. </H4> <P> Bulk of the target independent optimizations is performed in this phase. The optimizations include constant propagation, common sub-expression elimination, loop invariant code movement, strength reduction of loop induction variables and dead-code elimination. <P> <H4><A NAME="SECTION001010040000000000000"></A><A NAME="4520"></A> <BR> Live range analysis </H4> <P> During intermediate code generation phase, the compiler assumes the target machine has infinite number of registers and generates a lot of temporary variables. The live range computation determines the lifetime of each of these compiler-generated temporaries. A picture speaks a thousand words. ICode example sections show the live range annotations for each of the operand. It is important to note here, each iCode is assigned a number in the order of its execution in the function. The live ranges are computed in terms of these numbers. The from number is the number of the iCode which first defines the operand and the to number signifies the iCode which uses this operand last. <P> <H4><A NAME="SECTION001010050000000000000"></A><A NAME="4521"></A> <BR> Register Allocation </H4> <P> The register allocation determines the type and number of registers needed by each operand. In most MCUs only a few registers can be used for indirect addressing. In case of 8051 for example the registers R0 & R1 can be used to indirectly address the internal ram and DPTR to indirectly address the external ram. The compiler will try to allocate the appropriate register to pointer variables if it can. ICode example section shows the operands annotated with the registers assigned to them. The compiler will try to keep operands in registers as much as possible; there are several schemes the compiler uses to do achieve this. When the compiler runs out of registers the compiler will check to see if there are any live operands which is not used or defined in the current basic block being processed, if there are any found then it will push that operand and use the registers in this block, the operand will then be popped at the end of the basic block. <P> There are other MCU specific considerations in this phase. Some MCUs have an accumulator; very short-lived operands could be assigned to the accumulator instead of a general-purpose register. <P> <H4><A NAME="SECTION001010060000000000000"> Code generation</A> </H4> <P> Figure II gives a table of iCode<A NAME="4523"></A> operations supported by the compiler. The code generation involves translating these operations into corresponding assembly code for the processor. This sounds overly simple but that is the essence of code generation. Some of the iCode operations are generated on a MCU specific manner for example, the z80 port does not use registers to pass parameters so the SEND and RECV iCode operations will not be generated, and it also does not support JUMPTABLES. <BR> <P> <FONT SIZE="-1">Figure II </FONT><TABLE CELLPADDING=3 BORDER="1"> <TR><TH ALIGN="LEFT" VALIGN="TOP" WIDTH=0><B>iCode</B><A NAME="4532"></A></TH> <TH ALIGN="LEFT" VALIGN="TOP" WIDTH=0> <B>Operands</B> </TH> <TH ALIGN="LEFT" VALIGN="TOP" WIDTH=0><B>Description</B></TH> <TH ALIGN="LEFT" VALIGN="TOP" WIDTH=0><B>C Equivalent</B></TH> </TR> <TR><TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0> </TD> <TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0> </TD> <TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0> </TD> <TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0> </TD> </TR> <TR><TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0><FONT SIZE="-1">'!'</FONT></TD> <TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0> <FONT SIZE="-1">IC_LEFT() IC_RESULT()</FONT> </TD> <TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0><FONT SIZE="-1">NOT operation </FONT></TD> <TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0><FONT SIZE="-1">IC_RESULT = ! IC_LEFT;</FONT></TD> </TR> <TR><TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0><FONT SIZE="-1">'~'</FONT></TD> <TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0> <FONT SIZE="-1">IC_LEFT() IC_RESULT()</FONT> </TD> <TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0><FONT SIZE="-1">Bitwise complement of </FONT></TD> <TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0><FONT SIZE="-1">IC_RESULT = ~IC_LEFT;</FONT></TD> </TR> <TR><TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0><FONT SIZE="-1">RRC</FONT></TD> <TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0> <FONT SIZE="-1">IC_LEFT() IC_RESULT()</FONT> </TD> <TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0><FONT SIZE="-1">Rotate right with carry</FONT></TD> <TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0><FONT SIZE="-1">IC_RESULT = (IC_LEFT « 1) | (IC_LEFT » (sizeof(IC_LEFT)*8-1));</FONT></TD> </TR> <TR><TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0><FONT SIZE="-1">RLC</FONT></TD> <TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0> <FONT SIZE="-1">IC_LEFT() IC_RESULT()</FONT> </TD> <TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0><FONT SIZE="-1">Rotate left with carry</FONT></TD> <TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0><FONT SIZE="-1">IC_RESULT = (IC_LEFT « (sizeof(LC_LEFT)*8-1) ) | (IC_LEFT » 1);</FONT></TD> </TR> <TR><TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0><FONT SIZE="-1">GETHBIT</FONT></TD> <TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0> <FONT SIZE="-1">IC_LEFT() IC_RESULT()</FONT> </TD> <TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0><FONT SIZE="-1">Get the highest order bit of IC_LEFT</FONT></TD> <TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0><FONT SIZE="-1">IC_RESULT = (IC_LEFT » (sizeof(IC_LEFT)*8 -1));</FONT></TD> </TR> <TR><TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0><FONT SIZE="-1">UNARYMINUS</FONT></TD> <TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0> <FONT SIZE="-1">IC_LEFT() IC_RESULT()</FONT> </TD> <TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0><FONT SIZE="-1">Unary minus</FONT></TD> <TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0><FONT SIZE="-1">IC_RESULT = - IC_LEFT;</FONT></TD> </TR> <TR><TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0><FONT SIZE="-1">IPUSH</FONT></TD> <TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0> <FONT SIZE="-1">IC_LEFT()</FONT> </TD> <TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0><FONT SIZE="-1">Push the operand into stack</FONT></TD> <TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0><FONT SIZE="-1">NONE</FONT></TD> </TR> <TR><TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0><FONT SIZE="-1">IPOP</FONT></TD> <TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0> <FONT SIZE="-1">IC_LEFT()</FONT> </TD> <TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0><FONT SIZE="-1">Pop the operand from the stack </FONT></TD> <TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0><FONT SIZE="-1">NONE</FONT></TD> </TR> <TR><TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0><FONT SIZE="-1">CALL</FONT></TD> <TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0> <FONT SIZE="-1">IC_LEFT() IC_RESULT()</FONT> </TD> <TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0><FONT SIZE="-1">Call the function represented by IC_LEFT </FONT></TD> <TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0><FONT SIZE="-1">IC_RESULT = IC_LEFT();</FONT></TD> </TR> <TR><TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0><FONT SIZE="-1">PCALL</FONT></TD> <TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0> <FONT SIZE="-1">IC_LEFT() IC_RESULT()</FONT> </TD> <TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0><FONT SIZE="-1">Call via function pointer</FONT></TD> <TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0><FONT SIZE="-1">IC_RESULT = (*IC_LEFT)();</FONT></TD> </TR> <TR><TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0><FONT SIZE="-1">RETURN</FONT></TD> <TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0> <FONT SIZE="-1">IC_LEFT()</FONT> </TD> <TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0><FONT SIZE="-1">Return the value in operand IC_LEFT </FONT></TD> <TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0><FONT SIZE="-1">return IC_LEFT;</FONT></TD> </TR> <TR><TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0><FONT SIZE="-1">LABEL</FONT></TD> <TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0> <FONT SIZE="-1">IC_LABEL() </FONT> </TD> <TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0><FONT SIZE="-1">Label</FONT></TD> <TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0><FONT SIZE="-1">IC_LABEL:</FONT></TD> </TR> <TR><TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0><FONT SIZE="-1">GOTO</FONT></TD> <TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0> <FONT SIZE="-1">IC_LABEL() </FONT> </TD> <TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0><FONT SIZE="-1">Goto label</FONT></TD> <TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0><FONT SIZE="-1">goto IC_LABEL();</FONT></TD> </TR> <TR><TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0><FONT SIZE="-1">'+'</FONT></TD> <TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0> <FONT SIZE="-1">IC_LEFT() IC_RIGHT() IC_RESULT()</FONT> </TD> <TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0><FONT SIZE="-1">Addition</FONT></TD> <TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0><FONT SIZE="-1">IC_RESULT = IC_LEFT + IC_RIGHT</FONT></TD> </TR> <TR><TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0><FONT SIZE="-1">'-'</FONT></TD> <TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0> <FONT SIZE="-1">IC_LEFT() IC_RIGHT() IC_RESULT()</FONT> </TD> <TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0><FONT SIZE="-1">Subtraction</FONT></TD> <TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0><FONT SIZE="-1">IC_RESULT = IC_LEFT - IC_RIGHT </FONT></TD> </TR> <TR><TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0><FONT SIZE="-1">'*'</FONT></TD> <TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0> <FONT SIZE="-1">IC_LEFT() IC_RIGHT() IC_RESULT()</FONT> </TD> <TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0><FONT SIZE="-1">Multiplication </FONT></TD> <TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0><FONT SIZE="-1">IC_RESULT = IC_LEFT * IC_RIGHT;</FONT></TD> </TR> <TR><TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0><FONT SIZE="-1">'/'</FONT></TD> <TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0> <FONT SIZE="-1">IC_LEFT() IC_RIGHT() IC_RESULT()</FONT> </TD> <TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0><FONT SIZE="-1">Division</FONT></TD> <TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0><FONT SIZE="-1">IC_RESULT = IC_LEFT / IC_RIGHT;</FONT></TD> </TR> <TR><TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0><FONT SIZE="-1">'%'</FONT></TD> <TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0> <FONT SIZE="-1">IC_LEFT() IC_RIGHT() IC_RESULT()</FONT> </TD> <TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0><FONT SIZE="-1">Modulus</FONT></TD> <TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0><FONT SIZE="-1">IC_RESULT = IC_LEFT % IC_RIGHT;</FONT></TD> </TR> <TR><TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0><FONT SIZE="-1">'<'</FONT></TD> <TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0> <FONT SIZE="-1">IC_LEFT() IC_RIGHT() IC_RESULT()</FONT> </TD> <TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0><FONT SIZE="-1">Less than</FONT></TD> <TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0><FONT SIZE="-1">IC_RESULT = IC_LEFT < IC_RIGHT;</FONT></TD> </TR> <TR><TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0><FONT SIZE="-1">'>'</FONT></TD> <TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0> <FONT SIZE="-1">IC_LEFT() IC_RIGHT() IC_RESULT()</FONT> </TD> <TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0><FONT SIZE="-1">Greater than </FONT></TD> <TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0><FONT SIZE="-1">IC_RESULT = IC_LEFT > IC_RIGHT;</FONT></TD> </TR> <TR><TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0><FONT SIZE="-1">EQ_OP</FONT></TD> <TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0> <FONT SIZE="-1">IC_LEFT() IC_RIGHT() IC_RESULT()</FONT> </TD> <TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0><FONT SIZE="-1">Equal to </FONT></TD> <TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0><FONT SIZE="-1">IC_RESULT = IC_LEFT == IC_RIGHT;</FONT></TD> </TR> <TR><TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0><FONT SIZE="-1">AND_OP</FONT></TD> <TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0> <FONT SIZE="-1">IC_LEFT() IC_RIGHT() IC_RESULT() </FONT> </TD> <TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0><FONT SIZE="-1">Logical and operation</FONT></TD> <TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0><FONT SIZE="-1">IC_RESULT = IC_LEFT && IC_RIGHT; </FONT></TD> </TR> <TR><TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0><FONT SIZE="-1">OR_OP</FONT></TD> <TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0> <FONT SIZE="-1">IC_LEFT() IC_RIGHT() IC_RESULT() </FONT> </TD> <TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0><FONT SIZE="-1">Logical or operation </FONT></TD> <TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0><FONT SIZE="-1">IC_RESULT = IC_LEFT || IC_RIGHT; </FONT></TD> </TR> <TR><TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0><FONT SIZE="-1">'^'</FONT></TD> <TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0> <FONT SIZE="-1">IC_LEFT() IC_RIGHT() IC_RESULT() </FONT> </TD> <TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0><FONT SIZE="-1">Exclusive OR</FONT></TD> <TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0><FONT SIZE="-1">IC_RESULT = IC_LEFT ^ IC_RIGHT;</FONT></TD> </TR> <TR><TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0><FONT SIZE="-1">'|'</FONT></TD> <TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0> <FONT SIZE="-1">IC_LEFT() IC_RIGHT() IC_RESULT() </FONT> </TD> <TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0><FONT SIZE="-1">Bitwise OR </FONT></TD> <TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0><FONT SIZE="-1">IC_RESULT = IC_LEFT | IC_RIGHT;</FONT></TD> </TR> <TR><TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0><FONT SIZE="-1">BITWISEAND</FONT></TD> <TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0> <FONT SIZE="-1">IC_LEFT() IC_RIGHT() IC_RESULT()</FONT> </TD> <TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0><FONT SIZE="-1">Bitwise AND </FONT></TD> <TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0><FONT SIZE="-1">IC_RESULT = IC_LEFT & IC_RIGHT;</FONT></TD> </TR> <TR><TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0><FONT SIZE="-1">LEFT_OP</FONT></TD> <TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0> <FONT SIZE="-1">IC_LEFT() IC_RIGHT() IC_RESULT()</FONT> </TD> <TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0><FONT SIZE="-1">Left shift </FONT></TD> <TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0><FONT SIZE="-1">IC_RESULT = IC_LEFT « IC_RIGHT </FONT></TD> </TR> <TR><TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0><FONT SIZE="-1">RIGHT_OP</FONT></TD> <TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0> <FONT SIZE="-1">IC_LEFT() IC_RIGHT() IC_RESULT()</FONT> </TD> <TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0><FONT SIZE="-1">Right shift</FONT></TD> <TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0><FONT SIZE="-1">IC_RESULT = IC_LEFT » IC_RIGHT </FONT></TD> </TR> <TR><TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0><FONT SIZE="-1">GET_VALUE_</FONT> <BR> <FONT SIZE="-1">AT_ ADDRESS</FONT></TD> <TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0> <FONT SIZE="-1">IC_LEFT() IC_RESULT()</FONT> </TD> <TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0><FONT SIZE="-1">Indirect fetch </FONT></TD> <TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0><FONT SIZE="-1">IC_RESULT = (*IC_LEFT);</FONT></TD> </TR> <TR><TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0><FONT SIZE="-1">POINTER_SET</FONT></TD> <TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0> <FONT SIZE="-1">IC_RIGHT() IC_RESULT() </FONT> </TD> <TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0><FONT SIZE="-1">Indirect set</FONT></TD> <TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0><FONT SIZE="-1">(*IC_RESULT) = IC_RIGHT;</FONT></TD> </TR> <TR><TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0><FONT SIZE="-1">'='</FONT></TD> <TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0> <FONT SIZE="-1">IC_RIGHT() IC_RESULT()</FONT> </TD> <TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0><FONT SIZE="-1">Assignment</FONT></TD> <TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0><FONT SIZE="-1">IC_RESULT = IC_RIGHT;</FONT></TD> </TR> <TR><TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0><FONT SIZE="-1">IFX</FONT></TD> <TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0> <FONT SIZE="-1">IC_COND IC_TRUE IC_LABEL</FONT> </TD> <TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0><FONT SIZE="-1">Conditional jump. If true label is present then jump to true label if condition is true else jump to false label if condition is false </FONT></TD> <TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0><FONT SIZE="-1">if (IC_COND) goto IC_TRUE; </FONT> <BR> <FONT SIZE="-1"> Or </FONT> <BR> <FONT SIZE="-1">If (!IC_COND) goto IC_FALSE;</FONT></TD> </TR> <TR><TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0><FONT SIZE="-1">ADDRESS_OF</FONT></TD> <TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0> <FONT SIZE="-1">IC_LEFT() IC_RESULT()</FONT> </TD> <TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0><FONT SIZE="-1">Address of </FONT></TD> <TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0><FONT SIZE="-1">IC_RESULT = &IC_LEFT();</FONT></TD> </TR> <TR><TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0><FONT SIZE="-1">JUMPTABLE</FONT></TD> <TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0> <FONT SIZE="-1">IC_JTCOND IC_JTLABELS</FONT> </TD> <TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0><FONT SIZE="-1">Jump to list of labels depending on the value of JTCOND</FONT></TD> <TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0><FONT SIZE="-1">Switch statement</FONT></TD> </TR> <TR><TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0><FONT SIZE="-1">CAST</FONT></TD> <TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0> <FONT SIZE="-1">IC_RIGHT() IC_LEFT() IC_RESULT()</FONT> </TD> <TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0><FONT SIZE="-1">Cast types </FONT></TD> <TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0><FONT SIZE="-1">IC_RESULT = (typeof IC_LEFT) IC_RIGHT;</FONT></TD> </TR> <TR><TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0><FONT SIZE="-1">SEND</FONT></TD> <TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0> <FONT SIZE="-1">IC_LEFT()</FONT> </TD> <TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0><FONT SIZE="-1">This is used for passing parameters in registers; </FONT> <BR> <FONT SIZE="-1">move IC_LEFT to the next available parameter register.</FONT></TD> <TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0><FONT SIZE="-1">None</FONT></TD> </TR> <TR><TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0><FONT SIZE="-1">RECV</FONT></TD> <TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0> <FONT SIZE="-1">IC_RESULT()</FONT> </TD> <TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0><FONT SIZE="-1">This is used for receiving parameters passed in registers;</FONT> <BR> <FONT SIZE="-1">Move the values in the next parameter register to IC_RESULT </FONT></TD> <TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0><FONT SIZE="-1">None</FONT></TD> </TR> <TR><TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0><I><FONT SIZE="-1">(some more have been added)</FONT></I></TD> <TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0> </TD> <TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0> </TD> <TD ALIGN="LEFT" VALIGN="TOP" WIDTH=0><I><FONT SIZE="-1">see f.e.</FONT></I><FONT SIZE="-1"> </FONT><TT><I><FONT SIZE="-1">gen51Code()</I></FONT></TT><I><FONT SIZE="-1">in</FONT></I><FONT SIZE="-1"> </FONT><TT><I><FONT SIZE="-1">src/mcs51/gen.c</I></FONT></TT></TD> </TR> </TABLE> <P> <P> <H4><A NAME="SECTION001010070000000000000"></A><A NAME="4704"></A> <BR> ICode Example </H4> <P> This section shows some details of iCode. The example C code does not do anything useful; it is used as an example to illustrate the intermediate code generated by the compiler. <BLOCKQUOTE> <TT>1. __xdata int * p;</TT> <BR><TT>2. int gint;</TT> <BR><TT>3. /* This function does nothing useful. It is used</TT> <BR><TT>4. for the purpose of explaining iCode */</TT> <BR><TT>5. short function (__data int *x)</TT> <BR><TT>6. {</TT> <BR><TT>7. short i=10; /* dead initialization eliminated */</TT> <BR><TT>8. short sum=10; /* dead initialization eliminated */</TT> <BR><TT>9. short mul;</TT> <BR><TT>10. int j ;</TT> <BR><TT>11. while (*x) *x++ = *p++; </TT> <BR><TT>12. sum = 0 ; </TT> <BR><TT>13. mul = 0;</TT> <BR><TT>14. /* compiler detects i,j to be induction variables */</TT> <BR><TT>15. for (i = 0, j = 10 ; i < 10 ; i++, j</TT>--<TT>) {</TT> <BR><TT>16. sum += i;</TT> <BR><TT>17. mul += i * 3; /* this multiplication remains */</TT> <BR><TT>18. gint += j * 3; /* this multiplication changed to addition */</TT> <BR><TT>19. }</TT> <BR><TT>20. return sum+mul;</TT> <BR><TT>21. }</TT> </BLOCKQUOTE> In addition to the operands each iCode contains information about the filename and line it corresponds to in the source file. The first field in the listing should be interpreted as follows: <BR><I><FONT SIZE="-1">Filename(linenumber: iCode Execution sequence number : ICode hash table key : loop depth of the iCode).</FONT></I> <BR> Then follows the human readable form of the ICode operation. Each operand of this triplet form can be of three basic types a) compiler generated temporary b) user defined variable c) a constant value. Note that local variables and parameters are replaced by compiler generated temporaries. Live ranges<A NAME="4739"></A> are computed only for temporaries (i.e. live ranges are not computed for global variables). Registers<A NAME="4740"></A> are allocated for temporaries only. Operands are formatted in the following manner: <BR><I><FONT SIZE="-1">Operand Name [lr live-from : live-to ] { type information } [ registers allocated ].</FONT></I> <BR> As mentioned earlier the live ranges are computed in terms of the execution sequence number of the iCodes, for example <BR> the iTemp0 is live from (i.e. first defined in iCode with execution sequence number 3, and is last used in the iCode with sequence number 5). For induction variables such as iTemp21 the live range computation extends the lifetime from the start to the end of the loop. <BR> The register allocator used the live range information to allocate registers, the same registers may be used for different temporaries if their live ranges do not overlap, for example r0 is allocated to both iTemp6 and to iTemp17 since their live ranges do not overlap. In addition the allocator also takes into consideration the type and usage of a temporary, for example itemp6 is a pointer to near space and is used as to fetch data from (i.e. used in GET_VALUE_AT_ADDRESS) so it is allocated a pointer register (r0). Some short lived temporaries are allocated to special registers which have meaning to the code generator e.g. iTemp13 is allocated to a pseudo register CC which tells the back end that the temporary is used only for a conditional jump the code generation makes use of this information to optimize a compare and jump ICode. <BR> There are several loop optimizations<A NAME="4745"></A> performed by the compiler. It can detect induction variables iTemp21(i) and iTemp23(j). Also note the compiler does selective strength reduction<A NAME="4746"></A>, i.e. the multiplication of an induction variable in line 18 (gint = j * 3) is changed to addition, a new temporary iTemp17 is allocated and assigned a initial value, a constant 3 is then added for each iteration of the loop. The compiler does not change the multiplication<A NAME="4748"></A> in line 17 however since the processor does support an 8 * 8 bit multiplication. <BR> Note the dead code elimination<A NAME="4750"></A> optimization eliminated the dead assignments in line 7 & 8 to I and sum respectively. <BR> <P> <FONT SIZE="-1">Sample.c (5:1:0:0) _entry($9) :</FONT> <P> <P> <FONT SIZE="-1">Sample.c(5:2:1:0) proc _function [lr0:0]{function short}</FONT> <P> <P> <FONT SIZE="-1">Sample.c(11:3:2:0) iTemp0 [lr3:5]{_near * int}[r2] = recv </FONT> <P> <P> <FONT SIZE="-1">Sample.c(11:4:53:0) preHeaderLbl0($11) :</FONT> <P> <P> <FONT SIZE="-1">Sample.c(11:5:55:0) iTemp6 [lr5:16]{_near * int}[r0] := iTemp0 [lr3:5]{_near * int}[r2]</FONT> <P> <P> <FONT SIZE="-1">Sample.c(11:6:5:1) _whilecontinue_0($1) :</FONT> <P> <P> <FONT SIZE="-1">Sample.c(11:7:7:1) iTemp4 [lr7:8]{int}[r2 r3] = @[iTemp6 [lr5:16]{_near * int}[r0]]</FONT> <P> <P> <FONT SIZE="-1">Sample.c(11:8:8:1) if iTemp4 [lr7:8]{int}[r2 r3] == 0 goto _whilebreak_0($3)</FONT> <P> <P> <FONT SIZE="-1">Sample.c(11:9:14:1) iTemp7 [lr9:13]{_far * int}[DPTR] := _p [lr0:0]{_far * int}</FONT> <P> <P> <FONT SIZE="-1">Sample.c(11:10:15:1) _p [lr0:0]{_far * int} = _p [lr0:0]{_far * int} + 0x2 {short}</FONT> <P> <P> <FONT SIZE="-1">Sample.c(11:13:18:1) iTemp10 [lr13:14]{int}[r2 r3] = @[iTemp7 [lr9:13]{_far * int}[DPTR]]</FONT> <P> <P> <FONT SIZE="-1">Sample.c(11:14:19:1) *(iTemp6 [lr5:16]{_near * int}[r0]) := iTemp10 [lr13:14]{int}[r2 r3]</FONT> <P> <P> <FONT SIZE="-1">Sample.c(11:15:12:1) iTemp6 [lr5:16]{_near * int}[r0] = iTemp6 [lr5:16]{_near * int}[r0] + 0x2 {short}</FONT> <P> <P> <FONT SIZE="-1">Sample.c(11:16:20:1) goto _whilecontinue_0($1)</FONT> <P> <P> <FONT SIZE="-1">Sample.c(11:17:21:0)_whilebreak_0($3) :</FONT> <P> <P> <FONT SIZE="-1">Sample.c(12:18:22:0) iTemp2 [lr18:40]{short}[r2] := 0x0 {short}</FONT> <P> <P> <FONT SIZE="-1">Sample.c(13:19:23:0) iTemp11 [lr19:40]{short}[r3] := 0x0 {short}</FONT> <P> <P> <FONT SIZE="-1">Sample.c(15:20:54:0)preHeaderLbl1($13) :</FONT> <P> <P> <FONT SIZE="-1">Sample.c(15:21:56:0) iTemp21 [lr21:38]{short}[r4] := 0x0 {short}</FONT> <P> <P> <FONT SIZE="-1">Sample.c(15:22:57:0) iTemp23 [lr22:38]{int}[r5 r6] := 0xa {int}</FONT> <P> <P> <FONT SIZE="-1">Sample.c(15:23:58:0) iTemp17 [lr23:38]{int}[r7 r0] := 0x1e {int}</FONT> <P> <P> <FONT SIZE="-1">Sample.c(15:24:26:1)_forcond_0($4) :</FONT> <P> <P> <FONT SIZE="-1">Sample.c(15:25:27:1) iTemp13 [lr25:26]{char}[CC] = iTemp21 [lr21:38]{short}[r4] < 0xa {short}</FONT> <P> <P> <FONT SIZE="-1">Sample.c(15:26:28:1) if iTemp13 [lr25:26]{char}[CC] == 0 goto _forbreak_0($7)</FONT> <P> <P> <FONT SIZE="-1">Sample.c(16:27:31:1) iTemp2 [lr18:40]{short}[r2] = iTemp2 [lr18:40]{short}[r2] + ITemp21 [lr21:38]{short}[r4]</FONT> <P> <P> <FONT SIZE="-1">Sample.c(17:29:33:1) iTemp15 [lr29:30]{short}[r1] = iTemp21 [lr21:38]{short}[r4] * 0x3 {short}</FONT> <P> <P> <FONT SIZE="-1">Sample.c(17:30:34:1) iTemp11 [lr19:40]{short}[r3] = iTemp11 [lr19:40]{short}[r3] + iTemp15 [lr29:30]{short}[r1]</FONT> <P> <P> <FONT SIZE="-1">Sample.c(18:32:36:1:1) iTemp17 [lr23:38]{int}[r7 r0]= iTemp17 [lr23:38]{int}[r7 r0]- 0x3 {short}</FONT> <P> <P> <FONT SIZE="-1">Sample.c(18:33:37:1) _gint [lr0:0]{int} = _gint [lr0:0]{int} + iTemp17 [lr23:38]{int}[r7 r0]</FONT> <P> <P> <FONT SIZE="-1">Sample.c(15:36:42:1) iTemp21 [lr21:38]{short}[r4] = iTemp21 [lr21:38]{short}[r4] + 0x1 {short}</FONT> <P> <P> <FONT SIZE="-1">Sample.c(15:37:45:1) iTemp23 [lr22:38]{int}[r5 r6]= iTemp23 [lr22:38]{int}[r5 r6]- 0x1 {short}</FONT> <P> <P> <FONT SIZE="-1">Sample.c(19:38:47:1) goto _forcond_0($4)</FONT> <P> <P> <FONT SIZE="-1">Sample.c(19:39:48:0)_forbreak_0($7) :</FONT> <P> <P> <FONT SIZE="-1">Sample.c(20:40:49:0) iTemp24 [lr40:41]{short}[DPTR] = iTemp2 [lr18:40]{short}[r2] + ITemp11 [lr19:40]{short}[r3]</FONT> <P> <P> <FONT SIZE="-1">Sample.c(20:41:50:0) ret iTemp24 [lr40:41]{short}</FONT> <P> <P> <FONT SIZE="-1">Sample.c(20:42:51:0)_return($8) :</FONT> <P> <P> <FONT SIZE="-1">Sample.c(20:43:52:0) eproc _function [lr0:0]{ ia0 re0 rm0}{function short}</FONT> <BR> <BR> Finally the code generated for this function: <BR> <P> <FONT SIZE="-1">.area DSEG (DATA)</FONT> <P> <P> <FONT SIZE="-1">_p::</FONT> <P> <P> <FONT SIZE="-1"> .ds 2</FONT> <P> <P> <FONT SIZE="-1">_gint::</FONT> <P> <P> <FONT SIZE="-1"> .ds 2</FONT> <P> <P> <FONT SIZE="-1">; sample.c 5</FONT> <P> <P> <FONT SIZE="-1">; -----------------------</FONT> <P> <P> <FONT SIZE="-1">; function function</FONT> <P> <P> <FONT SIZE="-1">; -----------------------</FONT> <P> <P> <FONT SIZE="-1">_function:</FONT> <P> <P> <FONT SIZE="-1">; iTemp0 [lr3:5]{_near * int}[r2] = recv </FONT> <P> <P> <FONT SIZE="-1"> mov r2,dpl</FONT> <P> <P> <FONT SIZE="-1">; iTemp6 [lr5:16]{_near * int}[r0] := iTemp0 [lr3:5]{_near * int}[r2]</FONT> <P> <P> <FONT SIZE="-1"> mov ar0,r2</FONT> <P> <P> <FONT SIZE="-1">;_whilecontinue_0($1) :</FONT> <P> <P> <FONT SIZE="-1">00101$:</FONT> <P> <P> <FONT SIZE="-1">; iTemp4 [lr7:8]{int}[r2 r3] = @[iTemp6 [lr5:16]{_near * int}[r0]]</FONT> <P> <P> <FONT SIZE="-1">; if iTemp4 [lr7:8]{int}[r2 r3] == 0 goto _whilebreak_0($3)</FONT> <P> <P> <FONT SIZE="-1"> mov ar2,@r0</FONT> <P> <P> <FONT SIZE="-1"> inc r0</FONT> <P> <P> <FONT SIZE="-1"> mov ar3,@r0</FONT> <P> <P> <FONT SIZE="-1"> dec r0</FONT> <P> <P> <FONT SIZE="-1"> mov a,r2</FONT> <P> <P> <FONT SIZE="-1"> orl a,r3</FONT> <P> <P> <FONT SIZE="-1"> jz 00103$</FONT> <P> <P> <FONT SIZE="-1">00114$:</FONT> <P> <P> <FONT SIZE="-1">; iTemp7 [lr9:13]{_far * int}[DPTR] := _p [lr0:0]{_far * int}</FONT> <P> <P> <FONT SIZE="-1"> mov dpl,_p</FONT> <P> <P> <FONT SIZE="-1"> mov dph,(_p + 1)</FONT> <P> <P> <FONT SIZE="-1">; _p [lr0:0]{_far * int} = _p [lr0:0]{_far * int} + 0x2 {short}</FONT> <P> <P> <FONT SIZE="-1"> mov a,#0x02</FONT> <P> <P> <FONT SIZE="-1"> add a,_p</FONT> <P> <P> <FONT SIZE="-1"> mov _p,a</FONT> <P> <P> <FONT SIZE="-1"> clr a</FONT> <P> <P> <FONT SIZE="-1"> addc a,(_p + 1)</FONT> <P> <P> <FONT SIZE="-1"> mov (_p + 1),a</FONT> <P> <P> <FONT SIZE="-1">; iTemp10 [lr13:14]{int}[r2 r3] = @[iTemp7 [lr9:13]{_far * int}[DPTR]]</FONT> <P> <P> <FONT SIZE="-1"> movx a,@dptr</FONT> <P> <P> <FONT SIZE="-1"> mov r2,a</FONT> <P> <P> <FONT SIZE="-1"> inc dptr</FONT> <P> <P> <FONT SIZE="-1"> movx a,@dptr</FONT> <P> <P> <FONT SIZE="-1"> mov r3,a</FONT> <P> <P> <FONT SIZE="-1">; *(iTemp6 [lr5:16]{_near * int}[r0]) := iTemp10 [lr13:14]{int}[r2 r3]</FONT> <P> <P> <FONT SIZE="-1"> mov @r0,ar2</FONT> <P> <P> <FONT SIZE="-1"> inc r0</FONT> <P> <P> <FONT SIZE="-1"> mov @r0,ar3</FONT> <P> <P> <FONT SIZE="-1">; iTemp6 [lr5:16]{_near * int}[r0] = </FONT> <P> <P> <FONT SIZE="-1">; iTemp6 [lr5:16]{_near * int}[r0] + </FONT> <P> <P> <FONT SIZE="-1">; 0x2 {short}</FONT> <P> <P> <FONT SIZE="-1"> inc r0</FONT> <P> <P> <FONT SIZE="-1">; goto _whilecontinue_0($1)</FONT> <P> <P> <FONT SIZE="-1"> sjmp 00101$</FONT> <P> <P> <FONT SIZE="-1">; _whilebreak_0($3) :</FONT> <P> <P> <FONT SIZE="-1">00103$:</FONT> <P> <P> <FONT SIZE="-1">; iTemp2 [lr18:40]{short}[r2] := 0x0 {short}</FONT> <P> <P> <FONT SIZE="-1"> mov r2,#0x00</FONT> <P> <P> <FONT SIZE="-1">; iTemp11 [lr19:40]{short}[r3] := 0x0 {short}</FONT> <P> <P> <FONT SIZE="-1"> mov r3,#0x00</FONT> <P> <P> <FONT SIZE="-1">; iTemp21 [lr21:38]{short}[r4] := 0x0 {short}</FONT> <P> <P> <FONT SIZE="-1"> mov r4,#0x00</FONT> <P> <P> <FONT SIZE="-1">; iTemp23 [lr22:38]{int}[r5 r6] := 0xa {int}</FONT> <P> <P> <FONT SIZE="-1"> mov r5,#0x0A</FONT> <P> <P> <FONT SIZE="-1"> mov r6,#0x00</FONT> <P> <P> <FONT SIZE="-1">; iTemp17 [lr23:38]{int}[r7 r0] := 0x1e {int}</FONT> <P> <P> <FONT SIZE="-1"> mov r7,#0x1E</FONT> <P> <P> <FONT SIZE="-1"> mov r0,#0x00</FONT> <P> <P> <FONT SIZE="-1">; _forcond_0($4) :</FONT> <P> <P> <FONT SIZE="-1">00104$:</FONT> <P> <P> <FONT SIZE="-1">; iTemp13 [lr25:26]{char}[CC] = iTemp21 [lr21:38]{short}[r4] < 0xa {short}</FONT> <P> <P> <FONT SIZE="-1">; if iTemp13 [lr25:26]{char}[CC] == 0 goto _forbreak_0($7)</FONT> <P> <P> <FONT SIZE="-1"> clr c</FONT> <P> <P> <FONT SIZE="-1"> mov a,r4</FONT> <P> <P> <FONT SIZE="-1"> xrl a,#0x80</FONT> <P> <P> <FONT SIZE="-1"> subb a,#0x8a</FONT> <P> <P> <FONT SIZE="-1"> jnc 00107$</FONT> <P> <P> <FONT SIZE="-1">00115$:</FONT> <P> <P> <FONT SIZE="-1">; iTemp2 [lr18:40]{short}[r2] = iTemp2 [lr18:40]{short}[r2] + </FONT> <P> <P> <FONT SIZE="-1">; iTemp21 [lr21:38]{short}[r4]</FONT> <P> <P> <FONT SIZE="-1"> mov a,r4</FONT> <P> <P> <FONT SIZE="-1"> add a,r2</FONT> <P> <P> <FONT SIZE="-1"> mov r2,a</FONT> <P> <P> <FONT SIZE="-1">; iTemp15 [lr29:30]{short}[r1] = iTemp21 [lr21:38]{short}[r4] * 0x3 {short}</FONT> <P> <P> <FONT SIZE="-1"> mov b,#0x03</FONT> <P> <P> <FONT SIZE="-1"> mov a,r4</FONT> <P> <P> <FONT SIZE="-1"> mul ab</FONT> <P> <P> <FONT SIZE="-1"> mov r1,a</FONT> <P> <P> <FONT SIZE="-1">; iTemp11 [lr19:40]{short}[r3] = iTemp11 [lr19:40]{short}[r3] + </FONT> <P> <P> <FONT SIZE="-1">; iTemp15 [lr29:30]{short}[r1]</FONT> <P> <P> <FONT SIZE="-1"> add a,r3</FONT> <P> <P> <FONT SIZE="-1"> mov r3,a</FONT> <P> <P> <FONT SIZE="-1">; iTemp17 [lr23:38]{int}[r7 r0]= iTemp17 [lr23:38]{int}[r7 r0]- 0x3 {short}</FONT> <P> <P> <FONT SIZE="-1"> mov a,r7</FONT> <P> <P> <FONT SIZE="-1"> add a,#0xfd</FONT> <P> <P> <FONT SIZE="-1"> mov r7,a</FONT> <P> <P> <FONT SIZE="-1"> mov a,r0</FONT> <P> <P> <FONT SIZE="-1"> addc a,#0xff</FONT> <P> <P> <FONT SIZE="-1"> mov r0,a</FONT> <P> <P> <FONT SIZE="-1">; _gint [lr0:0]{int} = _gint [lr0:0]{int} + iTemp17 [lr23:38]{int}[r7 r0]</FONT> <P> <P> <FONT SIZE="-1"> mov a,r7</FONT> <P> <P> <FONT SIZE="-1"> add a,_gint</FONT> <P> <P> <FONT SIZE="-1"> mov _gint,a</FONT> <P> <P> <FONT SIZE="-1"> mov a,r0</FONT> <P> <P> <FONT SIZE="-1"> addc a,(_gint + 1)</FONT> <P> <P> <FONT SIZE="-1"> mov (_gint + 1),a</FONT> <P> <P> <FONT SIZE="-1">; iTemp21 [lr21:38]{short}[r4] = iTemp21 [lr21:38]{short}[r4] + 0x1 {short}</FONT> <P> <P> <FONT SIZE="-1"> inc r4</FONT> <P> <P> <FONT SIZE="-1">; iTemp23 [lr22:38]{int}[r5 r6]= iTemp23 [lr22:38]{int}[r5 r6]- 0x1 {short}</FONT> <P> <P> <FONT SIZE="-1"> dec r5</FONT> <P> <P> <FONT SIZE="-1"> cjne r5,#0xff,00104$</FONT> <P> <P> <FONT SIZE="-1"> dec r6</FONT> <P> <P> <FONT SIZE="-1">; goto _forcond_0($4)</FONT> <P> <P> <FONT SIZE="-1"> sjmp 00104$</FONT> <P> <P> <FONT SIZE="-1">; _forbreak_0($7) :</FONT> <P> <P> <FONT SIZE="-1">00107$:</FONT> <P> <P> <FONT SIZE="-1">; ret iTemp24 [lr40:41]{short}</FONT> <P> <P> <FONT SIZE="-1"> mov a,r3</FONT> <P> <P> <FONT SIZE="-1"> add a,r2</FONT> <P> <P> <FONT SIZE="-1"> mov dpl,a</FONT> <P> <P> <FONT SIZE="-1">; _return($8) :</FONT> <P> <P> <FONT SIZE="-1">00108$:</FONT> <P> <P> <FONT SIZE="-1"> ret</FONT> <BR> <P> <P> <BR><HR> <!--Table of Child-Links--> <A NAME="CHILD_LINKS"><STRONG>Subsections</STRONG></A> <UL> <LI><UL> <LI><UL> <LI><A NAME="tex2html3616" HREF="node187.html#SECTION001010010000000000000">Parsing </A> <LI><A NAME="tex2html3617" HREF="node187.html#SECTION001010020000000000000">Generating iCode</A> <LI><A NAME="tex2html3618" HREF="node187.html#SECTION001010030000000000000">Optimizations.</A> <LI><A NAME="tex2html3619" HREF="node187.html#SECTION001010040000000000000">Live range analysis</A> <LI><A NAME="tex2html3620" HREF="node187.html#SECTION001010050000000000000">Register Allocation</A> <LI><A NAME="tex2html3621" HREF="node187.html#SECTION001010060000000000000">Code generation</A> <LI><A NAME="tex2html3622" HREF="node187.html#SECTION001010070000000000000">ICode Example</A> </UL></UL></UL> <!--End of Table of Child-Links--> <HR> <!--Navigation Panel--> <A NAME="tex2html3614" HREF="node188.html"> <IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next" SRC="next.png"></A> <A NAME="tex2html3608" HREF="node186.html"> <IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up" SRC="up.png"></A> <A NAME="tex2html3602" HREF="node186.html"> <IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous" SRC="prev.png"></A> <A NAME="tex2html3610" HREF="node1.html"> <IMG WIDTH="65" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="contents" SRC="contents.png"></A> <A NAME="tex2html3612" HREF="node191.html"> <IMG WIDTH="43" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="index" SRC="index.png"></A> <BR> <B> Next:</B> <A NAME="tex2html3615" HREF="node188.html">9.2 A few words</A> <B> Up:</B> <A NAME="tex2html3609" HREF="node186.html">9. Compiler internals</A> <B> Previous:</B> <A NAME="tex2html3603" HREF="node186.html">9. Compiler internals</A> <B> <A NAME="tex2html3611" HREF="node1.html">Contents</A></B> <B> <A NAME="tex2html3613" HREF="node191.html">Index</A></B> <!--End of Navigation Panel--> <ADDRESS> 2011-03-20 </ADDRESS> </BODY> </HTML>