Category:ARM Assembly: Difference between revisions

Content added Content deleted
m (→‎Limitations of the ARM: Formatting (again))
m (→‎Conditional Opcodes: Rephrased a sentence for clarity)
Line 33: Line 33:




If your code does one thing when a flag is set and another when that same flag is clear, the ARM can do both without having to branch at all.
If your code does one thing when a flag is set and another when that same flag is clear, the ARM can select the correct option without having to branch at all:


<lang ARM Assembly>;ARM ASSEMBLY
<lang ARM Assembly>;ARM ASSEMBLY
Line 51: Line 51:
sub ax,bx
sub ax,bx
done:</lang>
done:</lang>

===Setting Flags===
===Setting Flags===
The flags, or condition codes, are only set by instructions that end in an "s," or by compare commands such as <code>CMP</code>. This lets you "preserve" the processor's state after an important calculation, but do some other things before execution branches depending on the result of that calculation. On any other processor, the calculation that determines whether a branch occurs MUST happen JUST before that branch statement or the branch will be taken based on the wrong data.
The flags, or condition codes, are only set by instructions that end in an "s," or by compare commands such as <code>CMP</code>. This lets you "preserve" the processor's state after an important calculation, but do some other things before execution branches depending on the result of that calculation. On any other processor, the calculation that determines whether a branch occurs MUST happen JUST before that branch statement or the branch will be taken based on the wrong data.