浮点数冒泡排序
2010-12-08 18:58
387 查看
;$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ ;-=- Double BubbleSort By G-Spider @2010 ;-=- ml /c /coff sort.asm ;-=- link /subsystem:console sort.obj ;$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ .386 .model flat,stdcall include user32.inc include kernel32.inc include msvcrt.inc includelib user32.lib includelib kernel32.lib includelib msvcrt.lib .data fmt0 db '%lf',0 fmt1 db '%.4lf ',0 fmt2 db 0dh,0ah,0 inform db 'Please input 6 real nums:',0dh,0ah,0 outform db 'Sort nums: ',0dh,0ah,0 szPause db 'Pause',0 .data? ArrTEST qword 10 dup(?) .code ;**************************** DoubleBubbleSort proc lpDest:DWORD,count:DWORD ; 双精度浮点冒泡排序,从小到大 mov edx, count mov ecx, 1 LOOP1: cmp ecx,0 je EXIT mov esi, lpDest xor ecx, ecx dec edx xor ebx, ebx LOOP2: cmp ebx, edx jge LOOP1 inc ebx ;比较 fld QWORD PTR[esi] fcom QWORD PTR[esi+8] fnstsw ax test ah, 65 jne NEXT2 ;需要交换 fld QWORD PTR[esi+8] fstp QWORD PTR[esi] fstp QWORD PTR[esi+8] mov ecx, 1 add esi, 8 jmp LOOP2 NEXT2: ;无须交换,恢复堆栈 fstp st(0) add esi, 8 jmp LOOP2 EXIT: xor eax,eax ret DoubleBubbleSort ENDP ;**************************** _Input proc xor ecx,ecx mov edi,offset ArrTEST @@: cmp ecx,6 je EXIT push ecx lea eax,dword ptr[edi+ecx*8] push eax push offset fmt0 call crt_scanf add esp,8 pop ecx inc ecx jmp @B EXIT: xor eax,eax ret _Input endp ;**************************** _Output proc lpDest:DWORD xor ecx,ecx mov edi,lpDest @@: cmp ecx,6 je EXIT push ecx fld qword ptr[edi+ecx*8] sub esp,8 fstp qword ptr[esp] push offset fmt1 call crt_printf add esp,12 pop ecx inc ecx jmp @B EXIT: xor eax,eax ret _Output endp ;**************************** start: push offset inform call crt_printf add esp,4 ;数据输出 ;-------- invoke _Input ;-------- ;冒泡排序 ;-------- invoke DoubleBubbleSort,offset ArrTEST,6 ;-------- push offset outform call crt_printf add esp,4 ;数据输出 ;-------- invoke _Output,offset ArrTEST ;-------- push offset fmt2 call crt_printf add esp,4 invoke crt_system,offset szPause invoke ExitProcess,0 end start </textarea>
相关文章推荐
- 从大到小排序(区分顺序排序和冒泡排序)
- PHP浮点数引起的四舍五入问题
- Python实现排序算法之冒泡排序
- 冒泡排序(BubbleSort)
- 冒泡排序
- 排序算法--冒泡排序(Bubble Sort)_C#程序实现
- 常用排序算法-冒泡排序
- 1.交换排序:冒泡排序和快速排序
- 面试 9:Java 玩转冒泡排序
- 浮点数加法 九度oj
- 冒泡排序
- 冒泡排序
- 各种排序算法实现——基数排序、归并排序、插入排序、冒泡排序、选择排序、快速排序、堆排序、希尔排序
- JAVA浮点数运算
- javascript中数组的冒泡排序使用示例
- javascipt----冒泡排序
- 交换排序之--冒泡排序,快速排序
- Java--选择排序,冒泡排序
- php 简单冒泡排序和选择排序
- day04,数组的操作,遍历,查找,选择冒泡排序,进制转换,二维数组