Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.
Motorola Binary Search Help
Hi Everyone! Hopefully most of the traffic on this site doesn't come from us kiddies in assembler classes wink
I'm having slight troubles with a Binary Search program in assembler. We are using Motorola 68k.
The purpose of the program is to load an array of data from some random file. The data in this random file is always integers -- positive and negative. Then we had to craft 2 subroutines, one to collect user input, one for the binary tree recursion. My user input works just dandy. My binary tree subroutine however is a little ... well off. I am purposely controlling the input so that elements will be "found" in the array. For some values, the algorithm can find it and correctly return the index back to the driving program to let the user know "hey, we found your value".
I have spent a few hours debugging and have found the troublesome code, but I can't seem to piece it together in the right way. What is happening is the binary search function will run a couple times, and then randomly get hooked up on one index, and continually stare at that index. We are passing addresses rather than values from the driving program for the hi & lo properties of the binary search.
Any ideas are appreciated :)
I can post code if necessary.
0 · ·