Code Generation/Exercise 8
From Wiki**3
< Code Generation
The Original Code
Consider the following C function:
<c> extern int printf(const char *format, ...); int printlist(int lo, int hi) {
int ix = lo; while (ix < hi) { printf("%d\n", ix); ix++; } return ix;
} </c>
directivas: text data rodata bss align label extrn globl const str char id byte double
acesso: addr addra addrv local loca locv load dload ldchr store dstore stchr alloc dup swap push pop int sp aritmética/lógica: add dadd sub dsub mul dmul div ddiv mod neg gt ge lt le eq ne cmp
bit a bit: rotl rotr shtl shtru shtrs and or not xor
funções/saltos: call ret start enter leave trash jmp jz jnz branch leap
Postfix Code
The Postfix code for the above function is as follows:
<asm>
</asm>
Compiling and Running
To compile the Postfix code directly, pf2asm can be used:
- pf2asm printlist.pf
- yasm -felf printlist.asm