以前練手寫的代碼,拿來湊些熱鬧.如果有不妥之處請各位多多指教! ;asm部份 . .model flat,stdcall casemap:none .code start: ;冒泡排序.只對long型數字按伸序排序 DunkSort proc uses edx edi ebx / lpArray:DWORD,nlen:DWORD,x1,x2 mov edi,lpArray ;取第一個形參 mov ecx,nlen ;取第二個形參 dec ecx ;置外循環次數 ;mov dl, lopfa: ; dl,dl ;jz ;xor dl,dl push ecx ;保存外循環次數 xor ebx,ebx lopch: mov eax,[edi+ebx] cmp eax,[edi+ebx+] jle xchg eax, [edi+ebx+] mov [edi+ebx],eax ;mov dl, : add ebx, lopch pop ecx ;彈出外循環次數 lopfa : ret DunkSort ENDP start VERSION . Begin VB.Form frmSort Caption = ClientHeight = ClientLeft = ClientTop = ClientWidth = LinkTopic = ScaleHeight = ScaleWidth = StartUpPosition = Begin VB.TextBox txtUseTime Height = = TabIndex = Top = Width = Begin VB.CommandButton cmdSortVB Caption = Enabled = Height = = TabIndex = Top = Width = Begin VB.CommandButton cmdSortAsm Caption = Enabled = Height = = TabIndex = Top = Width = Begin VB.CommandButton cmdRndArray Caption = Height = = TabIndex = Top = Width = Begin VB.TextBox txtArrBottom Height = = TabIndex = Top = Width = Begin VB.Label Label2 AutoSize = - Caption = Height = = TabIndex = Top = Width = Begin VB.Label Label1 AutoSize = - Caption = Height = = TabIndex = Top = Width = Attribute VB_Name = Attribute VB_GlobalNameSpace = Attribute VB_Creatable = Attribute VB_PredeclaredId = Attribute VB_Exposed = QueryPerformanceCounter (lpPerformanceCount LARGE_INTEGER) LARGE_INTEGER lowpart highpart CallAsmProc _ ( lpAsmFn&, var1&, var2&, var3&, var4&) szAsmDKfn( ) arrVB() , arrAsmDK() arrBottom cmdRndArray_Click() I .Cls arrBottom = Val(txtArrBottom.Text) arrBottom < arrVB(arrBottom), arrAsmDK(arrBottom) I = arrBottom arrVB(I) = Rnd * (arrBottom + ) arrAsmDK(I) = arrVB(I) PrintData arrVB cmdSortVB.Enabled = : cmdSortAsm.Enabled = cmdSortAsm_Click() J , I , tmp , t1 t1 = GetTime CallAsmProc VarPtr(szAsmDKfn()), VarPtr(arrAsmDK()), arrBottom + , , txtUseTime.Text = GetTime - t1 PrintData arrAsmDK cmdSortAsm.Enabled = cmdSortVB_Click() J , I , tmp , t1 t1 = GetTime I = arrBottom - J = arrBottom - I - arrVB(J) > arrVB(J + ) tmp = arrVB(J) arrVB(J) = arrVB(J + ): arrVB(J + ) = tmp txtUseTime.Text = GetTime - t1 PrintData arrVB cmdSortVB.Enabled = Form_Load() szAsmDKfn() = : szAsmDKfn() = : szAsmDKfn() = : szAsmDKfn() = : szAsmDKfn() = : szAsmDKfn() = szAsmDKfn() = : szAsmDKfn() = : szAsmDKfn() = : szAsmDKfn() = : szAsmDKfn() = : szAsmDKfn() = szAsmDKfn() = : szAsmDKfn() = : szAsmDKfn() = : szAsmDKfn() = : szAsmDKfn() = : szAsmDKfn() = szAsmDKfn() = : szAsmDKfn() = : szAsmDKfn() = : szAsmDKfn() = : szAsmDKfn() = : szAsmDKfn() = szAsmDKfn() = : szAsmDKfn() = : szAsmDKfn() = : szAsmDKfn() = : szAsmDKfn() = : szAsmDKfn() = szAsmDKfn() = : szAsmDKfn() = : szAsmDKfn() = : szAsmDKfn() = : szAsmDKfn() = : szAsmDKfn() = szAsmDKfn() = : szAsmDKfn() = : szAsmDKfn() = : szAsmDKfn() = : szAsmDKfn() = : szAsmDKfn() = szAsmDKfn() = : szAsmDKfn() = : szAsmDKfn() = : szAsmDKfn() = : szAsmDKfn() = PrintData(arr() ) I .Cls I = arrBottom arr(I); (I + ) = GetTime() LI LARGE_INTEGER QueryPerformanceCounter LI GetTime = LI.lowpart
VB內嵌彙編玩排序
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.