30.04.2013 Views

Compiler Compiler Tutorial

Compiler Compiler Tutorial

Compiler Compiler Tutorial

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Translation<br />

Source Code<br />

int Sqr( int x )<br />

{<br />

var int n = x;<br />

n = n * n;<br />

return n;<br />

}<br />

Target Code<br />

push ebp<br />

mov ebp,esp<br />

sub esp,0CCh<br />

push ebx<br />

push esi<br />

push edi<br />

lea edi,[ebp-0CCh]<br />

mov ecx,33h<br />

mov eax,0CCCCCCCCh<br />

rep stos dword ptr es:[edi]<br />

mov eax,dword ptr [x]<br />

mov dword ptr [n],eax<br />

mov eax,dword ptr [n]<br />

imul eax,dword ptr [n]<br />

mov dword ptr [n],eax<br />

mov eax,dword ptr [n]<br />

pop edi<br />

pop esi<br />

pop ebx<br />

mov esp,ebp<br />

pop ebp<br />

ret

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!