Consider the following S9 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>
The Postfix code for the above function is as follows:
<asm> TEXT ALIGN GLOBL click, FUNC LABEL click ENTER 8 ;-- x@+8 dim@+12 res@-4 i@-8
LOCV 12 INT 2 SUB DUP LOCA -8 TRASH 4
LOCV 8 LOCV 12 INT 4 MUL ADD INT 1 INT 4 MUL SUB DUP LOCA -4 TRASH 4
ALIGN LABEL for LOCV -8 INT 0 GE JZ forend
LOCV 8 ; x LOVC -8 ; i INT 4 MUL ADD ; x+i LOAD ; x[i] = *(x+i)
LOCV -4 ; res LOAD ; *res
GT JZ ifend
LOCV 8 ; x LOVC -8 ; i INT 4 MUL ADD ; x+i = &x[i] DUP LOCA -4 ; res = &x[i] TRASH 4
ALIGN LABEL ifend
ALIGN LABEL forincr LOCV -8 ; i DUP INT 1 SUB LOCA -8 TRASH 4
JMP for
ALIGN LABEL forend
LOCV -4 ; res
POP LEAVE RET </asm>
To compile the Postfix code directly, pf2asm can be used: