home ホーム search 検索 -  login ログイン  | reload edit datainfo version cmd icon diff delete  | help ヘルプ

C言語系/呼び出し規約/x86

C言語系/呼び出し規約/x86

C言語系 / 呼び出し規約 / x86
id: 615 所有者: msakamoto-sf    作成日: 2010-03-17 10:12:28
カテゴリ: Assembler C言語 UNIX Windows 

x86(80x86)CPUにおける各種「呼び出し規約」, "Calling Convention(s)" が実際にどのようなアセンブラコードになるのか延々と載せていくページ

  • C言語, Cコンパイラ, x86アセンブラの知識を前提としてます。C++も"thiscall"呼び出し規約でちょっとだけ必要。
  • 各種呼び出し規約が、各種コンパイラでどのようなアセンブラコードになるのか、延々と載せていきます。
  • 呼び出し規約それ自体の解説は殆どしてません。末尾の「参考資料」に図入りで詳しいページもありますので、各自適当に調べて下さい。
  • ある程度御存知の方は、末尾の「参考資料」のみリンクショートカットとしてご利用下さい。
  • どのような場合にも掲載されているアセンブラコードになるという保証はありません。関数呼び出しの前後のコードによっては、汎用レジスタの退避・保存用のアセンブラコードが入ってくる可能性もあります。比較的単純なケースでのサンプル集としてご利用下さい。


実行環境

各種コンパイラのバージョンについて。

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)

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

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

@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

参考資料

書籍:

Webページ:



プレーンテキスト形式でダウンロード
現在のバージョン : 2
更新者: msakamoto-sf
更新日: 2010-03-27 17:19:17
md5:7eee8d1800099af1a7ae90f56bf35e82
sha1:1d037cbe630b2f65be12e928076dccab16862a0b
コメント
コメントを投稿するにはログインして下さい。