Difference between revisions of "Code Generation/Example 1"

From Wiki**3

< Code Generation
(Postfix Code)
(Postfix Code)
Line 16: Line 16:
  
 
The Postfix code for the above function is as follows:
 
The Postfix code for the above function is as follows:
 +
{{CollapsedCode|Postfix code|
 
<asm>
 
<asm>
 
TEXT
 
TEXT
Line 82: Line 83:
 
RET
 
RET
 
</asm>
 
</asm>
 +
}}
  
 
[[category:Compiladores]]
 
[[category:Compiladores]]
 
[[category:Ensino]]
 
[[category:Ensino]]

Revision as of 09:26, 9 May 2017

The Original Code

Consider the following C function: <c> int main() {

 int n = 45, i = 0, j = 1, *seg = &i;
 while (n-- > 0) {
   print(*seg = i + j);
   seg = (seg == &i) ? &j : &i;
 }
 return 0;

} </c>

Postfix Code

The Postfix code for the above function is as follows:

Postfix code
{{{2}}}