Web lists-archives.com

Re: Request for an example x68 assembler portable Hello World script




I frequently cannot contribute discussion to Cygwin topics, but due to
my work porting a database (fis-gtm) to Cygwin, I can chime in here.

This is a good article to give you an overview of the different
calling conventions out there:
https://eli.thegreenplace.net/2011/09/06/stack-frame-layout-on-x86-64.

Here's a summary of what I learned:
1. Cygwin x32 and Linux x32 use the same assembly layout--application
binary interface (ABI).
2. Cygwin x64 uses the Windows 64 ABI. Linux x64 uses the AMD64 ABI.

This tutorial article is a good place to learn about x64 ABI for
Linux: https://cs.lmu.edu/~ray/notes/gasexamples/.

--Sam

On Sun, Apr 28, 2019 at 4:00 PM Eliot Moss <moss@xxxxxxxxxxxx> wrote:
>
> On 4/26/2019 5:04 PM, Jesse Thompson wrote:
>
> > Ultimately what I am trying to research is how to begin building a simple
> > compilation system of my own, so how do the *makers* of compilers deal with
> > these differences in calling convention?
>
> They make parts of the compilers conditional on the overall platform.
> For example, if a compiler is written in C / C++, they use #define
> and #if tests, and may include different modules in a build, etc.
>
> They also try to code various algorithms, such a register allocation,
> to be parameterized by a description of how things work on a given
> platform.
>
> There are whole swaths that are essentially target independent,
> especially those having to do with higher level optimizations.
> However, even there, platform differences may lead to different
> parameter settings (e.g., default number of times to unroll a
> loop) or strategies (presence / absence of vector units and
> of predicated instructions (as on the ARM) affect how you want
> to generate even the high-level target-independent code).
>
> In the case that you are talking about, most of the code generation
> and optimization strategies are the same -- there are just some
> fine points different about calling sequences, register usage
> conventions, etc.  I think those are mostly addressed by the kind
> of parameterization-by-descriptions (or by #defines) that I have
> described.
>
> You may still see somewhat different code from different compilers,
> even for the same platform, simply because the different designers
> chose different base code sequences - which may be equivalent. For
> example, to move a constant into a register, add-immediate (adding
> to zero) and or-immediate (again, ORing with zero) give the same
> result for many arguments, to the choice is arbitrary.  One can
> come up with many such examples.
>
> Supporting multiple target instruction sets, or even the range of
> models of the x86 line, requires some amount of platform-specific
> work, of course, and lot of attention to how to build components
> that are either independent of the ISA or retargetable in some way.
>
> Regards - Eliot Moss
>
> --
> Problem reports:       http://cygwin.com/problems.html
> FAQ:                   http://cygwin.com/faq/
> Documentation:         http://cygwin.com/docs.html
> Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
>

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple