Win32 Compilation Bubble sort

Source: Internet
Author: User

Used to write a bubble, to make a record, mainly the use of learning cycle

.386.model flat,stdcalloption casemap:noneinclude windows.incinclude user32.incincludelib user32.libinclude Kernel32.incincludelib kernel32.lib.databytes db ' hello,asm ', 0lenth DW?.  CODESWAP proc Nearpush Ebp;mov EBP, espsub ESP, 100push ebxpush ESI Lea Edi,[esp];mov Eax,0cccccccch;mov ecx,25;rep STOs DWORD ptr Es:[edi];mov Eax,[ebp+8]mov [Ebp-4],eax;mov Eax,[ebp+12];mov [Ebp-8],eax;mov Eax,[ebp-4];//temp=amov Al,[eax ];mov [Ebp-12],al;mov Eax,[ebp-8];//a=b;mov al,[eax];mov Ebx,[ebp-4];mov [Ebx],al;mov Al,[ebp-12];//b=tmpmov ebx,[ Ebp-8];mov [Ebx],al;pop esi;pop ebx;add ESP, 100;pop ebp;ret 8swap endpbublesort proc Nearpush Ebpmov ebp,espsub ESP, 100p Ush ebx;push Esi;lea Edi,[ebp-100];mov Eax,0cccccccchmov ecx,25rep stos dword ptr Es:[edi];mov Eax,[ebp+8]mov [ebp-4],eax ; mov Eax,[ebp+12]mov [Ebp-8],eax;mov eax,0; mov [ebp-12],eax;jmp looponejudge; Looponebody:mov Eax,0;mov [ebp-16],eax;jmp Looptwojudge; Looptwobody:mov eax,[ebp-4];add Eax,[ebp-16];mov Bl,[eax];mov bh,[eax+1];cmp bl,bh;jl SwApend;push eax;add eax,1;push Eax;call swap; Swapend:mov eax,[ebp-16];inc Eax;mov [Ebp-16],eax; Looptwojudge:mov Eax,[ebp-16];mov ebx,[ebp-8];sub ebx,[ebp-12];sub ebx,1;cmp eax,ebx;jl LoopTwoBody;mov eax,[ebp-12]; Inc Eax;mov [Ebp-12],eax; Looponejudge:mov Eax,[ebp-12]mov ebx,[ebp-8];sub ebx,1cmp eax,ebx;jl looponebody;pop esi;pop ebx;add esp,100;pop ebp; RET 8;bublesort Endpstart:mov eax,9;push eax;mov eax,offset bytes;push eax;call bublesort;invoke MessageBox,0,offset Bytes,0,mb_okretend start



Win32 Compilation Bubble sort

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.