Re: A89: recursion question


[Prev][Next][Index][Thread]

Re: A89: recursion question




Justin M Bosch wrote:

> >move.w      #1,d0
> >move.w      d0,stuff
> 
> I'm still learning 68k, and reading this made me wonder a few things.
> Whenever you want to store a number into a register, is it preceded by
> "#"?

Whenever you want to store an *immediate* value in a register, you have
to precede it by a #.  If it doesn't start with a #, it is considered
to be the address of the data.

> Also, is "stuff" a variable like as in computer programming languages, 
> or is it used like (stuff) would be used in Z80?  I'm sorry if the
> second question is hard to understand.

Yes.  The two ways you listed are virtually the same thing.  Whenever
you write "stuff" as the source or destination of an instruction, it is
taken as the address of the data since it doesn't start with a #, so
the processor will read or write data at the address of "stuff".

If that doesn't make sense, these examples should make it very clear;

 move.l	#40,d5		;Sets D5 equal to 40
 move.l	(40),d5		;Copies data from memory at address 40 to D5 
 move.l	40,d5		;Exactly the same as above

 move.l	#stuff,d5	;Puts the *address* of stuff in D5
 move.l (stuff),d5	;Copies the value in stuff to D5 (like on Z80)
 move.l	stuff,d5	;Exactly the same as above
 move.l stuff(pc),d5	;Same as above, but PC-relative (faster, smaller)

Of course, these assume that stuff refers to data in memory, like

stuff:
 dc.l	400


Follow-Ups: References: