; $ $ <Br/>; -=-double bubblesort by G-spider @ 2010 <br/>;-=-ml/C/coff sort. ASM <br/>;-=-link/subsystem: Console sort. OBJ <br/>; $ $ <br/>. 386 <br/>. model flat, stdcall </P> <p> include user32.inc <br/> include kernel32.inc <br/> include msvcrt. INC </P> <p> includelib user32.lib <br/> includelib kernel32.lib <br/> includelib msvcr T. lib </P> <p>. data <br/> fmt0 dB '% lf', 0 <br/> fmt1 db' %. 4lf ', 0 <br/> fmt2 dB 0dh, 0ah, 0 <br/> Inform dB 'Please Input 6 real Nums:', 0dh, 0ah, 0 <br/> outform dB 'sort Nums: ', 0dh, 0ah, 0 <br/> szpause dB 'pause', 0 </P> <p>. data? <Br/> arrtest qword 10 DUP (?) </P> <p>. code <br/>; * ************************* <br/> doublebubblesort proc lpdest: DWORD, count: DWORD <br/>; double-precision floating point Bubble sorting, from small to large </P> <p> mov edX, count <br/> mov ECx, 1 </P> <p> loop1: <br/> CMP ECx, 0 <br/> je exit </P> <p> mov ESI, lpdest <br/> XOR ECx, ECx </P> <p> dec edX <br/> xor ebx, EBX <br/> loop2: <br/> cmp ebx, edX <br/> jge loop1 <br/> Inc EBX </P> <p>; comparison <br/> benchmark qword PTR [esi] <br/> fcom qword PTR [ESI + 8] </P> <p> fnstsw ax <br/> test ah, 65 <br/> JNE next2 <br/>; need to switch <br/> FLD qword PTR [ESI + 8] <br/> fstp qword PTR [esi] <br/> fstp qword PTR [ESI + 8] <br/> moV ECx, 1 <br/> Add ESI, 8 <br/> JMP loop2 </P> <p> next2: <br/>; no need to exchange, stack recovery <br/> fstp ST (0) <br/> Add ESI, 8 <br/> JMP loop2 </P> <p> Exit: <br/> XOR eax, eax <br/> RET <br/> doublebubblesort endp <br/>; * ************************** <br/> _ INPUT proc <br/> XOR ECX, ECX <br/> mov EDI, offset arrtest <br/>@:< br/> CMP ECx, 6 <br/> je exit <br/> push ECx <br/> Lea eax, dword ptr [EDI + ECx * 8] <br/> push eax <br/> push offset fmt0 <br/> call crt_scanf <br/> Add ESP, 8 <br/> pop ECx <br/> Inc ECx <br/> JMP @ B </P> <p> Exit: <br/> XOR eax, eax <br/> RET <br/> _ INPUT endp <br/>; * ************************** <br/> _ output proc lpdest: DWORD <br/> XOR ECx, ECx <br/> mov EDI, lpdest <br/>@:< br/> CMP ECx, 6 <br/> je exit <br/> push ECx <br/> export qword PTR [EDI + ECx * 8] <br/> sub ESP, 8 <br/> fstp qword PTR [esp] <br/> push offset fmt1 <br/> call crt_printf <br/> Add ESP, 12 <br/> pop ECx <br/> Inc ECx <br/> JMP @ B </P> <p> Exit: <br/> XOR eax, eax <br/> RET <br/> _ output endp <br/>; * ************************** <br/> start: <br/> push offset inform <br/> call crt_printf <br/> Add ESP, 4 <br/>; data output <br/>; -------- <br/> invoke _ INPUT <br/>; -------- </P> <p>; Bubble Sorting <br/>; -------- <br/> invoke doublebubblesort, offset arrtest, 6 <br/>; -------- <br/> push offset outform <br/> call crt_printf <br/> Add ESP, 4 <br/>; data output <br/>; -------- <br/> invoke _ output, offset arrtest <br/>; -------- <br/> push offset fmt2 <br/> call crt_printf <br/> Add ESP, 4 </P> <p> invoke crt_system, offset szpause <br/> invoke exitprocess, 0 </P> <p> end start </P> <p> </textarea>