汇编--实现二分法和划分法

本文深入探讨如何使用汇编语言来实现高效的二分查找算法和数据划分策略。通过实例代码详细解释了底层逻辑,帮助读者理解在低级别编程中如何运用这两种算法。
摘要由CSDN通过智能技术生成
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				
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值