25.10.2015 Views

Write You a Haskell Stephen Diehl

1kEcQTb

1kEcQTb

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.

f:<br />

mov res, arg<br />

add res, 1<br />

ret<br />

define i32 @f(i32 %x) {<br />

entry:<br />

%add = add nsw i32 %x, 1<br />

ret i32 %add<br />

}<br />

From here the target language can be compiled into the system’s assembly language. All code that is<br />

required for evaluation is linked into the resulting module.<br />

f:<br />

movl<br />

movl<br />

addl<br />

movl<br />

ret<br />

%edi, -4(%rsp)<br />

-4(%rsp), %edi<br />

$1, %edi<br />

%edi, %eax<br />

And ultimately this code will be assembled into platform specific instructions by the native code generator,<br />

encoded as a predefined sequence of CPU instructions defined by the processor specification.<br />

0000000000000000 :<br />

0: 89 7c 24 fc mov %edi,-0x4(%rsp)<br />

4: 8b 7c 24 fc mov -0x4(%rsp),%edi<br />

8: 81 c7 01 00 00 00 add $0x1,%edi<br />

e: 89 f8 mov %edi,%eax<br />

10: c3 retq<br />

13

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

Saved successfully!

Ooh no, something went wrong!