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
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
#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).
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:
OR
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:
This moved the value $11 to the RAM address I specified. Hope that clears this up.
© 2022 - 2024 — McMap. All rights reserved.