For example, what would be the difference between, MOVE 8,D2 and MOVE #8,D2? Just wondering what the # represents and what would happen without it.
-
1It's the prefix for an immediate value. – fuz Sep 29 '18 at 18:22
-
1Possible duplicate: https://stackoverflow.com/questions/6097958/what-does-the-hash-value-associated-with-the-arm-ldr-instruction-mean – Sigma Sep 29 '18 at 18:27
-
1@Sigma The linked question is on ARM, this one on m68k - How can this be a duplicate? ARM uses # on offsets as well, m68k doesn't. – tofro Oct 04 '18 at 08:52
4 Answers
in 68k assembly, the # sign denotes immediate constants. Everything else is normally considered an address:
move.w #6,d0
will load the constant immediate value 6 into register d0, while
move.w 6,d0
will do something entirely different: It will fetch the word at the constant address 6 into register d0

- 5,640
- 14
- 31
In GNU AS, if you use the # before anything else on a given line, the line will be ignored (comment). If use # before a value after an instruction, the value will be considered an immediate. If you want to use in-line comments at that point on the same line, you have to use C-style (i.e., /* comment here */) comments. For example:
# Write the palette to CRAM
lea Palette, a0 /* Move palette address to a0 */
move.w #size_palette_w-1, d0 /* Loop counter = 8 words in palette */

- 196
- 2
- 14
Normally in ARM and OP's code means an immediate constant but in other assembler types this symbol is different for example # is the same as $ in x86.

- 387
- 3
- 17