Hello all,
I need to implement iterative (non-recursive) binary search in assembly. The array has 10 elements, starting from 0x10000100, in address 0x10000004 there's the element to search for, and the answer should be put in address 0x10000008

It should be for MIPS and I ran it in QTSpim

Here's the pseudo-code of the method I should impelement:

#	first = 0
#	last = size -1
#	while (last - first > 1) {
#		mid = (last-first)/2 + first
#		if A[mid] == val
#			break;
#		if A[mid] > val
#			last = mid;
#			continue
#		else
#			first = mid;
#			continue;
#	}

Does anyone can help me with this please?

Is this for a MIPS assembler programming class, or do you just need to do this with a MIPS processor target? If the latter, just program it in C and compile it with a GNU MIPS cross-compiler. If the former, then get a start on it before you ask us for help.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.