X-Recipient: archive-cygwin AT delorie DOT com DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:mime-version:references:in-reply-to:from:date :message-id:subject:to:content-type; q=dns; s=default; b=jxcsNMl ptYARdwq4xt6ouhniIxBEr5GPiTvsbGtolkl72rCGCqXjrDNbptENzgu62tvHYEq RasWwJ0dTvTYrLTZ3KvK2Jw/n49SPpQc17LpiyAqsY9xu/aLDNMPFUXTh20xOzbI uqsa3ZFUi7eefoHCtm7ZaVgVGGNPN0phzBQc= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:mime-version:references:in-reply-to:from:date :message-id:subject:to:content-type; s=default; bh=NfiHvNZeO8a/j D1korjIuA3N+9Q=; b=K9UXxq24d7mLLZreq3ei+TLdjeImKvkJ3OWy1v+rLC0Hs 4tqUvYlWiZIsMTZrfXsKWVoc2cUtmeofmYCrrc7e8uKJNcafYHoidlXbnlsHKEpE +DfxOzkuMg8Tp5GxNEhDS+tR0/JLXPJUZgUnj/qGtOwbPCsybkNCDO1BrxYLqg= Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=0.2 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,FROM_LOCAL_NOVOWEL,HK_RANDOM_ENVFROM,KAM_SHORT,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=no version=3.3.1 spammy=Doug, doug, Collection, HX-Languages-Length:2516 X-HELO: mail-qt1-f194.google.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=kd8bDKI5dDoFgxNW4TaPihi6zyqqLVMIyarV5jKYzGI=; b=mOvyD6hN8BE/E5lrGydcfFdu3q/X/v5uvXZKxMb3EGrpk9sNd1Cfu+TmEtOIzFmm6F mnzUVnBtXI4LrXbGsMxrfFRLWilKIi9ygr5DfVhYyRTdI44KfARDCib6P6gZwfTr15zm uquNiHN7TPirZ8sTChBYdzZoxE6UIgLnetqwoZHEu+2M70gfYir3Z7UOCR3o3QSCNGG/ yueWNw/6NgJnwCtzR5nG8ivaUSH1y4n3ZsEUloTRENx37qXvHKkGjRkRuMNPlrOXJMdC NT8TXVB0mI6GzGrMqHGkIvhanyMHuZer+eJb6MTrBcfOBe9DB5jSc59u3OHA6YS4JAyr ZJzg== MIME-Version: 1.0 References: In-Reply-To: From: Doug Henderson Date: Fri, 26 Apr 2019 19:56:35 -0600 Message-ID: Subject: Re: Request for an example x68 assembler portable Hello World script To: cygwin Content-Type: text/plain; charset="UTF-8" X-IsSubscribed: yes On Fri, 26 Apr 2019 at 15:04, Jesse Thompson <> wrote: > > > From: Eliot Moss <> > > To: cygwin AT cygwin DOT com > > 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 OSs. 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. HTH, Doug -- 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