Created
December 2, 2012 22:26
-
-
Save wjlafrance/4191330 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <stdio.h> | |
int main(int argc, char **argv) { | |
void(^doHello)() = ^{ | |
printf("Hello\n"); | |
}; | |
doHello(); | |
return 0; | |
} | |
__text:00001F10 ; Attributes: bp-based frame | |
__text:00001F10 | |
__text:00001F10 ; int __cdecl main(int argc, char **argv) | |
__text:00001F10 public _main | |
__text:00001F10 _main proc near | |
__text:00001F10 | |
__text:00001F10 var_zero = dword ptr -18h | |
__text:00001F10 var_blockptr = dword ptr -14h | |
__text:00001F10 var_argv = dword ptr -10h | |
__text:00001F10 var_argc = dword ptr -0Ch | |
__text:00001F10 var_unused = dword ptr -8 | |
__text:00001F10 argc = dword ptr 8 | |
__text:00001F10 argv = dword ptr 0Ch | |
__text:00001F10 | |
__text:00001F10 push ebp | |
__text:00001F11 mov ebp, esp | |
__text:00001F13 push esi | |
__text:00001F14 sub esp, 24h ; set 0x24 byte stack | |
__text:00001F14 ; esp is extended (32-bit) stack pointer | |
__text:00001F17 call $+5 | |
__text:00001F1C pop eax | |
__text:00001F1D mov ecx, [ebp+argv] | |
__text:00001F20 mov edx, [ebp+argc] | |
__text:00001F23 mov esi, 0 | |
__text:00001F28 lea eax, [eax+104h] ; copy block pointer to register | |
__text:00001F2E mov [ebp+var_unused], 0 | |
__text:00001F35 mov [ebp+var_argc], edx ; args are moved to vars on stack | |
__text:00001F38 mov [ebp+var_argv], ecx | |
__text:00001F3B mov [ebp+var_blockptr], eax | |
__text:00001F3E mov eax, [ebp+var_blockptr] ; <-- that's awful redundant isn't it clang? | |
__text:00001F41 mov ecx, eax | |
__text:00001F43 mov [esp], ecx ; put block pointer first on stack | |
__text:00001F46 mov [ebp+var_zero], esi ; esi is zero, from 1F23 | |
__text:00001F46 ; weird that return code is setup before func is called? | |
__text:00001F49 call [eax+BlockStruct.invoke] ; blockFunc(var_blockptr) | |
__text:00001F4C mov eax, [ebp+var_zero] ; set eax to zero (eax holds return code) | |
__text:00001F4F add esp, 24h ; empty stack | |
__text:00001F52 pop esi | |
__text:00001F53 pop ebp | |
__text:00001F54 retn | |
__text:00001F54 _main endp | |
__text:00001F54 | |
__text:00001F54 ; --------------------------------------------------------------------------- | |
__text:00001F55 align 10h | |
__text:00001F60 | |
__text:00001F60 ; =============== S U B R O U T I N E ======================================= | |
__text:00001F60 | |
__text:00001F60 ; Attributes: bp-based frame | |
__text:00001F60 | |
__text:00001F60 ; int __cdecl __main_block_invoke_0(void *blockptr) | |
__text:00001F60 ___main_block_invoke_0 proc near ; DATA XREF: __const:___block_literal_globalo | |
__text:00001F60 | |
__text:00001F60 var_printf_ret = dword ptr -8 | |
__text:00001F60 var_blockptr = dword ptr -4 | |
__text:00001F60 blockptr = dword ptr 8 | |
__text:00001F60 | |
__text:00001F60 push ebp | |
__text:00001F61 mov ebp, esp | |
__text:00001F63 sub esp, 18h ; sets up 0x18 byte stack | |
__text:00001F66 call $+5 | |
__text:00001F6B pop eax | |
__text:00001F6C mov ecx, [ebp+blockptr] | |
__text:00001F6F lea eax, (aHello - 1F6Bh)[eax] ; "Hello\n" | |
__text:00001F75 mov [esp], eax ; moves "Hello\n"* to first stack position | |
__text:00001F78 mov [ebp+var_blockptr], ecx | |
__text:00001F7B call _printf ; printf("Hello\n") | |
__text:00001F80 mov [ebp+var_printf_ret], eax ; return value from printf is stored, unused | |
__text:00001F83 add esp, 18h | |
__text:00001F86 pop ebp | |
__text:00001F87 retn | |
__text:00001F87 ___main_block_invoke_0 endp | |
__text:00001F87 | |
__text:00001F87 __text ends | |
__text:00001F87 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment