Code Generation/Example 3

From Wiki**3

< Code Generation
Revision as of 09:29, 9 May 2017 by Root (talk | contribs) (Postfix Code)

The Original Code

Consider the following C function:

<c> int *click(int *x, int dim) {

 int *res, i;
 for (i = dim-2, res = x+dim-1; i >= 0; i--)
   if (x[i] > *res) res = &x[i];
 return res;

} </c>

Postfix Code

The Postfix code for the above function is as follows:

Postfix code
{{{2}}}

Compiling and Running

To compile the Postfix code directly, pf2asm can be used:

  • pf2asm click.pf
  • yasm -felf click.asm