Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 08 Sep 2014 11:44:27 -0400
From:      John Baldwin <jhb@freebsd.org>
To:        freebsd-doc@freebsd.org
Subject:   Re: Syscall x86 convention in Devlopers' Handbook
Message-ID:  <1928479.9KfryLvuNc@ralph.baldwin.cx>
In-Reply-To: <396A5D5F-AED3-4D79-8CD4-356A7FECCF9F@icloud.com>
References:  <396A5D5F-AED3-4D79-8CD4-356A7FECCF9F@icloud.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Saturday, September 06, 2014 02:40:33 PM Seo Townsend wrote:
> Hey guys, this is my first time in this mailing list so I=E2=80=99m n=
ot fully aware
> of all the procedures=E2=80=A6
>=20
> I was looking through the developer handbook and noticed that the
> Developer=E2=80=99s Handbook section on Assembly for x86 doesn=E2=80=99=
t make any mention
> of the change in the syscall calling convention from i386 to x86-64 a=
nd I
> can=E2=80=99t seem to find this documented anywhere.  The documentati=
on does
> mention =E2=80=9CFreeBSD kernel uses the C calling convention=E2=80=9D=
 (11.3.1) but doesn=E2=80=99t
> point out that the C calling convention changed from i386 to x86-64; =
and
> the architecture listed for 11 is generically (x86 Assembly Language
> Programming).

Arguably, the "C calling convention" on x86-64 is to pass by register s=
ince=20
that is what C uses on x86-64, so I'm not sure the statement is wrong.

> Thoughts?  Some ideas I had are:
> (1). Change =E2=80=9Cx86 Assembly Language Programming=E2=80=9D to =E2=
=80=9Ci386 Assembly=E2=80=9D - This
> would clear up the disambiguity of the 32bit architecture and 64bit
> architecture.

I think this is probably a fine thing to do.

> (2). Add a footnote to (11.3.1) with =E2=80=9CIf you are using
> x86-64, please note that the calling convention for both C and syscal=
l
> changed from pushing arguments on the stack to using a list of ordere=
d
> registered as outlined in the System V AMD64 ABI specification=E2=80=9D=


I don't really think this is the proper place to document the well-know=
n=20
x86-64 calling conventions. :)  If you are programming 64-bit assembly =
you=20
should already know those.

> (3). I would not mind eventually adding a section for =E2=80=9Cx86-64=
 assembly=E2=80=9D for
> (11.3.2) if I could get someone to help mentor me.

I suspect it would be more useful to just replace the current 32-bit ex=
ample
with only a 64-bit example and not try to keep both.

--=20
John Baldwin



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1928479.9KfryLvuNc>