Трансляция объектов в машинный код в Delphi
В объектном стиле |
В процедурном стиле |
program ObjTest;
uses Windows;
type T_TEST = Class
procedure test();
end;
procedure T_TEST.test();
begin
MessageBox(0, 'test', 'test',0);
end;
var obj: T_TEST;
begin
obj:=T_TEST.Create;
obj.Test();
obj.Test();
obj.Free;
end. |
program ObjTest;
uses Windows;
procedure test();
begin
MessageBox(0, 'test', 'test',0);
end;
begin
Test();
Test();
end.
|
mov eax, ebx
call 00403620
mov eax, ebx
call 00403620
...
00403620:
push 00
push 00403640; "test"
push 00403640; "test"
push 00
call User32!MessageBoxA
ret
|
call 00401E90
call 00401E90
...
00401E90:
push 00
push 00403640; "test"
push 00403640; "test"
push 00
call User32!MessageBoxA
ret
|
В объектном стиле | В процедурном стиле |
program ObjTest;
uses Windows;
type T_TEST = Class
function add(a,b: Integer):Integer;
end;
function T_TEST.add(a,b: Integer):Integer;
begin
MessageBox(0, 'test', 'test',0);
Result:=a+b;
end;
var obj: T_TEST;
begin
obj:=T_TEST.Create;
obj.add(2,3);
obj.add(3,4);
obj.Free;
end. |
program ObjTest;
uses Windows;
function add(a,b: Integer):Integer;
begin
MessageBox(0, 'test', 'test',0);
Result:=a+b;
end;
begin
add(2,3);
add(3,4);
end.
|
mov ecx, 00000004
mov edx, 00000003
mov eax, ebx
call 00403620
...
00403620:
push ebx
push esi
mov esi, ecx
mov ebx, edx
push 00
push 00403640; "test"
push 00403640; "test"
push 00
call User32!MessageBoxA
lea eax, [ebx+esi]
pop esi
pop ebx
ret
|
mov edx, 00000004
mov eax, 00000003
call 00401E90
...
00401E90:
push ebx
push esi
mov esi, edx
mov ebx, eax
push 00
push 00403640; "test"
push 00403640; "test"
push 00
call User32!MessageBoxA
lea eax, [ebx+esi]
pop esi
pop ebx
ret
|
|