![]() |
ASM in Lazarus
Code:
the code above works in all versions of delphi, I have set {$asmmode intel} but it seams the push is not working, does anyone have an opinion why that could be.
begin
AInt := Args[i]; asm push AInt; end; end; Cheers PS: I am working x64 windows version of lazarus 0.9.30 |
AW: ASM in Lazarus
What means "is not working"?
|
AW: ASM in Lazarus
Zitat:
|
AW: ASM in Lazarus
Zitat:
You might also want to read ![]() Regards, Sven |
AW: ASM in Lazarus
@JamesTKirk
Thank you man, but pushq is an invalid operand. Below is actually the code that worked in Delphi, and I am trying to port it to Laz. Weird thing is, x64 push raises a silent exception and on x86 it crashes the app. I have tried many variations and yet no result. Please if anyone knows what is wrong, help me. Or if anyone has a diff solution for calling dll's dynamically with dynamic parms, please let me know. I am trying to make this work on Lazaruz 0.90, for x64 and x86 on Win, Lin, and Mac.
Code:
function DynamicDllCallName(Dll: String; const Name: String; HasResult: Boolean; var Returned: Cardinal; const Parameters: array of Pointer): Boolean;
var prc: Pointer; x, n: Integer; p: Pointer; dllh: THandle; begin dllh := GetModuleHandle(PChar(Dll)); if dllh = 0 then begin dllh := LoadLibrary(PChar(Dll)); end; if dllh <> 0 then begin prc := GetProcAddress(dllh, PChar(Name)); if Assigned(prc) then begin n := High(Parameters); if n > -1 then begin x := n; repeat p := Parameters[x]; asm PUSH p end; Dec(x); until x = -1; end; asm CALL prc end; if HasResult then begin asm MOV p, EAX end; Returned := Cardinal(p); end else begin Returned := 0; end; end else begin Returned := 0; end; Result := Assigned(prc); end else begin Result := false; end; end; |
AW: ASM in Lazarus
You’re calling
Delphi-Quellcode:
right in the middle of your high level code – this is almost bound to cause problems because the asm code generated by the compiler from your source code most likely uses the stack, too. You were just lucky that it didn’t break before.
push
|
AW: ASM in Lazarus
Zitat:
I am trying to find a way to do the same in Lazarus. I also tried to make a simple call without any params (so a simple
Delphi-Quellcode:
)
asm call proc; end;
and does not work either. I think this is a FPC bug. |
AW: ASM in Lazarus
Zitat:
Zitat:
Also: Have you checked what instructions the FPC compiler actually generates? I don’t know if FPC/Lazarus comes with a debugger like the one included in Delphi where you can set a breakpoint somewhere in the source code and then switch to the cpu pane to see the generated asm code... that would be the easiest way. If there isn’t such a thing, you could always put an
Delphi-Quellcode:
(which acts as a breakpoint) at the beginning of the routine and run it through an ordinary debugger (though it will be more difficult to figure out which opcodes correspond to which instruction in the source code that way). If it really is a bug in FPC, you may spot something here.
asm int 3; end;
|
AW: ASM in Lazarus
Zitat:
|
AW: ASM in Lazarus
Zitat:
![]() Regards, Sven |
Alle Zeitangaben in WEZ +1. Es ist jetzt 22:17 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz