Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

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.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading