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

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

AREA Sort,CODE,READONLY		;declare for code area
	ENTRY					;entry for the whole code
start						;main code flag
	MOV R4,#0				;clear r4
	LDR R6,=src				;r6 point to the begining of numbers
	ADD R6,R6,#len			;r6 point to the end of numbers  
outer					 	;outer loop begining
	LDR R1,=src				;r1 point to the begining of numbers 
inner						;inner loop begining
	LDR R2,[R1]				;get the number in address of r1
	LDR R3,[R1,#4]			;get the number in address next to r1
	CMP R2,R3				;compare two numbers we gotten
	STRGT R3,[R1]			;if the first > the second 
	STRGT R2,[R1,#4]			;exchange the position of two numbers
	ADD R1,R1,#4				;the point of r1 move
	CMP R1,R6				;compare position current  and ending
	BLT inner				;if not meet the ending go on to loop

	ADD R4,R4,#4				;global counter +1
	CMP R4,#len				;compare the current position
	SUBLE R6,R6,#4			;if not meet the ending
	BLE outer				;go on to loop

	AREA Array,DATA,READWRITE ;decare for data area
src	DCD 2,4,10,8,14,1,20	  	;init the original numbers
len	EQU 7*4					;get the length of numbers

	END						;end of whole code

  • 18
    点赞
  • 56
    收藏
    觉得还不错? 一键收藏
  • 6
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值