View Issue Details

IDProjectCategoryView StatusLast Update
0037266FPCDocumentationpublic2020-06-28 15:14
ReporterKai Burghardt Assigned ToMichael Van Canneyt  
PrioritynormalSeverityminorReproducibilityalways
Status assignedResolutionopen 
Platformx86_64OSGNU/Linux 
Product Version3.0.4 
Summary0037266: Reference Guide erroneously claims EAX, ECX, EDX were used for the first three parameters in `register` calling convention
DescriptionIt should be EDI, ESI, EDX instead.
Additional InformationJust delete the claim.
TagsNo tags attached.
Fixed in Revision
FPCOldBugId
FPCTarget
Attached Files

Activities

Kai Burghardt

2020-06-26 11:47

reporter  

ref.tex.patch (648 bytes)   
--- ref.tex~	2020-06-26 09:45:00.171076316 +0000
+++ ref.tex	2020-06-26 09:45:00.171076316 +0000
@@ -11527,8 +11527,7 @@
 \label{se:register}\index{register}\index{Modifiers!register}\keywordlink{register}
 The \var{register} keyword is used for compatibility with Delphi. In
 version 1.0.x of the compiler, this directive has no effect on the
-generated code. As of the 1.9.X versions, this directive is supported. The
-first three arguments are passed in registers EAX, ECX and EDX.
+generated code. As of the 1.9.X versions, this directive is supported.
 
 \subsection{safecall}
 \index{safecall}\index{Modifiers!safecall}\keywordlink{savecall}
ref.tex.patch (648 bytes)   

Max Nazhalov

2020-06-26 13:11

reporter   ~0123599

Last edited: 2020-06-26 21:10

View 3 revisions

The claim is (almost) correct for x86-32-bit: register calling convention uses EAX EDX ECX as first 3 parameters, in that order.
For 64-bit [as you've tagged your report x86_64 GNU/Linux] RDI, RSI et al are used, NOT EDI ESI etc,

Sven Barth

2020-06-26 16:32

manager   ~0123601

> For 64-bit RDI, RSI et al are used, NOT EDI ESI etc,

For x86_64 the "register" calling convention does not exist as a separate calling convention instead the platform's default calling convention is used (Win64 vs. non-Win64). On non-Win64 it is indeed RDI and RSI that are used (amongst others), but for Win64 it would RCX, RDX, R8 and R9.

@Michael: it might be best to document that the "register" calling convention as such exists only on specific platforms (currently i386 and m68k) otherwise the default will be used.

Kai Burghardt

2020-06-27 09:02

reporter   ~0123610

OK, thanks for the clarification.

I’d still delete the claim though, in the spirit of 0035867:0117336 “It does not make sense to reproduce the ABIs of every supported platform in our own documentation.”

Sven Barth

2020-06-27 10:30

manager   ~0123611

Last edited: 2020-06-27 10:31

View 2 revisions

For the register calling convention it does make sense though, because it is not part of the platform ABI and in those cases where it doesn't match the platform ABI (namely i386, i8086 and m68k) the users should know which registers to use for assembly routines.

Serge Anvarov

2020-06-27 12:32

reporter   ~0123614

I understand that this will require further development in the future, but it might be better to specify a table where for each platform to specify which registers are used?

Kai Burghardt

2020-06-28 15:14

reporter   ~0123648

OK, but then please move it to the “Programmer’s guide.“ The “Reference guide” is, as far as I understand, about the Language, while the Programmer’s guide explains issues concerning this particular compiler, FPC.

(In § “Calling mechanism” (of the Programmer’s guide) there is already a statement, quote, “The list of registers that are modified is highly dependent on the processor, calling convention and ABI of the target platform.”)

Issue History

Date Modified Username Field Change
2020-06-26 11:47 Kai Burghardt New Issue
2020-06-26 11:47 Kai Burghardt Status new => assigned
2020-06-26 11:47 Kai Burghardt Assigned To => Michael Van Canneyt
2020-06-26 11:47 Kai Burghardt File Added: ref.tex.patch
2020-06-26 13:11 Max Nazhalov Note Added: 0123599
2020-06-26 13:13 Max Nazhalov Note Edited: 0123599 View Revisions
2020-06-26 16:32 Sven Barth Note Added: 0123601
2020-06-26 21:10 Max Nazhalov Note Edited: 0123599 View Revisions
2020-06-27 09:02 Kai Burghardt Note Added: 0123610
2020-06-27 10:30 Sven Barth Note Added: 0123611
2020-06-27 10:31 Sven Barth Note Edited: 0123611 View Revisions
2020-06-27 12:32 Serge Anvarov Note Added: 0123614
2020-06-28 15:14 Kai Burghardt Note Added: 0123648