5.3.4. MOV, MVN, and NEG

Move, Move NOT, and Negate.

Syntax

MOV Rd, #expr
MOV Rd, Rm
MVN Rd, Rm
NEG Rd, Rm

where:

Rd

is the destination register.

expr

is an expression that evaluates (at assembly time)to an integer in the range 0-255.

Rm

is the source register.

Usage

The MOV instruction places #expr, or the value from Rm, in Rd.

The MVN instruction takes the value in Rm, performs a bitwise logical NOT operation on the value, and places the result in Rd.

The NEG instruction takes the value in Rm, multiplies it by –1, and places the result in Rd.

Restrictions

In MOV Rd,#expr, MVN, and NEG instructions, Rd and Rm must be in the range r0 to r7.

In MOV Rd, Rm instructions, Rd and Rm can be any register r0 to r15, but see Condition flags.

Condition flags

MOV Rd,#expr and MVN instructions update the N and Z flags. They have no effect on the C or V flags.

NEG instructions update the N, Z, C, and V flags.

MOV Rd, Rm behaves as follows:

  • if either Rd or Rm is a high register (r8-r15), the flags are unaffected

  • if both Rd and Rm are low registers (r0-r7), the N and Z flags are updated, and C and V flags are cleared.

    Note

    You can use LSL, with a shift of zero, to move between low registers without clearing the C and V flags (see ASR, LSL, LSR, and ROR).

Architectures

These instructions are available in all T variants of the ARM architecture.

Examples

    MOV r3,#0
    MOV r0,r12  ; does not update flags
    MVN r7,r1
    NEG r2,r2

Incorrect examples

    MOV r2,#256 ; immediate value out of range
    MOV r8,#3   ; cannot move immediate to high register
    MVN r8,r2   ; high registers not allowed with MVN or NEG
    NEG r0,#3   ; immediate value not allowed with MVN or NEG
Copyright © 2000, 2001 ARM Limited. All rights reserved.ARM DUI 0068B
Non-Confidential