include irvine32.inc
.data
array DWORD 2,6,12,17,24,29,53,64,80,91 ;Define an array
array1 DWORD 51,3,34,6,5,1,31,19,72,48
step DWORD TYPE array ;this is step
key BYTE 12
pivot BYTE 30 ;Key
prompt BYTE "There is not key!!!" ;Prompt
.code
main PROC
mov esi,offset array ;esi load the array of pointer
mov ecx,lengthof array ;ecx is the length of array
mov al,key ;It is the key
call binarySearchB
call crlf
mov esi,offset array1
mov al,pivot
call partitionB
call crlf
call waitmsg
exit
main ENDP
binarySearchB PROC uses EAX EBX ECX ESI EDX
mov edx,0 ;for the first element in array(first)
mov ecx,lengthof array - 1 ;foe the last element in array(last)
beginwhile: ;This is the main while
cmp edx,ecx ;compare first and last
JA failwhile ;if first > last and still do not find key
;jump to failwhile
mov ebp,edx ;
add ebp,ecx
汇编--实现二分法和划分法
最新推荐文章于 2022-12-21 10:41:32 发布
本文深入探讨如何使用汇编语言来实现高效的二分查找算法和数据划分策略。通过实例代码详细解释了底层逻辑,帮助读者理解在低级别编程中如何运用这两种算法。
摘要由CSDN通过智能技术生成