f



[9fans] Plan9 Calling Convention (x86)

Hi,

I'm in the process of porting dyncall (http://dyncall.org) to Plan9, and I
was wondering if there are any documents about the calling convention used
by Plan9 - specifically for x86, for starters. I was unable to find any at
the time of writing, and well, hoped that it would be similar to the
SystemV calling convention(s) used by the *BSDs or Linux, etc., but that
doesn't seem to be the case.
The only information I found so far, is, that most of the compiled Plan9
functions don't seem to have any prologue/epilogue, however, this
assumption might be wrong (maybe I didn't get how Plan9 works on the
machine-level, so far).

I'm still new to Plan9, but it's quite mind-opening to discover certain
aspects of the OS - especially after getting so (too) used to Unix/Windows
OS design decisions and accepting them as the normal/right way to do
things...

Thanks,
Tassilo


0
tphilipp (5)
7/26/2010 7:34:51 PM
comp.os.plan9 9252 articles. 1 followers. quanstro (3876) is leader. Post Follow

3 Replies
521 Views

Similar Articles

[PageSpeed] 45

On 26 Jul 2010, at 8:27, Tassilo Philipp wrote:

> Hi,
>
> I'm in the process of porting dyncall (http://dyncall.org) to Plan9,  
> and I
> was wondering if there are any documents about the calling  
> convention used
> by Plan9 - specifically for x86, for starters. I was unable to find  
> any at
> the time of writing, and well, hoped that it would be similar to the
> SystemV calling convention(s) used by the *BSDs or Linux, etc., but  
> that
> doesn't seem to be the case.
> The only information I found so far, is, that most of the compiled  
> Plan9
> functions don't seem to have any prologue/epilogue, however, this
> assumption might be wrong (maybe I didn't get how Plan9 works on the
> machine-level, so far).

I hope you don't mind me asking, but what do the prologue and epilogue  
normally do? With only a basic knowledge of C and assembler, I can't  
imagine what they might be for. Are they anything to do with dynamic  
linking?

>
> I'm still new to Plan9, but it's quite mind-opening to discover  
> certain
> aspects of the OS - especially after getting so (too) used to Unix/ 
> Windows
> OS design decisions and accepting them as the normal/right way to do
> things...

Oh tell me about it, I'm finding

>
> Thanks,
> Tassilo
>
>


0
eekee57
7/26/2010 8:08:13 PM
This is a multi-part message in MIME format.
--upas-mvydoxhekmiqjfavjnfhnthvjf
Content-Disposition: inline
Content-Type: text/plain; charset="US-ASCII"
Content-Transfer-Encoding: 7bit

caller saves, so function is free to use any register.  params are put
on the stack and then just uses a call instruction wich leaves the
return pc on the stack.  function allocates space for its local
variables on the stack and restores SP before return.  return value of
a function is put in AX (for integers and pointers).  structures and
64bit vlongs are returned the way that the caller allocates it and
passes a pointer to it as the first parameter (on the stack).  AX is
then not used as return value and can be used freely in the callee.

--
cinap

--upas-mvydoxhekmiqjfavjnfhnthvjf
Content-Type: message/rfc822
Content-Disposition: inline

Return-Path: <9fans-bounces+cinap_lenrek=gmx.de@9fans.net>
Delivered-To: GMX delivery to cinap_lenrek@gmx.de
Received: (qmail invoked by alias); 26 Jul 2010 19:36:17 -0000
Received: from gouda.swtch.com (EHLO gouda.swtch.com) [67.207.142.3]
  by mx0.gmx.net (mx001) with SMTP; 26 Jul 2010 21:36:17 +0200
Received: from localhost ([127.0.0.1] helo=gouda.swtch.com)
	by gouda.swtch.com with esmtp (Exim 4.69)
	(envelope-from <9fans-bounces@9fans.net>)
	id 1OdTKY-0002Ub-Tv; Mon, 26 Jul 2010 19:27:19 +0000
Received: from jordan.mc0.hosteurope.de ([80.237.138.9])
	by gouda.swtch.com with esmtp (Exim 4.69)
	(envelope-from <tphilipp@potion-studios.com>) id 1OdTKX-0002UW-14
	for 9fans@9fans.net; Mon, 26 Jul 2010 19:27:17 +0000
Received: from server01.webmailer.hosteurope.de ([10.9.0.180]); 
	by mailout.hosteurope.de (jordan.mc0.hosteurope.de) running
	EXperimental Internet Mailer with esmtps (TLSv1:AES256-SHA:256)
	id 1OdTKQ-0006vS-TD
	for 9fans@9fans.net; Mon, 26 Jul 2010 21:27:10 +0200
Received: from nobody by server01.webmailer.hosteurope.de with local (Exim
	4.69) (envelope-from <tphilipp@potion-studios.com>)
	id 1OdTKQ-0001z3-Rq
	for 9fans@9fans.net; Mon, 26 Jul 2010 21:27:10 +0200
X-Squirrel-UserHash: EhVcXl1ERwBcRx0AAAwEUR8f
X-Squirrel-FromHash: UVZZCQsXTFQ=
Message-ID: <899e1dd0ffcee329db7dc0b8faf0b201-EhVcXl1ERwBcRx0AAAwEUR8fGQlVS19cWF9EAV1EWEZaOl4PQVh/H1dXXkFeRExtXlhRQFlSWgxcXw==-webmailer2@server01.webmailer.hosteurope.de>
Date: Mon, 26 Jul 2010 21:27:10 +0200
From: "Tassilo Philipp" <tphilipp@potion-studios.com>
To: 9fans@9fans.net
User-Agent: Host Europe Webmailer/1.0
MIME-Version: 1.0
Content-Type: text/plain;charset=iso-8859-1
Content-Transfer-Encoding: 8bit
X-Priority: 3 (Normal)
Importance: Normal
X-HE-Access: Yes
X-bounce-key: webpack.hosteurope.de; tphilipp@potion-studios.com; 1280172430;
	023dacc5; 
Subject: [9fans] Plan9 Calling Convention (x86)
X-BeenThere: 9fans@9fans.net
X-Mailman-Version: 2.1.10
Precedence: list
Reply-To: tphilipp@potion-studios.com,
	Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net>
List-Id: Fans of the OS Plan 9 from Bell Labs <9fans.9fans.net>
List-Unsubscribe: <http://mail.9fans.net/options/9fans>,
	<mailto:9fans-request@9fans.net?subject=unsubscribe>
List-Archive: <http://mail.9fans.net/private/9fans>
List-Post: <mailto:9fans@9fans.net>
List-Help: <mailto:9fans-request@9fans.net?subject=help>
List-Subscribe: <http://mail.9fans.net/listinfo/9fans>,
	<mailto:9fans-request@9fans.net?subject=subscribe>
Sender: 9fans-bounces@9fans.net
Errors-To: 9fans-bounces+cinap_lenrek=gmx.de@9fans.net
X-GMX-Antivirus: 0 (no virus found)
X-GMX-Antispam: 0 (Mail was not recognized as spam);
 Detail=5D7Q89H36p77e5KAPs1l6v/Sb97LojnDtMgfETrECMLUO9erHzOJe+OynZRhvlGqb5A0X
 bbiCt2rAnnct/NAlbHMvoAL6GY+23tB3khNK7au3fkL89Y026H2WJg1zsjGg0I0r5V9ldzzR5wBB
 /r19Q==V1;
X-Flags: 0000
X-GMX-UID: 5oY/bE9FeSE5Lp4kyHQhdwB2IGRvb0Dg

Hi,

I'm in the process of porting dyncall (http://dyncall.org) to Plan9, and I
was wondering if there are any documents about the calling convention used
by Plan9 - specifically for x86, for starters. I was unable to find any at
the time of writing, and well, hoped that it would be similar to the
SystemV calling convention(s) used by the *BSDs or Linux, etc., but that
doesn't seem to be the case.
The only information I found so far, is, that most of the compiled Plan9
functions don't seem to have any prologue/epilogue, however, this
assumption might be wrong (maybe I didn't get how Plan9 works on the
machine-level, so far).

I'm still new to Plan9, but it's quite mind-opening to discover certain
aspects of the OS - especially after getting so (too) used to Unix/Windows
OS design decisions and accepting them as the normal/right way to do
things...

Thanks,
Tassilo

--upas-mvydoxhekmiqjfavjnfhnthvjf--

0
cinap_lenrek (315)
7/26/2010 9:19:28 PM
information on the compiler's implementation here:

http://plan9.bell-labs.com/sys/doc/compiler.pdf

-Steve

0
steve
7/26/2010 10:37:54 PM
Reply: