View Single Post
Old 19 January 2007, 10:47   #15
BippyM
Global Moderator
 
BippyM's Avatar
 
Join Date: Nov 2001
Location: Derby, UK
Age: 48
Posts: 9,355
Data Movement

Again I will be returning to these posts if needed

----

Code:
    move.<size>    source,destination
The move command simply moves data from source to destination

example
Code:
    move.b    #10,d0
Moves 10 into the lower 8 bits of register d0

the following flags are affected by the move command N, Z, V, C

the Z & N flags are set while the C and V flags are cleared.

Here is a simple asm program using the move command to copy the contents of a memory location to another. Not all commands have been discussed yet but they will be later so stick with it

Code:
    move.b    X,d0    Copy contents of X into d0
    move.b    d0,Y    Copy contents of d0 to Y
    rts       end

X    dc.b    10    set X to 10
Y    ds.b    1    Allocate 1 byte of memory
This program basically sets a memory location to 10 (X) and reserves memory for it to be copied to (Y). It then uses register d0 as a temporary storage. It then copies the contents of X to d0 and then from d0 to Y.

A simpler way would be

Code:
    move.b    X,Y    Copy contents of X directly to Y
    rts       end

X    dc.b    10    set X to 10
Y    ds.b    1    Allocate 1 byte of memory
Memory could be initialised and then the value copied directly. When taking this approach the data requires a # symbol placing in front of it

Code:
    move.l    #10,X    Copy 10 into X
    move.l    X,Y    Copy contents of X to Y
    rts        end

X    dc.l    1    Allocate 1 long of memory
Y    ds.l    1    Allocate 1 long of memory
Address registers can be used instead of data registers but the move command cannot be used. A special form must be used which is the movea command. To copy data from an address register the normal move command can be used. Moving data into an address register wont affect the SR
BippyM is offline  
 
Page generated in 0.08391 seconds with 11 queries