RE:嵌入式作业一排序
作者:拉格浪日 标签:编程 | 阅读次数:27 |
![]() ![]() ![]() |
| ![]() ![]() ![]() |
在CODE WARRIOR下通过!
#include #include void select(int * src,int number) { __asm{ SUBS R1,R1,#1 loop: MOV R7,R1 MOV R4,R0 loop2: LDR R5,[R4] LDR R6,[R4,#4]! CMP R5,R6 BLS skip STR R5,[R4] STR R6,[R4,#-4] skip: SUBS R1,R1,#1 BNE loop2 MOV R1,R7 SUBS R1,R1,#1 BNE loop //quit: } } 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); } select(array,num); printf("=========================\nthe result is:\n"); for(i = 0; i } return 0; } |