Question

I have this line of code:

X   DC.W    5   

This means basically X = 5 But shouldn't be X DC.W #5 ?

When using MOVE I need always #

MOVE.B  #1,VAR
Was it helpful?

Solution

#1 means immediate value, i.e. the value 1. Without the #, it would mean the contents of the memory location 1.

With DC.* you place values (I guess you can call them "immediate" values) into memory locations specified by X. It is not a processor instruction, but the instruction for the assembler to reserve memory and fill it with specified value(s).

OTHER TIPS

Typically dc.(b/w/l) is used for hardcoded data being put into a table in ROM. E.g. if you wanted to create a table of four bytes, it'd look like the following:

EITHER ONE WILL WORK:

  • dc.b 4, 2, $10, $1A

OR

  • dc.b 4
  • dc.b 2
  • dc.b $10
  • dc.b $1A

They both mean the same thing, as they are declaring 4 bytes of data. Now, using MOVE is a little bit different, in that it is moving data to a data register, or a location in RAM. This data can be from... say, the table we created above, from a data register, or a simple number value starting with this '#', like so:

  • move.b #$11,($FFFFFE00).w

This moved the value $11 to the RAM address I specified. Hope that clears this up.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top