I need to speed up a search in a list.
Now I do a trivial cpir, the code looks like this:
n_block_up: equ 12
block_up:
db 42
db 55
db 126
db 127
db 128
db 129
db 136
db 145
db 146
db 156
db 157
db 161
; in E the byte to search
search:
ld hl,block_up
ld bc,n_block_up
ld a,e
cpir
ret nz ; not found
found:
etc...
But.... as the list is sorted there could be a faster way to search the byte in E
The fact is that my list is always short, no more that 10 - 12 bytes, so implementing binary search seems a bit too much to me... Any solution off the shell ?
Login or register to post comments

HL) seems to add a lot of overhead making vain the whole thing.