I see a lot of ARM assembly where immediate opcode values are prefixed with a #
, and plenty of examples where it's not used. I've been searching everywhere to try a find a grammar or description for when it is needed, but found nothing.
In my testing all the below produce the same expected machine code output (i.e. 16 multiplied by an integer to be added to the stack pointer), however some of the formats cause my syntax highlighter issues.
stp x2, x3, [sp, #16]
stp x4, x5, [sp, (16 * 2)]
stp x6, x7, [sp, #16 * 3]
stp x8, x9, [sp, 64]
stp x10, x11, [sp, #(16 * 5)]
Some forms are rejected by the compiler, such as the hash inside the parens [sp, (#16 * 2)]
or on the second integer [sp, #16 * #2]
Is the #
prefix required for any use-cases? Or is it entirely optional? (And is it documented anywhere?)