The and flags are set reflect the status the result register
ARM Assembly Language Programming - Chapter 3 - The Instruction Set
MVN R1,#0 ;Get -1 in R1
CMP R0,R1 ;Do the comparison
which uses two instructions and an auxiliary register, compared to this:
CMN R0,#1 ;Compare R0 with -1
Note that whereas MVN is 'move NOT', CMN is 'compare negative', so there is a slight difference in the way <rhs> is altered before being used in the operation.
19 of 37
ARM Assembly Language Programming - Chapter 3 - The Instruction Set
If S is present in the instruction, and the instruction isn't one of TST, TEQ, CMP, or CMN (which are explained below), the status bits which are allowed to be altered in the current processor mode are overwritten directly by the result. (As opposed to the status of the result.) An example should make this clear. To explicitly set the carry flag (bit 29 of R15) we might use:
ORRS R15,R15,#&20000000
20 of 37
ARM Assembly Language Programming - Chapter 3 - The Instruction Set
MOV tmp,R15 ;Get the status
BIC tmp,tmp,#1<<28;Clear bit 28
TEQP R15,tmp ;Store the new statusFinally, we have to say something about performing arithmetic on R15 in order to alter the execution path of the program. As we will see later in this chapter, there is a special B (for Branch) instruction, which causes the PC to take on a new value, This causes a jump to another part of the program, similar to the BASIC GOTO statement. However, by changing the value of R15 using group one instructions such as ADD, we can achieve more versatile control, for example emulating the BASIC ON..GOTO statement.
There is a small class of instructions which is similar in form to the group one instructions, but doesn't belong in that group. These are the multiply instructions, whose form bears a similarity to the simplest form of group one instructions.
Two distinct operations make up this group, multiply and multiply with accumulate. The
All operands are simple registers; there are no immediate operands or shifted registers. MUL multiplies <lhs> by <rhs> and stores the result in <dest>. MLA does the same, but adds register <add> before storing the result.
You must obey certain restrictions on the operands when using these instructions. The registers used for <rhs> and <dest> must be different. Additionally, you should not use R15 as a destination, as this would produce a meaningless result. In fact, R15 is protected from modification by the multiply instructions. There are no other restrictions.
MUL R0,R1,R2
Summary of group one
The following <op2>s have no <lhs> field: MOV, MVN.
� <dest> and <lhs> are registers.
� <register>, RRX
3.3 Group two - load and store
Addressing modes
When storing data into memory, you have to be able to specify the desired location. There
<srce> is the register from which the data is to be transferred to memory. <base> is a register containing the base address of memory location required. <offset> is an optional number which is added to the address before the data is stored. So the address actually
used to store the <srce> data is <base>+<offset>
it is subtracted from the base address. An example is:
STR R0,[R1,#-200]