简体   繁体   中英

how does s suffix in arm assembly instructions work?

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?

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 (ie 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM