Section 01 Part 05 – The MOVE Instruction

 

Computers are like Old Testament gods; lots of rules and no mercy.”  ~Joseph Campbell

 

 

 

Introduction

 

MOVE – copy data from source to destination

 

You’ve seen this instruction used multiple times by now in the previous parts, so let’s look at it in more detail.

 

This instruction will copy the number from the source operand and move it to the destination operand, the source operand will remain unchanged.

 

 

 

Examples

 

Examples are always good; so we’ll start with moving a byte to a data register:

 

          move.b    #$95,d0

 

This will copy the byte 95 into data register d0:

 

 

As you can see, no matter what was in d0 before, it will always be replaced with the byte 95.

 

Here are a few more examples:

 

 

As you can see, only the right byte is replaced, the rest remains the same, this is because the instruction had .b telling the processor to move only a byte.

 

Here’s an example using .w for word:

 

          move.w    #$40F5,d0

 

This will copy the word 40F5 into data register d0:

 

 

As you can see, no matter what was in d0 before, it will always be replaced with the word 40F5.

 

Here are a few more examples:

 

 

As you can see, only a word of d0 was replaced, the rest of d0 remains the same, this is because the instruction had .w telling the processor to move only a word.

 

Here’s an example using .l for long-word:

 

          move.l    #$55667788,d0

 

This will copy the long-word 55667788 into data register d0:

 

 

As you can see no matter what was in d0, it will always be replaced by 55667788.  Because the instruction had .l for long-word, the entire register gets changed.

 

 

 

Other Examples

 

You can move numbers from one register to another as well, for example:

 

          move.w    d0,d1

 

This will copy a word of data from d0 to d1.

 

 

The 4567 was copied from d0 over to d1, d0 will still contain 01234567 though.  Remember, the source operand always remains unchanged.

 

Moving to and from memory:

 

          move.w    d0,$0000104E

 

This will copy the word in d0, and move it into memory at offset $0000104E.  If d0 contains 99004980, then 4980 is copied to memory at offsets 0000104E and 0000104F:

 

Offset

0

1

2

3

4

5

6

7

8

9

A

B

C

D

E

F

etc

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

00001030

00

00

00

00

00

00

00

00

00

00

00

00

00

00

00

00

00001040

00

00

00

00

00

00

00

00

00

00

00

00

00

00

49

80

00001050

00

00

00

00

00

00

00

00

00

00

00

00

00

00

00

00

00001060

00

00

00

00

00

00

00

00

00

00

00

00

00

00

00

00

etc

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

You can copy data from memory to a data register:

 

          move.w    $00001062,d0

 

If d0 contains 40414243, and the data in memory is:

 

Offset

0

1

2

3

4

5

6

7

8

9

A

B

C

D

E

F

etc

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

00001030

00

00

00

00

00

00

00

00

00

00

00

00

00

00

00

00

00001040

00

00

00

00

00

00

00

00

00

00

00

00

00

00

00

00

00001050

00

00

00

00

00

00

00

00

00

00

00

00

00

00

00

00

00001060

00

00

00

22

00

00

00

00

00

00

00

00

00

00

00

00

etc

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

0022 is copied to d0, and d0 will then contain 40410022.

 

You can copy from memory to memory:

 

          move.l    $00000800,$00000822

 

This is moving a long-word, so if the data in memory is:

 

Offset

0

1

2

3

4

5

6

7

8

9

A

B

C

D

E

F

etc

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

000007F0

00

12

33

00

8E

00

00

00

00

00

7F

00

00

00

00

00

00000800

00

00

99

1A

00

00

00

00

00

00

00

00

00

00

00

00

00000810

00

00

00

00

00

00

00

44

00

00

00

00

34

44

45

00

00000820

00

12

34

43

99

08

FE

04

00

00

00

00

00

00

00

00

etc

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

The bytes from 00000800, 00000801, 00000802 and 00000803, are copied over to 00000822, 00000823, 00000824 and 00000825:

 

Offset

0

1

2

3

4

5

6

7

8

9

A

B

C

D

E

F

etc

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

000007F0

00

12

33

00

8E

00

00

00

00

00

7F

00

00

00

00

00

00000800

00

00

99

1A

00

00

00

00

00

00

00

00

00

00

00

00

00000810

00

00

00

00

00

00

00

44

00

00

00

00

34

44

45

00

00000820

00

12

00

00

99

1A

FE

04

00

00

00

00

00

00

00

00

etc

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

If you recall on Part 04, we talked about “address registers”.

 

You can copy data to memory through the “address registers” too, by indexing, the auto incrementing/decrementing, and others.

 

Here are a few examples just to give you a rough idea of the possibilities:

 

          move.w    (a0),(a1)

          move.w    (a0),d0

          move.w    d1,(a0)+

          move.w    d1,$10(a1)

          move.b    #$98,(a0)+

          move.l    $29(a0),$00120020

          move.b    $00120020,(a1)+

 

 

 

Previous Part

Main Page

Next Part