1. 程式人生 > >問題:彙編裡 IMPORT和EXPORT有什麼區別?

問題:彙編裡 IMPORT和EXPORT有什麼區別?

。然後,就可以在C中使用該函數了。從C的角度,並不知道該函式的實現是用C還是彙編。更深的原因是因為C的函式名起到表明函式程式碼起始地址的左右,這個和彙編的label是一致的。
/* cfile.c * in C,call an asm function, asm_strcpy * Sep 9, 2004 */ 
#include
 extern void asm_strcpy(const char *src, char *dest); 
int main() { const char *s = "seasons in the sun"; char d[32]; asm_strcpy(s, d); printf("source: %s", s); printf(" destination: %s",d); return 0; } ;asm function implementation AREA asmfile, CODE, READONLY EXPORT asm_strcpy asm_strcpy loop ldrb r4, [r0], #1 ;address increment after read cmp r4, #0 beq over strb r4, [r1], #1 b loop over mov pc, lr END 在這裡,C和彙編之間的引數傳遞是通過ATPCS(ARM Thumb Procedure Call Standard)的規定來進行的。簡單的說就是如果函式有不多於四個引數,對應的用R0-R3來進行傳遞,多於4個時藉助棧,函式的返回值通過R0來返回。