Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int get_c_from_a (int a)
- {
- struct s tmp;
- tmp = get_some_values(a);
- return tmp.c;
- }
- ======
- get_c_from_a:
- ; prolog - setup the local frame
- push ebp
- mov ebp, esp
- sub esp, 0xc ; make room on the stack for tmp (3 * 4-byte ints)
- mov eax, [ebp+8] ; eax = arg1 to get_c_from_a = a
- push eax ; pushing it as arg1 to get_some_values
- lea eax, [ebp-0xc] ; eax = &tmp
- push eax ; push &tmp (we only push a return value pointer for complex return objects)
- call get_some_values
- ; our struct now looks like
- ; [ebp-c]: tmp.a = a + 1
- ; [ebp-8]: tmp.b = a + 2
- ; [ebp-4]: tmp.c = a + 3
- ; and we want to return tmp.c in eax
- mov eax, [ebp-4]
- ; epilog - restores esp and ebp to their entry values, cleaning up our stack usage
- mov esp, ebp
- pop ebp
- ret
Advertisement
Add Comment
Please, Sign In to add comment