(→Postfix Code) |
|||
Line 3: | Line 3: | ||
Consider the following C function: | Consider the following C function: | ||
− | <c> | + | <source lang="c"> |
int gcd(int a, int b) { | int gcd(int a, int b) { | ||
static int temp = 0; | static int temp = 0; | ||
Line 15: | Line 15: | ||
return b; | return b; | ||
} | } | ||
− | </ | + | </source> |
== Postfix Code == | == Postfix Code == | ||
Line 21: | Line 21: | ||
The Postfix code for the above function is as follows: | The Postfix code for the above function is as follows: | ||
{{CollapsedCode|Postfix code| | {{CollapsedCode|Postfix code| | ||
− | <asm> | + | <source lang="asm"> |
− | </ | + | </source> |
}} | }} | ||
Consider the following C function:
int gcd(int a, int b) {
static int temp = 0;
if (temp) temp = swap(&a, &b);
while (1) {
a %= b;
if (a == 0) break;
b %= a;
if (b == 0) return a;
}
return b;
}
The Postfix code for the above function is as follows:
[Expand] Postfix code |
---|
To compile the Postfix code directly, pf2asm can be used:
pf2asm gcd.pf yasm -felf gcd.asm