|

楼主 |
发表于 2009-2-10 16:59:13
|
显示全部楼层
请告诉我该不该展开循环....
- .386
- .model flat, stdcall
- option casemap :none
- .data
- dwarray dd '8','7','9','4','1','5','2','3','6'
- arrayend label dword
- .code
- start:
- mov ebx,offset arrayend
- mov ecx,9
- ;save
- push dword ptr [ebx]
- push ebx
- push edx
- push ebp
- jmp insertionsort
- align 16
- aftersort:
- ;restore
- pop ebp
- pop edx
- pop ebx
- pop dword ptr [ebx]
- ret
- align 16
- ;ebx-pointer to array end
- ;ecx-array length
- ;aftersort-return address
- ;destroys eax,ebx,ecx,edx,esi,edi,ebp,dword at array end
- insertionsort proc
- db 0c7h,83h,00h,00h,00h,00h,0ffh,0ffh,0ffh,0ffh ;mov dword ptr [ebx+0],-1
- db 81h,0ebh,04h,00h,00h,00h ;sub ebx,4
- @@1:
- sub ecx,1
- nop
- db 0fh,84h ;jz near aftersort
- dd aftersort-($+4)
- mov esi,ebx
- sub ebx,4
- mov eax,[ebx]
-
- mov edx,[esi]
- cmp eax,edx
- jbe @@1
- mov [ebx],edx
- nop
- db 66h,0fh,1fh,44h,00h,00h ;nop6
-
- @@2:
- mov edx,[esi+4]
- cmp eax,edx
- jbe short @@3
- mov [esi],edx
-
- mov edi,[esi+8]
- add esi,12
- mov ebp,[esi]
- cmp eax,edi
- jbe short @@4
- mov [esi-8],edi
- cmp eax,ebp
- jbe short @@5
- mov [esi-4],ebp
- nop
- jmp @@2
-
- align 16
- @@3:
- mov [esi],eax
- nop
- jmp @@1
-
- align 16
- @@4:
- mov [esi-8],eax
- nop
- jmp @@1
-
- align 16
- @@5:
- mov [esi-4],eax
- nop
- jmp @@1
- endp
- end start
复制代码
[ 本帖最后由 littlekevin 于 2009-2-10 17:03 编辑 ] |
|