void main(void)
{
tsk_test5();
.......
}
void tsk_test5(void)
{
unsigned int i,j;
unsigned char a,b;
unsigned long l;
i=0xAA55;
j=0x55AA;
a=0x88;
b=0x99;
l=0x11223344;
while(i--){
printf("haha5\n");
printf("test5 count = %d",count++);
funtionarg(i,b,l);
}
}
//CCS下反汇编
void tsk_test5(void)
{
800019B8 STMFD R13!, {R0-R3, R14} //这块没有为局部变量分配栈空间,不需要,因为此函数被main()第一个调用
//所以可以用前面的空间也不会覆盖什么数据,如用[R13,0x4]存放j,
//因为这个位置先前也没数据,所以不用sub R13,R13,0xXX;来分配空间
unsigned int i,j;
unsigned char a,b;
unsigned long l;
i=0xAA55;
800019BC MOV R12, #0x55 //R12=0x55;
800019C0 ADD R12, R12, #0xAA00 //R12=R12+0xAA00;
800019C4 STR R12, [R13] //*R13=R12;压栈
j=0x55AA;
800019C8 MOV R12, #0xAA
800019CC ADD R12, R12, #0x5500
800019D0 STR R12, [R13, #0x4] //*(R13+4)=R12;store 4 Btytes to momery
a=0x88;
800019D4 MOV R12, #0x88
800019D8 STRB R12, [R13, #0x8] //*(R13+8)=R12,store byte to momery
b=0x99;
800019DC MOV R12, #0x99
800019E0 STRB R12, [R13, #0x9] //*(R13+9)=R12,store byte to momery
l=0x11223344;
800019E4 LDR R12, CON18
800019E8 STR R12, [R13, #0xC] //*(R13+12)=R12,好像是存储4字节(要4字节对齐)
while(i--){
800019EC LDR R12, [R13]
800019F0 SUB R0, R12, #0x1 //把i值放入寄存器中并减1
800019F4 CMP R12, #0x0 //比较 看是否为0
800019F8 STR R0, [R13] //先减后存放,
800019FC BEQ DW$L$_tsk_test5$2$E
printf("haha5\n");
80001A00 DW$L$_tsk_test5$2$B, L17:
80001A00 ADD R0, PC, #0x64
80001A04 BL printf
printf("test5 count = %d",count++);
80001A08 LDR R0, CON19
80001A0C LDR R1, [R0]
80001A10 ADD R12, R1, #0x1
80001A14 STR R12, [R0]
80001A18 ADD R0, PC, #0x54
80001A1C BL printf //没有用栈传递参数,可能是因为printf是库函数吧,
funtionarg(i,b,l);
80001A20 LDR R0, [R13] //R0 R1 R2 把i,b,l传递过去
80001A24 LDRB R1, [R13, #0x9]
80001A28 LDR R2, [R13, #0xC]
80001A2C BL funtionarg
}
80001A30 LDR R12, [R13]
80001A34 SUB R0, R12, #0x1
80001A38 CMP R12, #0x0
80001A3C STR R0, [R13]
80001A40 BNE L17
80001A44 L18, DW$L$_tsk_test5$2$E:
80001A44 STR R0, [R13]
80001A48 LDMFD R13!, {R0-R3, PC} //弹栈,R13的值一直没改变
}
阅读(1355) | 评论(0) | 转发(0) |