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++ 및 어셈블리 언어 조합3. armlink strtest.o scopy.o -o strtest를 입력하여 개체 파일을 링크합니다.4. 호환되는 디버거를 적절한 디버그 타겟과 함께 사용하여 이미지를 실행합니다.어셈블리 언어에서 C 호출예제 4-6과 예제 4-7에서는 어셈블리 언어에서 C를 호출하는 방법을 보여 줍니다.예제 4-6 C에서 함수 정의int g (int a, int b, int c, int d, int e){return a + b + c + d + e;}예제 4-7 어셈블리 언어 호출; int f (int i) { return g (i, 2*i, 3*i, 4*i, 5*i) ; }PRESERVE8EXPORT fAREA f, CODE, READONLYIMPORT g; i is in R0STR lr, [sp, #-4]! ; preserve lrADD R1, R0, R0 ; compute 2*i (2nd param)ADD R2, R1, R0 ; compute 3*i (3rd param)ADD R3, R1, R2 ; compute 5*iSTR R3, [sp, #-4]! ; 5th param on stackADD R3, R1, R1 ; compute 4*i (4th param)BL g; branch to C functionADD sp, sp, #4 ; remove 5th paramLDR pc, [sp], #4 ; returnEND<strong>ARM</strong> DUI 0203IK Copyright © 2002-2008 <strong>ARM</strong> Limited. All rights reserved. 4-11Unrestricted AccessNon-Confidential

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

Saved successfully!

Ooh no, something went wrong!