嵌入式作业一排序
作者:拉格浪日 标签:编程 | 阅读次数:225 |
![]() ![]() ![]() |
| ![]() ![]() ![]() |
这么个东西还搞了半天,而且不知道结果如何.
现在真是该好好动动手了。 #include void select(int * src ,int number) { SUBS R1,R1,#1 ; loop STMFD R13!,R1 ;保存外循环计数入栈 MOV R2,#0 loop2 LDRH R3,[R0+R2] ;参数一地址的内容放到R3中 LDRH R4,[R0+R2+2];仅仅是为了比较半个字 CMP R3,R4 ;比较R3第二个数据 BLS skip ;低于或等于则跳转 MOV R5,R4 ;交换 MOV R4,R3 MOV R3,R5 ;CAN I CHANGE IT TO THIS ?SWP R3,R3,[R0+R2+2];前大即交换 skip ADD R2,#2 SUBS R1,R1,#1 BNE loop2 LDMFD R13!,R1 SUBS R1,R1,#1 BNE loop } int main() { int i=0; int num=0; int *array=NULL; while(num <= 0) { printf("please enter the number of elements:\n"); scanf("%d",&num); if(num > 0) { break; } } if(NULL == (array = (int *)malloc(num*sizeof(int)))) { printf("malloc failed!\n"); exit(-1); } printf("please enter the elements:\n"); for(i = 0; i scanf("%d", array+i); } __asm{ MOV R0,array MOV R1,num BL select,{R0,R1}; } printf("=========================\nthe result is:\n"); for(i = 0; i } return 0; } ![]() ![]() |