For eg. LDR R0, =#0x20000001 20000001 is now stored in R0 but where is 0x stored?

  • 1
    \$\begingroup\$ It isn't stored \$\endgroup\$ May 2, 2020 at 15:15
  • 2
    \$\begingroup\$ 0x is a prefix specifying that the operand is a hexadecimal number. \$\endgroup\$ May 2, 2020 at 15:27
  • 2
    \$\begingroup\$ The # isnt stored either \$\endgroup\$
    – old_timer
    May 2, 2020 at 16:48
  • \$\begingroup\$ note that is not the correct syntax for the mainstream arm/cortex-ms assemblers (gnu, arm, etc) LDR R0,=0x20000001 is correct the # is used like this for example mov r0,#0x20000001, which is actually a legal immediate for some arm instruction sets (but not any in an stm32) \$\endgroup\$
    – old_timer
    May 2, 2020 at 16:55

1 Answer 1


The 0x isn't part of the data and doesn't need to be stored. It is a marker to indicate that the data following the 0x is represented in hexadecimal format. An alternative way of showing hexadecimal data is to follow it with h or H, e.g. 12ABh.

A leading 0 (without the x) can be used to indicate that the following data is represented in octal format (less seen nowadays).

Decimal data is shown without any leading characters.

  • \$\begingroup\$ assembly language is defined by the assembler (not the target, etc) and some assembly languages default to decimal, octal, or hex depends on the author of the assembler that created the assembly language. Although, I have yet to see an arm assembler that doesnt have decimal for a default. \$\endgroup\$
    – old_timer
    May 2, 2020 at 16:51
  • 2
    \$\begingroup\$ the 0x also helps to show that 0xABCD is a number not ABCD a label. or depending on the programming language language 0ABCDh or 0ABCD can all be hex. And for certain assembly languages in particular it is required to use 0ABCDh to represent a 16 bit number even though it looks like a 20 bit number. That leading 0 isnt stored either in that case. \$\endgroup\$
    – old_timer
    May 2, 2020 at 16:53
  • \$\begingroup\$ @old_timer That was helpful! \$\endgroup\$
    – Ajay Rajan
    May 6, 2020 at 11:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.