ARM carry flag on EOR/XOR and AND


I was looking up some ARM assembly and i notice EOR/XOR and AND all set the C and O flag. How does that work? Are they always cleared? what conditions are they set?

Best Solution

If you decide to continue with ARM assembler you need a copy of the ARM ARM, which is the ARM Architecture Reference Manual. There are many versions and each have their own "features". I recommend collecting as many as you can but thats another story. There are a number of ways to get an electronic copy for free. Either way:

AND you need the S bit set which for ARM means use ANDS instead of AND. For thumb mode you are always using ANDS but gas for example refuses to accept ANDS in thumb mode (but always disassembles it as an ands).

If S==1 and Rd == R15 then 
else if S==1
  N Flag = Rd[31]
  Z Flag = if Rd == 0 then 1 else 0
  C Flag = shifter_carry_out
  V flag = unaffected

EOR is the same as AND when it comes to the flags