Omnimaga
Calculator Community => TI Calculators => Axe => Topic started by: 133794m3r on December 21, 2012, 10:23:10 pm
-
The code below is supposed to search through the data, and then if it finds the byte given to it, in the clump of data(r2) it'll return it's index(0 based). Otherwise it should have 65535 be stored as the
.SEARCH
Lbl SEARCH
65535->theta
255->X
For(B,0,X)
If {{r1}}={B+{r2}}
B->theta
255->X
Return
End
End
Return
The code below is the code that calls that subroutine.
.RC1
"SILLY STRING"->Str1
length(Str1)->L
Disp L>Dec,[i]
Pause 2000
0-Z
For(A,0,768)
0->{L1+A}
End
For(A,0,12)
SEARCH({Str1+A},L1)->theta
If theta!=65535
{L1+theta}^^r++
Else
{Str1+A}->{L1+A}
0->{A+255+L1}^^r
Z+1->Z
End
End
prgmSEARCH
I've tried debuggingn it by displaying the two values, and they _should_ match but it never seems to fire off right, and I have no idea why. I never seem to get a single byte to match a single other byte in the data. Even when I _know_ it should be in there and I can clearly see it.
-
I haven't looked too closely, but one thing I do notice is that you pass {A+Str1} into the routine, which is a number from 0-255. Then you do {r₁}, which tries to load a value from an address in the range 0-255. Such an address cannot be in ram (and is highly unlikely to be an address at all). I'm guessing you just have too many {}.
-
Jacobly, I think that's a result of sourcecoder/tokens parsing which represents the token r1 as {r1}
Just kidding, there're double brackets.
-
It's working now, so I'm going to lock this topic, as I honestly donn't think there's much else to be said about it. My mistake was found, and thanks to all who helped.