The 68000 Hardware and Software
The 68000 Hardware and Software
Consulting Editor
Professor F. H. Sumner, University of Manchester
Patrick Jaulent
Microprocessor System Training Engineer
Microprocess
Puteaux, France
M
MACMILLAN
© Editions EYROLLES, Paris 1983
Translated by M. J. Stewart
Published by
Higher and Further Education Division
MACMILLAN PUBLISHERS LTD
Houndmills, Basingstoke, Hampshire RG212XS
and London
Companies and representatives
throughout the world
Acknowledgements ix
3 Bus Operation 18
Introduction 18
Data Transfer 18
Rerun Cycle 27
Bus Allocation Arbitration 29
Halt and Single Step Operation 32
Interaction with Synchronous Circuits (6800 family) 35
4 Exception Procedures 38
Exceptions 38
Technical File 58
vii
viii Contents
®
PAD (Programmable Array Logic) is a registered trade
mark of Monolithic Memories Inc.
ix
1 Pin Assignment of the MC 68000
and MC 68010
TECHNICAL HISTORY
04
03 -- -- 1
2
64
63. ----- ----
05
06
02
-- - 3 62 07
01
-- -- 4 61
-- : 08
AS - ---
DO 5 60 09
UOS
6
7
59
58
-
.-
.-
010
011
lOS 8 57 - 012
R/W
OTACK
9
10
56
55
-
..:-
-
:
013
014
~
B'GA"C"K
11
12
54
53 - - 015
GNO
SR 13 52 A23
68000
Vee 14 and 51 A22
ClK 15 68010 50 A21
GNO 16 49
- -:..
Vee
HALT 17 48 A20
- -
~
RESET 18 47 A19
VMA 19 46 A18
E 20 45 A17
VPA 21 44 A16
BERR 22 43 A15
IPl2 23 42 A14
iPL1 24 41 A13
iP[Q 25 40 A12
FC2 26 39 A11
FC1 27 38 A10
FCO 28 37 A9
A1 29 36 A8
A2 30 35 A7
A3 31 34 A6
A4 32 33 A5
Figure 1.1
Pin Assignment of the MC 68000 and MC 68010 3
Table 1.1
AO R/W LOS UOS Lower Upper Operation Address
line line
(00-07) (08-015)
0 0 0 Reserved User
0 0 1 Data User
0 1 0 Program User
0 1 1 Reserved User
1 0 0 Reserved Supervisor
1 0 1 Data Supervisor
1 1 0 Program Supervisor
1 1 1 Interrupt Supervisor
These lines therefore constitute an additional
security for the system, while also making it possible
to increase the addressing capacity of the 68000 from
16 megabytes to 64 megabytes by using the noted
reserved combinations.
The timing diagram shown in figure~.2 compares the
electrical relationships between the AS signals, FCO,
FCl, FC2 and the address bus.
SO S2 S4 S6 so
CLOCK
A1-A23~ >-C
\ /
AS
FCO-FC2 J C
74 LS138
Reserved Y7 A FCO
User program Y6 8 FC1
Supervisor data YS C FC2
Reserved Y4
Reserved Y3
Supervisor program Y2 G1 +SV
Supervisor data Y1 G2A AS
Interrupt acknowledge YO G28
-
Figure 1.2
Pin Assignment of the MC 68000 and MC 68010 5
Bus Request BR
This input, at low state, informs the processor that an
external device requires the bus (for example, the DDMA
68440, DMAC 68450 or SBC 68430).
Bus Grant BG
While authorising the calling circuit to take control
of the bus, the 68000 alerts its surrounding circuitry
that it will surrender the bus at the end of the
current bus cycle.
1. BG asserted (BG = o)
2. AS invalid (AS = 1 )
3. DTACK invalid (DTACK 1)
4. BGACK invalid (BGACK = 1 )
INTERRUPTS
SYSTEM CONTROL
Example
Absence of the DTACK signal during a reading or
writing operation in working memory after a time delay
fixed by the design~
Enabling of the BERR input leads either to a
sequential rerouting, called a trap, or to a rerun
cycle.
Reset on output
Execution by the processor of the RESET instruction
sets the reset line to the low state for 124 clock
cycles. Handling this instruction does not affect the
internal registers of the processor.
For example, this instruction is used to initialise
a system or to program a peripheral circuit (PIA,
timer, etc).
HALT on output
An example is the display of a double bus error. This
follows a double error on the bus (for example, a
hardware fault).
If during the initialisation phase (RESET and
HALT on input at low state) a hardware or software
anomaly occurs, the 68000 takes this to be catastrophic
for the remainder of the program. In such a case it
places itself at the halt state and alerts the outside
world via the HALT output line.
Pin Assignment of the MC 68000 and MC 68010 7
Enable E
This periodic signal, which is generated from a
floating clock internal to the 68000, represents the
time reference for all exchanges with the synchronous
circuits of the 6800 family.
The period of signal E is equal to 10 periods of the
signal fed to the input clock of the 68000, and has the
form of 6 low states and 4 high states, as shown in
figure 1.3.
CLOCK
I I I
i
I
! 3 4 : 5
Figure 1.3
Clock : eLK
The 68000 is able to produce the different signals
required to allow it to function (for example, the E
clock of the 6800 family), beginning from the clock
signal fed to the 68000 eLK input.
The TTL compatible signal must be perfectly stable
and adhere to the manufacturer/s specifications as set
out in table 1.3.
Table 1.3
CLOCK
Max transfer ti me = 10 ns
Figure 1.4
2 Internal Organisation of the 68000
DO
I BYTE
I I
~ WO:RD ??~ , registers
Data
I (Dn)
t~ LONG YJO RD •!
I
I,07
31 15 0
I I~ WORD ~ I AO
I
@ LONG:WORD ~l
Data
registers
(An)
9
10 The 68000 Hardware and Software
15 13 10 9 8 7 o
Figure 2.2
ADDRESS ENABLE
SUPERVISOR
DATA
SUPERVISOR MEMORY
FeO SUPERVISOR
Fe1 PROGRAM
MEMORY
Fe2
68000
USER
DATA
ASt----- MEMORY
USER
PROGRAM
ADDRESS BUS MEMORY
." , I T T
r-=--
"'...
"0
no l' !"
' to 1 I ' l Ol
I
RJ W
.,
DOO'':l
' CJ
lOS
I ~; U'05 iii
U,·
"11
1..!j11 A8 13
f '.LS'""
?
~ 1-1--
'- S r<
.1111
f' T
~
<
~
AI A1 ., " I~~A OO I" ........... .
m
P." I'''-J ''
'JIl ta u:: 1- Of Ar- ~
~?i
... ·'V iAUi1
=:
1-
~t SE , ~ I'vO!)
CS '-I A '; GO" UllJ~
8!n
."
~
Bf AR
T I-irr .
vcs
"S
G~,
m
.....-. -.,
d ~A!U :;)1 4(, 1,
= -
riUl1 R/W'
5TiCi iO ~r
~.w
AI' 13 ~ ...C
t..:,. AS l o h"e rn
PA Ot) l !.
~ 0Titi""
., « DC
~
ii» ::: A 1 S~
uOS
I; uo W;;;;
tm lOS
IlffiT ~
rO' CS
~-
.. m f--
,Pl O ~
'Pl' .,~, ~ ~ C0 1
1",- 'CJ
i
IPlJ
'------
Al AI
bB
~
5.s '..,.,
h OK...
JlESfT
(
Fig u r e 2 .3b Memor y org ani sa t i o n wi th MMU
SUPERVISOR MODE S = I
15 8
~ ISR
.........---~
L Interrupt mask
1
- - - - - - - - - Status supervisor
- - - - - - - - - - - T R A C E Mode
Figure 2.4
Trace Mode
After each instruction the processor tests internally
whether bit T of the status register is enabled
(T = 1).
When T = 1, a program can be traced, instruction by
instruction. It is the software equivalent to the
single step operation carried out in 8-bit
microprocessors. The trace function can be used to
debug a program, whether in supervisor or user mode.
Processor Status
S 1 fixes the processor in supervisor mode
S = 0 fixes the processor in user mode
Interrupt Mask
The 68000 has seven interrupt levels that can be
programmed by bits 12, II and 10, as shown by the table
in figure 2.5.
These three bits fix the interrupt mask, and also
the priority level of the interrupt currently being
handled.
Level 12 11 10
7 1 1 1 . - - Highest priority level
(NM I type interrupt)
6 1 1 0
5 1 0 1
Increasing 4 1 0 0
priorities
3 0 1 1
2 0 1 0
Figure 2.5
Internal Organisation of the 68000 13
USER MODE S = 0
Flag Identification
As figure 2.6 shows, only the first five bits of the
user byte are of importance for the programmer.
---Zero
~---- Negative
- - - - - - Extension
Figure 2.6
14 The 68000 Hardware and Software
Arithmetic processing
Logical processing
The instruction LSL.W #1,04 causes a logical shift one
position to the left.
Figure 2.7 shows the flags requested by the
instruction.
31 15 o
04 rUNAFFECTEDBYTHE-~-------""" ~O
L.. _ _ .l!'J"§..T.!!~.JJQf'J ........ ---,
Figure 2.7
DATA REGISTERS
31 1615 8· 7 o
DO
I to
07
11 BYTE = 8 bits
• II
~ 1 WORD = 16 bits-----..
,. 1 LONG WORD = 32 bits •
Figure 2.8
UNAFFECTED
--
CLR .B 02
It Destination
Size (Byte)
- - - - - - Mnemonic
Figure 2.9
Example
MOVEA.W # $8000, AS
Destination register
Hexadecimal operand
l6-bit word size
Mnemonic
F F F F 8 o o o
Figure 2.10
16 The 68000 Hardware and Software
DATA
DATA HIGH
AS
ADDRESS
LOW
DO .18 '2
D1 17 74lS245 3
D2 16 4
D3 15 5
D4 14 6
D5 13 7
11 8
D6 12
D7 19 9
D8 D8
D9 14ls245 I
I
D10
~ ---.......-...............-.1
I
D11
D12 ....-----~ HALT
I
D13 I
I
D14 I
D15 D15
R/W
AO 18 2 A1
A1 16 74lS244 4 :68000
A2 14
6 I
I
A3
A4
12
7
~
~
8
~
13
..----...,...t--. : I
I ...10----- VPA
5 15 :
DTACK
A5 3 17 :
A6 9
A7 19 11 ~8 BERR
R/W
A8 A9
A9 74lS244 I
I
A10 I FCO
I
A11 t -. .- - - -...~t--. ..I FC1
A12 I
FC2
I
A13 I
I
A14 I
I
A15 19 A16
E
BLOCK 1 A16 19 1 A17
BLOCK 2 VMA
14ls244 A17 18 2
BLOCK 3 A18 17 3
BLOCK 4 A 19 16 4 I--"~ __
BLOCK 5 A20 PAL 5
I5
BLOCK 6 A21 ~10 L86
BLOCK 7 10 H8 A22
13 7 A23
BLOCK 8
19 12 MAKPAGE
AS
MODE
CLK IPL IPL 1 iPI2
Figure 2.11 Shows the interface between the 68000 and
MAKBUS. The 74LS244/5 devices buffer the 68000 signals,
and the PAL10L8 acts as memory management unit (see
also Appendix 5). Note that the availability of the
MODE signal allows two possible configurations, such as
MAKBUS and MAKBUS+. (Copyright Microprocess)
Internal Organisation of the 68000 17
Problem
What is the content of register AS after the processor
has executed the instruction MOVEA.W #$2AOO,AS? Can you
explain your answer?
INTRODUCTION
data transfer
rerun cycle
bus allocation arbitration
halt or single-step operation
dialogue with synchronous circuits.
DATA TRANSFER
1 Read Cycle
During a read cycle the processor receives an item of
data from memory or peripheral circuits. The 68000
always reads a byte type data item using an internal
bit AO, in order to determine which line the data item
should follow.
If AO = 1 and the LOS signal is asserted, the
data item can be read on the lower line 00-07, to an
odd address.
If AO = 0 and the UOS signal is asserted, the
data item can be read on the upper line 08-015, to an
even address.
On the other hand, when the instruction code
indicates reading of a word (or a lo~word)L-!he 68000
processor simultaneously enables LOS and UOS,
while AO = 0, since in this case the specified address
can only be even.
The reader is urged to study closely the timings for
reading a word, as illustrated in figures 3.2 and 3.3,
referring where necessary to table 3.1 for further
details.
18
Bus Operation 19
4.7krl
+5V
VPA
OTACK
SYS
BERR
R/W
68000
FCD FCD
FC1 FC1
FC2 FC2
LOS LOS
>
LO
+ OS
UOS UOS
E E
VMA VMA
R/W
v
MAKBUS®
Period
A1-
A23
AS--+--+-,""",
ODS- - + - - + - - -
00-07
----+--+---~
08-015
elK
UOS
--......--+-_.
AtW
2 Write Cycle
For a write cycle, the MC 68000 processor places the
data on the bus, to be sent to an addressable area
(memories or peripherals).
In a manner similar to the read operation, the data
written by the processor is byte type. We therefore do
not need to go into the conditions that lead to its
being sent on the lower or upper line. Of course, if
the operation code specifies a word or long word data
item, the two lines are enabled by means of LOS and
UDS signals (with AO = 0), as shown in table 3.2.
Figure 3.4 shows the timing of a write cycle.
Period
eLK
A1·A23
AS
---+--~
oss- - - - + - - - + - + - ' - \ ,
00-07
08-015
LS164
1/4 LS03
UDS
elR A
LDS
CK
OA
as Clc aD B
CKIJP
1/2 LSD3
Jumper --.
•••
Memory
Address _ _---,
selection
PAU
PROM
Control
2
CK.uP CK
QA
OB Multiplexer DTACK
AS CLR Oc
00
We recall that
1. DTACK, when recognised by the processor
during a read cycle, indicates that the data is latched
and that the bus cycle is terminated.
2. DTACK, when recognised during a write cycle,
indicates that the bus cycle is terminated.
Most systems use a timer (counter) to detect a
nonexistent addressable area (removed or damaged memory
locations). If no DTACK signal has been received
when the timer reaches a timeout value, a bus error
signal is generated (see next section).
Bus Operation 25
RAM SaMSEL
15 14
SELECT [1 [2 [3 [4 Hi Fi2 R3 R4
ROM 58167
16 18
SELECT 10 x 4.7k.Q
H4
17 8
H3
12
H2
13 6
H1
19
DTACK
l4
PAL 4
16L8 l3
3
l2
l1
10
N C")
~ ~ ~
r
C/) C/) C/)
20
9 r
I
I
r-o r-o-i
L ...I I
L
I
L
+
21 20 19 18 17 16 15 14 6
PAL 12L 10_ 20 L 10
DS 23 22 9 10 11 13 1
+5V---+--"""--
I:i:
I~
I~
II
15
1:3
I~
I:J
RERUN CYCLE
BEAR
HALT
-+--I. Reading of word _~-- Processor at HALT-- - - Rerun
cycle
Rerun Condition
If the aborted bus cycle is not indivisible (TAS
instruction read/modify/write cycle) and, if the
BERR line is again positioned at high, a rerun
cycle can be envisaged. __
3. As soon as the HALT line is disabled by the
external circuitry (HALT = 1), the 68000 moves to the
preceding rerun cycle using the address and data
transmitted by their respective buses which have
previously been set to high.
28 The 68000 Hardware and Software
~=o
and
HALT on start up = 0
-0-
L:r
MC 68000 MC 6809
DATA
Example
In the multiprocessor system shown in figure 3.10, the
MC 6809 microprocessor uses RAM when the MC 68000
processor wishes to access it (CS RAM 68000 enabled).
While waiting for the memory to be available to the
68000, the former executes n rerun cycles.
1 Bus Request
When an external unit wishes to take control of the
bus, whether in a multiprocessor context by means of
the BAM 68452 bus arbitration module or for a direct
memory access via a DMA controller, it make~ its
request of the MC 68000 with the enabling signal BR
(Bus Request).
The 68000 then confirms that it has received the
signal by replying with ~G (Bus Grant). The
acknowledgement, that is, BG at low, occurs~etween
1.5 and 3.5 clock periods after the request (BR
at low), which will lead us quite naturally to propose
several consequences.
4 Methods of Operation
We shall examine three examples of requests that might
occur in practice.
elK
SO S2 S4 56 so
BR
BG
BGACK ---~-I-:,L.~::;:;:$t=~---
A1-A23
AS
FCOFC2===x ...-.---------....., C
R/W ---.J
OTACK --f /11//
+
00 o 15-------L_.ltmpMl!UtIID----------;-----L_-.mmm
Word read cycle ~ Busesunder DMA control Processor has resumed bus control
CLK
so 52 54 56 so 52 54 56 SO
BR----_
BG----~:::;:~=~-\-
BGACi<
A 1A23 - - - - - (
AS
Uos-----\ r----------~ r_
COS-----\ r ~ r_
FCOFC2=:Y ) ( 'C
R/W
BGA:~------~tL.;Ll
_S_~_0~t5~~~§43_~,--_0---J4_---JI _
A1 A23 --{== -=______ ( _
AS~'-_ _---J/ ~
U05 ~ I------'-----------~
L05~ / ~
FCOFC2:X (-----
R/W - _ _~ ___J
OTACK---_......
~ 11III '-
00-015
DBAn
BA
f
Beginning
of bus cycle f
End of bus cycle;
address and data
buses set to high
impedance T1 T2 I
r Beginning of
next bus cycle
A1·A23
lDS/UDS__
AS
~=======--+-+- ---l -+--_-=======~+--_
Riw
DTACK-=;;;;;~~~~~~~~====1::==:±==~~~~2~=
00-015
~~==~-----t------j======:::t=============+-===
FCO-2
+- - -
HALT
~ - Read - - Halt - - - Read - ~
1.2 On output
When the HALT line is asserted on output (HALT at low),
the outside world is alerted that the processor is
halted, following~rdware of software event. Only an
action on the RESET pin will cause it to leave this
state.
ADDRESS BUS
DATA BUS
IRQ ACIA1
I
~HA8 18 IRQ3 IRQ4
9 E ~
10 R/W
8 ACIA1
7643 ." -- .'~ +5V VMA RXD
PROM MAKPAGE CTS
decoder • I. .. MYRAM
v
I-IAl t:ttl : MYROM
:;x: • 10 I I I
M
:;x:H1 15 ~
A6 Cb
2 16 2
3 21 3
4 22 4 ~
5 18 5 8
6 PA L
I : ~~~~RAM 6
718 L4 A11- 7 ~
...,
SEL10
8 1
L~,)A:'-_----------=LD=S~~· 81
9 ~
Q)
10 ~
11 12 AS.. ' Q)
13 23 +5V :'::3
Q..
Al 8 14 17
~
56 F !
p -
I
OMil _ 56pF RTS
Q)
DOl 6850 ~
\ TXD ~
t ACIA2
RXD
CTS
~
.::,t,
,.... D7
~
DO-D7
clock E (Enable)
validation of a peripheral address
(VPA : Valid Peripheral Address)
validation of an addressed position
(VMA : Valid Memory Address).
State 0 : SO
line R/W is at read (preceding cycle)
address lines are at high
lines FCO-FC2 show the processor status.
36 The 68000 Hardware and Software
State 1 Sl
address bus is freed from the high
impedance state
the processor places the current address
on lines Al-A23.
State 2 S2
the 68000 address strobe AS is
asserted, indicating that there is a
valid address on the bus.
Write Read
Line R/W Output LOS
is set to low, enabling
write (R/W 0) channel 00-07
(or UOS for
channel 08-015)
State 3 : S3 State 3 S3
The processor presents
the data item on channel 00-07,
then one half clock cycle
later, asserts LOS
(LOS = 0) confirming
the validity of
the data on 00-07.
(Alternatively, on 08-015 by
asserting UOS.)
Write Read
States 5 and 6 States 5 and 6
(55 and S6) (S5 and S6)
The data item is The processor
latched when clock carries out a read
E moves from at the high state
high to low. of signal E.
Bus Operation 37
State 7 S7
Output LOS (or UOS) is disabled
by the 6~00.
Outputs AS and VMA are set high,
which authorises the ~OO peripheral
circuit to disable VPA(VPA = 1).
Note that OTACK must on no account
be enabled at the same time as VPA.
~~~wwwwwwwwwwwwwww~~
ClK
A1·A23 }{~ }C
\ I
DlACK
\\--_ _---JI
Figure 3.17 "Worst" timing exchange with a synchronous
peripheral (6800 family)
505254 W W W W W W56 5052
A1.A2~'__ ~>--< _
AS~ ~
DTACK
-------------------------
Data o_u_t--~'_ ____J)>----
E \~
,'------
,'--
--JI
-..J!
VMA - - - - - - - - - - - . \ \ - ---J/
Figure 3.18 "Best" timing with a synchronous peripheral
(6800 family)
4 Exception Procedures
EXCEPTIONS
1 Overview
The name trap or exception is given to a change in
routeing of the program which is generally the result
of internal (software) or external (hardware) events.
Each trap or exception has a byte associated with it
that represents a vector number which, when multiplied
by four, gives the offset of the corresponding vector.
The 68000 microprocessor contains 255 vectors in
memory, arranged in an exception table 512 words in
length (1024 bytes), from address $000000 to address
$0003FF. See table 4.1.
Each exception vector is 32 bits long, except for
the initialisation vector which is coded in 64 bits.
It should also be noted that all the vectors in the
exception table are located in the data supervisor
memory area, except for the initialisation vector which
resides in the program supervisor memory area, thus
providing greater security. Table 4.1 shows how the
exception table is organised.
Before embarking on a detailed study of the
different types of exception, it is valuable to have a
knowledge of the general procedure followed by the
processor when handling an exception. This may be
summarised as follows
1. A temporary copy of the status register is made
in an internal register of the 68000.
2. Bit S (8 = 1) is asserted, thus placing the
processor in supervisor mode. All exceptions will
therefore be handled in supervisor mode.
3. Trace bit (T = 0) of the status register is
disabled.
4. The vector number is obtained.
5. The program counter and the previously copied
status register are saved to the supervisor stack.
(Additional information is stored in the case of
address error or bus error exceptions.)
6. The table is consulted for the start address of
the exception program.
We shall see that only exceptions caused by an
external event do not more or less exactly follow this
procedure.
38
Exception Procedures 39
68000
Exception
processing
Figure 4.1
2 Internal Exceptions
Internal exceptions or traps occur in the following
instances
l.when certain instructions are being carried out
2. when there is a programming error
3. when the trace bit of the status register is
asserted.
This new concept confirms the software bias of the
MC 68000 and the considerable importance that the
manufacturer has attached to ensuring the security of
the system.
Program Error
There are three types of exception or trap resulting
from a programming error.
CLK
A1.A23--{ H ~
AS
\ 1\ ~ L-
UOS
/68010 ~
.
I
. L
\ .. '
'------- --- __1.... 68000
LOS , ~
\ / ____________J! L
.J \ ~ L-
•
RIW
/'
_________1J- 680~0
~
'-
OTACK
III '~\
4 External Exceptions
External exceptions can be generated by the following.
1. On start, keeping both the RESET and HALT lines
low for 100 ms, this being the initialisation phase: or
again low for 10 clock cycles in order to exit the
68000 from the HALT state following a double bus error.
2. A bus error detected by an external device or by
a MC 68451 MMU circuit, which asserts the input BERR of
the 68000 processor low, following a hardware anomaly
during execution of an instruction (protected segment
on write).
3. An interrupt request made to the processor by
means of lines IPLO, IPLI and IPL2.
100 milliseconds
RESET!C »l~ _
l '
H'AIT
l ~1
BUS 1
CYCLE ~
2 3 4 5 6
1. Internal start up time.
2. Load 16 high order bits of the supervisor stack
pointer.
3. Load 16 low order bits of the supervisor stack
pointer with the contents of addresses $000002 and
$000003.
4. Load 16 high order bits of program counter with the
contents of addresses $000004 and $000005.
5. Load 16 low order bits of program counter with the
contents of addresses $000006 and $000007.
6. Fetch first instruction.
'----
\
No response Bus error I Bus error
~ Read ~ (card missing - ~ recovery vector
detection
operation perhaps) after saving to
supervisor stack
Start address of
exception handling
program fetched
Program counter
loaded with exception
handling address.
Exception program
executed
15 2 o
Supervisor stack
pointer after
exception
Status register
_ Supervisor stack
pointer at moment
of except ion
Interrupts
The 68000 microprocessor possesses 192 usable vectors
for peripherals that can provide a vector number (for
example, MFP 68901, PI/T 68230, etc) and 7 autovectors
allocated to 6800 family circuits (ACIA 6850, Timer
6840 and PIA 6821) that do not generate a vector
number.
Seven levels of priority, fixed by the programming
of the interrupt mask (see status register), can be
assigned to these 199 vectors, as shown in the
following table.
Exception Procedures 49
Level 12 II 10
7 1 1 1 Highest priority
6 1 1 o
5 1 o 1
4 1 o o
3 o 1 1
2 o 1 o
1 o o 1 Lowest priority
o o o o No priority (no
interrupt request)
Interrupt recognition
When an interrupt request reaches the processor, it is
first made to wait, before being interpreted by the
processor at the end of the instruction cycle. (See
figure 4.7 for timing diagram.)
If the interrupt level present on lines IPLO, IPLI
and IPL2 is less than or equal to the interrupt
mask, the processor executes the next instruction and
ignores the request. However, if the request level is
greater than that of the mask, the processor proceeds
to the interrupt recognition described below. Note that
level 7 priority is a special case; it cannot be
inhibited by the interrupt mask. Level 7 interrupt thus'
provides a non-maskable interrupt capability.
~
~_----::::::==========~--\'-----
,""' ..Jr---\\- _
(
Vector number ~,,_ _~
--------(~---->---<----
------........ '<'------~
IPLO-2 \ - - - - - -.... ~---------_-I SR and
I Bus cycle of I 14 Interrupt acknowledge .1_ high PC .1
• an instruction • (Vector number acquisition) saved to
supervisor stack
Problem
Does the interrupt recognised by the processor corne
from a 6800 peripheral (figure 4.8) or from a 68000
peripheral (figure 4.9)?
fPCO
fl5IT
fP[2
Me 68000
00-07
(or 08-015)
Figure 4.9
R/W-~::::~~=========::"'-
OUCl(
06-0 1S, -~->-+------------
OO.01C~~~~~====~=~=::::;C
FCO· 2 )
FC'
,
IPl O· 2 FCO
VP'~~~~~~~~;==
Viii \
__ ----l
/":
[i5S_~~~~====================:!....-~
Rm
OTACK~
0 8-015 ---eJ~---------------
00-07 ~>----------------
X 'I 'C
__
FCO·2
RESET
t
t t MC 68000
Exception table
R/W PC
PIIT
68230
DB $000000 -Initiafisation
--Buserror
ddress
error
07 ------411
$000 100 .......
User
PIRQ $000 3 FF interrupt
vector
TOUT
T+5V
DTACK
RS1RS5 ~
jrthcK7ddress
FCO
_ decoding FC1
CS and FC2
lACK LOS
Address bus
Figure 4.12
68000 therefore uses the autovectorisation procedure
that allows it to access the 7 autovectors of the
exception table (numbers 25 1 0 to 31).
The vector number is determined from the priority
-- --
level established by lines IPL2 to IPLO, remembering
that these lines are enabled at low state.
Example
Interrupt mask: 12 = 1; II = 0; IQ =_1_
Interrupt request: IPL2 = 1; IPLI = 1; IPLO 0
The 68000 "internally" supplies the vector number 30
that corresponds to level 6 (vector address = 30 x 4
10
= 120 = $78).
10
6b. 68000 peripheral
When the decoding logic recognises the interrupting
circuit, it places a vector number on lines 00-07 of
the data bus (LOS = UOS = 0) and sends the DTACK signal
to confirm the transfer of a data item.
CLK
Fi> ~_@) -------i"
"D2
A2 '--- -r;-J .. 01
I-----~ .. DlACK
i ]- - - - -- __ IPL2 A1 I- - - - - - - ..
~ DD
FC2
1------_~ t P L l
FC'
-,-
F~ure 3
so S1 52 53 94 S5 56 97
CLK
Al - 23 - ---1-:-"7--:'1
--.J } I
~ i..
_16_
RiW_---1+_-l
- ---1+---/''I--------i - - - - - - - I
~
FCO- 2
I
~·=tt=~------~tt======= !-
r; r--
I
0 0- 7
+ -:-:-::---::'1
OTACK _ _
_1'9~~ I
1 CLOCK PERIOD (80 ns) 8 CLOCK HIGH TO R /W HIGH (60 ns) 15 DATA VALID TO OS LOW ( 15 ns )
2 CLOCK LOW TO ADDR ESS (SS ns) 9 CLOCK HIGH TO RiW LOW (60 ns) 16 C LOCK HIGH TO AS , os LOW (55 ns)
3 CLOCK HI GH TO ADDR ESS Hi-Z (60 ns) 10 CLOCK HIGH TO Fe VALID (55 ns ) 17 PA L's INPUT TO Hi -Z (25 ns)
4 CLOCK HIGH TO AS LOW (55 n.) 11 CLOCK HIGH TO OATA Hi·Z (60 ns) 18 PAL 's INPUT TO Hi -Z (25 n51
5 C LOCK lOW TO AS HIGH (50 ns) 12 AS HIGH TO ClACK HIGH (70 ns) 19 PAL 's INPUT TO Hi -Z (25 n51
6 C LOCK HIGH TO oslOW (55 n s) 13 PAL·s CLOCK TO OUT (25 ns )
7 C LOCK LOW TO osHIG H (50 ns) 14 MI NIMUM seTUP TIME ( 20 ns)
Example
Suppose that th e peripheral circuit PI /T 68230 (see
s ection 4 .2) positions the ve c tor number 64 in base 10
(equi valent to 40 in base 16). Figure 4.11 show s that
the address pointed to, equal to $40 x 4 = $100, is
ind eed the v e c t o r corresponding to the number 64 ,
10
54 The 68000 Hardware and Software
Problem
What happens if during interrupt recognition no
peripheral (whether 6800 or 68000) replies by
maintaining at low the signals VPA (for the 6800
family) and OTACK (for the 68000)?
Answer
The explanations given so far would lead one to assume
that the BERR line (bus error exception) would
terminate the acquisition of the vector number. Now,
the the program is rerouted by the 68000 towards the
spurious interrupt vector number 24 1 0.
Example
Suppose that the PI/T 68230 circuit generates a
vectored interrupt after time out (that is, at the
timer level), and that the timer interrupt vector
register (TIVR) has not been initialised. In this case,
and in common with most of the 68000 peripherals that
have interrupt vector registers, the MC 68230
peripheral dispatches the uninitialised interrupt
vector or vector number 15 1 0($OF).
In fact, this number is automatically loaded into
the interrupt vector registers (PIVR and TIVR) when
there is a reset on the peripheral circuit. As a
result, it is possible to recover in a uniform way from
a programming error (by having the same number for all
circuits).
Exception Procedures 55
+5V
3 1 12 10 20
BG 6
BR 13 PAL 16 R4
BGACK 4
18 11 14 19
iPL1
IPLO IPL2
+5V +5V
T
MAKBUS®
ADDRESS BUS
DATA BUS
RS1
I
I
I
I
I
I PORTA
RS5
DO
I
I
I
I
I
I H1
I
I H2
I
I
H3
I H4
I
07
68230
AS PORT B
FCO
FC1
FC2
IRQACK OUT
IIRQACK IN
V322P
0 - - - - - - 1 TOUT
PORTC
ClK
USER
Group 0
Group 0 consists of three exceptions - initialisation,
bus error and address error - which are recognised by
the 68000 at the end of a clock cycle. These occupy the
position of highest priority group. In addition, if
during the handling of an address error exception the
BERR (bus error) line is set to low, the processor
abandons handling the address error exception in order
to execute the bus error exception. Thus, even at the
heart of group 0 a hierarchy of exceptions is
established. As a result, the initialisation exception
Exception Procedures 57
1
o Reset End of
Bus error clock cycle
Address error
1 Trace
interrupts
Illegal End of
instructions instruction
Privilege cycle
violation
2 TRAP # 0 to
TRAP # 15 During an
TRAPV CHK instruction
DIVU,DIVS cycle
(if zero d i v , )
! Increasing priority
I No priority
Group 1
Of lesser priority than group 0, the exceptions that
make up group 1 include those recognised at the end of
an instruction cycle (3), like tracing and interrupts,
together with those recognised at the end of a bus
cycle (2), namely illegal instructions and privilege
violations.
The different nature of the exceptions that go to
make up group 1 explains the natural hierarchy between
them, as can be seen from the following.
Group 2
Group 2 has the lowest group priority. It consists of
instructions that eventually lead to a trap (exception)
like CHK and TRAPV.
Given that a single instruction cannot be executed
at once, and that recognition takes place during an
instruction cycle (3), no hierarchy is established
between the instructions of group 2. Table 4.2
summarises the three groups.
58 The 68000 Hardware and Software
Definitions
Exception Periods
Example
Bus error 50 periods made up
of 4 read bus
cycles and 7 write
bus cycles.
TECHNICAL FILE
DO-D7 PAQ-7
RS1·RS5 PBQ-7
RiW H1
H2
~
H3
MC68230 H4
PIIT
RESET PC71TIACK·
PC6/PIACK·
PC5/PIRO·
ClK PC4/DMAREO·
PC3lTour·
VCC
PC2ITIN·
GND PC1
PCO
* dual function lines
TYPES OF ADDRESS
DEFINITION
Example 5.1
MOVE.W DO,$lFFE
61
62 The 68000 Hardware and Software
MP 68000 Workspace
Source Destination
Role of the instruction
The instruction MOVE.W DO,$lFFE (or MOVE DO,$lFFE)
gives the order to the processor to transfer the 16 low
order bits of the data register DO to the destination
location $lFFE (and $lFFF).
Details
The size specified by the instruction can be
Source Destination
Addressing Modes of MC 68000, MC 68008 and MC 68010 63
Source ~ \\-----Destination
MP 68000 Workspace
31 16 15 0
I FFFF I 8000 8000
t---- --....-t $ 5000 (and $ 5001)
t A2
I
32· bit
extension
Destination Source
Details
The size specified by the instruction can be word or
long word.
When a register An is used as destination, the
transfer of an operand to it leads systematically to a
32-bit sign extension.
64 The 68000 Hardware and Software
Demonstration
) 2000
2000
*.
"' ~ :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::-.:
'i(.
~: {~FTEf.~ EXECUTION::
~, :::::::::::::::::::::::::::::::::::::::::::::::::::::::::
*2000;T }"1
TRAC PC= 002004 « ';£-:7'" S:::O ...C') ()OC) C::: SF'::: ()()()()()l>() 0
DO::: OO()()()O()() D'I::: 00000000 D~~::: ()()()() ()()()() 1)3::: ()()()(){)()()O
D.I-t:: O()()()()()()() os- O()()()()()O() D6:::: ()()()()()()()() D7::: ()()()()()()()()
t~()::: {)()OOOOOO A"I::: O()()()()O()O I
f'~":?::: FFFFBOOol A:3::: OO()(){)OOO
(.'14= ()()()()()()()() A~j:::: ()()()()()()()() (-l6:::: O()()()()O()() ~~7::: ()()()()O60()
* AFTER EXECUTION::
~,
* ::::::::::::::::::::::::::::::::::::::::::::::::::::::
*
Addressing Modes of MC 68000, MC 68008 and MC 68010 65
Example 5.4
MOVE (Al) ,01
MP 68000 Workspace
ABeD $ 2000
(and $ 2001)
0000 2000
A1
Details
The size specified by the instruction can be byte, word
or long word. However, if the size is word or long
word, the address register indirect must point to an
exclusively even address. If this rule is not
respected, an exception rerouteing called an illegal
address will occur.
Generally speaking, these details will apply
whatever the type of indirect address.
66 The 68000 Hardware and Software
5L
Example 5.5
MOVE.W
Instruction source
Size
J (A5\) + , $
_.--------Source
Destination
MP 68000 Workspace
Before
00002000 I ABCD
t--------4
$ 5000 (and $ 5001)
AS
After
0000 2002 I Source ~----f
ABCD $ 2000 (and $ 2001)
AS
Example 5.6
--1 ! ,
MOVE.W -(A5),$5000
Instruction source
Size ..
L Destination
Source
Addressing Modes of MC 68000, MC 68008 and MC 68010 67
MP 68000 Workspace
I nitial status of A5
31 1615 0
I 0000 I 2002 I 1234
t------4
$ 5000
(and $ 5001 )
A5
Before processing
I 0000 2000 1234
A5
Details
The size specified by the instruction can be byte, word
or long word. If the address register used as
indirection is the stack pointer, and if the size is
byte, the register An is always decremented by two in
order to keep the size to word.
Example 5.7
MOVE.L $5000(AI),D5
16-bit signed
displacement
~
Source
Register (An)
Destination
MP 68000 Workspace
31 16 15 0
11234156781
05
1 2
34
56
0000 2000 78
A1
Destination Source
Al ~ 0000 2000
+
16-bit signed ---.- 0000 5000
displacement
with 32-bit
extension
0000 7000
Details
For a word or long word operation, the effective
address must be even. However, for a byte size the
effective address can be even or odd.
EA = (An) + (Xi.W) + d8
Example 5.8
MOVE.W $08 (A2,D3.W), DO
---I
l l
Instruction ----l l
Size
8-bit signed
displacement
Register An
Register xi
Index size
Destination
Addressing Modes of MC 68000, MC 68008 and MC 68010 69
MP68000 Workspace
Destination
unaffected
31 1615 0
I 0000 I 3000 I
03
~ ..--A_B ~ $ 4008
31 1615 0 Source l..--C_D ~ $ 4009
I 0000 1000 I
A2
) 4:.
2000~ T )'1
il:· rR~:,C PC:;: O()~.~()O" •• i,E?"'1 ~):::O~) 000 1"::.: • N. •• ~)p::: O()()OO{.()()
DO:= C;!)OO(.'BCD D" ::: ()()OOOOI]O D~?:::: OI]O()()OOO 1)::3::: 0()OO~3()()D
[).<i::: OO()()OOOO [)~.;::: OOO()()()OO Dl,::: OOO()()O()O [) 7 ::: OOO()OO()O
{~() :: I]() () () I]()()0 (.\"1 ::: () oo()() 0 0 () A:~~ ::: 0 ()()()"1 ()()() (.) ::3 ::: I] () () () DOD0
f~·IL~:-.:: 00000000 (~~:;::: OOOOOO()O ~~ ~.) :::: ()()()()OO ()() rl 7 :::: 00000600
~------Destination
Details
See address register indirect with displacement.
EA = (An) + (Xi.L) + d8
Example 5.9
Instruction ~
Size
8-bit signed
displacement
Register An
Register xi
Index size
Destination
Addressing Modes of MC 68000, MC 68008 and MC 68010 71
MP 68000 Workspace
unaffected
31 1615 0
I 0001 I 0000 I
03
61
31 1615 0 00
0000 I 2000 I
A2
Destination Source
~.
..
i(.
~
I t-t::;TPUCTION::
::::::::::::::::::::::::::::::::::::::::
~;O'-.JE.l·1 "OB(A~?:oD:~.L) :rOO
20()(), T >'1
~. lR AC P c:= O()~,~()()'; tt 'tE7 '1 S:::() S O()() C::: Sp:::: O()()()06()()
DO::: ()()()()6'" 00 D'1::: (){)OOOOOO ()OO()()()()()
D:~?::: D~~::: O()()··, DO()O
D.lt ::: O()OO()()()() os- (}()()()()()()() Db::: ()O()()()O()() D7::: ()()()()()()()()
L
A()::: ()()()()()()()() A'I::: O{)()()OO()() (.\:~~::: O()()()~?O()() A~3::: ()()(){)O(JO()
M= 00000000 A5= 00000000 Ab=' O()OOOOOO A7= 00000600
the contents of DO.W have been loaded with the contents of addresses
: AFTER EXECUTION $1F008 and $1F009
* :::::::::::::::::::::::::::::::::::::::::::::::::::::
*
Absolute Address
There are two types of absolute address
Example 5.10
MOVE.W $2000,$5000
or
\
MOVE $2000,$5000
MP 68000 Workspace
Destination 12
AS
12
Source
AS
Details
The size specified by the instruction can be
Example 5.11
! ,'----------:~~~~~~
NOT.B $F400l
Instruction - - - - - - - -
Si ze f__ ve
MP 68000 Workspace
......,. ~ $ OF 4001
Details
The size specified by the instruction must be
4 Immediate Address
The immediate address mode allows an operand (data
item), whether 8, 16 or 32 bits, to be sent to one of
the following
data register
address register
memory location
Example 5.12
MOVEA.W #$2000,A5
or
MOVEA #2000,A5
I I
31 16 15 0
I 0000 2000 AS
3~
extension # $ 2000
J
The above instruction loads address register AS with
the immediate value #$2000.
Details
1. There is always a 32-bit extension when the
destination is an address register (for a 16-bit source
or da ta item).
2. The size specified by the instruction can only be
word or long word. Byte is forbidden.
Example 5.13
1. MOVE #$8000,A5
1- Sign bit is
negative
31 16 15 0
I FFFF
I 8000
I
/
32-bit extension # $ 8oo0 J
Addressing Modes of MC 68000, MC 68008 and MC 68010 75
Example 5.14
MOVE.B #$6A,02
I I I
31 16 15 87 0
XXXX XX 6A 02
~)
# $ 6A
Details
1. The size specified by the instruction can be
Example 5.15
MOVEQ #$6A,04
0000
)
32-bit signed
extension
76 The 68000 Hardware and Software
Details of MOVEQ
1. The destination is always a data register.
2. The size can only be byte.
3. There is 32-bit sign extension (the only occurrence
of sign extension on a data register).
Special note
The instructions AOOQ and SUBQ specify a 3-bit operand
whose different combinations code values lying between
1 and 8 inclusive.
000 represents value 8; 001 value 1; 010 value 2,
and so on, with III representing value 7.
Simulation
~,
~, ::::::::::::::::::::::::::::::::::::
~.
~ BEF()PE EXECUTION
'* ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
~:
PC:;: oo~~ ()()" *. '.E 7 '1 ~~ :::: () S ()()() C::; SP ::: OO()()()600
DO::: ()()()Of,~>"'1 ()O D"::: O()()()()()()O D;.~::: ()()OO()()OO D~3::: O()()"J DOOO
I Doli:: OO()()()()()() I [)~:;::: ouoooono Dt,::: OOOO()(}(}(} [) 7::: ()()()(}()(}()()
(~o::: ()()O()()()OO I~~'" :::O{)OOO()()() A:2::: ()()()():;~()()() (.':3::: O()()()OOOO
{i.fi:::: ()O()()()()OO {:\~5::: ()()()()()()(}() A6::: O()()()()()()() ~~ 7 ::: ()()()()06()()
;.~O()() ; T ) '1
-:0:. TRAe PC::: 0 () ~.~ 0 () ~~ ..'tE 7 '1 s :::o s ()()() C::: sp::: O()()()060()
D()::: ()()()()(~d 00 D"'::
O()()O()O()() D~~::: ()()()()()()O() D~3:: 000'1 DODO
I[)"',:"_-: O()()()()()f.:.F\ I [)~;::: ()()()()()()()() DtJ::: ()()()()()()()O [) 7 ::; 00000000
(.)() ::: ()0 () () (1() o o A'" = o()ooo0 () o o()
A :-:~ :::: 00 ()0 ~~ 0 (-\:3::: O()(){)OOOO
t.iJ::: ()()()()()()()() A~:i:::: ()()OO()()O() A6:::: OO()()O()()O (.\7::: ()O()()Ot,()()
> :11:
) *
oJ:
* IN~:)TRUCTION:; MOl~JE(~ "~;,fiO ,Dol;
* ~::::::::::::::::::::::::::::::::::::::
*
2()()() 7El6Ao--7BElO 4E7 1-- } loading 0
of program
> ~.
PC::: () 0 ~~ o()~? 4t Lt E 7 ." S:::() S ()() () C::: SF' :::: O()O()()6()()
DO::: nO()06" no I)'.'::: nnoooooo I):~~:::: O()()(){)()()O D]::: ()()()'1 DODO
I[).fi::: I
AD:::
{jLot:::
()()()()()()t)A
on()()I]()()O
OO()()()()()()
f'", : : ()()()()()()()()
[)~:j::
A~,i::::
()()()()()()()()
O()()()()O()()
[)l'):::
A~~:::
(~6::::
()()()()()()()()
()()()();:~()()O
()()()()()()()()
[) 7:::
A:3:::
O()()O()()O()
()()()()O()()()
A7 ::: OO()()()6()()
Example
ADDI.B #$80,$4000
Example 5.16
Basis
The value contained in the program counter (PC) is used
to calculate the effective address for instruction
handling, with the knowledge that the PC value is equal
to the current instruction address +2.
All instructions using relative program counter
addressing must be written in a section of program
called RORG. This special feature allows position
independent programs to be written.
78 The 68000 Hardware and Software
Example
In the following we shall examine some program
instructions defined in a RORG section.
Formula EA (PC) + d 16
l ! ~
v..
giving
2024 (2004 + 2) + 00 1 E
TRAPCHK
/ Program
!
Label address counter +2 displacement
shown by op-code
(2024 - 20006 = 00 1 E)
Addressing Modes of MC 68000, MC 68008 and MC 68010 79
Data register On EA = On
direct
Address register An EA An
direct
Relative program
counter address raddr 16 EA (PC) + d 16
with displacement
Relative program
counter address raddr 8 (Xi) EA (PC) + (Xi) + d 8
with displacement
and index
Formula EA (PC) + d 16
~ ~ +
-:
20DC (200C + 2) + 00 CE
-,
TABLE
Label address
Program
•
counter +2
Relative
displacement
shown by op-code
(20 DC - 200 E)
Formula
EA = (PC) + (Xi.W) + d8
or
»> -,
EA = (PC) + (Xi.L) + d8
Current value
t
Index register, 8-bit signed
of PC + 2 a 16 or 32-bit displacement
data or address
register
Implicit Address
Table 5.2 lists the instructions that make implicit
reference to the following
Table 5.2
Instruction Implied registers
MOVE.W -(An),-(Am)
Microinstruction 2
Microinstruction 3
6 68000 I nstruction Set
bit
BCD digit (4 bits)
byte (8 bits)
word (16 bits)
long word (32 bits)
Example
MOVE.B Source, destination
MOVE.W Source, destination
or MOVE Source, destination
MOVE.L Source, destination
82
68000 Instruction Set 83
In pseudo-code In pseudo-code
I
WHILE CONDITION TRUE
ACTION
REPEAT
I ACTION
UNTIL condition TRUE
END
Selection
In pseudo-code
IF condition TRUE THEN
IACTIONl
ELSE
IACTION2
END
Figure 6.1
84 The 68000 Hardware and Software
Loading Instructions
LEA and PEA cause a pointer to be initialised (LEA
Src,An means An := effective address) and saved to the
stack (PEA Src means Src = effective address -) -(SP)).
These two instructions, which share the same
addressing modes, are to some extent complementary.
Special instructions
Comparison Instructions
The first two instructions of the third group are
concerned with comparisons. This is one area where the
instructions set could be criticised. In fact, the
memory to memory comparison (CMPM) is only possible
with a source and destination having the addressing
mode (An)+. As for the CMP instruction, the source can
only be a Dn register. Finally, CMPI compares the
destination with the source specified as immediate.
(CMPI # Immediate, Dst.)
The CHK instruction compares the word LSB of a
register Dn with a bounded value, where the lower bound
is 0 and the upper bound is a 16-bit signed operand. If
the word LSB does not belong to the interval, the
processor is rerouted to the exception procedure
TRAPCHK whose vector number is $6.
The TAS (test and set) instruction allows management
of a resource that can be shared by several processors,
since during a single bus cycle it executes the
reading, testing and finally modifying of a destination
byte (memory or register) called a semaphore.
The next two instructions, CLR and TST, present
little difficulty, save for the fact that the
destination cannot be an An register.
Special Instructions
The fourth and last group in this category only affect
An and On registers. The instruction SWAP exchanges
bits 0-15 of a Dn register with bits 16-31. EXT carries
out a signed l6-bit or 32-bit extension in a Dn
register.
The last of the special instructions, EXG, instructs
the 68000 to exchange the 32 bits of a source register
with the 32 bits of a destination register (register =
An and/or Dn ) ,
Logical Instructions
Logical Instructions
The next group (3), the logical instructions, will be
well known to programmers. It includes AND and ANOI
which carry out a logical AND of the source and the
destination, with the result being stored in the
destination.
We have however noted that memory to memory
operations are not possible and that, for EaR and EaRl
(exclusive OR), the source can only be a On register or
an immediate operand.
Program Control
The most significant advances have been made within the
category of the program control instructions. Table 6.5
lists the various instructions involved.
NOP / / 1 No operation
JMP Address / I Unconditional jump to
address
BRA Displ. / 3 Branch always
Condition operation
Privileged instructions
Logical traps
Notes
(1) The address is specified in absolute: all
addressing modes allowed except
Immediate,Dn,An,(An)+,-(An).
(2) Displacement lies between $8000 (-32 768) and $7FFF
(+32 767).
(3) Displacement is 16 bits signed (32K).
(4) See table 6.5 for condition codes.
(5) Destination can use all addressing modes except
Immediate,An,d(PC),d(PC,XI).
(6) Source may use all addressing modes except An.
(7) Only word size is allowed even if destination is
byte (in which case CCR is loaded with the source LSB).
(8) The data on immediate is a function of the
instruction specified size.
(9) Privileged instructions can only be handled in
supervisor mode.
(10) The vector lies between 0 and 15.
Examples
Example
OIVU 01,00 := $FFFFFFFF
TRAPV 01 $XXXX0002
BRA*
The 68000 carries out the signed or unsigned
division of the 32 bits of the destination (DO in the
above example) by the 16 low order bits of the source
(01) .
The 32 bits of the result available in the
destination are distributed as follows: the remainder
in 16 bits (bits 16-31 of the destination); the
quotient in 16 bits (bits 0-15 of the destination).
If the result exceeds this format, the 68000 does
not carry out the operation, but sets V to 1, without
68000 Instruction Set 95
DBee INSTRUCTIONS
Role of DBee
Instruction OBcc On,d16 is a looping primitive with
three parameters: the condition specified by cc, the
loop counter represented by a data register On, and the
relative 16-bit displacement.
Execution of this instruction by the CPU causes the
following sequence of events
1. Condition cc is tested (cc can be one of the 16
conditions listed in table 6.6). If the condition is
true, instruction OBcc is terminated and the processor
executes the rest of the program.
OBcc On,d16
1
No Yes I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
'-------------
End
-------------- J
In pseudo-code
IF cc FALSE THEN
On := On -1
IF On<> - 1 THEN
PC := PC + l6-bit displacement
END
ELSE
NOP
END
Figure 6.2
68000 Instruction Set 97
Examples
1. The assembler programs in listings 6.1a and 6.1b
instruct the Me 68000 to print out n times the message
"The 68000 microprocessor is wonderful".
The value n stored in byte $2054 before execution of
the program represents the contents of the loop counter
register of the primitive DBLT D2,LOOP.
The different simulations prove that the test on the
loop counter is carried out on value -1.
Listing 6.1a
20
*******************************'*****'*****'**'*****'*'*'***'******'***********
30
40
'* THREE PARAMETER LOOPING PRIMITIVE
* DBCC INSTRUCTION
50
*
60
* '*
70
*******'*******'************************************'**********'**********
90 000'1F9E9 ACIA EQU $"1F9E9 = ADDRESS ACIA 6850 EUROMA~; 68000
'*
'* S 1. MULATION PROGRf.,M
~. ::::::::::::::::::::::::::::::::::::::::::::::::::::::
*
> ;?()~:j'1. B
* 00205't > O~?
* ()O~~05!5 )
200CHG
THE 6ElO()() MICROPROCESSOR IS ~JONDERFUI..
THE 680(){) MICROPROCESSOR IS WONDERFUL
THE 6El()()() MICROPROCESSOR IS WONDERFUl..
> *
> * WHY· ??
') -t(.
;?O~:.i4. B
.:* O()~?05't
* ()O~?055
) -;.,()OO; o
THE 6E}()()() MICROPROCESSOR IS ~JONOEI~FUL
THE b80{)() MICROPROCESSOR IS I"JONDERFUL
THE 68()(lO MICROPROCESSOR IS ~JONDERFUL.
THE 680{)() MICROPROCESSOR IS I"JONDERFUL
20
*****************************'*******'*********'****************'******
30 * *
40 * THREE PARAMETER LOOPING PRIMITIVE (EXERCISE 2 ) *
50 * *
60 * TWO STRINGS ARE COf1PARED TO SEE IF THEY ARE THE SAME *
70 * *
80
*************************1*********************************************
** Al = POINTS TO THE BEGINNING OF
100
'110 THE FIRST STRING
'120 * A2 = POINTS TO THE BEGINNING OF THE SECONO STRING
130 * 02 = NUMBER OF CHARCTERS
140 OOO'lE178 OUTMES EQU $'1[178 ; PRINT TEXT STRING OF CHARS
Listing 6.2
20
30
**********************************************************************
40
** EXAMPLE OF USE OF "INDIRECT AORESSING" WITH INDEX **
50 * AE = d+An+Xn *
60 * FINDING THE LARGEST OPERAND IN THE TABLE (size Long Word) *
70 * Program Written in Position Independent Code *
80
90
* *
**********************************************************************
110 00002000 ORG S2000
Simulation
~:'
.'
;.)('1'1(":;1)
~?()OO; Fi
~(- . . J~)TP F,'C::: OO~?O--I C tt '1£:','1 f;:::O S 000 c::: sp::: 00000(,00
PC::: ()() ? ()'1C U ,:~ [' ,; ,., S:::0 S 00 () C:: ~)p::: O()OO()600
DO=: OOOOF F FF D'I::: ()OOO()()~?B D~?:::: O()O()OO()() D~3:::: 77777777
[)L,::: OO()()OOCl() [)~:j::: ()()O()O()()O Dt}::: OO()()()O()() [)i' ::: OOO()OO()()
i~():::: O()()O:3()()() (~"I::: OO{)O:3()()() (.\;':~::: Oo()n()()oo A:;3::: O()()()l)DOO
~~~(;:::: ()OOO()OOO ~~~:;::: ()OOOOOO() ~~t,::: O()()()()()()O (~7:: 00000600
> *
:> *
]000.1.,
:cf OO~3()()O
~ 00::300 l t
* OO]()OB
~cf ()O~3()OC 00000000
* OO]()-" I] (., {ll~~\~~\r'(lr\~~\
* ()()]()'14 6 c':·(,',t!.'.,{,c",66
:do OO]()'IB 7777?'700
* OO:J()'I C
* no]o~~~O EEEEF:EEE
* () ():3() ~':? ,:j. 7FFFFFFF
* O()::3();~~B
") ?O-1 C; I)
2000;13
-G~ I,JSTP P C::: O()~.~O·1 C U ':'1:'.';'1 S:::O~) DOO C::: sp::: OO()()0600
DO::: OOOOFFFF D-I:: ()O()()()O~?B D:~?::: OOO()()()OO D3:::: lFFFFFFF
D,(1:: OOO()()()()() os- OOOOOO(}O [){:.:::: OO()O(}()(}() D7::: OO()O()O(JO
(~o::: OO()O:)OOO ~'-I ::: ()OO()~JOOO A~~::: OO()OO{)OO A]::: O()O()ODOO
f~Ll:: OOO()()O()() ~~~:;:::: OOOOOO()() (.,6::: OOOOO()()O (-\7::: ()()()()0600
68000 Instruction Set 101
Sec INSTRUCTION
1 Role of Sec
Instruction Scc dst tests one of the 16 cc conditions
summarised in table 6.6.
The destination byte is positioned at $FF if the
condition specified by cc is true, and at 00 if cc is
false.
This instruction is generally used to position a
boolean variable after evaluating an expression, where
the true variable is coded $FF and the false variable
is coded 00 (see the example in listing 6.3).
2 Syntax of Sec
....;
In assembler
Scc dst
Instructi~
mnemonic effective address
IF cc TRUE THEN
I destination .= $FF
ELSE
f destination .= 00 End
ENDIF
Figure 6.3
102 The 68000 Hardware and Software
Listing 6.3
30
40
**********************************************************************
50
* USE Sec INSTRUCTION
*
60
* *
70
* *
80
* PROGRAM TO DETECT ·16 BIT PALINDROMES
90
*
... (USING MACROS)
*
100
1"10
* *
**********************************************************************
-130
*
140 ** ALGORITHM :
-150 * ---------
160
"170
*
-180
** BTST [1"1. (AD) ~ ~ BTST DO. (AD)
-190
200
* v v
2-10
* ++++++++++++++++
220
*
230
* :- 0
*
240
*
260 *
270 ** MACROS
280 * ------
300 TEXT MACRO
3-10 \a HOVEM.L OO-D7/AO-A6,-(A7)
320 LEA STRING\i,AO
330 JSR OUTMES
340 MOVEM.L (A7)+,DD-[l7/AO-A6
350 RTS
360 ENDM
380 oo01E-178 OUTMES EQU $1[178 • OUTPUT STRING OF CHARS (EURO~;AK 68(00)
..*
780
790
800 TEXT 2
800 002060 48E7FFFE ~(I02 MOVEM.L DO-D7/AO-A6.-(A7)
800 002064 41F820A3 LEA STRING2,AO
800 002068 4EB9000-tE178 JSR OUTMES
800 00206E 4C(~7FFF MOVEM. L (A7) +, DO-D7.1 AO-A.~
800 002072 4E75 RTS
Simulation
~.
) *
.
"> *iI: S IMUL("TION PRO G RAM
-i(.
") 1/..
'
~'>07Li. t,.J
:.. {)O~?()7,ct AFF~:.i
·)f OO:;~Ol,~
;';000;13
fHF "'lORD r s NOT (" PAI,..INDI~OME
;~07L;. 1,01
:.. O()~?()7 "t F FFF
* ()O~?07lJ )
20()O ~ o
THE "'lORD IS A PALIN[)I~OME
) ;.~07Lt. W
* 00207 it (" ~:,i~;;~~
:tf. ()O:~~()7 6 ;~
> 2000;G
THE ""ORD IS A PALINDr~OME
) 207't.l·J
* () I] ~? () ? it (ol~:j f~~:.;
* ()O:~?O? 6
2000;(1
THE WORD IS A PALINDROME
Instructio_n ~!
mnerno n i c
Ldestination
Number of
bit tested
-------_-----.1
IF numb = 0 THEN
I
ELSE
Z -= 1
I Z
ENDIF
-= 0
numb -= 1
Figure 6.4
106 The 68000 Hardware and Software
IF numb 1 THEN
I
ELSE
Z .= 0
I
ENDIF
z := 1
numb := 0
Figure 6.5
IF numb = 0 THEN
I
ELSE
Z .= 1
I Z
ENDIF
.= 0
Figure 6.6
68000 Instruction Set 107
I
IF numb = 0 THEN
.=
num~ .= 1
1
Inum~ .=
ELSE
:= 0
0
ENDIF
Figure 6.7
2 Program Examples
The program shown in listing 6.4 causes the number of
Is and as contained in a long word to be displayed.
Listing 6.4
20
30
**********************************************************************
40 PROGRAM TO DISPLAY A LONG WORr, IN BINARY
*
50
*
60
**********************************************************************
80 00O'lF9E9 AeIA EQU SlF9E9 ADDRESS ACIA EUROMAK 68000 SYSTEM
Simulation
'*
~: S IMUI...(~T ION pr~OGR~~,M
it: :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::=
> *-
> *-
* ~~O~:jO. L.::: 1... ONG ~IOPD
*;!o~)o .. I..
:If OO:?()~50 FFFFFFFF
()():~~ os I.t
*
~?OOO; G
68000 Instruction Set 109
'1'1'1"1'1 '1'1'1'1'1'1'1'1'1'1'1"1'1'1'1"1'1'1'1'1'1'1'1'1'1'1'1
*
*
;?O~;,;(). L..
* 0020~jO 00000000
* (){):~?O!5/'t
*2000;G
OOOOO()(}O()()()()OOOO(}O()O()()O()()(l()()()()()()
Listing 6.5
20
*'***************'**********'*****************'****************************
**' PROGRAM TO COUNT THE NtJIBER OF -1 " IN A LONG WORD *
30
40 ..
. .
/I
50
60
***********************************************************************
80
90
** FUNCTION REGISTERS
'100 * -----------------
'1'10 * [lO.B = COUNT BIT
'120 * O'l.B = COUNT LOOP
'130 * 02.L = LONG WORD
'140
150 00002000
*' ORG 52000
> it:·
~: .iusr BEFORE f-'ROGR(.,M EXECUTION
* _.. _ - - __ -.. - _ .
i(-
;~O;!E .t
-:tf· ()()~?O~~~E FFFFFFFF
* OO::'?O::3:;?
*~~ 0 :];~ oaoo-
;?OOO1: Fi
1I::
..:
~. AFTER E X[CUTION
-_ ...... -...... _.. _ _ ..._....._..
;.~ oaz 2 ooo .
) *
> ~~();?E. L
* O():':.~()2E FFFFFFFF
* ()O~?():]:;?
20()();G
;?():~;:~ '1 F (l().•.
oJ(-
> ~:.
ASR.W #cnt,On
31 1615 o
On
t
Sign bit
retained
Figure 6.8
Example
ROL.W #8,On
Before
31 16 15
,----------~.
87 0
]
~
Dcarry
After
31 1615 87 0
1...- - - - - - - - - ]
l
ri-.
Figure 6.9
112 The 68000 Hardware and Software
Dynamic Dm,Dn
The total number of rotations or elementary shifts of
the content of Dn is specified by the 6 low order bits
of register Dm (modulo 64).
31 5 4 3 2 1 0
20
21
_ _ _ 22
'---- 23
'---- 24
_______ 25
Figure 6.10
Example
The maximum number of rotations or shifts is equal to
N = 1 + 2 + 4 + 8 + 16 + 32 63
Programming
Memory Position
If the destination location (dst) is an address, all
memory addressing modes are authorised, except for
immediate (# Op, dst), relative and relative indexed.
However, the word is the only authorised size.
Example
ROXR.W dst
Memory
15 0
.,
[
Figure 6.11
Program Example
The program shown in listing 6.6 carries out a BCD -)
binary conversion and displays the result (see
simulation).
Listing 6.6
30
40
************************************************************************
50
**' U SIN G "M U L U and M U L S 1 N S T RUe T ION S ...
1\
60
70 * WRITTEN BY: PATRICK JAULENT
*
80 * MACMILLAN EDITION
90
* *
100
no ************************************************************************
-120 ** BCD --) BINARY CONVERSION
"i30 * ===========================
140 '* RESULT DISPLAY IN BINARY
-160 000-lF9E9 ADDRACIA EQU $lF9E9 :ACIA 6850 SYSTEM EUROMAK 68000
300
310
*** BCD --) BINARY CONVERSION
320 * -------------------------
330 * ALGORITHM:
340 * =========
350 *
360 * RESULT= Di'1*10"'0 + Oi2*'10..··1 + Oi3*10"'2 + Oi4*'10"'3
370 *
390 00201A 48E778OO CONVERSION MOVEM.L 01-04,-(SP) SAVE ALTEREO REGISTERS
400 0020-1E 322F0014 MOVE.W 20(SP) ,0'1 LOAD NUMBER BCD
410 002022 4283 CLR.L 03 03.L:=0
420 002024 4284 CLR.L 04 04.L:=O
430 002026 7401 MOVEQ '1,02 INITIALIZATION MULTIPLICAND
440 002028 OC422710 LOOP CMPI.W #'10000,02 DO WHILE 02 < #$'1000
450 00202C 6C12 BGE.S EXIT
460 oo202E 3801 MOVE.W 0'1,04 ! D4.W:=0·1
470 002030 0244000F ANOI.W #fF, 04 ~ i* MASQ OIGIT LOW *1
480 002034 C8C2 MULU D2,[)4 ! D4.W*D2.W:=D4.L
490 002036 0644 ADD.W 04,03 ! D3.W+04.W:=D3
500 002038 E849 LSR.W #4,0'1 ~ 1* SHIFT NYBBLE TO HIGH *i
510 00203A C4FCOOOA MULU #'10,02 ! 02.W*·10:=02.L
520 oo203E 60E8 BRA.S LOOP ENODO
530 002040 3F430014 EXIT MOVE.W D3,20(SP) STORE RESULT
540 002044 4COF001E MOVEI'1.L (SP)+,D1-D4 RESTORE REGISTERS
550 002048 4E75 RTS
570 *
580 ** OUTPUT BINARY RESULT
590 * ===================
610 00204A 48E7FOOO DISPLAYED MOVEM.L DO-03,-(SP) SAVE ALTEREO REGISTERS
620 oo204E 7403 MOVEQ #4-'1 ,02 NYBBLE NUMBER
630 002050 7603 RBIN"! MOVEQ #4-'1 ,03 BITS BUMBER
640 002052 7020 MOVEQ #$20,00 ASCII SPACE
650 002054 6-12A BSR. S OUT CH'1 OUTPUT CHAR.
660 002056 "103C0030 RBIN2 MOVE.B #'0' ,00 ASCII 0
670 002D5A E349 LSL.W #'1,0-1
680 00205C 6404 BCC.S RBIN3 IF BIT =0 THEN
690 00205E '103COOJl MOVE.B #'1' ,DO ~ 1* 0 ,DISPLAYEO *1
700 002062 61-1 C RBIN3 BSR.S DUTCH'! ELSE
710 002064 51CBFFFO £lBRA 03,RBIN2 ! 1* '1 ,DISPLAYED *i
7~~ 002068 51CAFFE6 OBRA D2, RBIN'! ENOIF
730 00206C 4CDFOOOF MOVEM.L (SP)+, 00-03 RESTORE REGISTERS
740 002070 4E75 RTS
760
770
***OUTPUT LINE FEEO & CARRIAGE RETURN
780 * ==================================
880
890
*'*'* SUBROUTINE TRANSMIT CHARACTER
900 *' =============================
920 002080 08'15000'1 OUTCHl 8TST B #'1, (AS)
I TEST ACIA TRANSMIT READY ?
930 002084 67FA BEQ.S OUTCH"!
940 002086 '1B400002 MOVEIB DD.2(A5) OK I TRANSMIT CHAR.
950 00208A 4E75 RTS
~:
.: S IMULf,TION PI~~OC:;f<AM
*. ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
.:
.:. 20BE .l·J :: NUMBEP E~C[)
.: •..-_ _ _--- .
> i(-
;~()B[. l·'
:cf DO:·~OBE > DO"tO
!If ()O:~?()90 >
~~OO() ~ G
1]000 0000 0000 '1 ()'1 0
*~'>OBE.l·J
!If DO~~ OBE > 0'1 CI()
:If ()()~?090
;,~OOO; Ci
OJOO 0000 0110 0100
> *.
*~.~()BE • l·J
!If ()O~~()BE > '1000
!If ()O:~~090
> ~~()OO; c:;
0']1]0 00'1'1 '1'1'1 () '1() 0 o
> *
*.
Example
ABCD - (An), -(AnI)
SBCD - (An), -(AnI)
Source 1 \\----Destination
~ Direction of calculation
,DIGIT MSB I I DIGIT LSB , Number 1
+ (ou-)
,DIGIT MSB , I DIGIT LSB I Number 2
Figure 6.12
68000 Instruction Set 117
7
oAdd resses 0 Add resse: 0
Increasing
LSB LSB
DIGIT MS -.-J ~ DIGIT MS~-.-J ~ DIGIT MS addresses
(visualisation
of result)
+
I
Decreasing ddresse Addresses
addresses DIGIT LS /MjSB, DIGIT LSB ",M~B,t-D-IG-I-T-L-S--tB
(calculation) T ,.
1---==-_--i~·(An) ~·(An1)
Program Example
The program of listing 6.7 demonstrates the use of the
ABCD instruction.
Listing 6.7
20
30
**********************************************************************
40
* USE ABC [I INS T RUe T ION
*
50
* II II
*
60
** WRITTEN BY: PATRICK JAULENT *
*
70 * EDITION : MACMILLAN *
80
****************************************H****************************
"100
-liD
** ADD THE SOURCE OPERAND TO THE OESTINATION OPERAND ALONG WITH THE
120 * EXTEND BIT (X), ANO STORE RESULT IN THE DESTINATION •
"130
·140 00002000
* OR6 $2000
'180
190 002008 7204
* MOVEQ 15-1,0'1 : NUt1BER OPERATION
200 00200A 023COOOF ANDI.B "OF ,CCR X:=o
210 00200E C'109 LOOP ABCD -(A'1) ,-(AD)
220 002010 51C9fFFC ClBRA 0'1 ,LOOP
230 002014 4E4'1 TRAP #'1
240 0020'16 0000 DC.W 0
Simulation
~:
~. ()F~)TIN~~l ION::
'* ._.4 •.•. ".•"__ .' •. __ ._
~.)O·1 F .I:~
* OO;;?'O'IF 9B
.)f- O():~~O~~O '1()
* ()O;~?n;~~" '1 ~:i
* O();,:~()2~~ ~)O
:cf ()O~?()::? ::3 ) '1 0
·:tf OO:~?O:;~ it
*
*. SOURCE::
,~(. .. -- _.... _.._-
..:
.:> 20'19. B
* O()~?O'I ~.;I o;~
:If O()~?()·" A ~~ 0
:4- ()()~.?()., B {, 0
* ()():~~O·' C '10
OO;?O·, D HO
OO:~?O'I E
'*
2000; 13
-1(.
'*
* O[SINATION:
* :::::::::::::::::::::::::::::::::::
'*
?O'1F .B
()O~?O"'F 00
68000 Insuuction Set 119
* O()~~()::~O 99
* OO~~():,:?·' 99
.:tf- 0020~~2 99
* O()~~()~~ ~3 99
* ()():':~o~~ 4
> ~
> * SORCE
~ SOURCE:
* __ . -
~
;.)()·19. B
* O()20·19 ()()
* 0020" A 99
* ()O:,:~()·' B 99
* ()o:~o·, C 99
* ()O~~()" f) 99
* ()()~~()·t E
)*
> *.
> 20()();G
> *
) * RESULT ) [)E~~TIN(-\TrON
> * -._._---_._-_.-..__._--.-_._-_..- _ .
} 20·1F > ()()~~()·1 F. 900·1-- 9999-" 9998···
31 16 15 0 15 0
Figure 6.14
120 The 68000 Hardware and Software
Details
Both source and destination cannot be an address
register.
Any zero division causes a trap.
If overflow occurs the 68000 does not carry out the
division (the registers are not modified) but sets V to
1.
Listing 6.8
***************************************************************~
) **
>
., [) I I..J U f~' ND () I I) S .. I N ~) T r~ U C T ION S *
*
~ *
) ****************************************************************
*
~: p ,~~ ('JGR (,,~'1::
..: ::::::::::::::::::::::
> ~:
2000; G Quotient
:P: ABR r PC::: ()()~~()()6 tt bOFE s-u s ()()C) c:::: sp:.-.: 0()()()()6()()
I)()::: ()()()"17FFF I)'" ::: ()()OO()()()~~ I) ~~ ::: () () () o()()()() 1):3:: ()()()O()(){)O
().Ii = O()()()()()()() [)~:;::: O()()()()()()() DtJ::: ()()()()()()()() ()? ::: ()()()()()()()()
A()::c ()()()()()O()() A "I::: ()()()()()()()() A~,~::: ()()()()()()()() (.'~3:= ()()()()()()OO
{V;:: ()()()()()()()() A~:;:::: ()()()()()()()() A6:::: ()()()()()(}()() A 7 ::: ()() () () 0 tJ00
Remainder
** AFTER EXECUTION
*
68000 Instruction Set 121
~.
* SECOND S IMUlJ:~TION=
~( _ - --..- -'" _..
> it:
* BEFORE E)(ECUTION=
* _._- - _ _ .
'>
*
;~O()O;[i
~: [) I . . .1... E'~~ r~! 0000 OOO()()()O() 0000
REG = P C::: •• fiE? 6
()O~.~(}()~.~ ~>:::() S ()()O C::: •• Z.. SF'::: ()()()()()6()()
DO::: D'" ::: O()()()()()()()
()()I.)();:?:~~:':~~~ D~?::: ()()()I]()()()() D~3::: ()()()()()()()()
I).t,::: ()()()(]()()()() Dt}:::: O()()()()()O() D6::: O()O()()()()() [) 7 :::: ()()()()()()()()
(-,()::: O()()()()()I.)O (-\., ::: ()()()O()()()() ~,;~?:::: {)()()()()()()() A::3::: OO()()()OOO
{,.It:: ()()()()()()()() ~~ ~j::: ()()()()()O()() (,,6 :::: ()()()() D()()O A 7 :::: ()()()()06()()
> *
* [) II....'J:~n:ON H '( ZERO !!!
* .--._ __ _--
) *
* T1-.1 II:'~() s I MUl..~~ TION::
* _.- __ .
*• [)'1 ::: OOO()O()()() ··OOOO()()O.. .i Di visor
• DO :: OOO();?~~;,.~;..~ .. FFFFFFFF Di vi dend
~.
OOC); C)
;~
~(. TR'J.. ERR! O()()O ()()()()()()()() ()()()() V := 1
r~EG:: PC::: ooaon- tt'tE7"1 S:::() S O()() C::: • N.V. SP::: ooooueno
DO::: FFFFFFFF f)"I::: noouooc- D;~~::: (){)()(){)()O() IX3::: ()()()()()()OO
D4== O()()()()()()() os- ()()()O()()()() Dt,::: O()()()()()OO D7== ()()()()()()()()
A{):: {)()()()()()()() A"I :::: ()()()()()()()() (:\;~~::: ()O()()()()()() A~3::: O()()()()O()()
r., "J::= ()0 () () () () () () ~~ ~:i :::: ()()()()()()()() A 6 :::: () () () () () () () () A 7 ::: () () () () () 6 () ()
> ~
i(. .., ~I: ::·1 J F Ot..'ERFI...OloJ
-Jt; •• -..-- •• -••• ---.-.-- ..... -•• -....-- ••.•---..
~:
CHK INSTRUCTION
1 Role of CHK
The CHK instruction compares the 16 low order bits of a
data register with a bounded value.
By definition, the lower bound is zero and the upper
bound is a 16-bit number.
~----lssssssssssssss1ss~ Interval
~ ] TRAP
Figure 6.15
122 The 68000 Hardware and Software
2 Syntax of CUR
In assembler
CHK <ea>, On
In pseudo-code
IF On < L THEN
I TRAP CHK
ELSE
IF On > H THEN
, TRAP CHK
ELSE
I
Execution of next instruction
ENOIF
ENOIF
Application Exercises
1. Write in 68000 assembly language a program to search
for a value called entry in a table. If this entry
($OOOF for our example) is not found in the table
arbitrarily fixed at five words - the program will need
to be rerouted into the TRAP CHK, with the aim of
displaying the message "Value not found in table". On
the other hand, if the entry is present, the system
returns to the control of the monitor.
The algorithm used to search for the entry will need
to be established in pseudo-code and the program
written in position independent code.
Suggested solution
*Pseudo-code
/*STACK INITIALISATION*/
/*VECTOR CHK INITIALISATION*/
/*TABLE ADDRESS INITIALISATION*/
NUMBER : = 5
READ 1 VALUE IN TABLE
IF VALUE <> ENTRY THEN
NUMBER : = NUMBER - 1
IF NUMBER <> -1 THEN
, REPEAT
ELSE
68000 Instruction Set 123
I/*RETURN MONITOR*/
ENDIF
Listing 6.9
20
************************'********************'************************
** SEARCH A TABLE OF 5 WORDS FOR SPECIFIC OPERAND (#$DDOF) *
30
40
50 * IF NOT FOUND THEN "TRAP CHK" *
60 * THE PROGRAM IS WRITTEN IN A "RORG" SECTION *
70 * *
80
*****'*'***'*********************'****************'*******************
'100 oo01E178 OUTMES EQU ; SUBROUTINE PRINT STRING OF CHARS
'1'10 00000018 VECTORCHK EQU ; ADDRESS VECTOR TRAP CHI<
120 00000005 NUMBER EQU ; SIZE TABLE
Simulation
'*
;~O:]f.:'.l·1
.)f OO~?():36 0000
-:tf ()()~?O~3B 6666
* O()~~f)::3f~ EHlElH
* OO~?()]C () nDn
:* O():~?O::3E 999~.)
.:11: OO~?040 > OOOF
* ()() ~? 0 I.. :~?
;'>OO();!3 THE OPER(-\ND IS NOT FOUND IN TABLE !!!
?O::-::o!:•• lol
.:11: O()~?()3,:':, 0000
:11: O()~?O:3B (it!.·;.b6
)(0 ()()~?()~3~~ BBHB
.:. ()0 :-:? () ::3C EEEE
':'(0 ()()~-?()]E OOOf~
:.. OO~?()40
;.~OO(); (oJ
:> ~
*
i(.
CORF~ECT
_._- •. '.00.00_.,_,
Listing 6.10
20
************************************************'*'**'*'*'***'*'**************
30
*
40 * EXCEPTION: CHK INSTRUCTION
*
50
'*' -I NI =<: NUMBER =<: +INI '*'
60
*
70
*' *
80
***********************************************************************
-100 ooo1E'178 OUTMES EQU ; MONITOR SUBROUTINE PRINT CHAR
1'10 00000018 VECTORCHK EQU VECTOR TRAP CHK
260 * ----------[--------]----------
270 * L=-$2000 NUMBER H=$'1000
280 i
290 002028 41B82048 CHK H,DO IF DO < -$2000 THEN
300 00202C 0078204A AOO.W L,OO ~ i* TRAP CHK *i
310 002030 4E41 TRAP #·1 ELSE IF DO> $·1000 THEN
320 002032 0000 DC.W 0 ~ 1* TRAP CHK */
ENOIF
330
340
* ENDIF
*
350
3bO 00002034
*
TRAPCHK EQU *
370 002034 48E7FFFE MOVEM.L 00-07/AO-Ab,-(SP) ; SAVE ALTERED REGISTERS
380 002038 4·1F8204E LEA.L TEXT,AD ; AD:= a TEXT
390 00203C 4E89OOO1E178 JSR OUTMES
400 002042 4COF7FFF MOVEM.L (SP)+,OO-(J7 iAO-Ab ; RESTORE REGISTERS
410 002046 4E73 RTE
** RESERVE
420
430
440 * -------
450 002048 000ססoo2 H DS.W : ADDRESS LIMIT H
460 00204A 00000002 L DS.W ; ADDRESS LIMIT L
470 00204C 00000002 NUMBER DS.W ; NUMBER FOR CONTROL
Simulation
..
11: ~?O'1C .u ::: NUi'1BEr~ FOI~ CONlf.-~OI..
~!()"C .loJ
* OO:-:?O'tC ·1000
* OO:-:?04E
:> ~~OOO; Ci
-!(
;,~Oi",C Ilil
* O() ~-:?O 4C ) ·10()-1
* on~-:~()'tE >
;~()OO; G
Tr~AP CHI(
126 The 68000 Hardware and Software
..'*
:.
;?()'1C • ~.J
00:20 -c ) E O()C)
* OO:;?Ol.tE
> '*
~~OO() ;G
~.
204C.W
* ()()20'tC DFFF
* ()O~~()4E
>
>
*
;.~()O(); (.)
TRAP CI-II(
*
*
;~()LtC • W
* O()~~?()4C FFFF
* O{)~~04E >
~~ OOCl; (~
MOVEM INSTRUCTION
I Role of MOVEM
The different versions of the MOVEM instruction
transfer, according to a predetermined order, a list of
address and/or data registers to or from a block of
memory.
The second word of the instruction (the first always
being the op-code) is established from a l6-bit order
table, in which each register occupies one bit, so that
any combination of the 16 registers can be specified by
the instruction.
2 Syntax of MOVEM
Whatever type of transfer is involved, whether
registers to memory or memory to registers, the size
specified by the instruction is word, which is the
default size, or long word.
MOVEM.W Al/A5/D2/D4,$1000
Memory
15
Me 68000
~o
1(J~~ 02 - 15 0
--...
~ 02 I
1_t>~2 04 .- 15 0
nA I
1t>04 A1 ,. 15 0
A1 I
A5 15 0
1~;8 ~ A5 I
1f)f)A
~
Order table
Increasing addresses
<
Figure 6.16 MOVEM.W A1/A5/D2/D4,$lOOO
Memory
31
o 68000
SP
after ~
execution
t-----... ~
SP
before
execution
Order table
Memory to registers transfer only
<----------------
Figure 6.17 MOVEM.L AO-A2/DO-D2,-(SP)
Listing 6.11
20 **********************************************************************
30
40 USE IN~;TRUCTI0N
50
60 **********************************************************************
80
90 * COpy N BYTES FROM ONE LOCATION TO ANOTHER LET L (LENGTH) BE
"100 * 2048 (2 K BYTES)
1·10 * EXEMPLE: 2048/32=64 LOOPS
120 it' -------
·130 *
·140 * AD =POINTS TO THE SOURCE BLOCK
·150 * Al =POINTS TO THE DESTINATION BLOCK
'160 * DO =NUMBER OF 32 BYTES TO MOVE
·170
·180 00002000
* RORG $2000
MOVEM.L (SP)+,DO-D7/AO-A6
Memory Me 68000
31 ~~
»31 0
SP
before ~ 00
~ Of)
execution 01
01
02
02
1
03 03
04 04
Increasing 05
05 addresses
06 06
07 07
31 0
A0 A0
A1 A1
A2 A2
A3 A3
A4 'f
--
A4
A5
--- .....,
AS
SP A6
--
A6
after ......
~
execution
SPI I
Increasing addresses
<------------------4
MOVEP INSTRUCTION
2 Role of MOVEP
The MOVEP instruction allows one to prcgram the 8-bit
peripheral circuits of the MC 6800 (PIA 6821, PTM 6840)
or MC 68000 (PI/T 68230) via the lower line (DO-D7) if
the peripheral address is odd, or via the upper line
(D8-DlS) if the address is even.
3 Syntax of MOVEP
In assembler
4 Programming Examples
VPA~-----
A3-A23
68000
Even Odd
addresses addresses
15
0
>< DORA
ORA $ 1DFF1
>< $ 1DFF3
Program *Equivalences*
*Program*
Using MOVEP
Program *Equivalence*
Programming Exercise
Let us suppose that we want to write in 68000 source
language the initialisation program of N peripheral PIA
6821 circuits. The operands (32 bits) belonging to each
peripheral circuit are stored in a table, whose begin
address is MEMTABLE.
Even Odd
addresses addresses
~ Peripheral
PIA@
~----+------·n
MEMTABLE ~
• Set memory of
® 6821 peripherals
*Table of
operand storage
Figure 6.21
Program
MOVEQ # N,DO Initialisation of number
of peripherals
LEA MEMTABLE,AO Loading AO with
MEMTABLE address
LEA PERIPHERAL,Al Loading Al with
peripheral address
BRA IN Adjustment of
primitive DBF
68000 Instruction Set 133
Method of Operation
Stack
1111
Figure 6.22
UNLK An
Method of Operation
31 0
FP ® Stack
~SP
Figure 6.23
Example
Reserving an area of memory between the main program
and the stack pointer
Increasing
addresses
31 0
SP (A7) I 0000 2000 I~
FP (A6) I I ~ J-------e
I-----~
0000 2002
Workspace
15
o
Reserved
Reserved
31 0
New FP (A6) I 0000 1 FFC I~ 0000
t--------4
2002
PC high
PC low
Reserved
Reserved
I
FP (A6) 0000 1 FFC I ~ ...--------4
0000
2002
Figure 6.25
68000 Instruction Set 137
PC high
PC low
SP
after I 0000 1 FF8 I ~ Reserved 31 16 15 0
FP I
(A6) .. 0000 1 FFA ,
after I~ 1st number -------- ~~~~~~]1st numberl 05
F'P (A6) L_Q.C!.02_!.!:.':9_J ~ -0000 MOVE.W 05, -(A6)
before 2002
Figure 6.26
16
o
PC high
PC low
2nd number
BCD
1st number
BCD
0000
2002
Figure 6.27
138 The 68000 Hardware and Software
FP (A6) ~1 . ~ 31 0
before L_~_!_~E~__ J ~n------~----t
2nd number
BCD ~ 1- 0000 1 FF8 ISP
FP (A6) I 0000 1 FFA I ~ 1st number
BCD
after u--;;...;;;"o;.......--..
0000
2002
unaffected
Figure 6.28
15
o
2nd number
BCD
1st number
BCD
0000
2002
31
Figure 6.29
E
FP
i
31 0
0000 1 FFC ~ 0000
--~ 0000 L2002 IFP (A6)
CP-.------------. 2002
t------f After instruction
• 00001 FFC :
... _------------~
SP
CD
31 0
I 0000 2000 I
SP
After instruction
Figure 6.30
,otiedulre 8
I}/
~~/--....
§o/ \
~O/
(j~,/;:- /
;/ s
., 1
LINK SP # d1~ t: JSR
LEA src, SP
LEAsrc, FP
I~I Procedure B
I
I
I 8 / ATE
I
I ~ / @
I ~ I
I
I ~
&. I
Return I
I I g
Interru~ I .~
I I ~
g'"
~I
I
I
I
\
Re't\'S
"
~.:<.<::-
I I ,
I
I I I
I
I
I I
I U~LK /
I RTS /
I
I @
JMP return
Figure 6'.31
140 The 68000 Hardware and Software
15
0
SP~
Memory block \
allocated to
program (C)
FP~ MSB of FP
LSB of FP
( LINK FP, # d16
~
Address of return
JSR Procedure 8
to program (C)
Status J
PC high Save on
interrupt
PC low
Memory block
allocated to J
program (A)
t LINK FP, #d16
MSB of FP
LSB of FP )
Address of return
to program (A) ~ JS R Procedure B
SP~
FP~
Figure 6.32
Listing 6.12
30
***************************************..*....********..****..******..***..****
40 * ..
50 * USE 0 F ilL INK and U N L K INS T RUe T ION S * I!
60
70
*
80 ******************************************************************'*******
UNSIGNED DIVISION:
90 *' ------------------
'100 * THE SIMPLEST BINARY DIVISION ALGORITHM IS ALSO BASED ON THE TECHNIQUE
"1'10 * WE LEARNED IN GRAMMAR SCHOOL.
'i20
'130 ** DIVISION: 64/32 = 32 BITS REMAINDER
'140 * = 32 BITS QUOTIENT
150 * ALGORITHM PSEUDOCODE
II II
"160 * =====================
"170
'180 * PROCEDURE DIVISION 64 BITS
'190 * I
4'10 * i I
500
*' COUNTER:=COUNTER-'l
*' I
ENODO
510
520
*'*' I ,
530
540
* I REMAINDER :=OO.L
QUOTIENT :=(il.L
550 *' ~
560 *~ ENOIF
570 *' ENDPROCEOLIRE
580
*'
600 ..
6'10 *' MACRO
620 .. -----
630 SHIFT64 MACRO
640 \!i LSL.L #'1, \1
650 ROXL.L 1H.\2
660 ENDM
b70
680 **' IN£iEX TABLE
690 * -----------
700
7'10 00000000
*
OLOFP EQU o .OLD FRAME POINTER
720 FFFFFFFE COUNTER EQU OLDFP-2 : COUNTER
730 00000008 OVSR EQU OLOFP+8 .OIVISOR <INPUT)
740 OOOOOOOC MSBDVD EQU OlDFP+'12 :MSa DIVIDEND <INPUT)
750 000000'10 LSBOVD EQU OLOFP+'16 ;LSB DIVIOEND €.INPUT)
760 00000018 STATUS EQU OLDFP+24 ; STATUS
770 OOOOOO"lA REMD EQU OLDFP+26 ; REMAINDER t.OUTPUT.i
780 OOOOOO'lE QUOT EQlI OL[fP+30 ;QUOTIENT (OUTPUI i
790 000"1E'178 OUTMES EQU $'1E'178 : OUTPUi STRING OF CHARS
8'10
820 *' D'1.L = LSB DIVIDEND
830 * DO.L = MSB DIVIDEND
840 * M.L = FRAME POINTER
850 *' A7.L = STACK POINTER
860
Simulation
i1:
> *- S I ~~ UL.. ~~\ T ION () I I...J I ~:; I ON
*- ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:> '*
) ~. L :::: MSB [) P)IDEND
?OB~:,.
'> '* .L::: LSB DJ:I..JIDEND
;!.Oe~E
:,; 2 09~.~. l..:::: 0 I I) I ~:;Ol~~
* ;'>096. L:::: QUOT TENT
~li: 20':';'(.\. l..::: F~ Et'1{1l:N()EI~~
~;
>- ~:.
.i.
~'>OB~~
:-.. 0020B1-":j 00000000
:'tf ()O~?OBE FFFFFFFF
* ()()~?()9~~~ O()O()OOO~~
* ()():~?()96 ClOOOOOOO
:rf O()~~?()9f; o (lO()OI]OO
:~ ()()~?()9E
> ~.~OOO; G
> ~.
> i1: [) I f.)PI..~~ y R E~~UI... T
'* .
*
P RNT.1.. BEG> ;,iOB(.\ END> ;?09A
* O()~?()BO O(l100FFe oononoi I] .ttE7~)()O()() O()()OFFFF
.-:. O()~~()9() FFFFO()()() O()()~.~7FFF FFFFOOOO OO()'10(-\(l[)
> ~.
~. 0 I '..JI S ION B Y () !!
it: :::::::::::::::::::::::::::::::::::::::::::::::::::::::::
i1:.
;.>OH(-\.l..
.:et- O()~?()B{~ 00000000
·)fo ()()~?()BE A t'::\I~~\~~'I~~\(.I~:\{.'
* O()~-~()O:;~:;? ) 00000000
:* ()O~.~09I,S
> ;.~OO(); G
DIVISION BY 0 OR QUOTIENT TOO BIG !!
'*
.;:.
'* QUOTlENT TOO BIG !!
*- :::::::::::::::::::::::::::::::::::::::::::::::r~ :::
;~OHA .t.
:If- O()~?08~~ '1 0000000
* ()()~~OBE OOOO()()()O
~~ (J o:~~ ()<? ~~ oOOO()()();.~
* (){):~~()(?6
> ;?OOO; G
DIVISION BY 0 or~ QUOTIENT TOO BIG ,!
68000 Instruction Set 145
*
*.
?OB(.l.L
OO~~()8~~ o()00 000 ..,
OO;":~()(3[ ()00()0 00 o
O():~~()9:;~ OO()OO()O~.~
* O()~~O~?I,S
;~OOO:: C";
Pf·~NT .1.. BEG) ~,~OBA END >~?091~~\
* ()()~~?OBO DO" ODFFe O()()()()O·, () 4El~)O()O() 000" 0000
.-: O()~.)OC)() OO()()(J()()O O()O?B()()() O(l()()()()()() O()()()()AOl)
-9:
Definition
When several processors (hard or soft) use one and the
same resource (printer, working memory, etc), we shall
speak of a shareable resource. It is vital, in order to
ensure synchronisation between the processors and the
resource, to assign a semaphore register (register or
memory byte) to the resource. (For example, the
peripheral circuit 6809/68000 IPC MC 68121 has six
semaphore registers.)
A semaphore register is made up of one or more flags
allocated to the same resource which inform the
programmer about the availability of the resource (SEM
bit) and about the arbitration between several
processors (bit ownership in the case of the Me 68121).
Generally, when the SEM bit is at 1 it indicates
that the resource assigned to this semaphore is
occupied, while SEM bit at 0 shows that it is
available.
Method of Operation
The method of operation is very simple. If in a
multiprocessor environment a particular processor
wishes to use a shareable resource, it must first
establish that it is free, by reading the semaphore
register; it then modifies the SEM bit to reserve the
resource for itself (that is, if it is available) and
writes the SEM bit in the semaphore register.
When the processor has finished using the resource,
it makes it available again by resetting the SEM bit to
o.
Example
Two processors, PI and P2, share the same resource (a
peripheral connected to a printer) within a multi-
processor system.
146 The 68000 Hardware and Software
Processor Pl Processor P2
Read
Yes Yes
~
t
Write
SEMbit--.
Semaphore register
Figure 6.33
(Note that in the case of the TAS instruction branch
Ll, L2 does not exist. If the resource is occupied
(SEM = 1) the processor continues with the program.)
3 Syntax of TAS
In assembler
TAS dst
Instruction
mnemonic ---------------
t , Oestination
address
Question
What is the difference between the instruction BSET
#7,dst and the instruction TAS dst?
Answer
These two instructions require the CPU to read the
destination (memory byte), modify its value and write a
1 in bit 7 of the destination.
However, instruction TAS dst must be used if two
processors share the same resource (dst represents the
semaphore of the resource). During execution of
148 The 68000 Hardware and Software
Yes
Indivisible
cycle
SEM: = 1
IF dst = 0 THEN
z := 1
I
ELSE
N := 0
IF SEM = 0
N .= 0
ELSE
N .= 1
ENDIF
ENDIF
Figure 6.34
68000 Instruction Set 149
50 51 52 53 54 55 56 57 58 59510511 512513514S15S16S17S18S19
CLK
A1·A23
AS
---\
\_------------------
/ --- \_---
,-
UDS or LDS
R/W
OTACIe \ /,---------..,.,
\
,-
D8-D5
-i-s-« ) ( }-
Or DO-D7
I=CO·2 =x x:
~---- --------- Indivisible cycle ----------~
Time
68000 68000
L
Semaphore
Shareable memory
Figure 6.36 Synchronisation of two 68000 processors
sharing one memory
7 Programming Exercises
1 EXCEPTIONS
HARDWARE USED
540
*' *'
550 * *========================================
560
* *
570 * * (lORA DORB
I eRA CRB
580 * *' OR OR
590 '* * ORA I ORB
600 * *
610
630
* ******'**'******'*******'************'*'*******
640 ** INITIALISE PIA 682"1
650 '* -------------------
660 *
670 00202C 40F90001DEOl LEA. L ADDRFIA. A6 ;INITIALISE ADDRESS PIA
b80 002032 223CFFFFOS04 MOVE. L t$FFFFOS04. [;"1 ;A s B SIDE ALL OUTPUTS
690 002038 03CEOOOO MOVEP.L (j'LOfA6) ~ INTERRUPT CAUSED BY CAl
700 00203(: 46FC2100 MOVE. w #$2'1 DO ~ SR ;ENABLE INTERRUPTS
7"10
720 002040 323C8000
*LOOP MOVE. w #$8000. [:'1
730 002044 038Eoooo LOOP'1 MOVEP.W O-LtVA6 i ;WRI TE ORA and ORB
740 002048 6-1000088 BSR DELAY
750 00204C E2SQ ROR.W .-1,0'1 ; ROTAiE RIGHT
"760 00204E 64F" BCC.S LOOP-!
780 ..
790 *'* ENABLE TPACE MODE (.T:=l) .LOAD STATUS REGISTER AND STOP
800 * -------------------------------------------------------
fHO '* A TRACE EXCEPTION WILL OCCUR IF THE TRACE STATE ]S ON WHEN THE STOP
820 '* INSTRUCTION IS EXECUTED.
152 The 68000 Hardware and Software
960 I
970 ff PROGRAM EXCEPTION CAUSEn BY LEVEL 2 INTERRUPT (CA1 OF PIA (821)
980 * ==============================================================
1160
'1·170
*
1* PROGRAM EXCEPTION CAUSED BY SPURIOUS INTERRUPT
1180 * ===========================================
"1'190 I IF DURING THE INTERRUPT ACKNOWLEDGE CYCLE ,THE PIA NO OEVICES
1200 I RESPOND BY ASSERTING VPA, THE PROCESSOR 68000 FETCHES THE SPURIOUS
1210 I INTERRUPT VECTOR.
1;'JqO
1300
**1 TRACE MOOE CAUSED IF THE T BIT IS ASSERTED AT THE BEGINNING OF THE
13"10 * =================================================================:
1320 * EXECUTION OF AN INSTRUCTION.
'1330 * ============================
Programming Exercises 153
14'10
1420
*** BUS ERROR CAUSED BY "HARDWARE PROBLEMS"
1430 * ======================================
1620
1630
**f DELAY
'1640 * =====
-1 bbO 002002 3F04 OELAY MOVE.W D4,-(SP)
1670 002004 383C61A8 MOVE.W i25000~D4
1680 oo20D8 51CCFFFE DELAY"! OBRA D4, DELAVl
-1690 0020DC 38-1F MOVE.W (SP"i+. [;4
1700 0020DE 4E75 RTS
Example
LEA.L HARDERROR,A6 loads register A6 with the address
indicated by HARDERROR ($20BO) while the storing of the
contents of A6 in the BUSERROR address is ensured by
the instruction MOVE.L A6,BUSERROR. The label BUSERROR
has been previously defined in the list of
equivalences, being the address resulting from the
following multiplication
2*4 $8
Statement of algorithm
BEGIN
FOR Dl altering from $8000 to $0000 by right shift 1
PIA := Dl
/*Under / DELAY PROGRAM*/
D4 : = 25000
REPEAT
I D4: = D4 - 1
UNTIL D4 = 0
ENDFOR
END
l.EVEL. 7 INlERr~lJPT
L.EVEL 7 rNTE'~RLJPT
I. El"JFl. 7 JNTE'~I~LJPl'
LEI..IEl 7 INTERRUPT
TI~ACE
L.E'VE L. '1 I NT E I~ R UP T ( P 1: A C{~'1 )
L.EVEL ? INTERRUPT
l.El,IEt. r INTERI~UPl
l.EVEl. '1 INTER'~UPT (PIA CA'" )
LEVEl.
LEVEL 7 INTERRUPT
'1 INTERI~UPT (p tA CA")
LEVEL. 7 INlERr~UPT
Programming Exercises 157
LEVEL 7 INTERRUPT
l.EVEL 7 INTERRUPT
LEVEL 7 INTERI?UPT
LEVEl... 7 INTEI~RUPT
LEVEL 7 INTERRUPT
LEVEl... 7 INTERRUPT
158 The 68000 Hardware and Software
SPURIOUS INTERRUPT
SPUI~ rous INTERRUPT
~~PUR rous INTERRUPT
~~PUI~ IOUS INTEI~I~UP T
Programming Exercises 159
Stack
15
o
PC high $ 225A
PC low $ 225C
SPbefore~ $ 225E
Figure 7.1
LEVEL 7 INTERRUPT
TRACE MODE •• TRACE MODE .•
TRACE MOOE .• TRACE MODE ..
Deselection of PIA card
* VSTP PC= 0020BO " 48E7 8=0 S 000
) *
*
;.~ zso 0 ~~B~';'-' Super status word
> 000'-'-·
(){)~~2~'5~,:~
> ()O~?~~~:;I, [)[-:O'1-- address on bus
> OO~?:;~!)6 03BE-- instruction code
> OO;.~~~58 ;~()()O··' status register (SR)
> r){):,:~2~'5t:' oooo- contents of program counter (PC)
()o~? ~~ ~'; C ;?() I, l, ...
> {)()::Z~?!5E 4'100-·
,..
~- AFT[I~ I NSlRUCTION: MOVEM. L [)O--[)71(-\O·-A~) '1-- (BP)
.... ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
~
~! ()C~.~ ; I.•'
;p
BUS ERROR•••• BUS Er~ROR ••••
* VSTP PC:: OO:,:?()C~~ .. '.7FA S:::D B ()OD C:: •• Z.. BP:: ()()O{)2~~~"5()
DO::: ()OO()()()()() [)'l::: FFFFO()8() O~?::: O()()()()()()() [):~::: ()()()()()()()()
D4= (JO()()()()OO D~)::: O()()()f)()()O D(S== ()(){)()()()()() D7:: ()()O()(X)()()
(o,()::: ()()()()O()()() A'1::: ()()()()()()(l(l A~,~::: ()()()()(l()()() A:~= ()()()()()()()()
A4= O()()()()O(){) AS::: ()()()()()l)()() A6::: ()(){)'1 DE()'I A7 = O()()(){)!.>()()
> ~
i(-* AFTER INSTRUCTION l.E(".l.. RETURN 'I A:·)
'* :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
)
*/
~:. TR~~C PC::: ()()~~(}CA n ',E)~j:~ 8::::0 S ClO() C::: •• Z. • SP::: O()()()~.~~~~jE
DO::: O()()O()(){)() D":: FFFF()OBO D~~::: O{)O()(){)()O D3== ()()(){)OO()()
[).i,:: O()OOOO()() ()~)::: O()()()OO()O Db::: OO()()()()()() D7::: OO()()()()OO
AO::: O{)()f){)()()() A'1::: OO()()()()()O A2::: ()()()()(){){)() A~3::: ()D{)O~?OOO
~~",::: OOOOO(JOO At;::: O()()()()()()() At,::: ()()()'1DE()'1 A7::: O()()()()60()
*- ::::::::::::::::::::::::::::::::::::::::::::::::::::::
RAe
" 4FEF
~:. PC::: ()O~?OCC 8:::() C'
",) OO() c:;: . . l .. sp:::: ()()()()~~~~~;A
DO::: ()l)()()()()()() D'I:::: FFFFOO8() D~~::: ()(){)()()O()O 1)~3:: OO{)()O()()()
[)/t::: OO()()()()()() O~:;:: ()()()()()()OO D6::: (}O()()O()()() D7:: O()()()()()OO
AD::: ()O{){)(){)O() A"I= OOO()()()()() A2::: ()(){)O()()()() A:3:: 0000:-2000
A4= O()()(}()O(}() A~5= ()()()()()()()() A6:: O()()'1D[O'1 A7== ()O()()()~)OO
162 The 68000 Hardware and Software
'*
> * AFTER I NST RUCT J: ON :: P [f" (~~:~ )
~. :::::::::::::::::::::::::::::::::::::::::::::::::::::
> *
> '*
) '*
> /
~l: TR AC P C::: O()~~ODO tt 'tE7:~ S:::O S OOC) C::: •• Z. • SP::: ()()()()2~~~5B
DO::: O()()OOOOO I)"':: FFFF()()BO D~~::: ()O()OO()()O D3= O()()OOOOO
[).It : : OOO()OOO() [)~)::: ()()()()()()(lO D6:::: O()()()OO()O D7:::: O()()O()()()O
A()::: O()()Of.)()()O A'1::: ()OO{)O{){)() A:~~::: O()OO{)OOO A~3::: O()OO~~O()()
~~l,(;:: O()()()(l()(lO A~:'::: OO()()OO()(l A6::: OOO'1DEO'1 A7:::: ()()O()()6()O
30 ****************************************************************+*****
**' **
40
50 MEMORY TEST
60
70
*
*
80 * WRITTEN BY PATRICK JAULENT : MAY '1984
90 *' COPYRIGHT:,.,l CROPROCESS
100 *'
1"10 ******************+*********'***************'***************************
** ALGORITHM: THE PROGRAM IS COMPOSED OF S MOOULES THERE ARE:
'120
-130 I
'140 * =========
**' -1- TEST : WRITING AT THE SELECTED ADDRESS : THE OPERAND $00000000
"150
'160
170 * AND RE-READING. IF THE RE-READING [tOES NOT CORRESPOND
"180 * TO THE wRITING THEN "ERROR 1 11
•
190
200 ** -2- TEST : WALKING 1: wRITING AT THE SELECTED ADDRESS THE OPERAND
2'10 .. $80 TO THE OPERAND $00 BY ROTATING ON PLACE TO THE RIGHT.
220 *' IF THERE' 5 A FAILURE THEN ;1 ERROR 2 ",
230
*
Programming Exercises 163
240 * -3- TEST : WRITING AT THE SELECTED ADDRESS THE OPERAND SFFFFFFFF
250 * THERE ARE 2 SEQUENCES:
2bO
270
*
280
* -'1- VERIFICATION IF THE REAOING CORRESPONDS TO
290
*
I
THE WRITING,IF THERE IS A FAILURE, THEN "ERROR 3".
340 * -4- TEST: WALKING 0: WRITING AT THE SELECTED ADORESS THE OPERAND
350 I $7F TO THE OPERAND $00 BY ROTATING ON PLACE THE RIGHT.
360 * IF THERE IS A FAILURE THEN " ERROR 5 ".
370
380
*
I -5- TEST : THE LAST TEST USES THE SOFTWARE FEATURES OF THE
390 I lITAS" INSTRUCTION.
400 I DESCRIPTION:
4-10 * -----------
4~1i
430
* TEST AND SET THE BYTE OPERAND AODRESSED BY THE
* EFFECTIVE AOORESS FIELD. THE OPERATION IS
440
450
*
I
INDI VISIBLE.
6bO
670
*
*1 EQUATES
b8D
690
* -------
START ;AOORESS PROGRAM COUNTER
0ססoo004 EQU '1*4
700 ס0ooooo8 BUSERROR EQU 2*4 ;BUS ERROR VECTOR
1'10 OOOOOOOC AOOERROR EQU 3*4 ;ADDRESS ERROR VECTOR
720 0ססoo018 TRAPCHEK EQU 6*4 ; CHK INSTRUCTION
730 o00ooo60 SPURIOUS EQU 24*4 ;SPURIOUS INTERRUPT
740 00ססoo64 IRQACIA EQU 25*4 ;LEVEL 1 INTERRUPT AUTOVECTOR
750 00OOOO7C ABORTIT EQlI 3"1*4 ;LEVEL 7 INTERRUPT AUTOVECTOR
760 00O"lF9E9 A[)ORACIA EQU $"1F9E9 ;AOORES5 ACIA .~850
860
870
*** THE SYSTEM IS IN SUPERVISOR MOOE
880 ** IF THE SYSTEM IS IN USER MOOE THEN WRITE:
890
900
** LEA. L BEGIN, AD
9'10
**
H MOVE.L AO,$80 (TRAP #0)
TRAP 10
920
** OC.W 0
930
940
**
*
960 *
970 ** INITIALISE STACK POINTER (SSP) AN[) EXCEPTION VECTOR
980 '* =====================================================
990 00002000 RORG $2000 ;P.1. C PROGRAM
** CONTROL REGISTER = 95
-1790
1800 1* ENABLE INTERRUPT GET CHARACTER *1
"18"10
1820 0020BA 1ABCOO95
*INITIRQ MOVE.B 1$95,(AS)
'1830 OO2OBE 4E75 RTS
1850
1860
*i* GET 5TART AND END A[)[)RESSES KEYBOARD
1870 * =====================================
2070 *
2080 ** TEST -1 : WRI TE $00000000 AND READ IF ADORESS EQUALS $00000000
2090 *' ======================================================
2'100
2-1-10 ** MODIFIES REGISTERS: 0 -1 2 3 4 5 t. 7
2'120 * ------------------(1
2130 I A* *
2-140
2160 OO2OEC 48E700CO TEST'1 HOVEM.L AD-At, -(A7) ;SAVE AlTERED REGISTERS
2'170 0020fO 7C01 MOVEQ #'1,06 ; IDENTIFIER MOOULE -I
2-180 002Of2 B3CA LOOPTl CMPA.L A2,A1 ;00 WHILE A'I =< A2
2-190 0020F4 62'12 BHI.S ENOl1 ;'
2200 002OF6 429'1 CLR.L (A-I) ; ~ MEM[Al]: =$00000000
2210 002OF8 4A9'l TST.L (A-1) ; ~ IF MEM[A1] <) $00000000 THEN
2220 0020FA 6708 BEQ.S OKTST-l ; ~ ~ If: AO.L:= a TEXT ERROR-1 *1
2230 0020FC 41FA037-1 LEA. L ERRORl ,AD • ~ ~ II PRINT STRING-! Ii
2240 002100 61000144 BSR FAILURE ,.
.1 I
2300 I
23-10 It TEST 2 : WALK ING ·1
2320 I =================
2330 I MODIFIES REGISTERS: 0 "1 2345 b7
2340 I ------------------(J *
2350 * AI
2300 * AO.l:= ADDRESS TEXT STRING2 INPUT PARAMETER PASSED
2370 * 02.B:=$80 INPUT PARAMETER PASSE[)
2380 I
2480 I
2490 1* TEST 3 :WRITE fFFFFFFFF AND READ
2500 * ===========================
2510 I MOOIFIES REGISTERS: 0 -1 2 3 4 5 b 7
~'520 * ------------------0
2530 I A**
2540
*
Programming Exercises 167
2820
2830
*
*1 TEST 4 : WALKING D
2840 * =================
2850 I
2860 I MODIFIES REGISTERS: 0 1 2 3 4 5 b 7
2870 I ---------------- 0 *
2880 I A*
2890
2900 I
* AO.L:= ADDRESS TEXT STRING4,INPUT PARAMETER PASSED
29'10 I 02.B:= 57F INPUT PARAMETER PASSEO
2920
*
2940 002162 48£72080 TEST4 HOVEM.L D2/AO,-(A7) ,SAVE ALTERED REGISTERS
2950 002160 E3CE LSl...B 11,D6 ;INDENTIFIER MOOllE 4
2960 002168 41FA03E2 LEA L
I ERROR4 ,AD ;AD. L:= ADDRESS TEXT ERROR 4
2970 00216C 747F MOVEQ 1$7F, D2 ; D2. B:=011 "l"U "1'1
2980 oo216E 612E BSR.S WALK ; CALLING SUBROUTINE WALK
2990 002170 4COF0104 MOVEH.L (A7)+,D2/AO ;RESTORE REGISTERS
3000 002174 4E75 RTS
30'10
3020
*
II TEST 5 : READ/WRITE (QUICK)
3030 I ========================
3040 I
3050 I MODIFIES REGISTERS: 0 1 2 3 4 5 b 7
3060 * ------------------0
3070 * AI *
3080 I
3340
** 02.8:=$80 ,AOIL:= ADDRESS TEXT ERROR2
3350 * OR
3360 * 02IB:=$7F ,AO. L:= ADDRESS TEXT ERROR4
3370
*
3390 002'19E 48E7E8CO WALK MOVEM.L DO-D2/(i4/AO-Al,-(A7)
3400 0021A2 B3CA LWAlK CMPA.l A2,A'1 ;DO WHILE A-l=(A2
34-10 002-1M 622E BHI.S ENOW ;~
3420 002-1Ab 1811 MOVE.B (A'I) ,04 ; ~ SAVE HEM[A'1 J
3430 002-1 AB 7207 MOVEQ 18-1,D-I ; ~ 01.8:=07
3440 0021 AA '1282 LWALK-I HOVEIB D2, (A'1) : ~ FOR D2=N UNTIL 0 DO
3450 0021AC B4'1 '1 CMP.B (Al) ,02 ; ~ ~ MEM[AIJ :=D2.B
3460 0021 AE 67-1 A BEQIS OKTW ; ~ ~ IF HEM[A'! ] <::> [12 THEN
3470 0021 BO 2F08 HOVE.L AO,-(AT) ,..1 ~ SAVE AOIL
3480 oo21B2 61OO00DC BSR PDATA ,..1 ~ 1* PRINT TEXT ERROR *1
3490 0021B6 61000-140 BSR ADORTEST .1
~ 1* ADOR. TEST ODD/EVEN *
3500 0021 BA 204E HOVEIL A6,AO ,..1" ~ AO.l:= ADDR O[Jo/EVEN
35-10 002-1BC 6HlO0002 BSR PDATA .1
~ 1* PRINT ADDRESS *1
3520 OO21CO 2009 MOVE.L A'l,DO ,.".1 ~ 00:=00-07/08-[;15
3530 OO21C2 61000100 BSR OUTHEX .1 I
~ 1* PRINT DO.L *1
3540 002'1 C6 6l-12 BSR.S DELAY ,-".1 ! 1* OISPLAY DELAY *1
3550 002-1 C8 205F MOVE.L (A7)+,AO ,..1 ~ RESTORE AO.l
35bO .1 ~ ENDIF
3640
3650
*** DELAY FOR DISPLAYING
3660 * ==================
** MODIFIES REGISTERS: 0 -1
3670
3b8D 234567
3690 * ------------------[) * *
3700 * A
37"10
*
Programming Exercises 169
4030 *
4040 ** GET ONE HEX CHARACTER
4050 * ========================
4060 * IF 0-9 OR A-F THEN CONVERTED BCD OTHERWISE [J2. B:=$80 AND RETURN
4070 *
4090 00220E 610000A4 INMEX BSR INPUT-I ;GET ON HEX
4100 0022"12 61000094 BSR OUTCH1 ;ECHO
4110 0022"16 OCOOOOOO CMPI.B #CR,DO ; IF CHAR=CR THEN
4"120 0022'1 A 6606 BNE.S SUITEMEX
4-130 0022-1 C 08C2ooo7 BSET .B #7,D2 ; ~ [l2.B:=$80
4-140 002220 60-14 BRA.S ENDt'1EX ; ~ RETURN TO INAD[)
;ELSE
4'150
4160 002222 04000030
*SUITEMEX SUBI. B i'D' ,00 ; ~ ASCII-)BCD CONVERSION
4170 002226 47FAFFE6 LEA.L INMEX,A3 ;! A3:= a RETURN IF TRAP CHK
4"180 00222A 4"1BC0016 CHK #$-16,00 ; ~ IF CHAR <0 OR :>9 THEN
4"190 ; ~ ~ 1* TRAP CHK */
* ; ~ ENDIF
4200
42-10 oo222E OCOOOOO9
* CMPI.B #9,00 ; ~ IF CHAR) 9 THEN
4220 002232 bF02 BLE.S ENDMEX */
;! ~ / '* AJUST
4230 002234 5FOO SUBQ.B #7,00 ; ~ ENOIF
4240 002236 4£75 ENDMEX RTS
4260
4270
*** TRAP CHK
4280
* --------
4300 002238 7007 CHECK MOVEQ #BEL,DO ; BIP ~ ~
170 The 68000 Hardware and Software
4480
4490 II
* PRINT THE IILINE Il ADORESS ERROR
4500 * ==============================
45-10 I IF THERE IS A FAILURE ,THE SUBROUTINE EXECUTES AN "EXCLUSIVE OR" BETWEEN
4520 I THE TWO POINTERS (A4.L & A1.L). THE RESULT WILL BE A LOGICAL '1 IN EACH
4530 * BIT POSITION WHERE THERE WAS A FAILURE.
** MOOIFIES REGISTERS: 0 -1 2 3 4 5 6 7
4540
4550
4560 * ------------------0 * * * * *
4570 * A*
4580
*
4600 002250 48E74480 TEST3'l MOVEM.L [l-1/05iAO.-(A7) ;SAVE ALTERE[I REGISTERS
46-10 002254 2209 MOVE.L A1,0-1 ; D-I •L: = AOORESS ERROR
4620 002256 2Aoe MOVE.L A4,OS ; [15 •L: = ADDRESS ERROR
4630 002258 8385 EOR.L 0'1 ,OS ;D5.L(±)D-1.L :=OS.L
4640 00225A 41FA02CE LEA.L ERROR31 ,AD ;AO.L:= A[)DRESS TEXT ERROR
4650 00225E 6-130 BSR.S POATA ;PRINT TEXT
4660 002260 6106 BSR.S BINARYADOR •CALLING OUTPUT BINARY AOR
4670 002262 4C[lFO-122 MOVEM •L (A7) +, AD.I 0-11 [15 ; RESTORE REGISTERS
4680 002266 4E75 RTS
4690 I
4700 002268 48E7B400 BINARYADDR MOVEM.L DO/02-03!(i5.-(A7) ;SAVE ALTERED REGISTERS
47'10 00226C 7407 MOVEQ 18-'1. (12 •NUMBER NVBBLE
4720 oo226E 7603 RBIN-l MOVEQ #4-1•D3 :NUMBER BIT
4730 002270 610000CC BSR SPACE
4740 002274 103C0058 RBIN2 MOVE.B #f Xi .DO .DO.B:=$S8
4750 002278 E380 LSL. L #-1 •OS
4760 00227 A 6404 scc.s RBIN3 ; IF 81T=0 THEN
4770 00227C 103C0031 MOVE.B i!l! ,DO : ~ If : X' DISPLAYEli Ii
4780 002280 6126 RBIN3 BSR. S OUT CH"t : ELSE
4790 002282 5'1 CBFFFO OBRA [13. RBIN2 ; i l* : '1' DISPLAYED to
4800 002286 5'1 CAFFE6 [JBRA 02.RBIN-! ; ENDIF
48'10 00228A 4COF002D MOVEM.L (A7)+.DOi[J2-[J3iD5
4820 00228£ 4E75 RTS
4840
4850 ''*** PRINT TE~T STRING OF CHARACTERS
4860 I ==================================
4870
4880 '* MODIFIES REGISTERS: 0 '1 2 3 't s6 7
Programming Exercises 171
4890 * ------------------0 *
4900 * AI
5500
55'10
* TEST : ADDRESS ERROR
**
5520 * ====================
5530
5540
** IF ADDRESS ODD (UDS) THEN DATA BUS IS [;8-015
5550 * IF ADDRESS EVEN(LOS) THEN DATA BUS IS DO-D7
5560
5570
** MODIFIES REGISTERS: 0 '1 2 3 4 5 6 7
55BO * ------------------0 * * *
5590 * A
5600
*
5620 0022FB 4BE70000 AODRTEST MOVEM.l 00-D·I/D3~-(A7) ;SAVE AliEREO REGISTERS
5630 0022FC "100'1 MOVE. B (J-1 ,00 ;SAVE ERROR POSITION
5640 0022FE 2609 MOVE.L A-1, D3 ; 03.l: = ADDRESS ON ERROR
5650 002300 08030000 8TST.8 #0,03 ; IF ADDRESS EVEN THEN
5660 002304 6628 BNE.S ODD
5670 002306 5040 AODQ #8,DO ; ~ II ADJUSTMENT D8-(l'15 */
56BO 002308 OCOOOO09 CMPI.8 19,DO ; ~ IF DIGIT >=9 THEN
5690 00230C 6F20 BlE.S O[)[; ;~
5700 00230E 0400FFFA SUBI.B #-6,00 ;~ ~ II DECIMAL AJUST II
57"10 0023-12 "1600 MOVE.B 00,03 ;~ ~ 03.8:=00.8
5720 0023-14 7201 MOVEQ 12-'1 ,01 ;~ ~ 0-1. B:=-1
5730 002316 E9'1B EVEN ROL.B 14,03 ;~ ~ REPEAT
5740 0023-18 2003 MOVE.l 03,00 ;~ ~ OO.l:=D3.l
5750 0023"1A 0200000F ANOI.8 #SF, DO ;~ ~ MASQ MSB OIGIT
5760 0023"1E 06000030 AODLB #'0' ,DO ;~ ~ BCD-)ASCII CONVERSION
5770 002322 6'184 BSR.S OUTCH'! ;~ ~ OUTPUT DIGIT
5780 002324 5'1C9FFFO OBRA 0'1 , EVEN ; ~ ~ UNTIl [J-l =--1
5790 002328 4COFooOB EXITAOR MOVEM.l (A7)+,[l0-O-1/03 ; ~ ENDIF
5800 OO232C 4E75 RTS ;~
58-10 00232E 6"10E ODD BSR. S SPACE ;ElSE
5820 002330 0200000F ANDI.S #fF,DO ; ~ 1* OUTPUT SPACE *1
5830 002334 06000030 ADDLB #'0 ' ,DO ; ~ II MASQ MSB 01G1T *1
5840 002338 6"100FFbE BSR OUTCHl ; ~ 1* BC[l=)ASCII CONV *i
5850 00233C bOEA BRA.S EXITAOR ; ~ 1* OUTPUT DIGIT *
58bO
* ;ENDIF
5880
5890
*** PRINT SPACE
5900 * =========
59-10 I MODIFY REGISTER: 00
5920
*
5940 00233E 2FOO SPACE MOVE.l DO,-(ATi ;SAVE 00
5950 002340 7020 MOVEQ ISPC,DO
5960 002342 6"100FF64 BSR OUTCH-l
5970 002346 20-1F MOVE.L (A7)+,DO ;RESTORE DO
5980 002348 4E75 RTS
6'100
61"10
*** SPURIOUS INTERRUPT
6'120 * =================
6'130 *
6'140 00235 C 4'1 FA0320 SPURIOUSIRQ LEA.L TEXTSPURIOUS,AO
6150 002360 610OFF2E BSR PDATA
6'160 002364 4E13 RTE
6'180
6'190
* LEVEL 7 INTERRUPT
**
6200 * ================
62'10
*
6230 002366 41FA0344 LEVEL7IRQ LEA.L TEXTLEVEL7,AO
6240 oo236A 610OfF24 BSR PDATA
6250 oo236E 4E73 RTE
6270 .
6280 **
as ERROR AND ADDRESS ERROR PROCEDURE
6290 * ====================================
6300
63"10 ** CASE
6320
6330 I IF BUS ERROR OR ADDRESS
~ ERROR DURING TEST-l THEN EXECUTE TEST2
6340 I IF BUS ERROR OR ADDRESS
~ ERROR DURING TEST2 THEN EXECUTE TEST3
6350 * ! IF BUS ERROR OR AODRESS ERROR DURING TEST3 THEN EXECUTE TEST4
6360 .. ~ IF BUS ERROR OR ADORESS ERROR DURING TEST4 THEN EXECUTE TESTS
6370 .. ~ IF BUS ERROR OR ADDRESS ERROR DURING TESTS THEN END
6380 .. !
6390 .. OTHERWISE
6400 * ~ I" ERROR STOPPING 68000 MICROPROCESSOR II
64'10 .. I
6420 .. ENOCASE
6430
6440
*
6450 002370 4'1FA02B4
*ERRORBUS LEA.L TEXTBUS,AO
6460 002374 6100FF1A BSR POATA ;
6470 002378 202FOO02 MOVE.L 2(A7) ,DO ; RESTORE AODRESS ERROR
6480 00237C 610OFF46 BSR OUTHEX ; PRINT ADDRESS ERROR
6490 002380 6'100FE58 BSR DELAY ;DISPLAYED [JELAY
6500 002384 '1 C06 MOVE.B 06,06 ;REGISTER CCR POSITIONED
65'10 002386 6742 BEQ.S OTHERWISE ; ERROR STOPPED 68000
6520 002388 44C6 HOVE.B 06,CCR ;CCR:=06.B
6530 00238A 650C scs.s MODULE'! ;ERROR DURING TEST'!
6540 00238C 69'14 BVS.S MOOULE2 ;ERROR OURING TEST2
6550 oo238E 67"! C BEQ.S MODULE3 ;ERROR DURING TEST3
6560 002390 6B24 BMI.S MODULE4 ;ERROR DURING TEST4
6570 002392 602C BRA.S MODULES ;ERROR DURING TESTS
6580 002394 508F EXITBA AO[J.L 18,A7 ;NO GOOD BUT ~ ~ ~
6590 002396 4E73 RTE
6600 ..
6ifl0 002398 47FAFD74 MOOULE1 LEA. L TEST2, A3
6620 00239C 2F4BOOOA MOVE.L A3,10(A7) RETURN EXECUTE TEST 2
6630 0023AO 6OF2 BRA.S EXITBA
6640 ..
174 The 68000 Hardware and Software
** TEXTS
6850
6860
6870 * ====
6880
6890 002304 'IB
*AOORBEGIN DC. B $'lB,$45,$18,$b8
6900 002308 40 (lC.B 'MEMORY TESTS : (C) '1984 BY MICROPROCESS ,INC I
69-10 002405 1B nC.B ua, $69 ,LF,LF,LF,LF,CR
6920 00240C 50 DC.B I PRESS ANY KEY TO STOP PROGRAM .'
6930 00242D OA [lC.B LF,LF,LF,CR
6940 002431 20 DC.B BEG AOORESS ----:> '
6950 00244E 04 OC.8 EOT
6960 00244F OA ADDRENO DC.B LF,CR
6970 00245'1 20 £lC.B END ADDRESS ----:> I
E N D 0 F r E s T "1
E N D 0 F T r G T ,')
,,0:..
1::: N D o F
··'0···· ... ,
IT '!~) I ~1P O~)~·;:I. BI'OF TO Ci~RRY IN [) .•j 1N OCtOO?~~()'1
1 r'~; r r1 P 0 ~:3 ~3 I E: l. F TO Ct~r~ I~ y "'0" IN D ...•.•j
line IN ::::::::::::: > f)UDO/UO:]
fault
F N D 0 F T E ~) T ';
line fault
END o F
END o F E B r :]
END <) F
~:~,[)D'~ E ~;f:::" s Er~RORS ::::::::::: > XXXX XXXX XXXX XXXX XXXX XXX X XXX'1 XXX>::
ADDI~E~3S" B E'~I~OI~S :::::::::::: ) XXXX
~(XXX X;'(XX XXXX XXXX XXXX XXX'" xrxx
f~,DDR E~)S' S [r~ r~ Ol~~ S :::::::::::: > XXXX XXXX XXXX XXXX XXX X XXXX XXX'1 XXXX
ADDI~ESB' S Et~I~OI~S ::::::::::::: > XXXX XXXX XXXX XXXX XXXX XXXX XXX"1 '1 xxx
ADDRE~)S'S ERRORS ::::::::::::: > XXXX XXXX XXXX XXXX XXXX XXXX XXX'1 '1'1 XX
ADDREBG'G ERJ~OI~B :-.:::::::::::: ) XXXX XXXX XXXX XXXX xxxx XXXX XXX'" XX;(X
(',D{)RE~)S" S ERRORS ::::::::::::: ) XXXX XXX
PRE~3G ON ABORT TO CONTINUE interrupt
-rEST~) PROGr~AM RUNNING
XXX)( XXXX XXXX XXXX XXX'1 '1'1 XX
ADDRE~3S' G EI~J~OI?S ::::::::::::: > XXXX XXXX XXXX XXX X XXXX XXXX XXX"1 "1 XXX
f~DDR E~~S'~) ERRORS :::::::::::: } XXXX XXXX )(XXX XXXX XXXX XXXX XXX'1 X'1XX
ADDJ~ES~J' B EI~I~Ot~S ::::::::::::: > XXXX XXX;( XXXX XXXX XXXX XXXX XXX'1 XXXX
{:,D[)I~ ESS ' S Er~RORS :::::::::::: > XXXX XXXX XXXX XXXX XXXX XXXX XXXX X"IXX
ADDI~ EB~; r ~3 EI~I~OI~S ::::-.:::::::::) XXXX XXXX XXXX XXXX XXXX XXXX XXXX -'I XXX
~~DOI~ E SS 7 ~) EI~RORS ::::::::::::: ) XXXX xxxx X:XXX xxxx xxxx X:x:XX >()t'~XX -1"1 XX
~'DDI~ESG'S E:1~t~OI?B :::::::::::: > XXXX XXXX XXXX XXXX XXXX XXXX XXXX ·1·'IXX
{,DDRESS'S ERI~OI~S ::::::::::::-.: > XXXX XXX X XXXX XXXX XXXx. XXXX XXXX '1XXX
ADD1~EBB' B Er~I?OI?B ::::::::::::;. XXXX XXX X XXXX XXXX XXXX XXX X XXXX X'IXX
~~,[)DR EBB'S EI~ROI~S :::::::::::::: > ),~XXX XXXX XXXX XXX X XXX X XXXX XXX'1 XXXX
ADDI~ ES~~ r s Et~I~OI~S ::::::::::::::: > XXXX XXXX XXXX XXXX XXXX XXXX XXX'1 X"IXX
f,DDRESS" S ERr~O'~S :::::::::::::: } XXXX XXXX XXXX XXXX XXXX XXX X XXX··, XXXX
f'D[)I~ E~3B ' S EI?I~ ()I~ ~3 :::::::::::: ) XXXX XXXX XXXX XXXX XXXX XXXX XXX"1 'IXXX
r.,DDRESS" s ERRORS :::::::::::::: > XXXX XXXX XXXX XXXX XXXX XXXX XXX-1 '1'1 XX
END o F T EST
END o F
f~,[)D~~ ESS 7 ~~ F~~R oas ::::::::::::::: > XXXX XXXX XXXX XXX X XXXX XXXX XXX1 XXXX
AJ)D'~ ESB T s EI~'?OI~ S ::::::::::::: > XXXX XXXX XXXX XXXX XXXX XXXX XXiX XXXX
~~i{)[)R E Ss r S ERRORS :::::::::::::;> XXXX XXXX XXXX XXXX XXXX XXXX XX11 XXXX
(.'DDJ~ESB' S EI~J~OR S :::::::::-.::::::) XXXX XXXX XXXX XXXX XXXX XXXX XiXX XXXX
(.iDDI~ESS' E I~ I~ or~~ S ::::::: :::::: >
S XXXX XXXX XXXX XXXX XXXX XXX X X1X1 XXXX
ADJ)I~EBS T S :::::::::::::::)
EI~f~OI?S XXXX XXXX XXXX XXXX XXXX XXXX X'I"I X XXXX
(.~'DDRESS' E; ERRORS :::::::::::::::) XXXX XXXX XXXX XXXX XXXX XXXX X111 XXXX
ADDf~ESB' S E I~ I~ () I~ S :::: ::::::: :::: ) XXX X XXXX XXXX XXXX XXX X XXXX iXXX XXXX
~~,[)[)R E~;S' S ERRORS :::::::::::::::~) XXX)( XXXX XX
SPUJ~ IOU!, INTEI~f?UP T !!!
F N D <) F T F S T '1
E N D o F T E B T ;;!
MEMOf~ Y T EST S : (C) '1 9 B 't UY MI Cf~ 0 P F<~ OCE: SS '1 INC
F N D 0 F T E B r .',
DO YOU ~IANT CONTINUE THE TEST ...,\ (YIN) y
IT'S IMPOSSIBL.E TO CA'~'~Y ""1" IN D·'I ~) IN ::::::::::::: > O()O()7BO it
IT'S Ifv1POSSIBl..E TO CAr~RY u'1 N
IN [)·1't IN ::::::::::::: > O()()07BO't
IT'S IMPOBSII3LE ro CAR'~Y "'1'" IN D·'I ~3 IN ::.:::::::::::: > ()()()0 7BO it
IT'S . , ..! u
IMPOSSIOl..E TO CARRY IN [)'1 ;.~ IN :::::::::::::: > OO()()7HO.lt
IT'S IMPOSBIBLE TO CAJ~J~ '( "·'1" IN 1)'-1'1 IN :::::::::::: > ()()()() 7BO/.t
IT'S IMPOS~)IBl..E TO CARRY ""1" IN [) 9 IN :::::::::::-.:: > O()()07BO't
IT' s IMP OBS I B1... (-: TO CAI~'~Y "'1" IN D B IN ::::::::::::: > OO()()/BOlt
IT'S J MP 0 S E> I BLE TO Cf~r~RY U·1 ~,
IN [)'1 ~:; IN :::::::::::::: > 00007 EJOtJ
IT' s IMPOB~3.r131._E TO CAR'~,( ""1" IN 1)·'1 it IN ::::::::::::: > ()OO()7BO(~
IT'S IMPOSSIBLE TO C(.,RRY . , ..!." IN [)'13 IN ::::::::::::: > ()o ()() 7 H()tJ
:r T '~) Il~POBB'[BLE ro C(~I~I~ y ""1'" IN D·I:..~ IN ::::::::::::: > O()()()700,,S
IT' ~; IMPOSSIBLE TO C(~I~ R'( ""'!" IN n·1··! IN :::::::::::::: > O()()()7B()t~
IT' ~, IMPOSSIBLE TO C(.\I~I~ y ".1 n IN D 9 IN :::::::::::::: ) ()OOO7BO"S
IT' s IMP O~)SIBl..E TO CAI\:RY ""1" IN D El IN :~ :::: :::: ::: > O()()()7B06
IT'B IMPOSSIBLE TO Ct~I~I~Y "'1" IN 1)"1 ~) IN ::::::::::::: > DOD()7~30B
IT'S IMPOSSIBLE TO C~~RRY' ""'!" IN D"!', IN ::::::::-.:::-.:: ) 0000/" BOB
:er's I t'1P OSB I Bl_E TO CAI?I~Y 1."'11.' IN 1)'13 IN :.:::::::::::: ) OOD07BOB
ITI'S I~1POSSIBI...E TO C{il~ I~ Y "'1'" IN D"! ~! IN :::::::::::::: ) ()OOO?BOa
IT' ~3 Il--1POSSIBI...E TO CA1~I?Y n "1 " IN D"" IN :::::::::::::: ) ()()()()7BOB
IT' s IMf'OSS lFJl.,E TO CAI~~RY " ..! ,~
IN o 9 IN ::::::::::::::: > OOOOi'~JOB
t T l' ~3 IMP O~; SIB I... E TO Ct~I~I~ y ""1" IN D B IN ::::::::::::: > {)()()()7nOB
F.:: N D 0 F T E ~) T ~~
IT'S IMPOSSIBLE TO l·JI~ ITE "'1 u IN :;::::: :::: :.~ > onOO7BOLt
('~DDI~E~3G'~, EI~I?OI~B :::::::::::: ) XXXX xxxx xxxx xxxx xxxx XXXX )(XXX '1"IX)(
IT' s IMPO~)~)18LE TO ~JR 1 TE . , ..! . , IN :;::::::::::: > OO(J07BOB
E N I) o F T E ("'
,) T ::3
IT I'~) IMPO~)SIBI...E TO C~~R I~ 'y' "'0'" IN [)'1 ~:; IN :::::::::::::: ) DO()O7 E~O,(1
IT'S IMPO~3SlI3I...E TO CAI~I?Y NO"" IN D'" it IN :.:::::::::::: > ()()I]07BO,(t
ITI' s IMPOSSlI3LF.:" TO C(;lr·~ R'y
.., () ..,
IN [)"13 IN ::::::::::::::: > 0OOO7EJ04
IT' ~3 IMPOB~3 IBLE TO CAI~'~Y "0" IN D"I ~~ IN ::::::::::::::: > ()()00 7BO /of
IT'S IMPOSSII3I...E TO CAI~~ R\( "I]" IN ()'10 IN :::::::::::::: > O()()()7BO't
IT' ~3 IMPOBSIBLE TO CAI~I~ Y ",0···· IN D ,,'j IN :::::::::::::: > ()()OO7BOlt
JT '1~) IMPO~)SIBLE TO CARRY "'0" IN [) B IN ::::::::::::: ) OOCl();' BO',
.r T'~, IMPOS~3 II3LE TO CAI~I~ Y UO" IN D·1!.:i IN ::::::::::::: > ODOO7BO(S
IT'S IMPO~;SlBL.,E TO CAr~RY "0" IN [v! '; IN :::::::::::::: > O()()()7B06
IT' ~, IMPOS~3 IBLE TO CAJ~I~ y "'010" IN D"I ::3 IN ::::.:::::::: > OO()()7B06
IT'S IMPOSSIBL.E TO CARF~Y ." ()" IN D'1 ;~ IN ::::::::::::::: > ()()()O i' EJCU)
IT' s IMP 0 S ~5 I: Bl. E TO C(~I~I~Y "() " IN D"I () IN :::::::::::::: > O()()()7B06
IT'S IMPOSSIBLE TO c~~r~R '( " 0" IN D ~) IN :::::::::::::: > O()()07B06
IT' s (t"1POBBIBLE TO C(."~ t~ Y IN D B
" ( ) I.'
IN ::::::::::::::: ) 00 D() 7BO{j
IT' ~~ IMPOSSIBLE TO CAr~RY .'10" IN L)'1 ~:; IN ::::::::::::::: > oooo 7 EJOB
IT'S I t"1P OS~3 I BI... E TO CAJ~I~Y '.'() N IN 1)'1 it IN ::::::::::::;:: ) ()()()07BOB
J'f' s IMPO~;S IBLE TO C('\RI~Y
.... () ..••
IN ()'1 ~~ IN :::::::::::::: ) ()()OO7HOEJ
() ,..
IT'S IMPOS~3 IBLE TO CAI?I?Y
".
IN D'L~~ IN :::::::::::::: > OO()07BOB
IT'S IMPO~)S IBl E TO CAF~I~Y "O·'~ IN [)'1 () IN :::::::::::::: > ()(JOO/BOB
182 The 68000 Hardware and Software
ADD Add destination operand Src,dst B/W/Uv ADD. Size Src,dst Impossible to ADD memory
to source operand. to memory.
Result in destination
SUB Subtract destination Src,dst B/W/LW SUB.Size Src,dst Impossible to SUB memory
operand to memory.
from source operand.
Result in destination
eMP Compare destination with Src,dst B/W/LW CMP.Size Src,dst Impossible to CaMP memory
source to memory; dst is a Dn
register.
AND AND destination operand Src,dst B/W/LW AND.Size Src,dst Impossible to AND memory
(X) to source operand. to memory. Src and dst
w Result in destination cannot be an An register.
Src can be immediate.
EaR Exclusive OR destination Src,dst B/W/LW EOR.Size Src,dst Impossible to EaR memory
operand to source to memory. Src and dst
operand. Result in cannot be an An register.
destination Src can be immediat2.
NEGX ~~o's complement with dst B/\'l/LW NEGX.Size dst Destination cannot be an
extend bit of the An register.
destination operand
NOT One's complement of dst B/W/LW NOT. Size dst Destination cannot be an
destination operand An register.
TST Compare operand with dst B/W/LW TS'LSize dst Dtstination cannot be an
zero. CCR is set An register.
Appendix Special Memory Reference Instructions
LEA Load effective Src,An UoJ LEA Src,An Whole register is affected
address by the instruction. CCR
is not modified
MOVEP Transfer from Dn,dst W/LW MOVEP.L Dn,d (dst) After transfer the data
register On alternate or MOVEP occupies alternate bytes
even or odd addresses in memory. Special 8-bit
to memory block peripherals
MOVEP Load On with data Src,Dn W/LW MOVEP.L d(Src),On Load data from alternate
from memory block or MOVEP memory byte. Special 8-
of even or odd bit peripherals
addresses
MOVEM Transfer multiple regs,dst W/LW MOVEM.L regs,dst List of registers can be
registers or MOVEM written: 00-D5 means that
registers DO to D5 are
transferred; DO/D5 that
registers DO and D5 are
.... transferred
(X)
~ MOVEM Load multiple Src,regs W/LW MOVEM.L src,regs If effective address (Src)
registers or MOVEM is postincrement, only
memory to register
transfer is allowed
AODX Add destination operand Src,dst B/h'/LW ADDX.Size Dn,Onl Src and dst use data
with extend bit X to or ADDX.Size -(An), register or predecrement
source operand. Result -(AnI) address modes
in destination
SUBX Subtract destination Src,dst B/W/LW SUBX.Size Dn,Onl Src and dst use data
operand with extend bit or SUBX.Size -(An), register or predecrement
X from source operand. -(AnI) address modes
Result in destination
ABCD Decimal addition Src,dst B ABCD Dn,Dnl Src and dst use data
with carry (bit X) or ABCD -(An) - (AnI) register or predccrement
address modes
SBCD Decimal subtraction Src,dst B SBCD Dn,Dnl Src and dst use data
with carry (bit X) or SBCD -(An) - (AnI) register or predecrement
address modes
Appendix 2 Special Memory Reference Instructions (continued)
BSET* Test bit specified by numb,dst B/LW BSET.Size # numb,dst numb can be contents
destination operand. or of a Dn register or
After test, bit is set BSET.Size Dn,dst an operand (# numb)
to 1
BCLR* Test bit specified by numb,dst B/LW BCLR.Size # numb,dst numb can be contents
destination operand. or of a Dn register or
After test, bit is BCLR.Size Dn,dst an operand (# numb)
set to 0
BCIIG* Test bit specified by numb,dst B/U-J BCHG.Size # numb,dst numb can be contents
operand, change its or of a Dn register or
value and write BCHG.Size Dn,dst an operand (# numb)
comolemented value in
bit"Z of CCR
BTST* Test bit specified by numb,dst B/U'J BTST.Size # numb,dst numb can be contents
destination operand. or of a Dn register or
After test, bit is BTST.Size Dn,dst an operand (# numb)
unmodified
Appendix 2 Special Memory Reference Instructions (continued)
CMPM Memory comparison by Src,dst B/W/LW CMPM.Size (An)+,(An)+ Src and dst use
virtual subtraction exclusively post-
of source from increment address
destination mode
TAS* Test and set an dst B TAS.B dst Tests byte operand
operand designated by dst.
If dst = 0, MSB bit
of dst is set to 1
(indivisible instruction)
HOXL* Hotate left Dm,Dn B/W/Uv ROXL.Size Dm,Dn Same as HOL with
with extend # cnt,Dn ROXL.Size # cnt,Dn extend bit included
dst ROXL.W dst in rotation
HOXH* Rotate right Om,Dn B/v.)jL\\1 ROXR.Size Dm,Dn Same as ROH with
with extend # cnt,Dn ROXR.Size # cnt,Dn extend bit X included
dst ROXR. \\1 dst in rotation
LSL* Logical shift Om,Dn B/\v/LW lSL.Size Dm,Dn Shift count contained
to left # cnt,Dn LSL.Size # cnt,On in Dm (1 to 63). # cnt
dst LSL. \\1 dst indicates total of
shifts. Only 1 bit
shift in c1st
LS/{* Logical shift Om,Dn B/W/LW LSR.Size Om,Dn Shift count contained in
to right # cnt,Dn LSR.Size # cnt,On OM (1 to 63). # cnt indi-
dst LSR.W dst cates total of shifts.
On 1y 1 bi t 5 h if t 5 in d s t
Appendix 4 Program Control Instructions
LINK* Link to stack An, Link An,# displacement -32768 < displacement
# dis~lacement < 32767 +32767
If On<)l, then
PC + displacement -) PC
Else NOP
~10VE Transfers An register l\n,USP Lv~ r·\OVE. L An, USP Privileqed ~nstr~ction
to user stack pointer
Appendix 4 Program Control Instructions (continued)
..... PC -) -(SSP)
TRAP Sequence branches to TRAP # number
~ vector number shown SR -) -(SSP)
by the instruction (Vector) -) PC
191
192 The 68000 Hardware and Software
16R4
16R4
, .......
·,,
I' l l I I I ' " "" IIIJ "'~ ' _'/ ' I 't 11"1111 ~ nn' l IInH 1I
Jv
~
,.
· I I
!
~
· " J "
I
"" J V
"
I
'.
"
~ ~
v "
~
"
"n"
·
""
n" '"l.. ".
·
v
~
~
n
"
, "
""
~ -;:t
·"
10"
v '.
~
~
1"0
"
.."" §b -;:t
v
.,
~
q
, ~
"
....
· Jv
·
· ..~
"
""
w I
"
··· "
~ -d
·."
"
!!
· I ~
18L4
18L4
'." "H'I .
" ii • I " "' I "" '" ""'111
11 11 " /I 11 II I t lJlI >o"
,
I
I
-{X
I
~
3 23
I
· "
s
"
"
"" p-
10
""
"
• I
"" - "
"
"
.
" -
.,
. "
,
"
"
.". "
"u '-'
• "
I
, I .,
"
I "
u
"
10L8
OCTAL 10 INPUT
AHO-QR·IHVERT QATE ARRAY
10L8
., - "
I
.
,
~
"
I
"" - "
.
~
·.. "
.
~
"" - "
I
·
"
- "
,
·
u
" ........
I
""
-
~
"
. "
I
Appllcetlon
...-". . .•
" 0"
.....---.! •
"ALl2t.1 -
..
. l
.."
..
.. . ....
" 1J
.
e
.. .
M
M
.. ......
~'O'
-
1
M M_~
.oo
.. ..
• l~
ffiiSi
.I .1
........
}* -
.. " .....
}~'
.
see ~
..uo '9 :.
~tlO t--!!-J U
~.- r--!!-'iiIi
~ ...... ~iiiACi
N!!' "0..1 '-".J ...
~ ...
\,.!!.,!lA' " .
L...--....!.• .,
M_ _
'0""
::~."
OD~S
" II "I I~'1 ""' I~ JlI'UII n" M ~ R ll . 1> .. " H II
23
"
"
OD- U1 :" ~ 22
J
HC
"
OD- U1 ~
.
" RD
"
"
TE ST
-
;JD-
U1
" ~
"
"" V "
,
,
·
"
"
"
::: OD- U1 ~ HC
RW
·. Or>- ~
FC2
7
"
"
O=J
." ~
·
"
~D-
~
FCl •
,
"
""
· OD- O=J ~
FCD
·.
· -OD- ~
~
C2
"
10
OD-~ ~
"
"
,"
HC
11
~