首页 | 手机版 | 三国演义 | 三国志 | 史将 | 背景 | 藏书阁
首页 -> 精彩文章 -> RE:嵌入式作业一排序(linux下arm)

RE:嵌入式作业一排序(linux下arm)

作者拉格浪日 标签编程 阅读次数:102
linux 下armv4l-unknown-linux-gcc 编译通过
-----------------------------------sort.c
#include
#include
extern void select1(int *src,int number);

int main(void) {
int i=0;
int num=0;
int *array=NULL;
int *array2[1];


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);
}
array2[0]=array;
printf("please enter the elements:\n");
for(i = 0; iprintf("\n%d:\t", i);
scanf("%d", array+i);
}
select1(array,num);
printf("the result is:\n");
for(i = 0; i{
printf("%d:\t%d\n", i, *(array2[0]+i));
}

return 0;

}
-------------------------------------------sortasm.s文件

.section .text
.globl select1
select1:
    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
-----------------------------------------------



©1998-2012 5iSanGuo.com 版权所有.保留所有权利.
浙ICP备06020153号-1 浙公网安备 33010602002334号


浙ICP备06020153号-1