#navi_header|C言語系|
''x86(80x86)CPUにおける各種「呼び出し規約」, "Calling Convention(s)" が実際にどのようなアセンブラコードになるのか延々と載せていくページ''
- C言語, Cコンパイラ, x86アセンブラの知識を前提としてます。C++も"thiscall"呼び出し規約でちょっとだけ必要。
- 各種呼び出し規約が、各種コンパイラでどのようなアセンブラコードになるのか、延々と載せていきます。
- 呼び出し規約それ自体の解説は殆どしてません。末尾の「参考資料」に図入りで詳しいページもありますので、各自適当に調べて下さい。
- ある程度御存知の方は、末尾の「参考資料」のみリンクショートカットとしてご利用下さい。
- ''どのような場合にも掲載されているアセンブラコードになるという保証はありません。'' 関数呼び出しの前後のコードによっては、汎用レジスタの退避・保存用のアセンブラコードが入ってくる可能性もあります。比較的単純なケースでのサンプル集としてご利用下さい。
----
#ls||
----
* 実行環境
各種コンパイラのバージョンについて。
Visual C++ 2008 Express Edition on Windows XP SP3
> cl
Microsoft(R) 32-bit C/C++ Optimizing Compiler Version 15.00.30729.01 for 80x86
Copyright (C) Microsoft Corporation. All rights reserved.
> link
Microsoft (R) Incremental Linker Version 9.00.30729.01
Copyright (C) Microsoft Corporation. All rights reserved.
Borland C++ Compiler 5.5.1 on Windows XP SP3
> bcc32
Borland C++ 5.5.1 for Win32 Copyright (c) 1993, 2000 Borland
(...)
> ilink32
Turbo Incremental Link 5.00 Copyright (c) 1997, 2000 Borland
(...)
OpenWatcom Compiler(16bit)
#pre||>
> wcl -v
Open Watcom C/C++16 Compile and Link Utility Version 1.8
Portions Copyright (c) 1988-2002 Sybase, Inc. All Rights Reserved.
Source code is available under the Sybase Open Watcom Public License.
See http://www.openwatcom.org/ for details.
> wcc -v
Open Watcom C16 Optimizing Compiler Version 1.8
Portions Copyright (c) 1984-2002 Sybase, Inc. All Rights Reserved.
Source code is available under the Sybase Open Watcom Public License.
See http://www.openwatcom.org/ for details.
Error! E1138: Filename required on command line
||<
OpenWatcom Compiler(32bit)
#pre||>
> wcl386 -v
Open Watcom C/C++32 Compile and Link Utility Version 1.8
Portions Copyright (c) 1988-2002 Sybase, Inc. All Rights Reserved.
Source code is available under the Sybase Open Watcom Public License.
See http://www.openwatcom.org/ for details.
> wcc386 -v
Open Watcom C32 Optimizing Compiler Version 1.8
Portions Copyright (c) 1984-2002 Sybase, Inc. All Rights Reserved.
Source code is available under the Sybase Open Watcom Public License.
See http://www.openwatcom.org/ for details.
Error! E1138: Filename required on command line
||<
OpenWatcom 環境変数(owsetenv.bat)
#pre||>
@echo off
echo Open Watcom Build Environment
set PATH=C:\WATCOM\BINNT;%PATH%
set PATH=C:\WATCOM\BINW;%PATH%
set INCLUDE=C:\WATCOM\H;%INCLUDE%
set INCLUDE=C:\WATCOM\H\NT;%INCLUDE%
set WATCOM=C:\WATCOM
set EDPATH=C:\WATCOM\EDDAT
||<
※一部16bitでのコンパイル時にのみ
set INCLUDE=%WATCOM%\h;%WATCOM%\h\win
によりヘッダファイルの読み込み位置を調整。
MinGWとgcc
MinGW-5.1.6
gcc.exe (GCC) 3.4.5 (mingw-vista special r3)
MSYS 1.0
Linux(CentOS5.2)上のgcc, binutils:
gcc-4.1.2-42.el5
libgcc-4.1.2-42.el5
binutils-2.17.50.0.6-6.el5
* 参考資料
書籍:
- &amazon() {エキスパートCプログラミング―知られざるCの深層 (Ascii books)
}
Webページ:
- x86 calling conventions - Wikipedia, the free encyclopedia
-- http://en.wikipedia.org/wiki/X86_calling_conventions
- Procedures and Functions - RAD Studio
-- http://docwiki.embarcadero.com/RADStudio/en/Procedures_and_Functions
- unixwiz.net, Using Win32 calling conventions
-- http://unixwiz.net/techtips/win32-callconv.html
- unixwiz.net, Intel x86 Function-call Conventions - Assembly View
-- http://unixwiz.net/techtips/win32-callconv-asm.html
- Function Attributes - Using the GNU Compiler Collection (GCC)
-- http://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html
- Calling Conventions Demystified - CodeProject
-- http://www.codeproject.com/KB/cpp/calling_conventions_demystified.aspx
- Calling conventions on the x86 platform
-- http://www.angelcode.com/dev/callconv/callconv.html
- Microsoft Calling Conventions
-- http://www.cs.cornell.edu/courses/cs412/2001sp/resources/microsoft-calling-conventions.html
- MSDN : C++ Language Reference, Calling Conventions
-- http://msdn.microsoft.com/en-us/library/k2b2ssfy%28VS.71%29.aspx
--- MSDN -> MSDN Library -> Development Tools and Languages -> Visual Studio .NET -> Visual C++ -> Reference -> C/C++ Languages -> C++ Language Reference -> Microsoft-Specific Modifiers -> Calling Conventions
- SYSTEM V APPLICATION BINARY INTERFACE Intel386O Architecture Processor Supplement Fourth Edition
-- http://www.sco.com/developers/devspecs/abi386-4.pdf
- The Old New Thing : The history of calling conventions, part 1 - 5
-- http://blogs.msdn.com/oldnewthing/archive/2004/01/02/47184.aspx
-- http://blogs.msdn.com/oldnewthing/archive/2004/01/07/48303.aspx
-- http://blogs.msdn.com/oldnewthing/archive/2004/01/08/48616.aspx
-- http://blogs.msdn.com/oldnewthing/archive/2004/01/13/58199.aspx
-- http://blogs.msdn.com/oldnewthing/archive/2004/01/14/58579.aspx
#navi_footer|C言語系|