In the process of getting from one place to another, I needed to concoct a binary search algorithm for the 65C816 running in native mode. The job was to look up display control "mnemonics" (actually parameterless macros) embedded in text strings and then send an escape sequence to the display device to produce the desired result. I chose the binary search because quite a few of these mnemonics could be used, making rapid performance essential.
Anyhow, I subsequently generalized my code so that it can be used to search through an ordered list of character strings of varying lengths, e.g, a list of names, using a 16 bit pointer array to index the strings. All working storage is on the stack. Code is attached, and has been submitted to Mike for inclusion in the code library. There's plenty of commentary so you can see what's going on.
Attachment:
File comment: Binary Search for 65C816
bsrch816.zip [199.42 KiB]
Downloaded 97 times