"在此项目中,您需要实施冒泡排序算法 用汇编语言。您需要在单独的过程中而不是在main函数中实现bubblesort。
到目前为止,我的代码如下。我有一个"休息"当它路由到bubblesort sub-protocal进行比较时(cmp)
非常感谢社区可以帮助我解决问题。
TITLE MASM Template (main.asm)
; Description:
;
; Revision date:
INCLUDE Irvine32.inc
.data
msg BYTE "Generating 100 element array",0
array DWORD 100 DUP(?)
Start DWORD ?
TOTAL DWORD ?
msg2 BYTE "Elapsed milliseconds: ",0
.code
BubbleSort PROC USES eax esi ecx
mov ecx, LENGTHOF array
dec ecx
L2:
push ecx
mov esi, array
L3:
mov eax, esi
cmp [esi+4], eax
jg L4
xchg eax, [esi+4]
mov [esi],eax
L4:
add esi, 4
loop L3
pop ecx
loop L4
L5: ret
exit
BubbleSort ENDP
main PROC
call Randomize
mov ecx, 10
mov esi, TYPE array
L1:
mov eax, 1000
call RandomRange
call WriteDec
call crlf
mov array[esi], eax
add esi, 4
loop L1
call GetMSeconds
mov Start, edx
call WriteDec
call Crlf
call BubbleSort
call GetMSeconds
call WriteDec
call Crlf
mov Total, edx
mov eax, Start
su Total, eax
call WriteDec
exit
main ENDP
END main