PDF version - ARM Information Center
PDF version - ARM Information Center
PDF version - ARM Information Center
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
C, C++ 및 어셈블리 언어 조합C 또는 어셈블리 언어에서 C++ 호출예제 4-18, 예제 4-19 및 예제 4-20에 나오는 코드에서는 C 또는 어셈블리 언어에서 비정적이며 가상이 아닌 C++ 구성원 함수를 호출하는 방법을 보여 줍니다. 함수의 잘린 이름을 찾으려면 컴파일러에서 어셈블러 출력을 사용합니다.예제 4-18 C++ 구성원 함수 호출struct T {T (int i) : t (i) { }int t;int f (int i) ;};int T::f (int i) { return i + t; }// Definition of the C++ function to be called from C.extern "C" int cfunc (T*) ;// Declaration of the C function to be called from C++.int f () {T t (5) ;// create an object of type Treturn cfunc (&t) ;}예제 4-19 C 함수 정의struct T;extern int _ZN1T1fEi (struct T*, int) ;/* the mangled name of the C++ *//* function to be called */int cfunc (struct T* t) {/* Definition of the C function to be called from C++. */return 3 * _ZN1T1fEi (t, 2) ; /* like '3 * t->f (2) ' */}예제 4-20 어셈블리 언어에서 함수 구현EXPORT cfuncAREA foo, CODEIMPORT _ZN1T1fEicfuncSTMFD sp!,{lr} ; R0 already contains the object pointerMOV R1, #2BL _ZN1T1fEi<strong>ARM</strong> DUI 0203IK Copyright © 2002-2008 <strong>ARM</strong> Limited. All rights reserved. 4-17Unrestricted AccessNon-Confidential