pawn
pawn copied to clipboard
`pri` is clobbered in `OP_CMPS` with custom `_R`.
If you set a custom _R macro the CMPS opcode becomes:
pri=0;
for (i=0; i+4<offs && pri==0; i+=4)
pri=_R32(data,alt+i)-_R32(data,pri+i);
This code is simultaneously using pri as the second comparison address and the comparision result. And since the comparison result in pri must remain 0 to continue the loop the second address is just always 0 instead of whatever was given.
Fixed code using val instead:
val=0;
for (i=0; i+4<offs && val==0; i+=4)
val=_R32(data,alt+i)-_R32(data,pri+i);
for ( ; i<offs && val==0; i++)
val=_R8(data,alt+i)-_R8(data,pri+i);
pri=val;
Edit: I double-checked the similar opcodes FILL and MOVE, neither of them have the same bug.