Home > Software design >  how does s suffix in arm assembly instructions work?
how does s suffix in arm assembly instructions work?

Time:01-01

I am new to assembly and wanted to know how does the s suffix added to the opcode of arm assembly instructions work. I have read it is used to update the condition flags based on the result of an operation. Is there a summary of the possible ways to update the condition flags based on a result of an operation? based on what properties of the result which flag bit do I update ?.

lets take this assembly code instruction as an example 000080fa movs r1, #0

what exactly does it do in the context of updating the condition flags?

CodePudding user response:

The way the flags are updated differs by instruction. But generally, the following happens when a flag-setting instruction is executed:

  • the N flag is set if the result is negative (i.e. the sign bit is set)
  • the Z flag is set if the result is zero
  • the C flag is set according to the carry out of the third operand shift
  • the V flag is unchanged

For instructions that shift the third operand by zero or do not have a way to encode a shift, the carry flag too remains unchanged. For instructions that are variants of addition, the C and V flags are instead set according to the carry and overflow of the addition.

  • Related