Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Object-Pascal / Delphi-Language (https://www.delphipraxis.net/32-object-pascal-delphi-language/)
-   -   Delphi is there any error in this function (https://www.delphipraxis.net/167254-there-any-error-function.html)

randy_dom 20. Mär 2012 11:38

Delphi-Version: 7

is there any error in this function
 
here is my function

Delphi-Quellcode:
Function call_to_func(mem, a, c: DWORD): integer;
var
b: integer;
begin
b := 0;
writeln(format('call_to_func: mem=%X a=%X c=%X',[mem,a,c]));
asm
mov ecx,a
mov edx,c
mov eax, mem
push ecx
call eax //--->!!! Program try to call assembled code which is stored in mem pointer
pop ecx
mov b, eax
end;
call_to_func := b;
end;
But when i call it i get an AV

Access violation at address 01496180. Write of address 01496180
...........
01496180 push esi ; <-- EXCEPTION
............

call_to_func works correctly
and assembled function called by "call eax"
but this assembled function can not push register??!!
stack not writeable???
All this under windows 7 .


Please is there any error in the above Function ?


many thanks

Bummi 20. Mär 2012 11:52

AW: is there any error in this function
 
Delphi-Quellcode:
Function call_to_func(mem, a, c: DWORD): integer;
var
b: integer;
begin
b := 0;

asm
mov ecx,mem
mov edx,c
mov eax, a
push ecx
call ecx //--->!!! Program try to call assembled code which is stored in mem pointer
pop ecx
mov b, eax
end;
call_to_func := b;
end;

randy_dom 20. Mär 2012 12:17

AW: is there any error in this function
 
thank you Bummi , But can you explain me what's the difference between my function and your modified one ?

Bummi 20. Mär 2012 12:25

AW: is there any error in this function
 
my assembler time is years ago, perhaps this will help
http://www.delphipraxis.net/8982-inl...uebergabe.html


Alle Zeitangaben in WEZ +1. Es ist jetzt 20:36 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz