Web lists-archives.com

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

On Fri, 26 Apr 2019 at 15:04, Jesse Thompson <> wrote:
> > From: Eliot Moss <>
> > To: cygwin@xxxxxxxxxx
> > Date: Fri, 26 Apr 2019 07:16:38 -0400
> > Subject: Re: Request for an example x68 assembler portable Hello World

> 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?

Each hardware and OS combination will usually publish an ABI (an
Application Binary Interface) specification that defines how to call
the OS services, and how applications should call each other and
vendor supplied libraries. Compiler authors will usually generate code
which adheres to these specifications. The C compiler will generate
code that will call the OS and external code accordingly to the
specification. Authors of assembler code must abide by the ABI if they
want their code to inter-operate with the OS and external higher level
language code, however they are free to use any calling convention
they like within their own code.

This page: https://cs.lmu.edu/~ray/notes/gasexamples/ illustrates the
ABI for calling the OS and C-language from assembler in a linux os on
an intel or amd 64-bit cpu. The calling conventions used by Windows on
the same hardware is different, due to different ABIs for those two

The GNU Compiler Collection (GCC) support a C-language feature that
allows you to embed assembler instruction in C and C++ code. In this
scenario, one writes otherwise normal C functions where the body of
the function is replaced by assembler instructions (or a mix of C and
assembler). The C compiler generates the correct code for the ABI. And
the assembler code can reference the function arguments by name,
regardless of how they were passed to the function. See:
https://gcc.gnu.org/onlinedocs/gcc/index.html the "Using the GNU
Compiler Collection (GCC)" document. See section 6.47 'How to Use
Inline Assembly Language in C Code" for details.

When you stray from the GNU path, though, things can get more chaotic
where platforms must be considered on a case by case basis.

Have you looked at VM based implementations? These use an intermediate
assembler-like language which is executed on a virtual machine. The VM
is specific to each platforms, but attempts to allow the "Write once,
run anywhere" goal of Java.


Doug Henderson, Calgary, Alberta, Canada - from gmail.com

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