demo1: 子程序,调用C函数
AREA MfArm,CODE,READONLY ENTRY EXPORT main IMPORT strcmp big DCB "hello world",0 small DCB "hello world",0 main MOV R0,#1 MOV R1,#2 BL ADD_SUM MOV R3,R0 ADR R0,big ADR R1,small BL strcmp mov R0,#0 B stop ADD_SUM ADD R0,R0,R1 BX LR stop END
demo2: C语言调用 ARM汇编
C代码:
#include<stdio.h> #include<string.h> extern void* _memcpy(void* dest,void* src, size_t size); int main(void) { char dest[100]={0}; char* src = "www.gyarmy.com"; _memcpy(dest,src,strlen(src)+1); return 0; }
ARM代码:
;_memcpy AREA Mfcode,CODE,READONLY EXPORT _memcpy _memcpy STMFD SP!,{R4,LR} mov r3,r0 mov r7,r1 copy CMP r2,#0 BLE exit LDRB r4,[r7] STRB r4,[r3] ADDS r7,r7,#1 ADDS r3,r3,#1 SUBS R2,R2,#1 BEQ exit B copy exit LDMFD SP!,{r4,PC} END
demo3
0则评论给“ARM测试demo”