Nicolas Pitre wrote: >> However if r4 is non-zero, the carry will be set, and the tsths will be >> executed. This >> clears the carry and sets the Z flag based on bit 20. > > No, not at all. The carry is not affected. And that's the point of the > tst instruction here rather than a cmp: it sets the N and Z flags but > leaves C alone as there is no shifter involved.
No, the carry is always set by logical operations with a shifted immediate. It is only unchanged if the immediate uses a zero rotate. So any shifted immediate > 255 will set the carry. This is detailed in the Arm Architecture Reference Manual, eg. see the pseudo code for A32ExpandImm_C in LSL (immediate). Wilco