⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 bsort.asm

📁 <<inter 汇编程序设计>>的源代码
💻 ASM
字号:
TITLE  BubbleSort Procedure                  (BSort.asm)

; Sort an array of signed integers, using the Bubble
; sort algorithm. The main program is in B_main.asm.
; Last update: 9/10/01

INCLUDE Irvine32.inc

.code
;----------------------------------------------------------
BubbleSort PROC USES eax ecx esi,
	pArray:PTR DWORD,		; pointer to array
	Count:DWORD		; array size
;
; Sort an array of 32-bit signed integers in ascending order
; using the bubble sort algorithm.
; Receives: pointer to array, array size
; Returns: nothing
;-----------------------------------------------------------

	mov ecx,Count
	dec ecx		; decrement count by 1

L1:	push ecx		; save outer loop count
	mov esi,pArray		; point to first value

L2:	mov eax,[esi]		; get array value
	cmp [esi+4],eax		; compare a pair of values
	jge L3		; if [esi] <= [edi], don't exch
	xchg eax,[esi+4]		; exchange the pair
	mov [esi],eax

L3:	add esi,4		; move both pointers forward
	loop L2		; inner loop

	pop ecx		; retrieve outer loop count
	loop L1		; else repeat outer loop

L4:	ret
BubbleSort ENDP

END

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -