10.07.2015 Views

PDF version - ARM Information Center

PDF version - ARM Information Center

PDF version - ARM Information Center

SHOW MORE
SHOW LESS

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++ 호출예제 4-14와 예제 4-15에서는 어셈블리 언어에서 C++를 호출하는 방법을 보여 줍니다.예제 4-14 C++에서 호출되도록 함수 정의struct S {// has no base classes or virtual functionsS (int s) : i (s) { }int i;};extern "C" void cppfunc (S * p) {// Definition of the C++ function to be called from ASM.// The body is C++, only the linkage is C.p->i += 5;}<strong>ARM</strong> 어셈블리 언어에서는 C++ 함수의 이름을 가져오고 BL (링크 포함 분기) 명령어를 사용하여 해당 함수를 호출합니다.예제 4-15 어셈블리 언어 함수 정의fAREA Asm, CODEIMPORT cppfuncEXPORTf; import the name of the C++; function to be called from AsmSTMFD sp!,{lr}MOV R0,#2STR R0,[sp,#-4]! ; initialize structMOV R0,sp ; argument is pointer to structBL cppfunc ; call 'cppfunc' so it can change the structLDR R0, [sp], #4ADD R0, R0, R0,LSL #1LDMFD sp!,{pc}END<strong>ARM</strong> DUI 0203IK Copyright © 2002-2008 <strong>ARM</strong> Limited. All rights reserved. 4-15Unrestricted AccessNon-Confidential

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!