Code Generation/Exercise 7
From Wiki**3
< Code Generation
The Original Code
Consider the following C function:
<c> int *traverse(int vec[], int lim) {
int *ptr = vec + lim - 1, ix = lim - 2; while (ix >= 0) { ptr = (vec[ix] > *ptr) ? vec + ix : ptr; ix--; } return ptr;
} </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 traverse.pf yasm -felf traverse.asm