CS255 Syllabus

# M68000 Assembler Instructions used in the course

• This webpage class note contains all the M68000 instructions discussed in CS255 - presented in the order of appearance....

• The notation of the operand size is as follows:

• b = byte size operand
• w = word size operand (16 bits)
• l = long word size operand (32 bits)

• Default operand size is word size

• Remember that operands can be found inside a register or in the memory. The register locations are denoted as d0, d1, etc, and the memory location is denoted by an address.

• The notation of the location of the operands are as follows:

• Dn = operand is in data register n
• An = operand is in address register n
• n = operand is in memory at address n
Note: a label can be used to replace n !
• #n = operand is the constant n
Note: a label can be used to replace n !
• (An) = operand is in memory at the address given by address register An
• d(An) = operand is in memory at the address given by the sum of the address register An and the constant d
• d(An, Dm.w) = operand is in memory at the address given by the sum of the address register An, the data register Dm and the constant d

• Move: copy data from a source

• Syntax: move.s SRC, DEST

• s = b, w or l
• SRC = you can use any addressing modes
• DEST = you can use any addressing modes except the immediate mode (#) and address registers

• Sets N, Z, V, C flags according to result

• Movea: copy data from a source to an address register

• Syntax: movea.s SRC, An

• s = w or l
NOTE: cannot use BYTE size operand
• SRC = you can use any addressing modes
• The destination register must be an address register

• Does not change N, Z, V, C flags !!!

• There are actually two add operations in M68000:

• add.s SRC, Dn - adds a source operand to a data register
• add.s Dn, DEST - adds a data register to source operand

• Notice that you must use a data register somewhere in an add operation (can't avoid it :-))

• s = b, w or l
• SRC = you can use any addressing modes
• DEST = you can use any addressing modes except the immediate mode (#) and address registers

• Sets N, Z, V, C flags according to result

• Summary:
```
CPU:
8 data registers:	D0, D1, ..., D7
8 address registers:	A0, A1, ..., A7

Spack pointer: A7

D0.b:   least significant byte in D0
D0.w:   least significant word in D0
D0.l:   entire register D0

A0.w:   least significant word in A0
A0.l:   entire register A0

--------------------------------------------------------------

Assembler Directives

ORG  n                  	; start assembler instruction at location n

L:   EQU    n		; Symbolic constant L = n

L:   DS.size  n		; reserve uninitialized space

L:   DC.size  c1, c2, ..	; reserve initialized space

; (no skip if current address is even)

end			; stop assembling

--------------------------------------------------------------

Reserve space for variables:

L:   DS.b   10          ; 10 bytes

L:   DS.w   10          ; 10 words (20 bytes)

L:   DS.l   10          ; 10 long words (40 bytes)

Make sure you reserve space at the end of the program

----------------------------------------------------------------
----------------------------------------------------------------

#n 		immediate, effective address = value n

E.g.:
MOVE #4, D0	D0 = 4

E.g.:
MOVE #A, D0	D0 = address of lable A

A:  ...

E.g.:
MOVE 4, D0	D0 = Mem[4]

E.g.:
MOVE A, D0	D0 = value stored at label A

A:  ...

Dn		direct, effective address = data register Dn

given by the value in An

E.g.:
MOVE.l #4, A0
MOVE (A0), D0		D0 = Mem[4]

E.g.:
MOVE.l #A, A0
MOVE (A0), D0		D0 = value stored at label A

A:  ...

E.g.:
MOVE.l #A, A0
MOVE (A0), D0		D0 = A[1]

A:  ...
...

given by the value An(32) + Dm(16) + u

E.g.:
MOVE.l #A, A0
MOVE.l #8, D0
MOVE 0(A0,D0.w), D0	D0 = A[2]

A:  ...
...

E.g.:
MOVE.l #A, A0
MOVE.l i, D0
MULS   #4, D0
MOVE 0(A0,D0.w), D0	D0 = A[i]

i:  ...
A:  ...
...

----------------------------------------------------------------
----------------------------------------------------------------
----------------------------------------------------------------
----------------------------------------------------------------
----------------------------------------------------------------

Assembler instructions:

Data movement

MOVE.s 			; copy data

Arithmetic

ADD.s  , Dn		; Dn = Dn + ea

SUB.s  , Dn		; Dn = Dn - ea

MULS   , Dn		; Dn(32) = Dn(16) * ea(16)

DIVS   , Dn		; Dn[31-16] = remainder of Dn(32)/ea
; Dn[15-0] = quotient of Dn(32)/ea

NEG.s  Dn			; Dn = -Dn

Logic

AND.s  , Dn		; Dn = Dn bitwise-AND ea

OR.s  , Dn		; Dn = Dn bitwise-OR ea

NOT.s  Dn			; Dn = bitwise-NOT Dn

Compare and branch:

MOVE.L A, D0	D0 = A
CMP.L  B, D0	Compare D0 (A) against B
BLT    L1		Branch to location L1 if A < B

...

L1:

BLT	branch less than
BGT
BLE	branch less than or equal
BGE
BEQ
BNE

Subroutine call and return:

JSR lable		- push return address on stack