Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why isn't # needed before numbers with DC.W (Define Constant), only instructions?

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
like image 549
dynamic Avatar asked Apr 29 '12 18:04

dynamic


People also ask

Whats the definition of isn t?

Definition of isn't : is not.

What is the meaning of isn't he?

used for emphasizing that you completely agree with what someone has just said, especially a criticism. 'That man loves the sound of his own voice. ' 'Doesn't he just? '

What is the full form of I ll?

: I will : I shall.

How do you write not in short form?

ain't | American Dictionary contraction of am not, is not, are not, has not, or have not: "Is Terry here?" "No, he ain't coming in today."


2 Answers

#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).

like image 163
Igor F. Avatar answered Nov 05 '22 04:11

Igor F.


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.

like image 43
Sonic Retro's KingofHarts Avatar answered Nov 05 '22 04:11

Sonic Retro's KingofHarts