
ttest test _fnc( ttest z )it will be interpreted as if it was defined as
void test_fnc( ttest *result_ptr, ttest z )so now first argument of function isnt stored under [EBP+08h], where now is placed pointer to return value. pointer is 4bytes long so first argument can be found under [EBP+0ch]. to set up return structure, we will need to use pointer stored in [EBP+08h] to get to the return structure.
if we define the same function in delphi
function test_fnc( z : ttest) : ttestdelphi compiler will treat that function as a procedure of type
procedure test_fnc( z:ttest; var result:ttest )in this case argument of our function will be pointed by EAX register, as we can see result structure of our function is treated as a second argument and EDX register points to it. so if we want to set up result value using assebler, we will just need to use EDX register.