Author Topic: InData like routine is never firing(even though it should)  (Read 3718 times)

0 Members and 1 Guest are viewing this topic.

Offline 133794m3r

  • LV2 Member (Next: 40)
  • **
  • Posts: 21
  • Rating: +1/-3
    • View Profile
InData like routine is never firing(even though it should)
« 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
Code: [Select]
.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.

Code: [Select]
.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.
« Last Edit: December 22, 2012, 07:15:03 pm by 133794m3r »

Offline jacobly

  • LV5 Advanced (Next: 300)
  • *****
  • Posts: 205
  • Rating: +161/-1
    • View Profile
Re: InData like routine is never firing(even though it should)
« Reply #1 on: December 22, 2012, 12:18:09 am »
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 {}.

Offline squidgetx

  • Food.
  • CoT Emeritus
  • LV10 31337 u53r (Next: 2000)
  • *
  • Posts: 1881
  • Rating: +503/-17
  • rawr.
    • View Profile
Re: InData like routine is never firing(even though it should)
« Reply #2 on: December 22, 2012, 01:09:28 pm »
Jacobly, I think that's a result of sourcecoder/tokens parsing which represents the token r1 as {r1}

Just kidding, there're double brackets.
« Last Edit: December 22, 2012, 01:11:09 pm by squidgetx »

Offline 133794m3r

  • LV2 Member (Next: 40)
  • **
  • Posts: 21
  • Rating: +1/-3
    • View Profile
Re: InData like routine is never firing(even though it should)
« Reply #3 on: December 22, 2012, 07:14:46 pm »
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.