RIT Scholar Works
Theses
Thesis/Dissertation Collections
5-2-1986
Software simulation of MC68000
Ramakrishnan Iyer
Follow this and additional works at:
http://scholarworks.rit.edu/theses
This Thesis is brought to you for free and open access by the Thesis/Dissertation Collections at RIT Scholar Works. It has been accepted for inclusion
in Theses by an authorized administrator of RIT Scholar Works. For more information, please contact
.
Recommended Citation
School of Computer Science and Technology
Software Simulation of MC 68000
Ramakrishnan A. Iyer
A thesis, submitted to
The Faculty of the School of Computer Science and Technology
in partial fulfillment of the requirements for the degree of
Master of Science in Computer Science
John L. Ellis
Approved by: ________________________________________ __
Dr. John Ellis
Margaret M. Reek
Prof. Margaret Reek
George A. Brown
Prof. George Brown
I, Ramakrishnan Iyer, hereby grant permission to the Wallace
Memorial Library, of R.I.T., to reproduce my thesis in whole
or in part.
Any reproduction will not be for commercial use
or profit.
Date :
tJ\o..u
2
I
I
q
g b
ABSTRACT
The
introduction
of
the
Motorola
MC68000
family
ofmicroprocessors
usheredin
a
new eraof
microprocessors.These
are
single-chip
microprocessors
designed
to
function
as
the
central
processing
units
of
sophisticated computersystems
.The
prime objectiveof
this
thesis
workis
to
develop
asimulator
for
the
MC68000
microprocessormainly
for
educational purposes.
The
simulator v/ouldhelp
in
any
test
or research work
utilizing
6R000
assembly
programsin
the
future.
Most
of
the
instructions
in
the
6FI000
family
areimplemented.
Roth
the
user modeand
supervisory
modeprograms can
be
v/ritten and runagainst
the
simulator.Besides
supporting
most ofthe
MC68000
features
the
Table
of
Contents
Title
Page
Acknowledgements
3
1.0
Introduction
4
2.0
MC68000
Microprocessor
-A
brief
description
7
3.0
Description
of
instruction
sets
11
4.0
Design
4&
5.0
Implementation
51
6.0
Conclusion
63
Appendix
A
(
User
Manual
)
72
Appendix
B
(
References
)
80
Appendix
C
(
Test
Programs
)
??
Figures
1.0
Data
Organization
in
Memory
12
2.0
Extension
word(
Indirect
addressing
withdisplacement
)
15
3.0
Arithmetic
Shift
(
ASL/ASR
)
21
4.0
Logical
Shift
(
LSP/LSL
)
31
5.0
Pegister
List
Mask
(
MOVEM
)
33
6.0
Potato
Without
Extend
(
ROL/POP
)
38
7.0
Rotate
With
Extend
(
RCXL/ROXR
)
39
CO
Vector
Assinnments
for
Exceptions
54
ACKNOWLEDGEMENTS
I
take
this
opportunity
to
thank
Dr.
John
Ellis
for
his
guidance
and encouragement notonly
during
the
course ofthis
thesis
workbut
alsoduring
my
entire career atthis
institution
.I
alsothank
Professor
Margaret
Reek
for
her
guidanceand
suggestions.
My
specialthanks
are alsodue
to
Professor
George
Brown
for
his
guidanceduring
the
implementation
ofthis
project
.I
amextremely
gratefulto
Dr.
P.
Peddy
ofComputer
Engineerino
Department
andProfessor
Thomas
Young
ofElectrical
Engineering
Technology
department
for
their
help
in
getting
usefulinformation
onthe
project atthe
initial
stage and
during
the
testing
stage.I
am alsothankful
to
Dr.
Peter
Anderson
for
his
kind
help
in
providing
assistance whenI
had
difficulty
in
CHAPTER
1
INTRODUCTION
Simulation
ofa
microprocessor
is
not
only
aninteresting
proposition
but
also
a usefulproject
in
any
environment.
Buying
the
hardware
involves
alot
of overhead(
For
eg:Maintenance
).
For
generalwork,
a simulatorshould
be
asatisfactory
alternative.Even
if
the
hardware
is
available
the
utility
of simulatorsdoes
notdecrease.
The
users can workindependent
ofthe
hardware
if
asimulator
exists.
Most
of
the
basic
programming
problersdone
by
students
do
notreally
needa
close association withthe
hardware.
The
existence ofa
simulator
has
another
advantage,
ahardware
update/maintenance need notjeopardize
work
currently
in
progress.These
are
the
considerations
which prompted
this
thesis
work.The
prime objective ofthis
thesis
is
to
develop
asimulator
for
the
MC68000
microprocessor
mainly
for
educational purposes.
The
PIT
professional
lab
has
available
a
68000
assembler
which
couldbe
utilized
to
the
advantage
of
the
usersif
there
wasa
68000
machinereadily
available.
A
68000
simulator wasa
good
choice
for
this
purpose.
This
would notonly
help
usersin
writing
6R000
programs
but
also wouldhelp
in
any
test
or
research
workFrom
the
historic
point
of
view,
the
conceptof
a16-bit
microprocessor
at
Motorola
Semiconductors,
Inc.,
wasfirst
generated
in
1976.
The
idea
wasto
design
a
16-bit
microprocessor
that
wouldbe
easy
to
program and supportwith
the
current
development
in
microprocessors.Previous
6800/6801/6809
instructions
wereincorporated
in
the
newmachine.
The
MC68000
is
a modern microprocessorby
any
standards.
Many
ofthe
instructions,
when combined withthe
different
addressing
modes,
moreclosely
resemblehigh-level
language
statements
than
assembly
language
instructions
oftraditional
4-bit
or8-bit
microprocessor.The
newMC68000
executes
40%
faster
than
such16-bit
microprocessors asthe
z8000
from
the
Zilog
andthe
8086
from
Intel
as perthe
references
in
Appendix
B.
Chapter
2
gives abrief
description
ofthe
MC68000
microprocessor.
It
givesa
generalidea
ofthe
MC68000
architecture,
which wouldhelp
in
understanding
the
working
of
the
variousinstructions
in
this
machine.This
is
followed
by
chapter3,
wherethe
different
instructions
areexplained
in
detail.
It
alsoincludes
a number ofillustrations
to
aidin
abetter
understanding
ofthese
instructions.
The
basic
design
ofthe
simulator
is
described
in
chapter4.
The
materialincludes
explanation
of
the
methodfollowed
in
decoding
the
instruction
set
ofthe
MC68000
microprocessor and explainsthe
suitability
ofthis
simulatorto
the
VAX
11/780
system.Chapter
5
deals
section
introduces
the
reader
to
the
different
capabilitiesof
the
MC68000
machine
in
general and ofthe
simulatorin
particular.
Additional
features
providedto
help
the
debugging
of
programs
is
also explained.Chapter
6
goesover
the
testing
procedurefollowed
for
the
simulator andthe
conclusions
derived
from
the
tests.
It
alsohighlights
the
restrictions
whichthe
user shouldbe
aware of.A
usermanual
is
givenin
the
appendix.This
willhelp
the
userin
understanding
the
procedureto
be
followed
in
using
the
simulator
.Development
ofthis
simulator was achallenging
experience.
Besides
the
time
spent
in
coding,
alot
oftime
was
devoted
to
testing
the
simulatorin
a number cfdifferent
ways.It
is
hoped
that
the
simulator will serveits
purpose as an educationaltool.
This
thesis
has
goneinto
sufficientdepth
to
provide a goodunderstanding
ofthe
simulator.
The
codeis
also writtenin
a simple andlucid
manner and
changes,
if
any,
shouldbe
easy
to
makein
the
wake of new
developments.
It
is
my
firm
belief
that
withthe
help
ofthe
MC68000
manufacturer's user manual(
andthis
thesis
)
the
reader willhave
little
difficulty
in
CHAPTER
2
THE
MC68000
MICROPROCESSOR-A
BPIEF
INTRODUCTION
The
MC68000,
designed
by
Motorola,
is
the
first
16
bit
microprocessor
to
have
a
32
bit
internal
architecture.It
has
about
68000
transistors
ona
single chip.In
the
early
years ofcomputers,
the
size ofthe
registers,
the
internal
instruction
register paths andthe
external
data
paths wereall
identical.
This
is
nottrue
now.
Large
external
paths requirethe
chip
packageto
have
a
larger
number of pins whichimplies
high
packaging
andproduction
costs.Thus
chipstend
to
have
larger
internal
paths
than
external
paths asin
the
caseof
MC68000.
The
external
16
bit
bus
is
multiplexedfrom
the
32
bits
inside
the
engine.The
sixteen32
bit
registers
are partitionedinto
8
address
registers and8
data
registers.Address
register
"A7
"is
usedas
supervisory
stackpointer
in
the
supervisory
mode and as userstack
pointerin
the
user mode.Hence
the
Motorola
Inc.,
treats
them
as
"A7
" and "A7
'In
other
words,
there
aretwo
"A7
"registers
withonly
one
of
them
in
operationat
a
time.
This
gives
the
effect
of
17
registers
in
total.
The
MC68000
has
a
very
regularinstruction
set,
raking
available several general
addressing
modes
for
most
instructions.
This
permitseasy
implementation
of
stacks
and oucues without special
instructions.
Two
32
bit
stack
flag
register
can
be
setto
movethe
machineinto
adebugging,
single
stepping
modefor
programdevelopment.
Eight
ofthe
general
purpose registers are used asdata
registers
for
byte
(8
bits),
(16
bits)
andlong
word(32
bits)
operations.
The
other nine general purpose registersare
address
registers
which canfunction
as stack pointersand
base
address
registers.All
17
generalpurpose-registers
can serve asindex
registers.Although
the
program
counter
is
32
bits
long,
only
the
low
order 2^bits
are used
in
the
basic
68000
design.
These
24
bits
providethe
68000
with anaddressing
range of16
Mbytes.
The
68000
can operate onfive
different
sizes ofdata
:bits,
4
hit
BCD,
8
bit
bytes,
16
bit
words and32
bit
lono
words.
Byte
data
may
be
addressed on even or odd addressboundaries;
whereas,
word andlong-word
data
mustbe
addressed on even address
boundaries.
The
status
registeris
16
bits
long
and consists of a userbyte
in
the
lower
order and a system
byte
in
the
upper part.The
systembyte
consists of
trace
and statusbits
andthe
interrupt
mask.The
userbyte
consists of condition codes.The
userbyte
can
be
addressed as a condition code register.The
condition code register consists of
overflow,
carry,
auxiliary
carry,
sign and zeroflag
bits.
The
instruction
set contains
56
basic
instruction
types
andthe
different
variations of
these
basic
instructions
give atotal
of81
instructions.
There
are14
different
addressing
modesTo
support
multi-user
andmulti-tasking
applications,
the
68000
operates
in
two
different
states,
namely,"
user "
for
normal
operation
and "supervisor"for
system control.All
instructions
canbe
executedin
the
supervisor state.However,
afew
instructions
like
"RESET
" and "STOP
" areunavailable
in
the
user state.Thus
the
system prevents oneuser or
task
from
violating
the
system'sintegrity.
The
lowest
8
bytes
ofmemory
hold
the
reset vector andreside
in
POM.
Additional
locations
in
the
lower
1024
bytes
are allocated
to
interrupt
vectors,
error vectors andvectors
for
various othertypes
of exceptions.These
locations
can reside eitherin
ROM
orRAM.
The
remainder ofthe
16
Mbyte
memory
map
ofthe
6R000
canbe
usedany
way
the
user wants.
Because
I/O
is
memory
mappedin
the
68000,
there
are no specificinstructions
for
I/O.
The
interrupt
structure ofthe
68000
provides sevenlevels
of vectoredinterrupts,
witha
maskin
the
statusregisters
to
lock
outinterrupts
at orbelow
the
currentpriority
level.
When
the
68000
receives an enabledinterrupt
request,
it
issues
an acknowledge signalto
the
device
requesting
service.Thereafter,
the
interrupting
device
must put a vector number onthe
data
bus.
This
vector selects one of a possible
192
interrupt
service
routines
in
memory.In
addition,
the
68000
provides
sevenunigue auto vectors
whereby
devices
that
cannot
generate
avector number can
interrupt
the
68000.
They
cause
the
CHAPTER
3
DESCRIPTION
OF
INSTRUCTION
SET
Before
describing
the
instruction
set
it
wouldbe
helpful
to
describe
data
organizationin
memory
andthe
various
addressing
modes.The
MC68000
instruction
canoccupy
from
oneto
five
words
in
the
memory-The
first
v/ordis
an opcode word whichcontains
the
bit
patternthat
the
68000
decodes
to
determine
the
instruction
types,
the
operand
addressing
modes,
and
the
length
of
the
instruction.
Additional
extensionwords
arerequired
for
operandaddressing
modesthat
useconstants,
absolute
addressesor
displacement
offsets.a.
Data
organizationin
merory
Bytes
areindividually
addressable withthe
high
orderbyte
having
an even address.Fig.l
on page12
makesthis
organization clear.
The
low
orderbyte
has
an odd addressthat
is
one counthigher
than
the
v/ord address.Instructions
and multibytedata
are accessedonly
on wordboundaries
.b.
Addressing
modesRegister
Direct
Modes
:These
effective
addressing
modes
specify
that
the
operandis
in
one
of
the
16
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 Word 000000
Bvie 000000 Byte000001
Byte 000002
Word000002
BylC 000003
z
z
Byie FFFFFE
WordFFFFFE
BvleFFFFFF
Word
Organization In
Mtmory
Bit Data 1Byte 8 Bits
7 6 5 4 3 2 10
IntegerData 1Bvte -BBits
15 14 13 12 11 10 9 B 7 6 5 4 3 2 1 0
MSB Byte 0 ISB Byte1
Bvte 2 Byte 3
15 14 13 12 11 10
1 Word*16Bits
9 B 7 6 5 4 3 2 1 0
MSB WordO ISB
Word1
Word 2
Data Organization
In
Mamory
(1)
Data
Register
Direct.
The
operandis
in
the
data
register
specified
by
the
effective address registerfield.
(2)
Address
Register
Direct.
The
operandis
in
the
address
register
specified
by
the
effective address registerfield.
Memory
Address
Modes:
These
effectiveaddressing
modesspecify
that
the
operandis
in
memory
and providethe
specific
address ofthe
operand.(1)
Address
Register
Indirect.
The
address ofthe
operand
is
in
the
address register specifiedby
the
registerfield.
(2)
Address
Register
Indirect
With
Postincrement.
The
address of
the
operandis
in
the
address register specifiedby
the
registerfield.
After
the
operand addressis
used,
it
is
incremented
by
one,
two,
orfour
depending
uponwhether
the
size ofthe
operandis
byte,
word,
orlong.
If
the
address registeris
the
stack pointer andthe
operandsize
is
byte,
the
addressis
incremented
by
two
ratherthan
one
to
keep
the
stack pointer on a wordboundary.
(3)
Address
Register
Indirect
With
Predecrement.
The
address of
the
operandis
in
the
address
registerspecified
by
the
registerfield.
The
operandaddress
is
decremented
by
one,
two
, orfour
depending
uponthe
size .However,
if
the
address registeris
the
stack pointer andthe
operand
one
to
keep
the
stack
pointer
on
a wordboundary.
(4)
Address
Register
Indirect
With
Displacement.
In
this
case
the
address
ofthe
operandis
the
sum ofthe
address
in
the
address
register
andthe
sign-extended16-bit
displacement
integer
in
the
extension word.(5)
Address
Register
Indirect
With
Index.
This
addressmode
requires
one word of extension.See
Fig.
2
on page15.
Bit
15
Index
Register
Indicator
0
data
register
1
address
registerBit
14
through
12
--Index
Register
Number
Bit
11
Index
Size
0
sign-extended,
low
orderinteger
in
index
register1
long
valuein
index
register
The
address ofthe
operandis
the
sum ofthe
addressin
the
addressregister,
the
sign-extendeddisplacement
integer
in
the
low
order eightbits
ofthe
extension word , andthe
contents of
the
index
register.Special
addressing
modes.In
this
case we usethe
effective address register
field
to
specify
the
special
Even Byte
7
6
5
4
3
2
1
15
14
13
12
11
10
9
8
Odd Byte
7
6
5
4
3
2
10
7
6
5
4
3
2
10
D/A
Register
W/L
0
0
0
Displacement
Integer
Bit
15
Index Register Indicator
0
data
register1
addressregisterBits
14 through
12
Index
Register Number
Bit
11
Index
Size
0
sign-extended, low
order wordInteger In index
register1
long
valueIn index
register(1)
Absolute
Short
address.
In
this
casethe
addressof
the
operand
is
in
the
extension
word.The
16-bit
addressis
sign-extended
before
it
is
used.(2)
Absolute
Long
Address.
The
addressis
formed
by
the
concatenation
oftwo
extension
words.(3)
Program
Counter
With
Displacement.
The
address ofthe
operand
is
the
sum ofthe
addressin
the
program counterand
the
sign-extended
16-bit
displacement
integer
in
the
extension
word .(4)
Program
Counter
With
Index.
This
is
same asaddress
register
indirect
withdisplacement
mode exceptthat
program counter
is
used asthe
address register.(5)
Immediate
Data.
This
address mode requires eitherone or
two
words of extensiondepending
onthe
size ofoperation .
In
addition,
there
areimplied
addressing
modes.For
eg:In
all "jsr
"(
jump
to
subroutine)
the
stack
is
implied.
Similarly
the
program counteris
alsoimplied
.There
is
no specialinstruction
to
indicate
that
Description
ofinstruction
sets:(1)
ABCD
(
Add
decimal
with extend).
This
instruction
has
two
forms.
a.
ABCD
Dy,
Dx
:This
form
usesdata
direct
addressing
for
both
the
operands.In
other wordsboth
operands
mustreside
in
internal
data
registers ofthe
68000.
b.
ABCD
-(Ay), -(Ax) :In
this
case predecrementaddress
register
indirect
addressing
is
usedto
specify
both
the
operands.This
mode permits access ofdata
storedin
memory
-ABCD
instruction
addsthe
contents ofthe
source anddestination
operandstogether
with extend(
X
)
bit
ofstatus register.
(2)
ADD
(
Add
Binary
).
This
instruction
has
the
following
form.
ADD
<ea>
,Dn
ADD
Dn
,<ea>
Note:
eadenotes
effective address.The
first
form
is
generally
usedto
processdata;
whereas,
the
secondform
is
usedto
modify
the
address.Both
the
instructions
addthe
contents ofdata
register
to
the
contents ofthe
location
specifiedby
the
effective
(3)
ADDA
(
Add
Address
).
This
is
similarto
ADr
instruction
except
that
there
is
only
oneform
having
the
address
register
asthe
destination.
ADD
<ea>
,An.
This
addsthe
source operandto
the
destination
address
register
and storesthe
resultin
the
address
register.(4)
ADDI
(
Add
immediate
).
This
instruction
has
the
following
form.
ADDI
<data>,
<ea>
Immediate
data
is
addedto
the
destination
operand andthe
resultis
storedin
the
destination
operand.(5)
ADDO
(
Add
quick)
.ADDP
<data>,
<ea>
This
instruction
is
a special variation ofthe
ADDI
instruction.
The
immediate
data
is
encodeddirectly
into
the
instruction
word.Therefore
opcodetakes
fewer
bytes
and executes
faster.
However
the
data
rangeis
only
1-8.
(6)
ADDX
(
Add
Extended
).
This
instruction
has
two
forms
.a.
ADDX
Dy
,Dx
:In
this
case contents ofthe
data
register
Dy
are addedto
that
ofDx
and extendbit
X.
The
b.
ADDX
-(Ay),
-(Ax) :This
is
a variation ofthe
above
form
withthe
maindifference
being
that
it
is
amemory
to
memory
add
andhence
operands are accessedusing
predecrement
address
register
indirect
addressing.(7)
AND
(
And
Logical
).
This
instruction
has
two
forms
.a.
AND
<ea>,
Dn
b.
AND
Dn
,<ea>
And
the
source operandto
the
destination
operand andstore
the
resultin
the
destination
operand.Note
that
immediate
addressing
modeis
not allowedby
most of
the
assemblers sinceit
willbe
treated
asANDI
instruction
whichis
explained next.(8)
ANDI
(
And
immediate
)
ANDI
<data>,
<ea>
This
instruction
andsthe
immediate
data
to
the
destination
operand and storesthe
result
in
the
destination
operand .
(9)
ANDI
to
CCR
(
And
Immediate
to
Condition
Codes
).
This
instruction
andsthe
immediate
operand withthe
condition
codes
andstores
the
resultin
the
low-order
byte
of
the
status
register.
(10)
ANDI
to
SR
(
And
Immediate
to
the
Status
Register
).
This
is
a
privilegedinstruction.
It
has
the
following
form
.Andi
xxx,
SR
This
instruction
andsthe
immediate
operand withthe
contents of
the
status register and storesthe
resultin
the
status register.
Note
that
allbits
ofthe
status
registerare affected.
(11)
ASL
(
Arithmetic
Shift
Left
)
ASR
(
Arithmetic
Shift
Right
)
This
instruction
has
three
forms.
a .
ASd
Dx
,Dy
b.
Asd
<data>,
Dy
c.
Asd
<ea>
This
instruction
arithmetically
shifts
the
bits
in
the
direction
specified.The
carry
bit
receives
the
last
bit
shifted out of
the
operand.The
shiftcount
in
case(a)
andFor
ASL,
the
operand
Is
shifted
left;
the
number ofpositions shifted
is the
shift
count.Bits
shifted out
ofthe high
orderbit
go
to both the
carry
and
the
extend
bits;
zeroes are shifted
into
the
low
orderbit.
The
overflowbit in
dicates
if
any
signchanges
occurduring
the
shift.C
-*ASL:
Operand
For
ASR,
the
operandis
shifted
right; the
number ofpositions
shiftedis the
shift count.
Bits
shifted
out ofthe
low
orderbit
go
to both the
carry
and
the
extendbits;
the
signbit is
replicatedinto the high
orderbit.
Operand
ASR:
1.
Immediate
:The
shift
countis
specifiedin
the
instruction.
The
range
is
1-8.
2.
Register:
The
shift
countis
containedin
adata
register
specified
in
the
instruction.
In
case
(b)
content
ofmemory
may
be
shifted onebit
only
and
the
operand
sizeis
restricted
to
a word.Fig.
3
on page21
further
clarifies
the
operation ofthese
instructions.
(12)
BCC
(
Branch
Conditionally
):
This
instruction
has
the
following
form.
Bcc
<
label
>
Here
"CC"is
usedto
specify
one ofthe
many
conditional relationships.
This
instruction
passes controlto
the
specifiedlabel
only
if
the
conditionalrelationship
is
true.
Otherwise
the
next sequentialstatement
is
executed .
(13)
BCHG
(
Test
aBit
andChange
):
This
instruction
has
two
modes as shownbelow
(1)
BCHG
Dn
,<ea>
...Immediate
modeA
bit
in
the
destination
operandis
tested,
andthe
state
ofthe
specified
bit
is
reflectedin
the
"z" conditionbit.
Thereafter
the
state
ofthat
bit
is
changed.Bit
operation
using
the
number
modulo32
is
performedin
case(2)
and
modulo
8
in
case
of
(3).
(14)
BCLR
(
Test
aBit
andClear
):
This
is
similar
to
the
above case exceptthat
the
bit
is
always
cleared
in
the
end.(15)
BRA
(
Branch
always):
In
this
case nextinstruction
is
fetched
from
the
address
formed
by
the
sum ofthe
current
program counter andthe
displacement.
Note
that
the
value of programlocation
used
for
this
computationis
the
currentlocation
counterplus
two.
Displacement
is
atwos
complementinteger
whichcounts
the
relativedistance
in
bytes.
The
displacement
canbe
8-bit
(
shortbranch
)
or16-bit
(
long
).
(16)
BSFT
(
Test
aBit
andSet
)
This
is
similartwo
BCLR
andBCHG
instruction
exceptthat
in
the
endthe
tested
bit
is
always set.(17)
BSR
(
Branch
to
Subroutine
):
This
is
similarto
BRA
instruction.
However
before
branching
the
long
word address ofthe
instruction
immediately
following
the
BSR
instruction
is
pushed
ontothe
(18)
BTST
(
Test
abit
)
:This
is
similar
to
BSET
except
that
the
tested
bit
remains
unchanged.
Only
the
condition codesare
set
as perthe
tests
performed
onthe
specified
bit.
(19)
CHK
(
Check
Register
Against
Bounds
):
This
is
a specialinstruction
found
only
in
this
machine.
Its
function
is
explainedby
the
following
algorithm
.if
Dn
<
0
orDn
>
(
<
ea>
)
then
TRAP
The
assembler syntaxis
as shownbelow.
CHK
<ea>,
Dn
The
content ofthe
low
order wordin
Dn
is
comparedv/ith
the
upperbound
in
<ea>.
If
it
is
less
than
zero orgreater
than
the
upperbound,
the
processorinitiates
anexception processing.
The
vector number "6"is
generatedto
reference
the
CHK
instruction
exception vector which resultsin
processing
the
exception routinelocated
at addresslocation
hex
018.
(20)
CLR
(
Clear
an operand):
In
this
casethe
destination
is
clearedto
all zero(21
)
CMP
(
Compare
)
:The
source
operand
is
subtractedfrom
the
destination
operand
andthe
result
obtainedis
usedto
decide
the
condition
codes.Note
that
the
destination
operandis
notchanged
.(22)
CMPA
(
Compare
address)
This
is
similarto
CMP
except
that
the
destination
operandis
an address registerwhich was not
the
casein
the
CMP
instruction.
The
size ofthe
source operandmay
be
specifiedto
be
word orlong.
Word
length
source operands are sign extendedto
32
bit
quantities
before
the
operationis
done.
(23)
CMPI
(
Compare
Immediate
):
This
is
again similarto
CMP
instruction
exceptthat
the
source operandis
always animmediate
data.
(24)
CMPM
(
Compare
Memory
):
This
instruction
has
the
following
form.
CMPM
(
Ay
)+,
(
Ax
)+.
The
source operandis
subtractedfrom
the
destination
operand and condition codes set
as
perthe
result.Note
that
the
operands are always addressed withthe
RIT
assembler
treats
the
first
operand asthe
sourceoperand.
This
is
different
from
most ofthe
standardMC68000
assemblers.
Hence
whenwriting
codefor
this
assembler
it
has
to
be
specified
as shownbelow:
CMPM
(
Ax
)+,
(
Ay
)+
(25)
DBcc
(
Test
Condition,
Decrement,
andBranch
):
This
instruction
is
extremely
usefulin
handling
loops.
The
algorithm
ofthis
instruction
is
givenbelow:
If
(
conditionfalse
)
then
Dn
-1
>
Dn
;
if
Dn
<>
-1then
PC
+
d
-->PC
(
d
displacement
)
else
PC
+2
(
Fall
through
to
nextinstruction
)
"cc"
represents
the
conditionsto
be
tested.
Dn
contains
the
count ofhow
many
times
the
loop
is
to
be
repeated.
If
the
test
is
true,
nobranch
is
taken
andthe
loop
is
terminated.
If
the
conditionis
false
the
contentof
the
specifieddata
registeris
decremented
by
1
.If
the
register count
is
-1the
branch
does
nottake
place .Otherwise
the
program controlbranches
back
to
performthe
(26)
DIVS
(
Signed
Divide
):
The
destination
operandis
divided
by
the
sourceoperand
andthe
result
is
stored
in
the
destination.
The
destination
operand
is
along
operand,
andthe
sourceis
aword
operand.
The
operationis
performedusing
signedarithmetic.
The
32
bit
resultis
arranged suchthat
the
lower
16
bits
containthe
result whilethe
upper16
bits
contain
the
remainder.(27)
DIVU
(
Unsigned
arithmetic):
This
is
similarto
DIVS
exceptthat
the
operationis
performed
using
unsigned arithmetic.(28)
FOP
(
Exclusive
OR
Logical
)
The
source operandis
exclusiveORed
withthe
destination
operand andthe
result storedin
the
destination
operand .
(29)
FORI
(
Exclusive
OR
immediate
):
This
is
same asFOR
exceptthat
the
source operandis
an
immediate
data.
(30)
EORI
to
CCR
(
Exclusive
OR
Immediate
to
Condition
Codes
)
:The
immediate
source operandis
exclusiveORed
withthe
(31)
EORI
to
SR
(
Exclusive
OP
Immediate
to
the
Status
Register
):
This
is
a
privilegedinstruction.
The
immediate
operand
is
exclusive
ORed
withthe
contentsof
the
status
register,
and
the
result
storedin
the
statusregister
.(32)
EXG
(
Exchange
Registers
):
This
instruction
exchanges
the
contents
oftwo
registers.All
combinationsof
data
register
and address registers are allowed.(33)
EXT
(
Sign
Extend
):
This
instruction
is
usedto
sign extend a
byte
to
a word or a wordto
along.
Bit
7
ofthe
specified registeris
copiedto
bits
7-15
in
case ofword
operation,
orbit
15
ofthe
specified registeris
copied
to
bits
16-32
in
case oflong
operation.(34)
JMP
(
Jump
):
Execution
continues atthe
effective address specified
by
the
instruction.
(35)
JSP
(
Jump
to
Subroutine
):
This
is
similarto
JMP
exceptthat
before
jumping
the
lonq
address ofthe
instruction
immediately
following
the
JSP
instruction
is
pushed ontothe
stack.(36)
LEA
(
Load
Effective
Address
):
The
specified address registeris
loaded
withthe
(37)
LINK
(
Link
and
Allocate
):
This
is
aspecial
instruction
ofits
kind
found
only
in
this
machine.
Before
the
main programcalls
a subroutineit
is
necessary
for
the
calling
programto
passthe
values ofsome
variables
to
the
subroutine.
These
variables are oftenpushed
onto
the
stack
before
calling
the
subroutine.Then
during
the
execution
ofthe
subroutine,
they
canbe
accessedfrom
the
stack.
In
addition
adata
areahas
to
be
allocatedfor
local
storage
of
parameters.
This
is
all achievedusing
this
command.
Its
format
is
as shownbelow.
LINK
An,
<displacement>
Its
algorithmis
:An
>
-(SP);SP
>
An;
SP
+d
>
SP
The
current
content ofthe
specified address registeris
pushed ontothe
stack.The
new stack pointeris
then
loaded
into
stack.This
acts asthe
frame
(
local
storage
area
)
reference.Finally
the
displacement
is
addedto
the
stack pointer.
This
reservesthe
local
parameterstorage
area .
(38)
UNLK
(
Unlink
)
:Its
format
is
An
>
SP;
(SP)+
>
An
The
priordata
frame
is
restoredusing
this
instruction.
This
is
achievedby
loading
the
stack
pointer
with
the
specified addressregister
followed
by loading
the
Thus
original
value of "An"is
restored.(39)
LSR,
LSL
(
Logical
Shift
):
Fig.
4
on page31
illustrates
the
operation
of
these
two
instructions.
The
"c"
bit
is
the
carry
bit
whilethe
"x"bit
is
the
extendbit.
(40)
Move
(
Move
Data
from
sourceto
destination
):
This
is
a simplebut
a powerfulinstruction
which movesthe
content
ofthe
sourceto
the
destination
location.
The
destination
location
cannot
be
an address register.(41)
MOVE
from
CCR
(
Move
from
the
Condition
Code
Register
)
:The
contents ofthe
status register are movedto
the
destination
location.
This
is
a wordoperation,
but
only
the
low
orderbyte
containsthe
condition codes.(42)
MOVE
to
CCR
(
Move
to
condition codes):
The
contents ofthe
source operand are movedto
the
condition codes.
As
in
the
abovecase,
only
the
low
orderbyte
is
usedto
updatethe
condition codes.(43)
Move
to
SR
(
Move
to
Status
Register
):
This
is
aprivileged
instruction.
The
contents ofthe
source operandFor
LSL,
the
operand
is
shifted
left;
the
number ofpositionsshifted
Is the
shift count.
Blts%hlfted
out
ofthe high
orderbit
go
to both the
carry
andthe
xtend
bits;
zeroes are shifted
Into
the low
orderbit.
LSL:
Operand
For
LSR,
the
operandis
shiftedright;
the
number of positionsshifted
is the
shift
count.Bits
shifted
out ofthe low
orderbit
goto both the
carry
andthe
xtend
bits;
zeroesare
shiftedinto the high
orderbit.
LSR:
Operand
(44)
MOVE
from
SR
(
Move
from
the
Status
Register
):
The
contents
ofthe
status
register are movedto
the
destination
location.
(45)
MOVE
USP
(
Move
User
Stack
Pointer
):
This
is
a
privileged
instruction.
The
contents
ofthe
user stackpointer are
transferred
to
or
from
the
specified addressregister
.(46)
MOVEA
(
Move
Address
):
Move
the
contents
ofthe
sourceto
the
destination
address register.
Word
size source operands are signextended
to
32
bit
quantitiesbefore
the
operationis
done.
PIT
assemblertreats
aMOVE
instruction
as aMOVEA
instruction
if
the
destination
operandis
an addressregister.
(47)
MOVEM
(
Move
Multiple
Registers
)
The
two
forms
ofthis
instruction
are(a)
MOVEM
<
registerlist
>
,<
ea>
(b)
MOVEM
<
ea>,
<
registerlist
>
This
instruction
savesthe
contents ofthe
registersspecified
in
registerlist
in
memory
or
vice-versa.The
reoister
list
caninclude
any
combination ofdata
registers
and address registers.
The
second wordis
called
the
Register List
Mask
field
Specifies
whichregisters
areto
be
transferred.
The
low
orderbit
corresponds
to the
first
registerto be
transferred;
the high
bit
corresponds
to the
last
registerto
be
transferred.
Thus,
both
for
controlmodes and
for the
postincrement mode
addresses, the
mask
correspondence
is
Fig.
5a
IS 14 13 12 11 10 9
A7
A6 A5
A4
A3 A2
A1
A0
D7
D6 D5
D4
D3 D2
D1
DO
while
for
the
predecrement
modeaddresses, the
mask correspondenceis
IS 14 13 12 11 10 0 8 7 6 5 4 3 2 1 0
DO D1 D2
D3 D4 D5 D6 D7 A0
A1
|A2
A3 A4|A5 A6
A7
The
selection
of
these
registers
depends
onthis
mask.Each
bit
ofthis
maskcorresponds
to
one ofthe
68000's
internal
registers.
Setting
abit
to
1
indicates
that
the
corresponding
register
is
included
in
the
list
and asetting
of
"0"indicates
that
it
is
notincluded.
The
normalmeaning
ofthe
bit
mask
is
asshown
in
Fig.5-a
on page33.
However
whenaddress
register
indirect
with predecrementaddressing
is
used,
the
meaning
ofthe
bit
maskis
changedas shown
in
Fig.5-b
on page33.
(48)
MOVEP
(
Move
peripheraldata
):
In
this
casedata
is
transferred
between
adata
register and alternatebytes
of
memory
starting
atthe
location
specified andincrementing
by
two.
The
high
orderbyte
ofdata
registeris
transferred
first
andthe
low
orderbyte
is
transferred
last.
If
the
addressis
even,
allthe
transfers
are
made onthe
high
orderhalf
ofthe
data
bus;
if
the
addressis
odd,
all
the
transfers
are made onthe
low
orderhalf
ofthe
data
bus
.This
instruction
is
actually
designed
for
communicating
with
LSI
peripheralsthat
interface
over an8-bit
data
bus.
(49)
MOVEO
(
Move
Ouick
):
This
is
similarto
the
MOVE
instruction
with animmediate
data
asthe
source operand.In
this
casedata
is
contained
in
an8-bit
operandfield
withinthe
operation
word.
However
it
is
sign extendedto
a
long
operandbefore
(50)
MULS
(
Signed
multiply
):
Multiply
two
signed
16-bit
operands
yielding
a32-bit
signed
result.
Signed
arithmetic
is
used.(51)
MULU
(
Unsigned
multiply
):
This
is
similar
to
"MULS
"except
that
unsignedarithmetic
is
used.(52)
NRCD
(
Negate
Decimal
withExtend
)
:This
is
best
explained
asfollows:
0
-(
Destination
)10
-X
>
Destination
The
operationis
performedusing
decimal
arithmetic.(53)
NEG
(
Negate
):
The
operand addressed asdestination
is
subtractedfrom
zero.
(54)
NEGX
(
Negate
with extend):
The
operand addressed asthe
destination
andthe
extendbit
are subtractedfrom
zero.(55)
NOP
(
No
operation):
In
this
case no operationis
performed.Only
the
(56)
NOT
(
Logical
Complement
):
The
ones
complement
ofthe
destination
is
storedin
the
destination
location.
(57)
OR
(
Inclusive
OP
Logical):
The
source
operand
is
inclusive
OPed
withthe
destination
operand,
andthe
resultis
storedin
the
destination
location.
(58)
ORI
(
Inclusive
OR
Immediate):
Inclusive
OP
the
immediate
data
to
the
destination
operand and store
the
resultin
the
destination
location.
(59)
ORI
to
CCP
(
Inclusive
Or
Immediate
to
conditioncodes
)
:Inclusive
OP
the
immediate
operand withthe
conditioncodes and store
the
resultin
the
low-order
byte
ofthe
status
register.(60)
ORI
to
SP
(
Inclusive
OP
Immediate
to
the
Status
Register
)
:This
is
a privilegedinstruction.
The
immediate
operand
is
exclusiveOPed
withthe
contents ofthe
status
stack
(61)
PEA
(
Push
effective
address
):
The
effective
address
is
computed
and pushed ontothe
(63)
RESET
(
Reset
External
Devices
):
This
is
amethod
whereby
external
devices
canbe
resetusing
software
instruction.
The
execution
continues with nextinstruction.
As
this
thesis
is
a software simulationthis
instruction
has
limited
use-(64)
POL,
ROP
(
Rotate
without extend):
This
operationis
best
described
by
Fig. 6
on page38.
The
shiftcount
may
be
specified as animmediate
operand
orin
register mode.(65)
ROXL
(
Rotate
withExtend
):
This
is
similarto
the
last
mentionedinstruction
except
that
the
extendbit
is
alsoincluded
in
the
rotation.Fig.
7
on page39
explainsthe
operation.(66)
RTE
(
Return
from
Exception
):
This
is
a
privilegedinstruction.
This
shouldbe
the
last
instruction
of all exception andinterrupt
routines.
The
status register andthe
program counterare
pulled
from
For
ROL,
the
operand
is
rotated
left;
the
numberofpositions shifted
is
the
shift count.
Bits
shifted
out ofthe
high
orderbit
go
to both the
carry bit
andback into
the low
orderbit.
The
extend
bit Is
not modified
or used.ROL:
C
-*Operand
For
ROR,
the
operandis
rotatedright; the
number ofpositionshifted
is the
shift
count.Bits
shifted out
ofthe
low
orderbit
go
to both the
carry bit
andback
into
the high
orderbit.
The
extend
bit
is
notmodified
orused.ROR:
4
Operand
For
ROXL,
the
operandIs
rotated
left;
the
numberof positions shiftedis the
shift
count.Bits
shifted out
ofthe high
orderbit
goto both
the
carry
and extend
bits;
the
previous
value ofthe
extend
bit is
shifted
into the low
orderbit.
ROXL:
X
c
-*Operand
For
ROXR,
the
operandis
rotatedright; the
number ofpositions
shiftedis
the
shift
count.Bits
shifted outofthe
low
orderbit
go
to both the carry
andxtend
bits;
the
previous value ofthe
extendbit
is
shiftedinto
the high
order
bit.
ROXR:
Operand
(67)
RTR
(
Return
and
Restore
Condition
Codes
):
This
is
best
described
by
the
following:
(SP)+
-->CC;
(SP)+
>
PC
The
condition
codes
andprogram
counterare
pulledfrom
the
stack.
The
previous
values
arelost.
(68)
RTS
(
Return
from
Subroutine
)
The
programcounter
is
pulledfrom
stack.(69)
SRCD
(
Subtract
Decimal
withExtend
):
This
is
described
by
the
following:
(Destination
)
10
-(source)lO
-X
>
Destination
The
subtractionis
performedusing
BCD
arithmetic.The
operand
may
be
addressedin
two
different
ways.(
1
)
SBCD
Dy,
Dx
(2)
SBCD
-(Ay) , -(Ax)In
the
second casethe
user should notethat
the
PIT
assembler
treats
Ax
asthe
source operan .This
is
different
from
the
standardMC68000
assembler.He
has
to
take
this
factor
into
consideration whilewriting
codein
assembly
(70)
Sec
(
Set
According
to
condition
):
In
this
case
"cc"denotes
the
condition
to
be
tested.
If
the
condition
is
true,
the
destination
is
set
to
allones;
if
the
condition
is
false,
it
is
setto
all zeroes.(71)
STOP
(
Load
Status
Register
andstop
):
This
is
aprivileged
instruction.
The
immediate
operand
is
moved
into
the
entirestatus
register.The
program
counter
points
to
the
nextinstruction,
but
the
process
stops
processing
andwaits
for
aninterrupt
to
resume
operation.
(72)
SUB
(
Subtract
Binary
):
The
source operandis
subtracted
from
the
destination
operand
andthe
result storedin
the
destination
operand.(73)
SUBA
(
Subtract
address)
:This
is
similarto
SUB
exceptthat
the
destination
operand
is
always an addressregister;
whereas,
in
the
previous case
this
was not so.The
PIT
assembler
automatically
treats
aSUB
instruction
asSUBA
if
the
destination
is
an address register anddoes
notflag
it
asan error.
This
is
similar
to
SUB
except
that
the
source operandis
always
an
immediate
value.
(75)
SUBO
(
Subtract
guick
):
This
is
similar
to
SUBI
except
that
the
source valueis
an
immediate
value
in
the
range1-8,
andthis
valueis
encoded as
part
ofthe
instruction
opcode-(76)
SUBX
(
Subtract
with extend):
This
is
described
by
the
following:
(
Destination
)
-(
Source
)
-X
>
destination.
(77)
SVJAP
(
Swap
Register
Halves
):
Exchange
the
upper andlower
wordsin
adata
register.(78
TAS
(
Test
and set an operand):
The
operandis
compared with zero andthe
conditioncodes set or reset as per
the
result.Independent
ofthis
result
the
most significantbit
ofthe
accessedbyte
is
setto
1.
This
instruction
is
basically
usedto
support
multiprocessing
andmultitasking
system environments.(79)
TRAP
(
Trap
to
exception routine):
This
instruction
initiates
exception processing.A
vector
numberis
generatedbased
onthe
low