### DIRECT

The content of the registers must be treated as values not pointers/addresses.

#### With data register Dn

• <ea> = Dn
• Syntax: Dn where n is 0 ... 7
• Details: The operand is in a data register. The effective address <ea> specifies this register.
• Comments: It is very common in use. Size of the operand can be byte, word or long word.
• Example:
```   move.l d1, d0 ; Source -> Destination
```

Copies the content of the register D1 to register D0. When instruction is executed both registers will contain the same information. When copying a byte or a word, the upper part of the register will remain unchanged.

```                 ; assuming D1 = 01234567, D0 = FFFFFFFF
move.w d1, d0 ; copies a word
; D1 = 01234567, D0 = FFFF4567
...
; assuming D1 = 01234567, D0 = FFFFFFFF
move.b d1, d0 ; copies a byte
; D1 = 01234567, D0 = FFFFFF67
```

• <ea> = An
• Syntax: An where n is 0 ... 7
• Details: The operand is in an address register. The effective address <ea> specifies this register.
• Comments: It is very common in use. Size of the operand can be word or long word. If you have a byte value extend the value to the word. All values will be treated as signed values.
• Example:
```   move.l a1, d0
```

Copies the whole register A1 to register D0. When instruction is executed both registers will contain the same information. When a word operand is transferred to an address register, the bit 15 of the operand (sign bit) will be copied through the whole upper word of the register (bits 31 .. 16). If wasn't so a negative number will become positive.

```                 ; assuming A1 = 01234567, D0 = FFFFFFFF
move.w a1, d0 ; copies from an address register, no sign change
; A1 = 01234567, D0 = FFFF4567
...
; assuming D0 = 01234567, A0 = FFFFFFFF
move.w d0, a0 ; copies to an address register, sign change
; D0 = 01234567, A0 = 00004567
...
; assuming D0 = 0000FFFF, A1 = 00000000
move.w d0, a1 ; copies to an address register, sign change
; D0 = 0000FFFF, A1 = FFFFFFFF
```

### INDIRECT

The content of the registers must be treated as pointers/addresses not values.

• <ea> = (An)
• Syntax: (An) where n is 0 ... 7
• Details: The operand is in memory. The effective address <ea> refers the address of this location.
• Comments: Classically C pointer. Size of the operand can be word or long word. If you have a byte value extend the value to the word. All values will be treated as signed values.
• Example:
```   move.l (a0), d0
```

Copies the long word stored in memory at address specified by register A0 to register D0. When you refer a word or a long word the address of the location must be an even number.

```                   ; assuming A1 = 00001000, D0 = FFFFFFFF, mem.addr. \$1000 = 01234567
move.w (a1), d0 ; copies word stored at the location pointed by A1 to D0
; A1 = 00001000, D0 = FFFF0123
```

#### Address register with postincrement (An)+

• <ea> = (An); An = An + sizeof(operand)
• Syntax: (An)+ where n is 0 ... 7
• Details: The operand is in memory. The effective address <ea> refers the address of this location. After the operand is used, the value stored in <ea> is incremented with size of the operand.
• Comments: Very used in stacks management among with complementary mode -(An). Also is the quickest way to parse forwardly the elements of an array of chars or a string. If the register is the program stack pointer A7/SP, and the operand size is a byte, the address is incremented by two to keep the stack pointer aligned to a word boundary.
• Example:
```   move.l (a1)+, d0
```

Copies the long word stored in memory at address specified by register A1 to register D0. Then increment value stored in A1 by 4 because of long operand specified in instruction suffix.

```                    ; assuming A1 = 00001000, D0 = FFFFFFFF, mem.addr. \$1000 = 01234567
move.w (a1)+, d0 ; copies word stored at the location pointed by A1 to D0,
; then increments the value stored in A1 by 2
; A1 = 00001002, D0 = FFFF0123
```

#### Address register with predecrement -(An)

• An = An - sizeof(operand); <ea> = (An)
• Syntax: -(An) where n is 0 ... 7
• Details: The operand is in memory. First, value contained by the address register is decremented with the size of the operand. The effective address <ea> refers the address of new location.
• Comments: Very used in stacks management among with complementary mode (An)+. Also is the quickest way to parse backwardly the elements of an array of chars or a string. If the register is the program stack pointer A7/SP, and the operand size is a byte, the address is decremented by two to keep the stack pointer aligned to a word boundary.
• Example:
```   move.l -(a0), d0
```

First, value contained by the register A0 is decremented with the 4, size of the long operand, then copies the long word stored in memory at this address to register D0.

```                    ; assuming A1 = 00001004, D0 = FFFFFFFF, mem.addr. \$1000 = 01234567
move.w -(a1), d0 ; decrements the value stored in A1 by 2,
; then copies word stored at the new location pointed by A1 to D0
; A1 = 00001002, D0 = FFFF4567
```

#### Address register with displacement (d16, An)

• <ea> = (An) + d16
• Syntax: x(An) where n is 0 ... 7 and x is a word
• Details: The operand is in memory. The effective address <ea> refers the address stored to register An altered with the value of displacement. The displacement is sign extended to 32 bits prior to be used in effective address calculation.
• Comments: Very used to address the global variables using A5 register as reference and the local variables using A7 or A6 register as reference.
• Example:
```   move.l 4(a1), d0
```

Copies the long word stored in memory at address pointed by register A1 altered (increased in this case) with 4 to register D0.

```                    ; assuming A1 = 00001000, D0 = FFFFFFFF, mem.addr. \$1002 = 01234567
move.w 2(a1), d0 ; copies word stored at location pointed by A1 + 2 to D0
; A1 = 00001000, D0 = FFFF0123
...
; assuming A1 = 00001000, D0 = FFFFFFFF, mem.addr. \$1002 = 01234567
move.w 4(a1), d0 ; copies word stored at location pointed by A1 + 4 to D0
; A1 = 00001000, D0 = FFFF4567
...
; assuming A1 = 00001000, D0 = FFFFFFFF, mem.addr. \$1004 = 01234567
move.l 4(a1), d0 ; copies long word stored at location pointed by A1 + 4 to D0
; A1 = 00001000, D0 = 01234567
```

#### Address register with index (d8, An, Xi)

• <ea> = (An) + (Xi) + d8
• Syntax:
x(An,Dn.L) where n is 0 ... 7 and x is a byte
x(An,Dn.W)
x(An,An.L)
x(An,An.W)
• Details: The operand is in memory. The effective address <ea> refers the address stored to register An altered with the value stored to index register Xi, and finally altered with the value of displacement. The displacement is sign extended to 16 bits prior to be used in effective address calculation.
• Comments: Very used to address the elements of an array or the members of a structure.
• Example:
```   move.l 10(a1, a2.l), d0
```

Copies the long word stored in memory at address A1 + A2 + 10 to register D0.

#### Program counter with displacement (d16, PC)

• <ea> = (PC) + d16
• Syntax: x(PC) x is a word
• Details: The operand is in memory (inside of the CODE SEGMENT). The effective address <ea> refers the address stored to PC altered with the value of displacement. The displacement is sign extended to 32 bits prior to be used in effective address calculation. Range of values for displacement -32k to +32k. This is the reason why the CODE SEGMENTS cannot be larger than 32k. If you forgot the PC points the address of the current instruction to be executed, inside the current CODE SEGMENT.
• Comments: Used to address the locations of the branch labels or the routine labels inside of the CODE SEGMENT.

#### Program counter with index (d8, PC, Xi)

• <ea> = (PC) + (Xi) + d8
• Syntax:
x(PC,Dn.L) where n is 0 ... 7 and x is a byte
x(PC,Dn.W)
x(PC,An.L)
x(PC,An.W)
• Details: Is similar with (d8, An, Xi).
• Comments: Used to address the locations of the branch labels or the routine labels inside of the CODE SEGMENT.

### ABSOLUTE

The given parameters must be treated as pointers/addresses not values.

#### Short/Near Abs.W

• <ea> = given value
• Syntax: x where x is 16-bits constant
• Details: The operand is in memory. The effective address <ea> of this location is the given value.
• Comments: The 16-bits address is sign-extended to 32-bits, means the near addressing can only be used on the first 32Kb. Take care when you use this type of addressing because you can read/write directly the value of any address into the real memory, not only of your application.
• Example:
```   move.l \$1000, d0
```

Copies the long word stored in memory at address \$1000 to register D0.

#### Long/Far Abs.L

• <ea> = given value
• Syntax: x where x is 32-bits constant
• Details: The operand is in memory. The effective address <ea> of this location is the given value.
• Comments: Take care when you use this type of addressing because you can read/write directly the value of any address into the real memory, not only of your application.
• Example:
```   move.l \$10000, d0
```

Copies the long word stored in memory at address \$10000 to register D0.

### IMMEDIATE #data

• <ea> = none
• Syntax: #x where x is 8, 16 or 32-bits constant
• Details:
• Comments: Commonly used for initialization. If you copy a word to an address register the word will be sign-extended.
• Example:
```   move.l #\$10002000, d0
```

Copies the value \$10002000 to register D0.

### IMPLIED SR/CCR

• <ea> = none
• Syntax: SR or CCR
• Details: Used to read/write the status or condition code register.
• Comments: The only allowed instruction to access SR/CCR are: MOVE to CCR, MOVE from CCR, ANDI to CCR, ORI to CCR, EORI to CCR, MOVE from SR, MOVE to SR, ANDI to SR, ORI to SR, EORI to SR. If the length is a byte the CCR will be changed. If it is a word, whole SR will be changed, but to do this S-bit (bit 13 from SR) must be set first.
• Example:
```                 ; assuming CCR = \$00
ori  #5, ccr  ; 5 | CCR -> CCR
; CCR == \$05, \$05 == 00000101
```

Set both carry flag (C) and zero flag (Z). The others flags will remain unchanged.