It never hurts to try, my idea is to 'correct' the offset by rescanning the string and doing +1 but when theres a 2 byte token skip the next byte:calc84maniac wrote:He doesn't want two byte token support, because that's the major slowdown factor in the TI-OS routines.driesguldolf wrote:
- If someone can tell me how to recognize a 2 byte token I can support that too
Code: Select all
; Assume hl->start of master string
; Assume bc->offset
ld de, 0
rescan:
ld a, (hl) ; [7]
inc hl ; [6]
; Assuming that all 2byte token identifiers start from a specific value
cp some_value ; [7]
jp nc, onebytetoken ; [10]
inc hl ; [6]
dec bc ; [6]
onebytetoken:
inc de ; [6]
; I know this can be faster, but it's just an example
dec bc ; [6]
ld a, b ; [4]
or c ; [4]
jp nz, rescan ; [10]
; One byte token: 60 tstates
; Two byte token: 72 tstates
;Plus if there exists such a thing as some_value I can also eleminate false/positive results by checking wether (pointer_to_start_of_substring-1) is a 2 byte token, if it is then it has to get back searching!
Ok, I was expecting a value a little bit higher ^^. Man it gotta suck to have programmed TIOS
Ouch:
I made a string with 2048 times "ABC" and then I wanted to stresstest my program by letting it search for all instances of "ABC"...
The answer is 2048! NOT 2928!!!
EDIT: tried again and it gives 2920... Please say that it's TIOS's fault...
This is so wrong:
Bug found!
But really theres nothing to celebrate:
Why does this sound familiar?...driesguldolf wrote: ; Calculate the amount of characters to look for
; = length(parent)-length(child)+1 +1 (the last +1 is a hack, it may ruin everything)
EDIT: all links updated (it turns out I uploaded an empty .zip file when you couldn't download it )
http://www.mediafire.com/?anheticyxtn
_________________
Former CursedGHOST shall be known as Cryzz.
Ok ok ok... My previous avatar sucked...
To make mistakes is human, to forgive is divine.
Crap char limit...
Minesweeper!