第一个ARM汇编程序——冒泡排序

来源:互联网 发布:国家统计局人口数据 编辑:程序博客网 时间:2024/06/03 09:22

引用请注明出处:http://blog.csdn.net/int64ago/article/details/7008883

AREA Sort,CODE,READONLY;declare for code areaENTRY;entry for the whole codestart;main code flagMOV R4,#0;clear r4LDR R6,=src;r6 point to the begining of numbersADD R6,R6,#len;r6 point to the end of numbers  outer ;outer loop beginingLDR R1,=src;r1 point to the begining of numbers inner;inner loop beginingLDR R2,[R1];get the number in address of r1LDR R3,[R1,#4];get the number in address next to r1CMP R2,R3;compare two numbers we gottenSTRGT R3,[R1];if the first > the second STRGT R2,[R1,#4];exchange the position of two numbersADD R1,R1,#4;the point of r1 moveCMP R1,R6;compare position current  and endingBLT inner;if not meet the ending go on to loopADD R4,R4,#4;global counter +1CMP R4,#len;compare the current positionSUBLE R6,R6,#4;if not meet the endingBLE outer;go on to loopAREA Array,DATA,READWRITE ;decare for data areasrcDCD 2,4,10,8,14,1,20  ;init the original numberslenEQU 7*4;get the length of numbersEND;end of whole code

原创粉丝点击