68000
68000
68000
1 Absolute Addressing:
Absolute Addressing uses the actual address of an operand;
either a memory location (e.g., CLR.B $1234) or,
If a register is involved, this type is also called data register
direct, e.g., MOVE.B D2,$2000
2 Immediate Addressing:
With Immediate Addressing, the actual operand is part of the
instruction; e.g., MOVE.B #25,D2
EECC250 - Shaaban
#1 Lec # 2 Winter99 12-1-99
EECC250 - Shaaban
#2 Lec # 2 Winter99 12-1-99
Examples
MOVE.B (A0)+,D3
MOVE.W (A0)+,D3
MOVE.L (A0)+,D3
MOVE.B -(A0),D3
MOVE.W -(A0),D3
MOVE.L -(A0),D3
EECC250 - Shaaban
#3 Lec # 2 Winter99 12-1-99
Description
Add decimal with extend
Add
Logical AND
Arithmetic shift left
Arithmetic shift right
Branch conditionally
Bit test and change
Bit test and clear
Branch always
Bit test and set
Branch to subroutine
Bit test
Check register against bounds
Clear operand
Compare
Decrement and branch
conditionally
Signed divide
Unsigned divide
Exclusive OR
Exchange registers
Sign extend
Jump
Jump to subroutine
Load Effective Address
Link stack
Logical shift left
Logical shift right
Instr
MOVE
MULS
MULU
NBCD
NEG
NOP
NOT
OR
PEA
RESET
ROL
ROR
ROXL
ROXR
RTD
RTE
Description
Move source to destination
Signed multiply
Unsigned multiply
Negate Decimal with Extend
Negate
No operation
Ones complement
Logical OR
Push effective address on stack
Reset External devices
Rotate left without extend
Rotate right without extend
Rotate left with extend
Rotate right with extend
Return and deallocate
Return from exception
RTR
RTS
SBCD
Scc
STOP
SUB
SWAP
TAS
TRAP
TRAPV
TST
EECC250 - Shaaban
#4 Lec # 2 Winter99 12-1-99
N
Z
V
C
X
Examples:
MOVE.B D1,D2
MOVE.B D1,1234
MOVE.B 1234,D1
MOVE.B 1234,2000
MOVE.B #4,D0
MOVE.B #4,1234
Register to register
Register to memory
Memory to register
Memory to memory
Literal to register
Literal to memory
EECC250 - Shaaban
#6 Lec # 2 Winter99 12-1-99
EECC250 - Shaaban
#7 Lec # 2 Winter99 12-1-99
Move to CCR
Copies the lower order byte of the operand to the CCR register.
Source Operand: All except address register direct.
Destination Operand: CCR register.
EXG
Exchanges the entire 32-bit contents of two registers. Frequently used to copy
an address register to a data register for processing. No effect on CCR.
Source Operand: Address or data register.
Destination Operand: Address or data register.
EECC250 - Shaaban
#8 Lec # 2 Winter99 12-1-99
EECC250 - Shaaban
#9 Lec # 2 Winter99 12-1-99
LEA
Copies an effective address into an address register.
Source Operand:
All except data register, address register direct, address register
indirect with pre-decrement or post-increment or immediate.
Destination Operand: Address register
No effect on CCR.
EECC250 - Shaaban
#10 Lec # 2 Winter99 12-1-99
EECC250 - Shaaban
#11 Lec # 2 Winter99 12-1-99
Action
LEA $0010FFFF,A5
LEA (A0),A5
LEA (12,A0),A5
LEA (12,A0,D4.L),A5
Compare Instructions
All compare instructions subtract the source operand, usually the contents
of one register (or memory location) from the contents of the destination
operand, usually another register (or memory location) in order to set the
CCR (except the X-bit). The results of the subtraction are discarded.
Compare instructions include the following:
CMP
CMPA
CMPI
CMPM
EECC250 - Shaaban
#13 Lec # 2 Winter99 12-1-99
Compare Instructions
CMP <source>,<destination>
X_Bigger MOVE.B
Exit
STOP #$2700
X,D0
Y,D0
X_Bigger
Q,P
Exit
R,P
IF X < Y THEN P = Q
ELSE P = R
Evaluate X - Y
If X is greater or equal to Y branch
IF X < Y THEN P = Q
IF X >= Y THEN P = R
Exit point for code-fragment
EECC250 - Shaaban
#14 Lec # 2 Winter99 12-1-99
EECC250 - Shaaban
#15 Lec # 2 Winter99 12-1-99
EECC250 - Shaaban
#16 Lec # 2 Winter99 12-1-99
EECC250 - Shaaban
#17 Lec # 2 Winter99 12-1-99
BVS
or BCC)
BHI
BLS
(BLO or BCS)
EECC250 - Shaaban
#18 Lec # 2 Winter99 12-1-99
Instruction
Branch on not equal
Branch on equal
Branch on not negative
Branch on negative
Branch on carry clear
Branch on carry set
Branch on overflow clear
Branch on overflow set
Branch Taken If
Z=0
Z=1
N=0
N=1
C=0
C=1
V=0
V=1
EECC250 - Shaaban
#19 Lec # 2 Winter99 12-1-99
BGT
BLE
BLT
OR
EECC250 - Shaaban
#20 Lec # 2 Winter99 12-1-99
Mnemonic
Instruction
Branch Taken If
BHS, BCC
C=0
BHI
C=0 AND Z =0
BLS
C=1 AND
BLO, BCS
C=1
Z=1
EECC250 - Shaaban
#21 Lec # 2 Winter99 12-1-99
BRA START
BRA EXIT
JMP
Jump to an address that can be changed during execution
Examples:
JMP (A0)
JMP D0
EECC250 - Shaaban
#22 Lec # 2 Winter99 12-1-99
EECC250 - Shaaban
#23 Lec # 2 Winter99 12-1-99
MOVEA,
ADDA,
SUBA,
CMPA
EECC250 - Shaaban
#24 Lec # 2 Winter99 12-1-99
Store X in D0
Compare Y and D0
Branch if X <= Y
Otherwise, Y is smaller
Halt processor at end of program
EECC250 - Shaaban
#25 Lec # 2 Winter99 12-1-99
ORG $400
Program origin
LEA Block1,A0
Point to the beginning of memory block 1
LEA Block2,A1
Point to the beginning of memory block 2
MOVE.W
#Size,D0 Store the long word count in size
LOOP
CMPM.L (A0)+,(A1)+
Compare the long words
BNE NotEq
Branch if not equal
SUBQ.W
#1,D0
Otherwise, decrement the count
BNE
LOOP
Go back for another comparison
CLR.L
D0
Two strings are equal so set
MOVE.B #$FF,D0
D0 to FF
BRA
Exit
NotEq
CLR.L
D0
Otherwise, set D0 to 00
ExitSTOP
#$2700
SizeEQU
2
Compare 2 words
ORG
$600
Block1
DC.L
'Bloc',1234'
Block 1
ORG
$700
Block2
DC.L
'Bloc',1234 '
Block 2
END
$400
EECC250 - Shaaban
#26 Lec # 2 Winter99 12-1-99
EECC250 - Shaaban
#27 Lec # 2 Winter99 12-1-99
LEA
String,A0 Make A0 point to the beginning
Loop2 MOVE.B -(A1),D0
Save the bottom byte
CMPA.L A1,A0
If A0 has reached or passed A1
BHS
Exit
Then the string is reversed
MOVE.B (A0),(A1) Move the top to the bottom byte
MOVE.B D0,(A0)+ Move the previously saved bottom byte
*
to the top byte
BRA
Loop2 Loop back for another byte
Exit
STOP
#$2700
ORG
$1000
String DS.B
128 Reserve up to 128 bytes for the string
END
$400
EECC250 - Shaaban
#28 Lec # 2 Winter99 12-1-99