Search unanswered questions...
Enter a question here...

Assembly language program to do binary search?

[Edit]

Answer

BinarySearch proc ;params: array (of integers), length, target
push ebp
mov ebp, esp

mov ebx, [ebp + 8]
mov ecx, [ebp + 12]
xor edx, edx
dec ecx
jmp LoopCond
LoopStart:
mov eax, edx
add eax, ecx
shr eax, 1
push ecx
mov ecx, [ebp + 16]
cmp [eax * 4 + ebx], ecx
pop ecx
je Exit
jl UpperHalf
mov ecx, eax
dec ecx
jmp LoopCond
UpperHalf:
mov edx, eax
inc edx
LoopCond:
cmp ecx, edx
jge LoopStart
mov eax, -1

Exit:
pop ebp
ret
BinarySearch endp

Improve Answer Discuss the question "Assembly language program to do binary search?" Watch Question

First answer by ID1024584061. Last edit by Sudennis315. Contributor trust: 20 [recommend contributor]. Question popularity: 3 [recommend question]

Research your answer:

Answers.com > Wiki Answers > Categories > Technology > Computers > Assembly language program to do binary search?

Our contributors said this page should be displayed for the questions below. (Where do these come from)
If any of these are not a genuine rephrasing of the question, please help out and edit these alternates.
C program to search an element using binary search?  In the binary language each 0 or 1 is referred to as a?  WRITE AN Assembly language program to do binary search?  Example program for binary search in 8086 microprocessor?