Keil Logo

Technical Support

On-Line Manuals

Compiler Reference Guide

Preface Arm Compiler Tools Overview armclang Reference armlink Reference fromelf Reference armar Reference armasm Legacy Assembler Reference armasm Command-line Options --16 --32 --apcs=qualifier…qualifier --arm --arm_only --bi --bigend --brief_diagnostics, --no_brief_diagnostics --checkreglist --cpreproc --cpreproc_opts=option[,option,…] --cpu=list (armasm) --cpu=name (armasm) --debug --depend=dependfile --depend_format=string --diag_error=tag[,tag,…] (armasm) --diag_remark=tag[,tag,…] (armasm) --diag_style={arm|ide|gnu} (armasm) --diag_suppress=tag[,tag,…] (armasm) --diag_warning=tag[,tag,…] (armasm) --dllexport_all --dwarf2 --dwarf3 --errors=errorfile --exceptions, --no_exceptions --exceptions_unwind, --no_exceptions_unwind --execstack, --no_execstack --execute_only --fpmode=model --fpu=list (armasm) --fpu=name (armasm) -g (armasm) --help (armasm) -idir[,dir, …] --keep (armasm) --length=n --li --library_type=lib --list=file --list= --littleend -m (armasm) --maxcache=n --md --no_code_gen --no_esc --no_hide_all --no_regs --no_terse --no_warn -o filename (armasm) --pd --predefine "directive" --reduce_paths, --no_reduce_paths --regnames --report-if-not-wysiwyg --show_cmdline (armasm) --thumb --unaligned_access, --no_unaligned_access --unsafe --untyped_local_labels --version_number (armasm) --via=filename (armasm) --vsn (armasm) --width=n --xref Structure of armasm Assembly Language Modules Syntax of source lines in armasm syntax assembly l Literals ELF sections and the AREA directive An example armasm syntax assembly language module Writing A32/T32 Instructions in armasm Syntax Asse About the Unified Assembler Language Syntax differences between UAL and A64 assembly la Register usage in subroutine calls Load immediate values Load immediate values using MOV and MVN Load immediate values using MOV32 Load immediate values using LDR Rd, =const Literal pools Load addresses into registers Load addresses to a register using ADR Load addresses to a register using ADRL Load addresses to a register using LDR Rd, =label Other ways to load and store registers Load and store multiple register instructions Load and store multiple register instructions in A Stack implementation using LDM and STM Stack operations for nested subroutines Block copy with LDM and STM Memory accesses The Read-Modify-Write operation Optional hash with immediate constants Use of macros Test-and-branch macro example Unsigned integer division macro example Instruction and directive relocations Symbol versions Frame directives Exception tables and Unwind tables Using armasm armasm command-line syntax Specify command-line options with an environment v Using stdin to input source code to the assembler Built-in variables and constants Identifying versions of armasm in source code Diagnostic messages Interlocks diagnostics Automatic IT block generation in T32 code T32 branch target alignment T32 code size diagnostics A32 and T32 instruction portability diagnostics T32 instruction width diagnostics Two pass assembler diagnostics Using the C preprocessor Address alignment in A32/T32 code Address alignment in A64 code Instruction width selection in T32 code Symbols, Literals, Expressions, and Operators in a Symbol naming rules Variables Numeric constants Assembly time substitution of variables Register-relative and PC-relative expressions Labels Labels for PC-relative addresses Labels for register-relative addresses Labels for absolute addresses Numeric local labels Syntax of numeric local labels String expressions String literals Numeric expressions Syntax of numeric literals Syntax of floating-point literals Logical expressions Logical literals Unary operators Binary operators Multiplicative operators String manipulation operators Shift operators Addition, subtraction, and logical operators Relational operators Boolean operators Operator precedence Difference between operator precedence in assembly armasm Directives Reference Alphabetical list of directives armasm assembly la About armasm assembly language control directives About frame directives Directives that can be omitted in pass 2 of the as ALIAS ALIGN AREA ARM or CODE32 directive ASSERT ATTR CN CODE16 directive COMMON CP DATA DCB DCD and DCDU DCDO DCFD and DCFDU DCFS and DCFSU DCI DCQ and DCQU DCW and DCWU END ENDFUNC or ENDP ENTRY EQU EXPORT or GLOBAL EXPORTAS FIELD FRAME ADDRESS FRAME POP FRAME PUSH FRAME REGISTER FRAME RESTORE FRAME RETURN ADDRESS FRAME SAVE FRAME STATE REMEMBER FRAME STATE RESTORE FRAME UNWIND ON FRAME UNWIND OFF FUNCTION or PROC GBLA, GBLL, and GBLS GET or INCLUDE IF, ELSE, ENDIF, and ELIF IMPORT and EXTERN INCBIN INFO KEEP LCLA, LCLL, and LCLS LTORG MACRO and MEND MAP MEXIT NOFP OPT QN, DN, and SN RELOC REQUIRE REQUIRE8 and PRESERVE8 RLIST RN ROUT SETA, SETL, and SETS SPACE or FILL THUMB directive TTL and SUBT WHILE and WEND WN and XN armasm-Specific A32 and T32 Instruction Set Featur armasm support for the CSDB instruction A32 and T32 pseudo-instruction summary ADRL pseudo-instruction CPY pseudo-instruction LDR pseudo-instruction MOV32 pseudo-instruction NEG pseudo-instruction UND pseudo-instruction Appendixes

Load immediate values using MOV and MVN

F3.5 Load immediate values using MOV and MVN

The MOV and MVN instructions can write a range of immediate values to a register.

In A32:

  • MOV can load any 8-bit immediate value, giving a range of 0x0-0xFF (0-255).

    It can also rotate these values by any even number.

    These values are also available as immediate operands in many data processing operations, without being loaded in a separate instruction.

  • MVN can load the bitwise complements of these values. The numerical values are -(n+1), where n is the value available in MOV.
  • MOV can load any 16-bit number, giving a range of 0x0-0xFFFF (0-65535).

The following table shows the range of 8-bit values that can be loaded in a single A32 MOV or MVN instruction (for data processing operations). The value to load must be a multiple of the value shown in the Step column.

Table F3-2 A32 state immediate values (8-bit)

Binary Decimal Step Hexadecimal MVN valuea Notes
000000000000000000000000abcdefgh 0-255 1 0-0xFF -1 to -256 -
0000000000000000000000abcdefgh00 0-1020 4 0-0x3FC -4 to -1024 -
00000000000000000000abcdefgh0000 0-4080 16 0-0xFF0 -16 to -4096 -
000000000000000000abcdefgh000000 0-16320 64 0-0x3FC0 -64 to -16384 -
... ... ... ... ... -
abcdefgh000000000000000000000000 0-255 x 224 224 0-0xFF000000 1-256 x -224 -
cdefgh000000000000000000000000ab (bit pattern) - - (bit pattern) See b in Note
efgh000000000000000000000000abcd (bit pattern) - - (bit pattern) See b in Note
gh000000000000000000000000abcdef (bit pattern) - - (bit pattern) See b in Note

The following table shows the range of 16-bit values that can be loaded in a single MOV A32 instruction:

Table F3-3 A32 state immediate values in MOV instructions

Binary Decimal Step Hexadecimal MVN value Notes
0000000000000000abcdefghijklmnop 0-65535 1 0-0xFFFF - See c in Note

Note:

These notes give extra information on both tables.

a
The MVN values are only available directly as operands in MVN instructions.
b
These values are available in A32 only. All the other values in this table are also available in 32-bit T32 instructions.
c
These values are not available directly as operands in other instructions.

In T32:

  • The 32-bit MOV instruction can load:
    • Any 8-bit immediate value, giving a range of 0x0-0xFF (0-255).
    • Any 8-bit immediate value, shifted left by any number.
    • Any 8-bit pattern duplicated in all four bytes of a register.
    • Any 8-bit pattern duplicated in bytes 0 and 2, with bytes 1 and 3 set to 0.
    • Any 8-bit pattern duplicated in bytes 1 and 3, with bytes 0 and 2 set to 0.

    These values are also available as immediate operands in many data processing operations, without being loaded in a separate instruction.

  • The 32-bit MVN instruction can load the bitwise complements of these values. The numerical values are -(n+1), where n is the value available in MOV.
  • The 32-bit MOV instruction can load any 16-bit number, giving a range of 0x0-0xFFFF (0-65535). These values are not available as immediate operands in data processing operations.

In architectures with T32, the 16-bit T32 MOV instruction can load any immediate value in the range 0-255.

The following table shows the range of values that can be loaded in a single 32-bit T32 MOV or MVN instruction (for data processing operations). The value to load must be a multiple of the value shown in the Step column.

Table F3-4 32-bit T32 immediate values

Binary Decimal Step Hexadecimal MVN valuea Notes
000000000000000000000000abcdefgh 0-255 1 0x0-0xFF -1 to -256 -
00000000000000000000000abcdefgh0 0-510 2 0x0-0x1FE -2 to -512 -
0000000000000000000000abcdefgh00 0-1020 4 0x0-0x3FC -4 to -1024 -
... ... ... ... ... -
0abcdefgh00000000000000000000000 0-255 x 223 223 0x0-0x7F800000 1-256 x -223 -
abcdefgh000000000000000000000000 0-255 x 224 224 0x0-0xFF000000 1-256 x -224 -
abcdefghabcdefghabcdefghabcdefgh (bit pattern) - 0xXYXYXYXY 0xXYXYXYXY -
00000000abcdefgh00000000abcdefgh (bit pattern) - 0x00XY00XY 0xFFXYFFXY -
abcdefgh00000000abcdefgh00000000 (bit pattern) - 0xXY00XY00 0xXYFFXYFF -
00000000000000000000abcdefghijkl 0-4095 1 0x0-0xFFF - See b in Note

The following table shows the range of 16-bit values that can be loaded by the MOV 32-bit T32 instruction:

Table F3-5 32-bit T32 immediate values in MOV instructions

Binary Decimal Step Hexadecimal MVN value Notes
0000000000000000abcdefghijklmnop 0-65535 1 0x0-0xFFFF - See c in Note

Note:

These notes give extra information on the tables.

a
The MVN values are only available directly as operands in MVN instructions.
b
These values are available directly as operands in ADD, SUB, and MOV instructions, but not in MVN or any other data processing instructions.
c
These values are only available in MOV instructions.

In both A32 and T32, you do not have to decide whether to use MOV or MVN. The assembler uses whichever is appropriate. This is useful if the value is an assembly-time variable.

If you write an instruction with an immediate value that is not available, the assembler reports the error: Immediate n out of range for this operation.

Non-ConfidentialPDF file icon PDF version101754_0614_00_en
Copyright © 2019, 2020 Arm Limited or its affiliates. All rights reserved. 
  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.