Skip to content

Find all hex starting with and has fixed length #2103

Discussion options

You must be logged in to vote

There is a mistake. if you wanted to find the magic sequence you would write

bool found = false;
if ($[$]==0x55 && $[$+1] == 0xAA) 
    found = true;

the while inside the array wants to avoid finding them which is the negative of finding them so it should be

!($[$]==0x55 && $[$+1] == 0xAA) =>  ($[$]!=0x55 || $[$+1] != 0xAA) 

So in the code change ($[$]!=0x55 && $[$+1] != 0xAA) to ($[$]!=0x55 || $[$+1] != 0xAA) and then it should work for you. The reason it didnt read the 0x55 is because the && makes it avoid either 0x55 or 0xAA so when it finds 0x55 it stops.

It actually was correct in the code you posted.

Replies: 1 comment 8 replies

Comment options

You must be logged in to vote
8 replies
@akshaybabloo
Comment options

@paxcut
Comment options

@akshaybabloo
Comment options

@paxcut
Comment options

Answer selected by akshaybabloo
@akshaybabloo
Comment options

@akshaybabloo
Comment options

@paxcut
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants