Saved searches

Use saved searches to filter your results more quickly

Cancel Create saved search Sign up Reseting focus

You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.

An Iterative Implementation of the Binary Search Algorithm in Assembly Language for the MIPS Architecture.

Notifications You must be signed in to change notification settings

juneadkhan/BinarySearch-Assembly

This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Go to file

Folders and files

Last commit message Last commit date

Latest commit

History

View all files

Repository files navigation

Binary Search in Assembly Language 🖥️🔍

Code Snippet:

binarySearch: li $t1, 0 # left = 0 li $t2, 0 # middle = 0 subu $t3, $s1, 1 # right = size - 1 li $t4, -1 # elementindex = -1 whileLoop: bgt $t1, $t3, end # end while when left > right subu $t2, $t3, $t1 # Middle = right - left srl $t2, $t2, 1 # Middle = (right - left) / 2 add $t2, $t2, $t1 # Middle = left + (right - left) / 2 sll $t6, $t2, 2 # index for A[Middle] addu $s0, $0, $t6 # point to middle lw $a0, 0($s0) # a0 = A[middle] bne $a0, $s2, notEqual # if ( A[middle] == v) < IF NOT SKIP TO notEqual add $t4, $0, $t2 # element_index = middle j end # BREAK notEqual: slt $t5, $a0, $s2 # is A[middle] < v . IF YES, t5 = TRUE beqz $t5, notLess 

About

An Iterative Implementation of the Binary Search Algorithm in Assembly Language for the MIPS Architecture.