Lazarus
Home
Help
TinyPortal
Search
Login
Register
Lazarus
»
Forum
»
Free Pascal
»
Beginners
(Moderators:
FPK
,
Tomas Hajny
) »
asm from delphi to fpc
Free Pascal
Website
Downloads
Wiki
Documentation
Bugtracker
Mailing List
Lazarus
Website
Downloads (Laz+FPC)
Packages (OPM)
FAQ
Wiki
Documentation (RTL/FCL/LCL)
Bugtracker
CCR Bugs
IRC channel
GIT
Mailing List
Other languages
Foundation
Website
Useful Wiki Links
Project Roadmap
Getting the Source
Screenshots
How to use the forum
About donations (wiki)
Bookstore
Computer Math and Games in Pascal
(preview)
Lazarus Handbook
Search
Advanced search
Recent
open dialog - default dir...
by
Nicole
[
Today
at 08:02:40 pm]
System.Now gives timestam...
by
Thaddy
[
Today
at 07:59:53 pm]
Installing and using Vamp...
by
Odacir
[
Today
at 07:58:22 pm]
Multidimensional arrays a...
by
Kays
[
Today
at 07:36:57 pm]
Demo Scene Picture sinwav...
by
circular
[
Today
at 07:27:02 pm]
Demo Scene Bitmap Font Sc...
by
KodeZwerg
[
Today
at 07:21:14 pm]
what's difference between...
by
ASerge
[
Today
at 07:09:52 pm]
splitting an image
by
KodeZwerg
[
Today
at 07:07:21 pm]
Debugger error
by
bobonwhidbey
[
Today
at 07:03:07 pm]
How to: create DLL file f...
by
paule32
[
Today
at 07:02:31 pm]
Your best UI design - con...
by
circular
[
Today
at 06:48:12 pm]
Web Applications with Pas...
by
1HuntnMan
[
Today
at 06:44:00 pm]
Converting a string/index...
by
1HuntnMan
[
Today
at 06:35:19 pm]
Drawing grid lines on a t...
by
KodeZwerg
[
Today
at 05:42:19 pm]
Compile/Convert Delphi pr...
by
Martin_fr
[
Today
at 05:29:03 pm]
Lazarus features in a non...
by
Lutz Mändle
[
Today
at 05:26:34 pm]
Lazarus for Windows on aa...
by
msintle
[
Today
at 05:03:57 pm]
AI, NLP and CAI: Text Gen...
by
indydev
[
Today
at 04:51:00 pm]
Parameter passing odditie...
by
KodeZwerg
[
Today
at 03:41:49 pm]
Surf Units in Text Mode I...
by
mosquito
[
Today
at 01:58:21 pm]
Ho Ho Ho IntraWeb in Laza...
by
Thaddy
[
Today
at 01:55:52 pm]
Generics - correct syntax
by
Thaddy
[
Today
at 01:48:32 pm]
FpDebug questions
by
440bx
[
Today
at 01:22:53 pm]
leetcode doesn’t support ...
by
codeninja
[
Today
at 01:16:43 pm]
Can function be used for ...
by
Joanna
[
Today
at 12:48:19 pm]
« previous
next »
Print
Pages: [
1
]
Author
Topic: asm from delphi to fpc (Read 2265 times)
nanobit
Full Member
Posts: 160
asm from delphi to fpc
«
on:
October 23, 2018, 08:26:32 am »
The following delphi asm code (to change the field TFreeObject.VMIndex: Integer)
does not compile with fpc. How could one port this?
Code: Pascal
[Select]
[+]
[-]
procedure
TFreedObject
.
GetVirtualMethodIndex
;
assembler
;
asm
Inc
(
VMIndex
)
;
Inc
(
VMIndex
)
;
Inc
(
VMIndex
)
;
Inc
(
VMIndex
)
;
Inc
(
VMIndex
)
;
Inc
(
VMIndex
)
;
Inc
(
VMIndex
)
;
Inc
(
VMIndex
)
;
Inc
(
VMIndex
)
;
Inc
(
VMIndex
)
;
jmp TFreedObject
.
VirtualMethodError
end
;
Logged
Thaddy
Hero Member
Posts: 14392
Sensorship about opinions does not belong here.
Re: asm from delphi to fpc
«
Reply #1 on:
October 23, 2018, 10:13:11 am »
Such code relies on very low level implementation detail and may even change between Delphi versions: it is bad code! in my opinion.
Since it relies on implementation detail it is not FPC compatible.
But you can use e.g. TObject.MethodAddress
Depends what you want?
[edit]
FPC Has a TypeOf() function that returns the VMT, so the index is something like (TYourObject.MethodAddress('methodname') - TypeOf(TYourObject)) div sizeOf(Pointer);
You can get the address and the VMT and subsequently the index.
That also means it is silly to use assembler for it.
«
Last Edit: October 23, 2018, 10:25:21 am by Thaddy
»
Logged
Object Pascal programmers should get rid of their "component fetish" especially with the non-visuals.
marcov
Administrator
Hero Member
Posts: 11459
FPC developer.
Re: asm from delphi to fpc
«
Reply #2 on:
October 23, 2018, 10:14:13 am »
Compile a small program that has a pascal version of the method with -Rintel -a and look at the generated code in the .s file.
Logged
Thaddy
Hero Member
Posts: 14392
Sensorship about opinions does not belong here.
Re: asm from delphi to fpc
«
Reply #3 on:
October 23, 2018, 10:22:44 am »
Marco, I did an edit. Would that work? [edit] No! but something can be done along those lines.
«
Last Edit: October 23, 2018, 11:33:44 am by Thaddy
»
Logged
Object Pascal programmers should get rid of their "component fetish" especially with the non-visuals.
nanobit
Full Member
Posts: 160
Re: asm from delphi to fpc
«
Reply #4 on:
October 23, 2018, 03:02:33 pm »
Unfortunately, I will give up. I wanted to port fastMM to Lazarus, but it compiles only without the FullDebugMode define. FullDebugMode is required to use detection of memory corruptions, the main reason I wanted to use it.
Logged
Thaddy
Hero Member
Posts: 14392
Sensorship about opinions does not belong here.
Re: asm from delphi to fpc
«
Reply #5 on:
October 23, 2018, 03:11:08 pm »
heaptrc.pp shows you how to detect memory corruption in much the same way. So examine that.
Also note the memory manager from Freepascal works internally different - not much but significant - from Delphi and is already fast (much faster than the default Delphi one once was before they changed to fastmm light) and it is cross-platform which fastmm isn't...
«
Last Edit: October 23, 2018, 03:29:40 pm by Thaddy
»
Logged
Object Pascal programmers should get rid of their "component fetish" especially with the non-visuals.
Print
Pages: [
1
]
« previous
next »
Lazarus
»
Forum
»
Free Pascal
»
Beginners
(Moderators:
FPK
,
Tomas Hajny
) »
asm from delphi to fpc
TinyPortal
© 2005-2018