KIM 1 Microprocessor Fundamentals PDF
KIM 1 Microprocessor Fundamentals PDF
KIM 1 Microprocessor Fundamentals PDF
IEuTrLS
,
sEttll[.an,
lfonrBoor
A SSORTCOT'NSE
rcR
SCIEilTI{NS AITDE[I[}I[EERS
Br
BAJUOND
!I. BEIWEST
II{D
DR. JOgEPHB. BGS
flEruClu NTS8IN'TE
FCR
PBOFEfISIOI{IL EDUCAIION
C.ER}IDOIE
BUIIDI}IG
nrr.rgFrqt RD.
uaDxso[,N. J.
o7gb0
PREFACE
alone.
Sls
just read,i.rngbooks
background, rsrlttea.naterlal,
and
COUNSEOUTLINE
1-1
RElDIlKt .{$S]I}ilMESITS
2-L
EXPENI!,TENTS
g[P. #t
EIP. #z
ETP. lf3
ETP. #b
EXP. #5
E]F. #6
3-1
3-3
3-5
3-8
3-9
3-lo
DEVTCES
rcGIC AI{DINTERT'ACE
B.SSTC
IPGIC
T. TOil-I}II'ENTINC BT'FFEN
II.
II{VERTSE BUffER
rI[.
.$ID SAIE
rT. $al{D GelS
V. ORGITE
VI. NORGAE
VTI. EXCU'SIYE-OR
GAIE
VIT[. EXCLTfiiIYE-ITO8
GAIE
OF IOW-IRI,EI'GIC
IX. DrSC'USSrOil
lr.1-8
lr.1-8
ruIP-EIOPS
I. R-S LAICH
R-S TLIP-fLOP
II.
D-fNE TLIP-FIPP
I[I.
IY. J-tr ITPE ELIP-FIOP
V. T-TIPE FLIP-EIOP
lr.2-L
b.2-L
b;2-2
L.2-2
I+.2-2
DECODERS,/DWT'LTIPIJAXENS
lr.3-1
LTIPI,&TffiS
A{CODERSATIJ
b.h-1
I}MffiFACE DE\IICES
OPEI{-COIJ,ESTOR
IOGIC
T?I-ST&TE IPGTC
BUS TRANSCEIVERS
h.5-1
\.5-2
b.5-lr
L.1-1
b.r-2
lr.1-2
b.1-3
lr.l.-lr
b.L-5
b.1-6
u.L-7
AlIltTZIilG SONilNJEE
PROBIE!{S
5.o
5-t
INTO TUUCTIONAI'
5. 2 STEP2: P.0BTIIIO$THEPROBLEI!
5-z
5-e
5. 3 Slm 3;
5-tz
5. L SfEP 1:
DEFINEltIE PA0BLEU
BIOCKS
.0IEOBITHUDETEIOP!{E!$?
Il]R EACHPTRTITIOII
(comnlurD)
PRoBIEI'Is
.lxttrzrNc soFlw^[RE
5.\
OBJECTTVES
TO FIOT'CHTBTS
5-n
5.5
PBOCEDURES
ArtER AICORT$IU DE\IEIOP!.IENT
5-22
QIIESTIONS
5-23
DEsrGu
tm ilnomng,/sorrliltRr tpPRoAcET0 I'frcRoccn-tnngR
II{IRODUCTION
6-L
5.1
6-2
COST
HIRDWARE
6.1.1
6.L.2
STSTEMSFEED
DIn{OBI BEQUTBEI'{EIIIS
6.L.3 Vo nregmB@NTS
5.1.1r PERIPEER.AL
DEVICES
6J.5 DEYICESTIPPORT
6.L.6 tflcRoPnocEsgoREfiDi{tRE
SEI^ECTIO}T
St'MM.Off
6.2
SOTffARECOSTB
6-2
6-3
6-5
6-7
6-7
6-9
6-9
6.2.L
ORG.0IITZATIOI{
PROCESSOn
6.2.2 PRSBAI'f-slBucrItnE
6.2.3 rI{PIAMENTAIIoN
r,JuWiU&E
6.3 sf,sr$-fcosrs
6.3.L DEVELoP!NT
cosrs
cosrs
6.3.2 MoDrrrclrroN
6,3.3
C6lS
!4.[IUTEN.0]ICE
6-10
6-11
6-II
6-L2
6-L2
6-r3
6-1I
6.h
oN C6TS
A PERSPECTTVE
6-L5
6.5
6-L6
6.9.L
6.5.2
oOIIDITIONS
WIIICHLEADTO
DESIOI{1n'.CDE
OI'FS
STS1EUSFEEDPROBIJ!{S
6.6.L pRocE$sons
txD ltEl.loRrns
6.6.2
6.6.3
6.6.b
6.6.5
6.7
I}ECODE
I'GIC
I{BORI ilITFEBS
SPEcI.ILIZEDI!{TEBTAcEDETICEI
D{IERRUPIS
SOFmAnErRtDE OmS
6.7.1. FRMRA}T
IOOPSAI{DSUBROTNINES
6-L6
6-n
6-A
6-2L
5-2J
622
622
623
6-U
6-25
6-25
6.7.2
6.7.3
5.8
FI'NCTIOIIAL
COUpUTATIOTS
BEPEAfEDCOUpUUIIoNS
6-26
6-27
6-27
$ruM.oR:r
RT,PNESEMTIIG
BI}IINT DAIA
7-L
NI'MBERSTSTEUCO}MERSIOI{S
DECIilAL TO BIT.ABT
BIS.OBTrc DECIUAL
DECIUALTO OCTAL
OCTEITO DECII{AL
DECII{ALTO HEIADECII.IAL
HEX.CDECII.'IL
fO DECI}{AL
coNvmslous
OC:TII TO BI}IABI,
HEI.qDECIUAL
TO BII{rff,
.OCIIL TO HEI.ADECII{AL;
fiO BACK
BCDmnAEnS
8-1
8-1
8-3
8-3
&L
8-5
8-5
9-L
BII{IRI IIRICTIOI{S
10-1
BIUARTARITHMETIC
IPGIC INSIRUCTIOTS
^OIID
11.1
CoUPUTER
.0RI$IME?ICII{SmUctIOilS
L1.1.1
IL.I.z
rL.2
NO4ATIO}I
tldo'S COUPI,EMENT
BINANI .0RIITIUEEIC
COUpUmnrtrrc
TNSTRUCTiOUS
Ll-1
u-1
u-3
\-5
tL-5
11-6
L1-6
IL-7
TPPESpICES
l.
UODITIED55OOOP CODET.{BI,E
B.
KIU INFOR}TIfIOII
A-1
B-1
rIil
B-2
BIPCK DIII}BA}T
KIU INTER,FACIT{G
DATASHET
B-3
COLLECTEDKIM SOFTWARE
DIS P LA Y ROUTINE
DIRECTORY
VU TAPE
SUPERTAPE
TAPE DUPE
MOV E-A -B LOCK
HEX DUMP
FRE QUE NCY
COUNT E R
A NA LOGTO DIGITAL CO NV E RS I O NDE MO
RE A L-TIME CLOCK
TIT,IER
HEDEC
B INA RY MULTIP LIC A T I O N A ND DI V I S I O N
16 B rT S QUA RERO O T
LUNAR LANDER
HORSE RACE
ONE-ARMEDBANDIT
KIMMAZE
MUS IC MA CHINE
HUNT THE WUMPUS
D.
B- 4
c- 1
c- 2
c- 3
c- 4
t.-/
c-8
c-10
c-11
c-13
C-L 4
c-15
c- 16
C-L 7
c-22
c-23
c- 26
c-27
c- 28
c-31
c- s3
KIM DEMONSTMTIONTAPE
INDE X
PROGRAMHEX DUMPS
D- 1
D- 2
KIM /6s00
E -1
E -3
KIM SOFTWARESOURCES
65OO MICROP ROCE S S OSRUP P T I E RS
G.
GENERALREFERENCEINFORMATION
H.
TTt REFERENCESHEETS
I.
J.
MI CROCOMPUTER
B IBt IOGRAPHY
K.
GLOSSARYOF COMMONLY
USED TERMS
F- 1
F- 5
3Nt1In0ltsunoc
MI CROPROCESS
I NG FUNDAMENTALS
CO URS EO UT L I NE
FIRS T DA Y
I.
II.
III.
IV.
Introduction
to Micro p ro c e s s o rs
A . Hardware
B . S oftware
C. Nurnber systems
a n d Mic ro c o mp u t e rs
1:
Loa d in g
a n d Ru n n in g a S in p le
Microc.omputer A rchi t e c t u re
a n d E le n e n t a ry
A . S inplifi-ed
CP U mo d e l
B . Data, address, a n d c o n t ro l
buses
C. Memory and I/O a d d re s s in g
D. The K IM monitor
E . A selected subs e t o f in s t ru c t i-o n s
P ro g ra m
P ro g ra rn n in g
V. Programming E xamples
A . P arallel
data in p u t a n d o u t p u t
B . Use of the K IM-1 k e y b o a rd a n d d is p la y
VI.
E xperinent
2:
P aralle l
Da t a I n p u t
and Output
SECONDDAY
I. In terfacing
Microconpu t e rs
t o E x t e rn a l De v ic e s
A . Using programma b le I / O lin e s f o r d e v ic e c o n t ro l
B . Device control
s o f t wa re t e c h n iq u e s
C. Common interface
d e v ic e s
D. A nalog input and o u t p u t t e c h n iq u e s
II.
III.
E xperiment
3: Contr o llin g
E x t e rn a l
Further S oftware
A . Flags and condi t io n a l
b ra n c h e s
B . Counting and tirn in g lo o p s
1- 1
De v ic e s
THIRD DAY
I.
II.
III.
5 and 6:
Us in g
the
I n t e rv a l
IV.
IV.
Fur ther
Topics
as Reque s t e d
L- 2
T ime r
a n d I n t e rrup t s
SINInN0|SSV
oNtovitu
P.EADII'IG ASSfGI!,IENTS
Ii
rith
this
This rnaterial
of expertise
PIRST NIGHT
seninar.
infor:nation
a hi.gher level
given
These assignraents
NOTFORDETAILEDknowledge.
KII'I-I USEP,
MAi{tJAT
HANDWARE
MANUAI
PRGRA},I
M..INUAT
SEMINAR
WORKBOOK
Chapter 1
Sections
2.1 thru 2 . lr
Chapter l
Section h.1
Chapter I
Sections
1.0 ttru
Chapter
Chapter
Basic Logic
Interf ace
Devices
l_
1.2, r.J.1,
L.3.3 t
1.)+ thru
1.L.1.2.L
SECOT.ID
NIOHT
Sections
1 . 3 . 2 t h ru
Glossary of
Cornmon?erms
Chapters
^!/U-
Section
11.3 r
11"3.1
Appendix H
1^^/
L.).2.O
1.5 thru
./l
.,L.Oo4.J
or not relevant.
tbe lecture
FOR.DEf,AILEDIC{O"{LEEEthe entire
You will
firrd
all
the jaforrnation
extremely useful.
2-r
this
eondensed and
sINStUtUrdXS
, {,
KIM EXPERIMENTS
WARNING:
Your KI}I-I
EXPERII,IEM 1
experinental
set-up
operates
on 1ow voltage
on1y.
Progran
1. KIM-I Ini.tializarion:
Tura oa 5V power.
Press the RS key (reset).
e''d show some ramdom hex nutbers.
light
The display
should
2. Address Selectlon:
Press AD to put ICIM ln address entry uode (address entry mode ls
autonatically
seJ-ected after reset).
Enter 0000 oo the keyboard.
Obsexive the dl-splay see 0000 tn the left
You are
four digLts.
looklug at locacloa 0000 in the KIM-I read/wrlt@ ulrtrorlr Ttre
Wtrat are the
rlght
two dlgits
show the contents of thls Iocat,lon.
Coatlnue pressing
cootents?
Look at the next location
by presslag *.
* to see what aumbers are 1a your DeEory after
system start uP.
Do you see a pattera
01001 0200t
Go to locatlons
to the ouubers?
you
readlwxLte
0300, 0800, etc. and note the nunbers
KIM
flad.
meaory rauges froa 0000 to 03I1F. I{hat utlrabers are found ln locatl-oos
whgre there is oo physlcal uenory?
3. Data Eatry:
Go to address O0OO. Put KIII into the data entry node by pressJng the
To go co the
DA key.
Press varLous keye and obsenre the display,
aext address, press *.
For practLce enter the followLng data lnto
the KIM-I memory:
address
data
0000
0001
0002
0003
00
01
02
03
3-1
Routine
MrcRopRocE S S oR coDI NG S HE E T
I"ABEL
A2
0001
04
0042
8A
0003
48
0004
A9
0005
62
0006
8D
0007
47
0008
L7
0009
20
000A
t9
0008
1F
000c
2c
000D
47
0008
L7
000F
L0
0010
F8
0011
68
0012
AA
0013
ca,
o014
DO
0015
EC
00L6
E6
0017
rA
0018
DO
0019
E6
001A
E6
0018
FB
001C
DO
00lD
E2
GENERAL COMMENTS1
3-2
COI&i1I{TS
PAGE
oF
5. Progr:m Execut.ion:
Go to the beginning of rhe progrrTq using rhe AD mode (address 0000).
Press the G key.
The address display will count up and the data
display will show the contents of each memory location.
To stop
the program and return t.o the KrM monitor,
press RS. This program
is written
as a loop and will run forever.
6. Opti.onal- Experiment:
select one of the game programs in the lj.terature
package and load
and run i.t.
Lunar Lander, Horserace, and Kj.maze are reasonably short.
ilGERII(ENT 2
Parallel
Dara Inpur
and Output
(red )
(black)
Experlmental
tr f'L
l -t
wl
3-3
Breadboard
.i t{st:i f
pi ,Jt{
i )6.r
+r{f
-;,.0t-
=
=
=
=
=
=
=
=
piu
pin
pin
pln
pin
pin
pin
pia
9
10
1l
J.2
13
14
15
16
to
to
to
to
ro
to
ro
to
lines
IA
IB
IC
ID
IE
IF
IG
IE
Use 6 sires
to connect the KIM PB ioput/output
switches and pulsers on the LR-25.
Connect:
pBQ =
pB1 =
pBZ =
pB3 =
pB4 =
pB5 =
ac
PB7
pin
ptn
pin
pin
pin
pi:r
pin
plu
I
2
3
4
5
5
7
8
to the I LED
to SA
ro SB
to SC
to SD
ro pt (0)
ro p2 (0)
used in interrupt
ro 61[D
llnes
to the
e:cp.
)-4
.. ,,i*
D8
M
I'F
8E
01
17
20
64
1F
8D
00
CLD
LDX//
$FF
STX@
$01
$17
JSR@
$6A
$1F
STAC
$00
call
oooB 17 $rz
000F
00L0
001L
0012
0013
0014
0015
0016
0017
0018
49
01
8D
IB
00
A'9
02
8D
FA
00
A9
100L9
. I 001A 03
{n I 00tB 8D
LDLII
$01
STA@
$TN
$00
LDA#
$02
STA@
$FA
$00
LDAI/I
$03
STA@
load first
store lt
number
ln left
display
dispJ-ay
in niddle
nr.rober
1rr rlght
dtsplay
[ooro
00
$00
I 0018 20 JSR@
' 001F lF $rr
lF $rr
-*'0920
'0 0 2 L 4C JMPG
lE
v''r
^i *,-'O022
oo23 00
call
dlsplay
routine
$18
$00
3-5
routlne
agaln
Note that
begtnnfug
Prograo.
project,
you rnright like
As a final
to 1lnk the keyboard
eatry program with the display
outpr.tt progrso so that the
hex key codes are displayed
in the righE hand displays.
Eow would the prognms given need to be nodifled?
Try
it and see what you can do.
EXPERIMENT3
'
"
Cootrolliag
ExternaL
Deviees
3-6
,,
DNT
'.AFFFF
3
f
( 1)
( 1)
( 0)
Nc
AGITAIOR
FILLii2
FILL#1
DMIN VALVE
Let SA = Level,
P2 = Stop.
A],ARIY
6 ItE.\TrR
4 nne
SB = Teup., SC = Drain,
SD = Ileat,
Pl = Start,
,l
"ir
\
r^rU
\v
|t
,-
.,
,l
j
l
tt\
tDA/l
STAG
LDAG
oM/l
STAG
LDAG
LD
2L
24
26
29
2C
2E
all
O c ' -'
(^i/1t \ (\v --
devices
$00
$1700
$1700 get outPut status
turn on coffee pot
$40
$1700
$1700 set status
A{
g*
Arr
{81
Se
turn off
, - ,,r '
( , ;o "
:.
li
t,.
ft'
t ,i:
I;-
bn ptni!r*
li)
co si,uulate
ff you want to have a program run just oncer You must end it
This can be
to the KIM monitor.
with a command to return
your Program with:
JMP@ $1C4f'.
done by terminating
.l
3-7
D\
.j:,
\D
oo
-'
E)(PERIMENT4
Countlng
1. Counting Loops:
The following
example shows how to set up a cotrnter (bere the
X register)
to a1low executioa of a progta'n segnent for some
preselected nunber of tlmes.
We eould Just as easily used the
accumulator,
the Y register
or any r/w moory locatiou
as a
couDter.
COUNT
LOOP
DONE
LI)A#
srA@
tDA/l
srAG
LDX/
INCG
DEX
BNEr
JMPG
establish PA aa output
$l'f
$1701
turn off all LED's
$00
$1700
SOe load cormter wLrh 10,
^
$1700 iocremeat rhe ourpurrflort
decrement the cor:nter
LoOP if cor"rater not zera. jr:mp to loop
$1C4F return ro rhe moniror
f { m ing
Change the
Loops:
LOOP
cycles
t"Dxlif $64
DEX
Bl{Er LOOP
2
2
3
aQ
)-v
Tjoe
Delay
:ii::r.:i:,
Test
Program
START
tDA/l
w:tth
Subroutine
$ff
.LsrAG $1701
{
LDA/I $00
I SUOW STAG $1700
n
CLC
clear
$D,9Jf,".,$Or
add 1 to A
rS
JMPG SHOW
16 ogtav
LDY# $ce
i., i$ LOOPY tDX/l $62"
STXZ $l'51' srr
iF
sii "i LOOPX DEX_9 o , * 'd
'
't'BNEr.',1L0OPX
'1,*.,-o
. DEY
LS
't"i
BNEt''{LOOpy
?-:
RTS.
The total
tiue
clear A
look at A
delay
here ls
carry
before
add
return
TD = 5Ty( Tx + 2 ) + L4
microsec.
The Interval
Timer
Tlor
$L704 1 USEC
$1705 8 USEC
$L706 64 USEC
$1707 I nSEC
3-9
(X)
Delay
$64
$64
$64
$64
100 uSEC
800 uSEC
6400 uSEC
100 nSEC
l-.
'
:., :
.j.
Interval
Timer Subroutl::e
INTDLY PEA
LDX/I
SIXG
WAIT
LDAG
BEQr
PI,A
DONE
RTS
ratlo
H(PERIMENT 6
Interrupts
1. The interval
tiuer can be prograurned to interrupt
the KIM-I system
every nnn machine cycles.
In this experiment we are going to generate
an interrupt
every 0.2 eec and uee ttili-s interrupt
to run a progrs:l
which will
increment the PA output port"
You shouLd run a ualn
progtam which does not use the PA port.
flre g,ane prograrus, or Ehe
display routine used in experiment 1 are good for this purpose.
Here is the interrupt
routine:
Interval
Timer Interrupt
1780
1781
1783
L786
1788
1788
178E
PHA
tDAil
STAG
rDAti
STAG
INCG
Pl"A
1-78F RTI
Program
$Ce
$170f
$FF
$1701
$1700
save A
ioad A wirh 2001n
Load tiner and 3Et aiviae rarlo
ro L{t24
froo
interrupt
We put this program in one of the enoall blocks of t/w Eemory not
used by Bost programs.
Set the IRQ interrupt
veetor to polnt tc
the above routine by storing the entry addrese in $17FE and $17FF
( store 980 in $17fE and $17 ln $17FF ).
You nnrst connect the
the lnterval
timer output slgnal to the IRQ lnput l.lne.
This le
acconpllshed as follows.
Attach a Bpare 22 pLn edge connector to
the expansion Lines on the KIM-I board.
Connect the orange clip
to the IRQ input (pin 4).
Connect a- ihort jr:mper between pins
7 and 8 of the dip plug.
Make sure PB7 is prograrnmed as an lnput
line eveo though it is used to send the tlmer signal out to IRQ.
After a system reset (RS key used) you mrst enable the lntervaL
timer interrupt
capabiLlty by readlng location $170E once. this
can be dcne manually uslng thc KII{ keyboarci.
You are now ready
to run'your rrrain Program. You shctrld obeerve noruel Program
executlon and apparently
simultaneous lncrementing of the PA
Be sure the processor atalcs wlth the interrupt
output lndlcat,ors.
enabled by storing
$00 in locatioa S00F1 befc're running the program.
TI{IS PBOGRAUWILI NOT T"TIIICTIONUNI,SS$ YOU REI'{OVETHE GNO$NDWIAE FRO},I
TT-6
' rrD rr
parrE' sTBurErraf aqf ur srofrsBdBc
sazrs fuaraJJTp EuTfrasur dq
Jo
.ooo0$
gurlrers-urergord,aqS ung
r(cuanba:y rof"TTTcso eqf rrpA
f"
'(t qd) ggg 1ndul ratunoc aqf of 3nd1no rofeTTTrso
{coTc SZ-g-I ar{l
'(r-g 'dxa u1 euop sB ? urd roleauuoc uo;suedxa o1 drlc
fJauuog
a8uBro aqf
pue g pu" Z suld .:adun.f) bUf ol /gd fcauuoc .f; peol
1ooq
arnfBrafTl
'atalced
:no{ u1 urarSo:d ra3unoS dcuanbarg aq1 dn qool
ralunoC dcuanba:g
:luau-:.radxg 1euo11dg .Z
sIctASolcvJuSINtoNv3t901
Latches,
&rffers,
ThEr
systems.
Condltloners.
ls tnportat
lt
borl'edge
taput or outlmt
ttUt ls greater
references
or Negatlve)
,.s stsnt
synbol
absence of thls
sig[a,L,
L@IC.
clrcle
the
eate ta ladlcate
lndlcatps
a loglcal-
IPI{-ItsUE or II&ATIVD-TRUB
ndn
and logleal-
(PoeXtlve
a xJ'tr or
elllre
and a logJcal
a loglcal
ar\y one
Tberefore,
stats,
Js greater
systan.
nlnber
s trgltt. Norrnally,
thls
operates tn tb btnary
loglc
lead tcrrch-
a LOU-TRUEfnprut/oaq)ut.
The
a HIGH-BIIE lrput/output.
fl
PGITTYE IOCIC
INPUT
NUiAITVE I'GIC
I![PUT
HIGH-IIR,{IEINPUT GATES
-
a_/
l-
aND
_{-\
gate
hput
LOI{-IRUEINPUTOAIEI
___<{-\
lc,--
NAIrD4*/
-_/
L.1- 1
___-ol--,
br-
AtrD 4_/
l-
NAI{D
.0n ogll,anatJo
I.
gates folLlons:
}ION-IIffERTINGBUFFER
TblE devl,ce l^s used prlnarlly
capabdlltles
alrry:
of aotbr
dsvtce.
dwlce rllJ.
INSIICY:
ff.
rr{gh lnput
&s srlth closed represeots
"
The srltch opeo represents a Low
laput
lrgh
the lar;> on rslreseots a
oulnrt
the lary of,f retrnreseots a J.owout4nrt
A e -
Inptrt
otttput
t?INE T.ABI,E;
A
BOOI,EAN
EQUATION:
a .e
II.
ffYERTIIffi MT'SER
Tbls.devLce ls used prlnarJty
ollut
lts
alrrys
Tbe
to
lnpet.
IITAI,OGT:
lbe erltcb cloaed repreeots a hlgh lapnt
The erttch open rqreamts
a 1or lnpnt
Tbe J.arp oB represelats a hrgin @Ulut
lbe 14l off rqrresente a lor output
Cl.osbg tbe srltch siA[ short
out tb 3'ap and turn Xt off .
Opltfug thc srltch rLLL rmove
the abmt end turlu on tJo IaP.
l'
I.OGIC $$TBOI,:
-
A+e
A -
Ilput
A - arEut
ths smet]. clrcJ.e at tb end of tbe
ate tadlcates outErt lsversis"
lnu$t tABLEl
-
POoLEailE@AITON:
A iE'
??.F
III.
IND
I srritch
A srLtch
Ttre J.ap
Xhe 1op
lr'1-3
l&B
- INPUS!
- 0Ut?Ul
IAI]TE TABT,E:
-
B0oLEArEQITA?ION!
lo
IY.
B s
U.OI{D
thls dwl,ce ls used the sae es t&s .A![D,ercept tbe ortput
ls LOtf-IRlIE.
INAIOGI:
4 srttcb
A sritch
l&e ]'ap
lhe J'ap
tt@ bot&
ebort out
If elths
short rILt
3.fubtm.
IPGIC SIMBOI:
a&8
- Iuprts
- Artlnrt
I3IN[ ?TBT.E:
-
L.1-L
EQU48S:
BO0r.E0s,
?EE'
Ao
VO OR
Sls
hlgho
lte o,$nrt
ls
ls EIDH-$UE.
A srrttrh
A snttph
&e 1ry
lte lap
rocrcs4agr:
A&B
e
IRUM TABI,E:
-
't
EOOI,EAII
E@IUTION:
A+Bte
b.t-5
- IEPute
- 0utpt
VI.
NOR
ltls
sutlnt
dnlae ls used for the sae Itulpose as the 0R gatee ercept tho
ls l0tf-ffiIE.
4{4'
A sttttcb closed relnesotg
At
Closbg of
sbrts ouf
offc Botb
to ADta o
Bt
,f1 C
lte laP
eB lu1l
ql rqlresots
e rrgh ottrrt
off relneseots a lcr ootput
IPGIC SIilBOL:
BINH TA8L8:
A
F@ATION:
BOOI.EAI{
A
a h{gh lnprt
l+.1-6
EE
A & B
Irytrts
OutErt
VII.
EKCLItsIgg -
OR
ls ECiH-tRtIEo
a{3rpcr:
!^
Fc tbe 14l
to be q,r qre srltch
urst be ln tbe n3.'t trnsltton
and oe
Oth,ff_
n1gt be ln tba r/n positJono
rlse, tb f-ql rlAL be of,fo
IOGIC SI!{BOL:
A&B
- Inputc
- Ortput
18,I'THTABI,E:
BOOI,EAI{EQIIATION:
a (DB.
aE+ - . ln r e
lr.1-7
VIII.
EICLIBM-NOB
lbls dwlcs Ls tne saFe as tbe EXCIJIIfIE-OB gatet ercept tbe Eutput
ls LOI|-IUIE.
IN.EIOGT:
I srrttch tlr tha rln posltdCIa relreeots
g h{gh
fDp11t
,lr:" ..
- lnputs
A&
IRUB TIBI,E:
- Output
EOOTE/IT
&IUATTON:
A @ B .A F+ T B : 0
I]T.
DT.CSCI'SSIOII
OF IPW-IRI'E IOGIC
lbe peceedbg
gatee rl,ti
I.C.rs
LOt{ e NE}ASM-$IIE
epeclf,lca{y
fuputse
lr.1-8
of tbe inrth
NOIE: b
of
nlr
b
r*,rlatlors}rt5s:
tne
nlrt
e
L4,
HIDH-lRllE INPUT
HIGH-BIIE .eilD
ISTf-TEIIEINPUT
trOtf-IRIIE 0B
LOLJ-lfgtB ggi
HIOH-IRIIE N.0ND
?
E
fl
lr.1-9
HIIIH-BIIE
OB
IOtf-lBIIE
AIID
IIW-tRIIE NIilD
HIDE-IBIIE NOB
lr.1-10
p(.
Lri
.j!
-4
:, !
:",' )
ai r
ELIP-ff[O-PSr
ffi
I.
{i
8"8 LAICE.
the n S, latcb
rat
probably
the flrst
t3pe of ft$-flop
enrc tnrflte
( n - R e s e t & S =$ e t)o
1*l 1*
]' lo
o ll
Itilort dlmd
lb mks tee 8 lafnh tato a ctocked (Ltptlepr
addedo
II.
ls tha slqfleet
of t&e f,Llgrf,lqrc
B
e e
NO,]HTM}I
o I
0
I
1*
1*
xt{ot altmed
tha addlilpn of ths bto NAIIDgates rrlt& t&e clock latrlt cbsses lt
lato a ctocked n S fljp-tXopc
&ange tbe
lr.2-1
tu
rrr.
for
a data latch,
D
CIOCK
rv.
can be made
It
at a given instant
be effectively
registers.
an
6'tt
V.
ft can
WHERE:
Qn = value
of Q during
previ.ous
clock eycle.
It
can be effectively
1
I
U
Therefore, tb
1
I
is held high.
It,2-2
DECODERS:
Tbese devices are most comrorrly used for address decodlng.
llrery are
conffuuratiqr.
For sinpl5.city,
a 2-1jne to lr-llne
decoder ls
sbffla belov:
.H
DUJIIILTIPLF.XTnS
:
these gats are the same as a decoder, except tbe NAIiD gates have an
addltlqra.l
lnprrt
for
data.
lhis
devlce
eeparates
serial
to separate Llnes.
B
ENcopEvur&rrPrFm$
EIICODEFS:
Ibese devices
Llrres.
several
lnputs
lnto
a few encoded
sritches.
I
MULTIPLETffi r
l0rltiplexorc
or Data $electors
h.lr-t
llne.
these
o
x
x
x
x
x
x
x
x
x
x
T
0
T
o
T
z-1'1
SEV9 frll00 =
x
x
ec
x
x
x
x
x
x
x
x
x
x
T
x
x
T
0
9c
TC
T
T
0
0
T
T
o
o
T
T
T
T
0
o
o
o
]NTERFACEDEYICES
OPE}I-COLI,ECTOR
INGIO
There are severaL instances where a large multiple
is needed.
a single
into
anottrer gate.
Therefore,
if
was hlghl
nhile
prevail
to 0R several iaterrupts
is to create a
BUT, this
outprt
inpui
just
any logic
together
finally
input oR gate
together.
gate.
The
pull-dolrn.
and one output
to make itrs
transistors
of one of the
The inte:nal
differenees
is 0PEN-C0r.T.trCTOR
circuits
is shomn
below:
STA}IDANDTTL
OUTPUTDRTVEA,
OPEN-COII,ECTOR
OUTPUTDRTVER
Vsc
Vcc
EXIERNAL
PUil-UP
RESISTOR
0ulPuT
OUTFUT
l+.5-t
NOIE:
The open-collector
active
nor passive).
to its
outpu.t to grotnd.
logic
has no inter4:]
Therefore,
to another gate.
resistor
Therefore,
is caleulated by:
2 .6 \D \1 r.5
(neither
what is attacbed
But their
device
pull-up
5' ."
isE;
W}ERE:
I1X
IS
sinking capaliU.ty
of
The lowest mocimrln ctrrent
any of the gates forming the WIRED-0Rwben its
output is 1or.
TRI.STATE I.OGIC
Il
systeua,to another is done via the DA?A BUS. In a large number of systemsl
the number of devices attached
capa.bi'lities
it.
Ttrerefore,
the sectious
of the system to
intellegent
commrnications,
Therefore,
on
discorurect al'l but the section ttrat has been enabled by the processor.
b.5-2
But a large
nr:rnber of devices
This is referenced
output that
to as tbee-state
IOhI-TRUEETIABI.ES
I+.5-3
states
(high or lon)
-
(higb,
or TRI-STATE 1ogic.
1ow,
The
like
will
their
off-staie.
commonllne
withcut
is enabled to output
outputs go to a high-inpedance or
devices caa be attached to a
unwanted interaction
-uo that
line
BUS TBA}ISCETVERS
lhe TRI-STATE devices that have been di-scussed are essential
to one-way cornmunications to a bus, BUT, the processor and a number
of other derrices are by-directional
directions
strapped together
two IRI-STATE
of communlcations (tr't
interfacing
If
this
is attached.
(j.rrput to output)
line.
There
the fC to
data bus or
the connection.
IN/OUT
make
sy|l3lgoud
3uv,l,uJos
oNtzlvNV
ANALYZING
SOFTUARE
PROBLEMS
I N T R OD U C T ION
T h e o bi e ct o f th i s ch a p te r ;s to pr esent a gener al pr ocedur eused to
d e s i g n so ftw a re to so l ve a pr ob' lem. This pr ocedur eis com pletelymac h'i ne
i n d e p e n d e n t,a n d 'i t ca n b e applied to any softwar e pr oblem syou ar e l .i k el y
t o e n co u n te r. T h e mo st i mpor tant thing to r eme+ nber
about this pr ocedur e
i s t h a t yo u d o n o t co n ce rnyounself with the pr ogr ar nming
languagede tai l s
u n t i l we l l i n to th e so l u ti on. This is tr ue of even the seemingly"tri v i al "
p r o g r a ms. T h e re i s n o w a ym or ecer tain to r esult in a pr ogr amthat is
s l o p p y' i l l -d e si g n e d , a n d har d to debugthan to tr y to wr ite the pr ogr am
d i r e c t l y fro m th e p ro b 'l e mdefinition. To be effective softwar emust be
d e s i g ne dfi rst a n d th e n i mplem ented
using the cor r ect techniques.
5 . 0 Th e S o ftw a re Oe si o nP rocedur e
T h e s yste ma ti c a p p ro a chto developinga pr ogr ar lnedsystemis a logica l
e x t e n s i o n o f th e n o rma l p roblemsolving cycle engineer sand scientists
h a v e e mp l o ye dfo r ye a rs. It consists of seven basic steps:
1.
p ro b l e md e fi n i ti o n,
2.
3.
4.
6.
d e b u g g i n ge a ch p rogr am,
i n te g ra ti n g th e pr ogr amsback into the system ,and
7.
fi n a l syste md e b ug.
5.
5-t
5-e
I'IAJOR
SYSTEM
ELOCK
SYSTEI'I
SUB-BLOCK
sYsTEt'l
SUB.BLOCK
SYSTEM
SUB-BLOCK
DEVELOP
ALGORITHM
II{TERFACE
ANDDEBUG
MAJOR
SYSTEI'I
BLOCK
FIGURE5"1 GENEML
PROBLEM
SOLUTION
PROCESS
)^
5-J
2.
3.
5-5
5-6
READ
=+
ADVANCE
TAPF
-->
READ/WRITE
II
ENDOF TAPE
WRITE
_>
TRANSFER
+-
D A T A (S )
+-
READY
..+
ADVANCE
TAPE
-..-> READ/WRITE
<_- ENDOF TAPE
HIGHIF PROTECTED
I.JRITEPROTECT
LOI,JIF ENABLED
1
DATA
TRANSFER
<--
READY
_->
ADVANCE
TAPE
ENDOF TAPE
<--
ENDOF TAPE
FIGURE5.2
TAPEDECKTIMINGIJAVEFORMS
t.n
i s the s pe c if ic a t io nf o r a n I / 0 d r iv e r r o u t in e . A ll a n
Th ea b ov eex ampl e
I/0 driver does is control the transfer of data betweenthe cqnputerand
an I/0 device. Notethat the specificationmakesno mentionof the requirements
for initialization of the tape drive, howthe data is to be
formatted,etc. This is because
an I/0 driver is strictly concerned
with
transferringdata to or from the device it interfaces. It is the responsibility of those progranswhichutilize an I/0 driver to interpret the data
and signals returned. A complete
tape I/0 systemwhichwill use this
d r i ve r w i l l be di s c us s edi n L e s s o n7 .
l e c if ic a t io n
1 1 .2 Us i ngthe Fungti onaSp
Thefunctional specificationis the baseuponwhichyou will build your
system. If it has beenproperlydesigned,it will supportand guide the
rest of your problemsolvingeffort. lfit has not beenproperlydesigned,
your project is probablydoomed
to failure or overrunbeforeyou evenget
started. Therefoie,onceyou haveestablisheda functional specification,
use it. If you don't, you are apt to run into that dreadedsoftware
or
whenan inadequate
diseaseknownas "creepingfeatures". This happens
disregardedproblemspecificationallows non-specified"neat" featuresto
creepinto the systgnafter rrprkhas begun. This can be disastrous,bein the planningstage can require massive
causechangeseasily ac@rmodated
stage. Usually, the
effort and re-designmrk during the implerilentation
farther work has progressed,the moreeffort is required to makeany sigbefore detectedand
nificant changes. Thediseaseis often well advanced
it can be fatal to eventhe best softwareprojects. (Professionalengineers
are notoriouscarriers of this disease. l,lhile
note: marketingdeparfinents
they are knownto infect entire departments.)
they seldomshowany syrnptoms,
features
Theabovecorrnentsshouldnot be construedto meanthat advanced
makesthese
are to be shunnedor omitted. Far from it. Themicrocomputer
featuresboth possibleandattainable. blhatis meantis that they should
be deslgnedin from the top, not addedfrom the side. Therefore,whenyou
designyour functional specifications,take sometime. Brainstormfor a
whi'leand comeup with a list of featuresthat the systemcan really accomplish. Try trading off somehardware
and softwareto lowercost or increase
D e ci d i n g o n th e S ystemBlocks
T h e d e c i si o n o f w h a t b l o cks to divide the systeminto initially is usua'l l y
m a d eb y r.e fe r.ri n gto th e ch ar acter istics defined in the functional spec i fication.
S o mecg mmoinn i ti a l
blocks ar e:
1-9
b.
i n p u t o p e ra ti o n s,
pro g ra mfu n cti o n s (transfer data, sear chmsnor y,do ar ithm etic,
etc. ) ,
c.
d.
o u tp u t o p e ra ti o n , a n d
ma j o r d a ta stru ctu re s ( tables, lists,
a.
e.
etc.) .
5-ro
TAPEDATAIN
ENDOFTAPE
WRITEPROTECT
READY
TAPEADVANCE
TRANSFER
DATA
DATA INPUT
TIM ING
AND
CONTROL
DATAOUTPUT
ERRORINDICATOE
DATAFROMSYSTEM
FIGURE
TAqEt/0 BLoCK
DIAGRAI1
5.3a MAGNETIC
DATAIHPUT
END
OF
INTERFACE
ENDOF TAPESTATUS
TAPEOETECT
TAPEADVANCE
TAPEADVANCE
CONTROL
READ/t.IRITE
SELECT
DATAOUTPUT
INTERFACE
WRITEPROTECT
TRANSFER
DATA
READY:
FIGURE
SUB-BLOCK
5.3b TIMII{GANOCONTROL
DIAGRAI'I
F T G URE
5.3
5-u
5-t2
others.
T yp e o f F l o w ch a rts
F l o w c ha rtsca n b e d ra w nto r epr esent algor ithm s at any desir ed level of
c o m p l exi ty. T h e tw o mo st cor mnonly
used types of flowchar t ar e the log i c
f l o w c h a rt a n d th e ma ch i n e -dep.endent
flowchar t. A logic flowchar t r epr es e n t s a l g o ri tl m l o g i c i n g ener al oper ating ter m s with no r efer ence to
s p e c i f ic ma ch i n efe a tu re s (r egister s, memor y,flags, etc.) . The m achi ne
d e p e n d e n fl
t o w ch a rt p re se n ts algor ithm logic within the context of the
to
f e a t u r e s p ro vi d e d b y so mespecific pr ocessor . It is advantageous
i n i t i a l l y d ra w a l o g i c fl o w c har :tfor each functional block in the bloc k
d i a g r a m. T h e sea re th e n th or oughlydebuggedand used as the basis for the
m a c h i n ed e p e n d e n tfl o w ch a rts r equir ed for the com puteryou ar e usin9.
I f y o u p ro g ra mi n h i g h e r l e vel languages,you will har dly ever use m ac hi ne
d e p e n de n fl
t o w ch a rts. T h e l ogic flowchar ts r equir ed to define the alg or i t l r n t o b e g se d a re a l l th at ar e r equir ed. This is becauseall of the
m a . c h i n de e p e n d e n d
t e ta i l s w ill be handledby the languagepr ocessor .
5-L3
SYMBOLS
EXAI-IPLES
PROGRAH
FLOW. ARROWS
INDICATE
SEQUENCE
THATTHE PROGRAH
FOLLO}JS.
P R OC ESS.
THEFUNCTION
SPECIT:IED
IN THERECTANGLE
IS TO BE PER.
F 0 R ME D,
e.9. A IS T0 BE MULIP L IE DB Y 2
A=AX2
P R E .D EFINED
PROCESS.
THEEXTERNALROUTINE
DEFINED
BY THENAIIIE
Ii'I THERECTANGLE
IS TO BT IIIVOKED
T 0 P E R F0RI4
ITS FUNCTI0N.e.9. THE
ROUTINE
DEFINED
BY THENAME
''TTI''
IS TO PERFORM
A FUNC'IION.
CALLTTI
A=A+ 1
OF THEPROGMI4
DECISIOI{. THEFLOI.J
I.IILLBE BASED
ONTHECONDITION
S P E C I F IEIN
D S ID ET H ED IA MONO.
=
e . g . I F A ? , A D Dl . 0 T H ERTJISE
AD D2 .
A=A+ ?
I/O OPERATION.
THEINPUTOR
OUTPUT
OPEMTION
INDICATEO
IN THE
PARALLELOGRAM
IS TO BE PERFORI4ED,
e.g. THEVALUE
0F THEVARIABLE
IIAIIIS TO 8E SENTTO AII OUTPUT
D E V IC E.
PRINTA
TERI''IINAL
OR INTERRUPT.THEOVAL
INDICATES
T}IEBEGINI{ING
OREI{DOF
EIITERTTI
A PROGMI'I
ORAN INTERRUPT
OPERA.
,.TTI" .
T I0 tl , e .9. TNTRY
P0INTFORR0UTINE
\.-/
\,/
I.IHET.I
FLOI.II,IIJST
PROCEED
CONNECTORS.
TO ANOTHER
PAGE
PLACE
0R ANoTHER
0N THESME PAGE,USEA
coNNEcr0R
IF IT Is AltKt{ARD
T0 usEANARR0IJ.
FiGURE5.4
FLOI.J
CHART
SYIIBOI.S
2.
J.
5.
Ke e pth e stru ctu re si mple. Hakeit a goal to keep the flow str aightf o r w a rd , l o g i ca l a n d cl ear . Be par ticular ly car eful about howyou
e n te r a n d e xi t fro m th e r outines. Ther e ar e r eally only a few sim pl e
s t r u ctu re s yo u sh o u l d ever need to use in constr uction of any algor i thm .
W ew i 'l l e xa mi n eth e se str uctur es in the next few lessons.
5-l.6
Ex a m p l e5 .3
L e t ' s d e ve l o p th e a l g o ri th ms r equ' ir ed for our magnetjctape dr ive
i n t e r f ace syste mu se d i n Exam ples
5.r andS.z. The fir st thing
t h a t be co me as p p a re n t i s that the data input and output blocks ar e
v e r y l arg e b l o cks a n d ve ry sm all pr ogr ams. The data is to pass
t h r o u gh th e ro u ti n e i n p a rallel without being m odified. Thus the
f l o w c h a rts fo r th o se b l o ck s would be simply one block each:
INPUT DATAFROMTAPEDECK
OUTPUTDATATO TAPEDECK
5-L7
EilTER
TAPEREAE
AEVANEE
TAPE
INPUT
TAPEilECK
STATUS
SET ERROR
INDICATOR
OUTPUT
TRAilISFER
SI6NAL
I}IPUT
TAPEDECK
STATUS
DATARFADY
l
F IGU R5E.5 T APEDECKREADLOGICFL0l'CHART
INPUT
TAPE
STATUS
PROTECT
SET ERROR
INDICATOR
FERSIGNAL
I NPUT
TAPE
STATUS
F IGU R5E.6
CHART
LOGICFLOt,l
T APEW RITE
5 . 4 O b j e c ti o n s to F l o w ch a rts
l' l e h a v e b e en u si n g (a n d w i I I co ntinue to use) flowchants to r epr eseni the
a l g o r i t h m s we h a ved e ve 'l o p e d . This pr ocedur eis not univer sally accepted ,
p a r t i c u l a r l y i n th e d a ta p ro ce s singindustr y. cr itics maintain, with a
c e r t a i n a m ou n to f i u sti fi ca ti o n , that flowchar ts ar e unnecessar and
y
even
m i s l e a d i n g . T h i s p o si ti o n a ri se s fr om the basic contention that ( 1) flowch a r t s a r e o n l y ma rg i n a l l y u se ful in higher level languagepr ogr amdevelopm e n t s a n d ( 2 ) co mp l e xfl o w ch a rts can become
ver y difficult to follow. To
su p p o r t t h i s p o si ti o n th e y ci te ver y valid evidencethat m ost pr ofessional
p r o g r a l m e r sd ra w o n l y ve ry l fmi ted flowchar ts pnior to com m encing
coding.
I n f a c t , m ost fl o w ch a rts fo r l a rge systemsar e dr awnfor documentation
p u r p o s e sa f te r th e p ro g ra mi s co mplete. This situation ar ises fr om the
f a c t t h a t w h e nw ri ti n g p ro g ra msin moder nhigher levei languages,a' lgor ith m s
c a n b e e f f i c i e n tl y d e ve l o p e dd i rectly in the languagewith no inter m ediate
f lo w c h a r t s at a l l .
T o a n s w e rt h e se a rg u me n ts(w h i ch we r eally basicaily agr ee with) , we must
po i n t t o t t t o b a si c fa cts: (1 ) satisfactor y higher level languagesar e
no t y e t g e n era l l y a va i l a b l e fo r rnicr ocom puter s,
and ( 2) m ost pr ogr ar m er s
d e v e l o p i n gmi cro co mp u tepr ro g ra m sar e not pr ofessional pr ogr amner s. The
c o n t e n t i o n t h a t p o o rl y stru ctu re d flowchar ts ar e har d to follow is comp l e t e l y t r u e . Wew i l l a l w a ysg o to gr eat lengths to keep flowchar t logic
s t r u c t u r e c l e a r.
Th e f i r s t
5-20
s u c h th a t a kn o w l e d g e
o f assemblylanguagewill still be r equ.ir ed. H .i gher
l e v e l l a n g u a g e sa re o n T y mar g' inallyeffective in
developingpr ogr amsfor
u s e i n co n tro l o r re a l ti m e app' lfcations. Pr ogr am sof
this type r equi r e
t h e co mp l e teco n tro J o f the computer ' shar dwar ethat assembly
langu age
p r o v i d e s. F o r a sse mb l y'l anguagBr
us of the flowchar t pr ovides a ps eudo
h i g h e r l e ve l l a n g u a g efo r algor ithm deveiopm entthat can
be either dependent
o r i n d e p e n d e not f th e co mputerto be used. ( L,lewill
havem uchmor eon
t h e h i g h e r l e ve i -a sse mb l ylanguagetr adeoffs .in l_esson9. )
T h a t mo st mi cro co mp u tepr rogr amm erar
s e not pr ofessjonal pr ogr am m erjss
a i s o fa i rl y o b vi o u s. Mo s t cur r ent m icr ocomputer
pr ogr ar ,r nerar
s e ' logi c
d e s i g n e rsa n d h o b b yi sts, n lanypr ' ugr ar r nr r ir
g ,Lhe !"ir .st,tim e. Sinc e they
f-ror
w i l I p ro b a b l y b e fo rce d to use assem btylanguage,these user s yu' ilI b e
l e a r n in g p ro g ra mmi n ga, i g or itir n developm ent,and m achjnestr uctur e a l l at
t h e s ameti me . T h e u se o f, assemblylanguagepr ogr anr ning
and flowchar ts
w i l l en a b l e u s to se p a ra te these jear ning activities.
In par ticu' lar, the
i n i t i a l p ro ce sso f te a ch i ng gener al algor ithm developmentis better pr es e n t e d w i th g e n e ra 'lfl o w char ts than with som especific language. The
t e c h n i q u e sp re se n te du si n g somespecific languaEem ay r eflect the com pr om i s e s ma d eb y th e l a n g u a g er ather than those r equ' ir ed to sclve the p r obl em .
Af t e r s o mei n i ti a l a 'l g o ri thmdeve' lopr nent
tr aining, the user m ay be a bi e
t o p r o ce e dto fl o w ch a rt free higher level languagepr ogr am m ing. For that
i n i t i a l tra i n i n g , h o w e ve r,the iogic flowchar t is an im por tant teach i ng
tool.
T o m a kema xi mu m
u se o f fl o wchar ts without becom ingunduiy attached to
t h e m w e w i l l a d o p t a ca re fully str uctur ed appr oach. Ali a' lgor ithm sw i l l
b e p r e se n te di n g e n e ra l l o g ic flowchar ts. l,{ ewill not use m achinedepend e n t f l o w ch a rts e xce p t i n the contexi of specific exam ples. All flowc har t
s t r u c t u re s w i l l b e ch o se nfrom a sr nall gr oup of simple, 1og' icall.ysuffi c i e n t stru ctu re s w h o seu se can be djr ectly tr ansfer r ed to m ost h' !gher
l e v e l l a n g u a g e s. i n th i s w ay we will makem axjmum
use of flowchar ts w hi l e
a v o i d i ng th e ma j o r o b j e cti o ns.
5-zt
(.5
5-22
QU E S T ION S
1.
2.
3.
D e scri b e " cre e p i n g featur est' . Haveyou ever seen it in actio n? W hat
w a s th e ca u se ? Whatwas the r esult?
4.
PROBLEI{S
1.
B =B * 2
B=A+1
2-
= t.
Thusthe Fibonacciseries can be representedas follows
N 01?34567
F(N ) 0 rL2 3 s 8 13 .
N
F ( N - 1 ) + F ( N- 2 )
5-U
l'lglSlq USrndHOCOUClltl
0I HCV0UddV
3UV/tA.ktOS/3UV,l
oUVHIHI
THEHARDWARE/SOFT}JARE
APPROACH
TO M ICROCOM PUTER
OESIGN
INTRODUCTION
I n th e co u rse o f d e si g n i ng a systemther e ar e a ser ies of cr ucial dec i s i ons
w h i ch mu st b e ma d ere g a r ding the u' ltimate systemim plementation. T hr ougho u t th e so ftw a re co u rse we ar e concer nedpr imar ily with the im plementati on
o f th e so ftw a re p o rti o n s of these systemsand how they inter act wi th av ai l a b ' l e h a rd w a re . T o b e su r e, this ar ea is vital to the designer . How ev er ,
t h e th o rn i e st p ro b l e mi n i tially confr onting m ost designer s of micr opr oc es s or
b a s edsyste msi s h o wto par tition the systemfunctions betweenhardw ar e
a n d so ftw a re i mp l e me n tatlons. This is under standablbsince r lost us er s ar e
f a r mo ree xp e ri e n ce dw i th har dwar edesign than softwar e design. How ev er ,
t h e p l a i n tru th i s th i s: within the speedlim its imposedby any com puter ,
a n y th i n g th a t ca n b e d o n e with har dwar ecan be done with softwar e. In fac t,
o n l y a sma l l p e rce n ta g eof applications will pr esent speedpr oblems .
U s u a l l y e ve n th e se a p p l i cations ar e only speedsensitive in ar eas w hi c h
c a n be re a d i l y i d e n ti fi e d and pr ocessedwith discr ete logic to m ak ethem
a d a pta b l eto a so ftw a re s olution. ice thus have a sliding scale of i m pl em e n ta ti o n p o ssi b i l i ti e s fr om applications with no softwar e ( i.e. no m i c r op r o c e sso r)to a p p l i ca ti o ns wher e 95%of the systemcost will be in the s oftw a r e . Gi ve n th i s w i d e ra nge of possibilities, howdo we decide wher eto
d r a w th e l i n e ? Wh e rei n deed. Assumingthat the objective is to do the
j o b a n d ma keso memo n e y,the answeris obvious: we dr aw the line a t the
point wherewe find the lowest cost hardware/softwaresystem that does
t h e jo b .
B e f o re w e cd n d i scu ss h o wto tr ade har dwar ecost for softwar e cost, w e
m u s t fi rst i d e n ti fy th e ar eas that affect cost in both of these ar eas .
F o r t h e p u rp o se so f d i scu ssion we shall consider cost to be localized i n
t h r e e a re a s: h a rd w a reco st, SOftwar ecost' and systemcost' After w e
h a v e d i scu sse dth e va ri o us cost ar eas we will be able to discuss tr adeoffs
r e q u ire d to mo d i fy syste mcost and per for mance.
6- 1
|l@-.
T h e r e a r e a l i mi te d n u mb e o
r f high speedm icr opr ocessor savailable, but
t h e s e a r e se ts o f d e vi ce s, n ot sing' le packagemicr opr ocessor s. They ar e
s o m e w h ahta rd e r to u se a n d co nsider ablym or e expensive. If you.begin to
u s e t h e s e yo u ma yd i sco ve r your cost r apidly exceedingthe cosflof som e
o t h e r f o r m o f l o g i c i mp l e me ntation. Also, high speedfor the CPUgener al l y
r e q u i r e s h i g h sp e e dme mo ri e s,inter face ' logic,andper ipher al devices,
f u r t h e r r a i si n g co sts.
6-2
anddynamig84F:.
Bead/writenelqry can be broadlydivided into static RAM
.a
a static memory
requires morea
me m o r o
y f si mi l a r si ze . S ta ti c m emor iesalso dissipate m or e powerper bit .
T h e l a r g e s t R A Mme mo ri e sa re , ther efor e, usual' ly dynam ic,at least initial l y .
A s t h e d e v ice te ch n o l o g yi mp ro v esthese lar ger m emor iesusual' ly then bec o m ea v a i l a b l e i n sta ti c fo rm.
T h e c o s t o f b o th sta ti c a n d d yn amicmemor ieshas declined and wil' l continu e
to d e c l i n e . T h i s co st i s b a se don the absolute cost per bit for a given
a m o u n to f s to ra g e . H o w e ve r,th e device or ganization and not this absolute
c o s t p e r b i t i s o fte n mo re i mp or tant in pr actical applications. In ter ms
oftea nrin'i{'J[*P-?g!qq-e---c-9u[!""91d
gas-eol.
tggglqe*y.$l_3ll.9"l1.ng:*-9,f,-"SM.
one
:y*g_tg!,g.t'3ce""ylll-1.
I3.'.':-..:.lTp"'!.!t.rhansheer
"vglyrye.Buv
b y e xp o si n gth e E R 0 M
to intense ultr aviolet light for a half hour or s o.
I n th i s w a y th e E R 0 Mcan
s be r e- used indefinitely. EROMs
ar e th e m os t
e x p e n si veL yp e o f R 0 M. Theyar e best used in development
wor k o r l ow
v o l u mep ro d u cti o n e g u ipnentwhich r equir e fr equent changesto the oper ati ng p ro g ra m.
A P R 0 Mi s a R Of'l
w h i ch comesfr om the manufactur erwith all locati ons as
o n e 's o r ze ro 's. It can then be pr ogr am m ed
by the user . Unlike an ER OM ,
however, once programmed
a PR0f'fcannot be erased. PR0l'lsare somewhat
l o w e r i n co st th a n E R Ol' ls.However ,fr equent pr ogr amchangescan qui c k l y
m a keth e mmo re e xp e n sive. Theyar e best used in pr oduction system sw hi c h
w i l l re q u l re fe w ch a n gesbut whosepr oduct' ionvolumedoes not jus ti fy a
maskprogrammed
ROM.
A mask programmed
R0l'lis fabricated by the manufacturerto contain the
d e si re d p ro g ra m. It i s neither field pr ogr amr nable
nor er asable. A R OM
i s o rd e re d b y se n d i n gthe ser niconductor
manufactur eryour pr oqr a m . T hey
t h e n g e n e ra te a cu sto mROMfr om your specification. The cost of R OM pr
s od u ce dth i s w a y i s th e l owest available. However ,the ssnicondu c torm anuf a c tu re rs ch a rg e a fl a t fee for the gener ation of the r equir ed mas k . T hi s
cost makesmask programmed
ROMs
cost effective only for those high volume
p r od u cts w h o sep ro g ra mwil' l never ( hopefully) r equir e change.
6 . 1.3 I/0 R e q u i !" e ments
I t i s ra p i d l y b e co mi n gappar entthat I/0 is the soft under belly o f m os t
microprocessorbased systems. Interfacing the microprocessorto the rest
of the system is always a requirement.
=
JE_fn-i_."rsp.r9cg9lgtg,*cgf.r-el!.U
. a va i l a b l e g e n e ra l l y p rovide only enoughinter face capability to di r ec tl y
j1. g{ out
?l! .!.r"9,.[9.].sJll.II3.e one normalTTt,device. This me.qns"!h,q"t
:l !rl.:*,_--Ti91oOrocesso.1
1u1t bg b.uffered, Further,control signalsmustbe
d e co d e d ,i n te rru p ts mu st be pr ocessed,data m ust be latched and h el d unti l
the processor or peripheral is ready to accept it, and manyother system
r e qu i re me n tsmu st b e met. All this falls within the r ealm of I/0.
6-s
6-B
0rqani za t io n
6 .2 .1 P roc es s or
Thearchitectureof the processoryou choosefor your systemcan havea
si g n i fi c ant effec t on y ou r s o f t wa r ec o s t s . T h is is f e lt p r im a r i1 yi n tw o
r ic his d e f ic ie n t in m e m o rad
and l /0. A p r o c e s s owh
a re as : memory
y d r e ssi n g m odes
w i l l requi re l ar g e r p r o g r a mtso a c c o m p listhh e s a m eio b as a
6- 10
Imp l e me n ta ti o nL a n quaqe
The level at which you develop your programshas its primary effect on
systemmemorysize and overa'll systemspeed. Programsdeve:lopedin higher
l e v e l l an g u a g e sw i l l g e n e rally be faster to develop, but they will tak e
more time to.execute and occupy from two to ten times more memorythan the
s a m ep ro g ra md o n e i n a sse mblylanguige. Assemblylanguagepr ogr am sc an
6. l1
SystemsCos_t
tgrdw.are
?esiS
A l l ti me a n d mo n e yspent designing and&buggingthe har dwar er equi r ed
t e sy stemhar dwar e.
to i mp l e me n th
2
S o ftw a reD e si q n
A l l ti me a n d mo n e yspent designing and debuggingthe pr ogr am s
re q u i re d fo r u se i n the system . This m ay include a s' ignificant
a mo u n to f e xp e n sefor timeshar ingcomputerusageif you do not
h a ve th e re q u i re d p r ogr amtr anslation facilities available in
h o use .
D e vq l o p me nTto o l s
T h i s i n cl u d e s a n -yspecial har dwar e( such as a m icr ocomputer
develognent systemor special test hardware)you have to buy
fo r d e b u g g i n ga n d checkingout the systemdesign. Som eof
th i s co st w l 'l l a ctu ally be spr eadout over al' l developments
w h i ch e n d u p b a se don the sam em icr opr ocessor .
D o cu me n ta ti o n
A l l co st sp e n t i n d evelopingthe user manuals,pr oduction
d o cu me n ts,re fe re n ce specificationsr dod other documents
e sse n ti a l to co n ve rting a wor king lab pr oiect into a viable
p ro d u ct. T h i s co st should not be under estimated. Thor ough
d o cu me n ta ti o nw i l l pr obably consume20- 25 per cent of your
d e ve l o p me nbt u d g e t. However ,it will be m oneywell spent as
yo u r p ro d u ct ma tu re sand r equir es changes.
Marketinq
T h i s i s th e co st i n cur r ed in taking your finished pr oduct
fro m th e l a b a n d p resenting it to the wor ld. This is not
u su a l l y a n e n g i n e e ringactivity.
6 . 3 . 2 Mo d i fi ca ti o n C o sts
0 n c e yo u h a ve a w o rki n g p r oduct, ther e is always the possibil ity th at y ou
w i l l w a n t to i ssu e a n e h ,' impr ovedver sion. T,lis is one ar ea where a
m i c r o p ro ce sso rb a se dsystemcan r eally save you time and money. In a
t o t a l h a rd w a resyste m,a design extension or r e- design will usually m ean
costs. How ev er '
a n a l mo st to ta l re -i n ve stm entof the initial development
with a microprocessorbased systemyou may be able to make substantial
6- 13
by addi ng s om e
5 . 3 . 3 Ma i n te n a n ce
C o sts
An y c ost yo u i n cu r w h e nyour pr oduct fails in the field comesunder thi s
h e a d in g . A l l th o se fi e l d ser vicemen,r etur n cler ks, r ewor k lines, a nd
o t h e r su p p o rt a re e xp e n sive. Her e too, the m icr opr ocessorcan save y ou
m o n e y. A l mo st b y d e fi n i ti on, the m icr opr ocessormust cor municatewith
t h e e nti re syste m. T h i s meansthat with the addition of som epr ogr a m m i ng,
memory,and sornesmall amountsof hardwareyou can convert your microproc e s s or b a se dsyste mi n to i ts owndiagnostic tester . Youmaynot need to
p r o v i d e th o ro u g h te sts, b ut even som esimple tests can maketr oubleshooti ng
a l o t e a si e r. A n yth i n g yo u can do to maketesting and ser vicing eas i er
w i l l lo w e r yo u r ma i n te n a ncecosts.
N a t u r a l l y, yo u mu st w e i g h the benefits of self- testing against the cos t
i t w i l l a d d . Ofte n , h o w ever ,you will discover at the end of the pr oj ec t
t h a t yo u h a ve so mee xtra I/0 lines or a par tially full ROl{ . Since thes e
a r e g o i n g to b e th e re a n yhow,you mayas we' ll use them if you can. S i nc e
t h i s t yp e o f th i n g i s n o t usually discover eduntil wel' l into the pr oj ec t,
t h e a dd i ti o n o f se l f te st featur es at that point is one of the few ti m es
*14
w h e ni t ma y b e d e sir able to add featur es after the design has s tar ted.
H o w e ve r,i f yo u w a nt to be sur e you have self- testing you shoul d nev er
w a i t to se e w h a t i s left over . In that case, the self- testing featur es
sh o u l d b e d e si g n e din like any other systemfeatur e.
6 .4 A P e rsp e cti ve0n Costs
N o wth a t w e h a ve e xam inedthe var ious component
costs, let' s s ee howthey
re l a te to th e to ta l cost per unit of our pr oposedpr oduct. bv er the total
l i fe o f a p ro d u ct, the cost can be r epr esentedby the following gener ai
e q u a ti o n :
1 g=.f+vc
as follows:
T h e seco nditions can be summ ar ized
3.
4.
5.
6.
1.
2.
6-t6
6-17
6.L9
6-20
6-21
6-22
b u ffe r ca n b e u se d to collect the data dur ing the bur st tr ansm i s s i on,
w i th th e C P Ure a d i n g the individual data elem entsfr om the buffer after
th e tra n smi ssi o ni s complete. This type of buffer ing can also be us ed i n
co n i u n cti o n w i th th e computer ' sDl' 1A
faci I i ty. In thi s case, the buffer
a ccu mu l a te sth e d a ta and tr ansfer s it into the main computermem or yi n a
si n g 'l e b l o ck tra n sfer
B u ffe rs ca n a 'l so b e used to solve per ipher al data r ate pr oblems . In thj s
ca se , th e C P Utra n sfer s the data out to the per ipher al buffer . T he per j p h e ra l ca n th e n ta ke the char acter s at its own r ate with no fur ther pr oc es s or
i n te rve n tio n.
A d d i ti o n o f b u ffe rs to the systemr eguir es the addition of con s i der abl e
h a rd w a ree xp e n se . A ccor dingly, they should only be addedif th e s y s tem
re a l l y n e e d sth e m. As long as speed is not a pr oblem,m ost mi c r opr oc es s or s
ca n d o a g o o d j o b o f implementingbuffer s. They can do this u s i ng al r eady
p re se n t ma i n me mo ryand som epr ogr anming. Data,is tr ansfer r ed i nto and
o u t o f th i s typ e o f buffer using an inter r upt. The device inter r upts
w h e ni t i s re a d y fo r a tr ansfer and the CPUper for msa single t r ans fer .
Wh e nth e b u ffe r b e comes
full or empty, the data is then pr oces s ed,i us t
a s w i th a d e d i ca te d buffer . This is alwaysm uchcheaperthan a n ex ter nal
b u ffe r syste m. In the cour seof the design, if you think you n eeddata
b u ffe ri n g , l o o k ve ry car efully to see if it can be done using softw ar e.
E ve na fte r th e d e si g n is doneyou maydiscover that a har dwarebuffer
th o u g h t n e c essar ycan actually be done in this way. It m ay be
wo rth th e re d e si g n cost to save the har dwar ecost, par ticular ly i f pr odu cti o n vo 'l u mew i l l be high
i n i ti a l l y
6-23
th e sa mero u ti n e a ddr ess. The softwar e m ust then poll all de v i c es i n the
syste rnto se e w h ogener atedthe inter r upt. This adds a signi fi c ant am ount
o f o ve rh e a dti me to the r outine, and will pr obably not be sat i s fac tor y for
fa ste r d e vi ce s.
A s a co mp ro mi seth
, e systemcan be im plemented
as a com binatj onof di r ec t
a n d i n d i re ct i n te rrupt decoding. In this caser lou assign your hi ghes t
p ri o ri ty o r fa ste st ( usually the sam e)devices their own identi fi c ati on
a d d re ss. T h e yw i l l then inter r upt dir ect' ly to their r outines w i th m i ni mu mti me l o ss. T h e lower pr ior ity devices can then be assign edto a c om m on
a d d re ssa n d th e se can be decodedunder slower , cheapersoftwar e c ontr ol .
6 .7 S o ftw a reT ra d e Offs
Software trade offs are madefor the samereason as hardwaretrade offs,
n a me l ymo d i fi ca ti o n s of systemcost and speed. W her ewe tr aded off har dware for differ'ent hardwareor a combinationof less hardwareand some
so ftw a re , w i th so ftwar e we will usually be tr ading off pt' ogr a ms peedf,or
In cre asesin pr ogr amspeedwill often take mor em em or y '
th e re b y co sti n g mo r emoney. Conver sely,if speedis not a pr o bl em ,c er tai n
p ro g ra mtyp e s ca n b e r eplaced by mar kedlyless code, with a su bs equent
l o w e ri n g o f me mo rys ize and cost. It must be kept in m ind, how ev er ,that
me mo rysi ze .
6-26
Sunmar.v
6-27
g gNt_LNitsifudlt-u
vrvo AuvNf
REPRESENTING
BINARY
DATA
Wh e nw o rki n g w i th digital computer sit is necessar yto r vorkw i th bi nar y
d a ta . C o mp u tecromponents
ar e built up fr om electr onic dev i c es w hi c h c an
o n l y re p re se n td ata as 0' s and l' s.
you will ha v e to us e
This nr eans
b i n a ry to re p re s entnum ber s. In spite of this, it is im po s s i bl eto
e sca p efro m th e fact that binar y data is not over ly conven i entto us e.
l{e'have all used base 10 numbersfor years and the base 2 numbersystem
se e msq u 'i te i n e fficient by com par ison. It takes 6 binar y di gi ts to r epre se n t th e n u mb er50r O ( 1100102) ,and it gets wor se. In th i s s ec ti on w e
w i l l d i scu ss h o wthe individua' l binar y data e' lgnentsar e r epr es entedand
h o w th e y ca n b e g r oupedtogether for m or econvenientuse. Bi nar y ar i thma ti c a n d l o g i c ar e discussedin the following supplementar sy ec ti on.
7 .1 - B i n a ry D a ta Elements
A co mp u te rd a ta e lementof ar bitr ar y length N is shownbelow .
FT- ll
"%
Y"
15
L4
13
t2
11
10
16-Bit Datat'lord
S i mi l arl y , an 8-bit m ic r o c o m p u two
e r u ldh a v ed a t a in b it p o si ti o n s0 - 7 :
7
8-Bit Datat{ord
Thuswhenwe speakof Ioading one' s into bits five and seve nof an ei ghtbi t regi s ter, w ew ill be loading the following patter n.
7-L
Bit Position
1
I
I
.A tA o =A N R N +AN- txRN- l+
+ AlxR1+ A0xR0
13610=1x R' + 3 x
Rl* 6 r Ro
base.)
\s ubs c r ip t t o identify nurnber
=1x(to)z* 3 x ( 1 0 ) + ' 6 x 1
=100+ 3 0 + 6
= 136 1 0
B i n a r y n u mb e rsca n b e si mi l a rl y repr esented. The differ ence is that wher e
in d e c i m a l we h a ve te n p o ssi b l e number s( 0- 9) , in binar y we only have tr r o
(0 a n d 1 ) . T h i s me a n sth a t re p r esentinga given num berin binar y wil' l r eq u i r e m o r edi g i t p o si ti o n s th a n r epr esentingthe sam enum berin decimal.
T h u s t h e b i na ry n u mb e r1 0 1 1 0i s r epr esentedas
= L x 24+ o x 2 3 , L x z Z * I x Z L + L x z 0
1 0 1 1z0 ^.
'=
1x 16+0+4+2 + 0
2?to
7-2
sNotsur^Noc
tutls^sussnnN
NI'MBERSXSTiff COUVERStrONS
DECII'IAI ?0 Bn{lRy
To convert
divide
divi{,ing
until
ETI}IPI,E:
2 ) b lz
) 1oB
/a
) itl
)zz
/t
)r:
t 6/t
)t
/o
)1
/r-l
)0
/t-,
b3ero
tl
v*
ErNAnI T,OpEqrUAr
As ln the deci:nal nunber systeu, the least signiJicant
the rlght
Ls a nultiple
digit
ls on the left
dlgtt
ls on
L3zro
b x
8-t
mA
+ )
l0l
+ 2 x
lO0
power of
trZn,
= f
IOIIA
So to eonvert
a binary
is a nultiple
to its
23
22
ZI
2A
decimal nunber.
2 0 =f
2 L =Q
2 ? =L
23 = 8
,lt
= 16
ar6 = 6r rg36
etc.
EXA}IPI,E:
101101
1 OL 1 O1 2= 1 x 2 5 + O * 2L * Ix
= 1x
-
3 2 +Ox16+1
3 2 +0 +B +b+ 0+ 1
1011012 = h51o
8-2
23 + I x 22 + A x 2L +1x
x8+ Ixb+ 0
xZ+1
x1
2O
COI{YERTINGDECI},I.AL11] OCTAJ,
Use t'tre sane nethod as to convert decinal
to bJ.ary
except dlvide
) 131
)re
/3
/o
/z
Btao = e3g
g.II.{At
CCIIVEBT
II{G_oCTAL_
TPJDE
To convert
from octal
EKAI{PI"E3
f:f
81 =,8
82 s d+
d=5L2
r
bo96
85 ,
32T(i8
66 .
262]|o
etc.
8-3
ef ttltt.
EXA!{PIE:
Convert 2O3U to decimal
2o3^ =
o
2 x B2+ox81*3*80
2 x( il+Ox8+ 3x1
= 1 2 8+ O+ l
= 131
c0livERTINGpECII.{ALTO.HEJilpECn{AI,
Agajnr use the sane nethod for decinal to biaary convErsion, except
use the base x16rt jastead and replace the renalnders of n10r to iltr5tr by
the letters
A to F respectively.
1 0 =A
U =B
J2 =C
13
U =f ,
$=f
EXAI"IPIE:
) 3 5 /r Jt
)
2 /3
o/z
9192ro
=;;l
:'ill,
binary
to decima-l conversiooe
A thrcrugb
1l respectively.
160= l
161
:162 =
16
L63
ba96
1*
65536
256
EXIIMPI.E:
Convert 23881d to decirnal
2 3 8 \6 =
+ 8x160
2xLO+3xt62+ Ex161
COT{VERTItrKI
OCUL TO BIXANf,. EEtrIDECII.{AIfO BIr.ONr.
OCT.[I.TO IGX'jDLCIMAI:ANDBACK
Convert to blnary firste
tlren tl
lnhese translate
8-5
dlrectly
the ISB.
llexadeciraal
BinarY
0ctaI
Bi-nary
000
oooo
001
0001
o10
0010
olJ
oo11
100
0100
101
0101
110
OILO
111
o111
1000
100r
1010
1011
ILOO
Ito1
1ILO
Ltu
E]NAMPT.q:
1) convertbnzncaato octal
btcncr,
= 112l.27b
hmncr, = ltzl2?bg
8-6
2)
!+358 = 3St6
B-7
ocg
sutSl,[nN
-/a
BCD }TIJI,IBERS
In some applicaLions it
is desirable
to be able to directly
1!nit
Decimal
rep-
possible
Instead, we
patternsl
BCD
oooo
0001
0010
0011
o100
0101
UJ.l-U
1
I
0111
1000
1001
provide instructions
e - 'l
can
applications.
to a1low direet
This means it
arithmeric
As a resulte
many computers
with BCDnwrbers.
sl{ott3vHs
AuvNts
/ /'
BINARYFRACTIONS
Binary numbers are generally considered as shole i.ntegers (i.e.,
2, 3, ..-).
Hcrcever,it
to the right
the bits
binary
sider
representati.on.
to the right
point.
representation
is an3.lagous to
of a declmal. point;
represent
consists
in biaar;y r we consider
to be a fracticn.
In a bilary
binary
the bits
fraction
of the
the following
1,
Con-
nrunber?
Binary Poj-nt
1101.1101
ltris
Z3 + 22 + O + ZO .
means
=B +lr+1+.5r.25 + . 0 6 2 5
= I3.B].,Z5
Numbers can be converted to and from binary fractions
techniques already shorn fe
not all
fractj-ons
converting
Whenwe try
using the
Unfortunately,
Consi<ier the
3 L /3IO = 3.3333......3r O
ir/-
) V 3LO = 11.01010101......012
The fracti,on repeats and there is obviously no exact result.
ri1l
We
For
10-1
The rouadlng
courerting
errol
the tnrncated
introduced
by ttris
tnuncatio,
can be coputed
by
fraction.
lbe possibility
error must alrays be taken into cqrsideratLon when using binary .fractioas,
partlcularly
ln dlvision
binary flacttons,
operations.
so the possibility
tn eract
sNotrcnursNt
3t901oNVctr3utHrruv
AuvNts
BINARY
ARITHMETIC
AtfpLgcrc rNSTRucTroNs
provide a nr"rnber
All computers
of instructions whichare usedto perform
arithmetic and log'ic operationson data. As discussedelsewherercoCIputr
data consists of patterns of bits in registers and memory
locations. However' there is a fundamental
difference betweenthe way the arithmetic
instructionsand logic instructionstreat this binary data. Thearithmetic
instructions interpret the data as numbers.The logic instructions, on
the other hand,interpret the data as a collection of individual bits.
'11.1 Computer
Arithmetic Instructi.ons
Themostbasic computer
arithmetic instruction is additlon. This instruction
and the logic complement
instruction can be used to lmplementany known
n6thematicalfunction. As a result, manycomputers
offer addition as
their only arlthrnetic instruction, After additlon, the next mostcoflilnon
arithrntic instruction is subtraction. This is becausesubtraction can
be perfomndusing the samebasic hard*areas addition. After addition
and subtractionyou haveto go to a considerablymorecomplexcomputer
to get mul ti pl i c ati on a n dd iv is io n a s b u ilt - in f u n c t io n s . T h eh a r d w a r e
required for these operationsis conslderablymorecomplexthan that used
for addition and subtraction. As of this writing (July L976)there are
no microprocessors
with built-in multiply and divide hardware.Thls wlll
certainly change. All of theseoperationsuse the contentsof the computer's
accumulator(s)
and anotherdata sourceas operandswith the result endlng
up in the accumulator.
3I;X.l TnosComplement
ilotatlg
Themostcormonway of representingnumbersfor arlthmetic operatlons in
the computeris twos complement
notation. To understandtwos complernent
notation let's considerthe binary nurnbers
that can be representedby an
8-bit data element. lrleknowthat an 8-bit data elernentcan represent256
individual values. Whenwe use a reglster as a counter, we can count up
to 256dlfferent values. The binary numbercountlngmethodfollows,
Lt-1
Binary
00000000
00000001
00000010
00000011
00000100
Count
0
1
2
3
4
::
1 1111110
254
1 1111111
255
IL.2
000=0
001=1
0 0 000
0 0 000
01
11
ll
11
1 ll' ' + 1 2 7
111= -1
110--2
101=-3
111
111
1 ll
111
::
10000000'-128
t{obhowbit 7 (the mostsignificant blt) is alwaysa zero for all positive
and alwaysa one for negatlvenumbers. Thenpst slgniflcant bit
numbers
numberis called the siqn bi3, becauseby testing
in a irl,oscomplement
it you can deterrnineif a numberis positive or negative.
tL. 1.2 BinarYAri thmtlc
Blnary arithmetic is perforrnd uslng the ALUand two operands' The
or slgned tms
operation can be perfonnedusing either unsignednr,mbers
numbers,dependinguponthe operation being perforrned' ibst
complement
performaddition and subtractionas unsignedoperations. They
computers
but
do provlde flags to indicate the result ln signed tms complement,
it ls up to you to keeptrack of the slgn and magnltude.
Addltion is perfonnedby addlngthe contents of an operandto the contents
of the accumulator. If the result ls greater than the largest number
whichcan be representedin the accumrlator,a flag rill be set to indlcate a carry out has Occurred. For example,conslder the operatlon of
addlng the number15rOto an 8-blt accu,rulatorwhlch contalns 25LO' The
operatlon would be performedas follows.
IL.3
A c c u m u la t o r 0 0 0 1 1 0 0 1
+0perand 0000I111
Re s u lt 0 0 1 0 1 0 0 0 = 4 0 , ^
Nowc ons i derthe add it io n o f lllr '
t o 1 4 5 1 0in t h e a c c u m u la t or .
Ac c u m u la t o r 1 0 0 1 0 0 0 1
+Operand 01101111
u00000000
carry out
T h e re su l t o f th i s o per ation is 25510. It causesa car y out to i ndi c ate
that the accumulatoroverflowed.
Subtraction is performedby taking the twos complement
of the subtrahend
an d a d d i n g i t to th e minuendin the accum ulator . Thus to subtrac t 10r O
from 25rOwe urouldperform the following operation
Subtrahend00001010
FormTwosComplementI 1 1 1 0 1 I 0
AddTo Accumulator 0 0 0 I 1 0 0 I
4000011
carry out
11=1510
A
b
n'.wr'^^Ir*d"
g*b*re-Iv,*A
K w-*+
Re s u lt 1 1 1 0 1 1 0 0
C omp le m e n0t 0 0 1 0 0 1 1
Addl
00010100=2010
Notice that the sense of the carry after a subtraction is reversed from
th a t o f a d d i ti o n . A car r y out indicites that the subtr ahendw as s m al l er
u-5
Accumulator r 0 1 0 1 1 0 1
Complement0 1 0 1 0 0 1 0
11.2.2 Loqic AND
The Logic ANDoperations (SymbolA) operatesuponthe bits of the accumulator
and an operandaccordingto the folloring truth table.
AccumrlatorBit
it
ResultBit
0011
Thusgnly those bit positions whichare logic ones in both the accumulator
and the operandwill be logic ones ln the accunnrlatorafter a Logic Al{D
operationhas beenperfonned. For example,considerthe following Logic
At{Doperation.
A c c u m u la t o r0 1 1 0 1 1 0 1
A0perand 11011011
Re s u lt 0 1 0 0 1 0 0 1
Only those bits whichwereonesin both operandsare in the result.
L t.2.3 Looi c ,0R
The Loglc 0R operation (symbolV) operatesuponthe bfts of the
and an operandaccordingto the folloring truth table.
accumulator
B it
Accumulator
nd B it
R e s u ltB it
001
0
Accumulator 1 0 1 1 0 1 1 0
V Operand 0 0 1 1 0 0 1 1
It
Resu
11110111
All bits whichwereonesin bcth operands
are onesin the results.
q.2.4
XOR
-Loqic
TheLogic Exclusive0R operation(symbolA, o-ten called XOR)is not
foundin all computers.It operatesuponthe bits of the accumulator
and an operandaccordingto the following truth tabSL
Accumulator
Bit
0011
a nd Bit
R es u ltB it
0110
u-7
APPENDIX
A
MODIFIED
6500OPCODETABLE
8RK
OR$(t
ORAz
ASLz
PHP
ORA#
ASLa
ORA@ ASI
*'
BPLr
ORAIy
ORAzx
ASLzx
cIf
oRlGy
:r
ORAGX ASIGx
BITz,
ANDz
ROLz
PLP
A"llD#
ROLa
BIIG
AND@ ROIS
* r
JSNG
ANDxt
EMIr
ANDiy
ANDzx
ROLzx
sEc
ANDCy
ANDGx ROIGx
RTI
EORxi
tt
EORs
LSRz
PHA
EOR#
LSRa
JMF@
EORG LSR@
BVCr
EORIy
EORzx
LSRzx
CLI
EORey
EOR@x LSRGx
RTS
ADCxI
ADCz
RORa
PIA
ADC#
RORa
JlrPt
ADC@ RORG|
E4rSr
ADCIy
ADCzx
RORzx
SEI
AD@y
AD@x
RORgn
ST)@
't
STAr(I
*.
STYz
STAz
STXz
DET
TXA
STTG
STAG
BCCr
STAty
STYzx
STAzx
STXzy
TYA
sTAGy
T)(S
rb
STA@x *
LDT#
LDAxl
IDX#
LDYa
LDAz
I"DXz
TAY
I.DA#
TN(
u)YG
I.DAG
tDX@
BCSr
LDAIy
IDYzx
LDAzx
LDXzy
cLv
IJeGy
TSX
IDI@x
LDAGx LDXGy
CPYf
CMP!(I
CPYz
CMPz
DECz
INY
CMP#
DEX
CPYG
CMF@ DEOG
BNEr
CMPIy
CMPzx
DECzx
CI.D
c[@y
a"tG*
DECGx
cPx*
SBCII
CPXz
SBCa
INCz
INX
SBC#
NOP
cP)(G
88C@
IN@
SBCIy
SBCzx
INCzx
SED
SB@y
SB@x
INCGr
BEQr
0
l2
9A
K ey to addressl ng el dol e:
t
@
t
r
a
lnnrediate
abeol ute
8ccumulatot
rel ati ve
tero PagG
&t, Gy
N*,, zV
rl
ty
absolute tndexed
Eero page tndexed
lndercd lndtrect
lndlrcct
lndexod
APPENDIX
B
KIM INFORMATTON
KIM PROGRA}MING
DATA SHEET
.5500
OP CODETAELE
4567
8RK
oR$(l
BPLr
oRAly
JSRG
ANDX,
BITt
Bltlr
ANDIy
RTI
EoRr(
BfCr
EoRfy
R?S
A.DCxi
BVSr
ADCty
ADCzx
STYZ
SI.tz
oRAz
ASLz
otu{zx
S rS T A xttt
9
BCCr
LDY+
9At
C D EF
PHP
ORA*
ASIJ
ORI{
ASI
ASLzx
cLc
ORnGy
OR{}x
ASICI
A.liDz
ROLz
PLP
AND'
ROL.
BITE
ANDG
ROItr
AJ{Dzx
ROLil
sEc
AND@y
AN[ax
ROLG!
EORZ
IJRz
PiIA
EOR#
ISRa
JlaG
Eo8
tsR
EORzx
LSRzx
cLt
EO@y
ECRj-ex f-sRLlr
ADCZ
RORZ
PIA
ADC#
RORs
.JnPt
ADC.a
RORG
RORzr
cFt
l\D@Y
STXz
DEY
* T XA*
ADC(ax
RORGI
sTr
sTr@
sr:@
STl:r
STArr
STXzy
TfA
STAGy
fXS
sTAGx *
.tDAxl
lrxt
l.J)Yz
ItAa
lJXz
TAY
I.DA#
TA,\
rcl
LDr&
cLv
I,l@y
TsX
IrlG*
LDA(?x LDX?y
cI'rG
cliRd
STAIy
BCSr
IDAIy
U)Y?r
lJAzx
L}Xzy
cPIf
cMht
CPY8
CltPz
DEC:
INY
cMPrr
D!!{
BNE!
C!{Ply
DECzx
ct
CilrGy
CEK'
SBGxt
CEX8
lNc"
BEQr
sBcty
INCa
ol2t
CliPzx
SBC?
SBCzr
I:!X
SED
6567
'
60nf
NoF
SB@y
LD&
DE@
C.'{I?x Df,CGr
8&r
5UW
lHg
fNO!fu
SB@x
CDEI
9i {8
STASUSREGISTER
TABLE
ASCII/HEXCONVERSION
P : NV
B DI Z C
76543210
t.&t
cu
I}IPORTAI{T
ADDRSSSES
00EF PCL
00F0 PCH
OOF1
o0F2
OOF3
OOF4
00F5
P
s
A
Y
X
w.i1,
Fi.1 ". -: ,-1700 pAD
... LTOL PADD
-rr.i, ,
PBD
4L702
1703 PBDD
,4 ' ,4
i;t11s..t
,/'
''
,:,!;'
t11' /
i
-i ,
'
aAJ
=,.,, ". ;,
RST-L
RsT-H
IRQ/BRK-L
IRQ/BRK.H
0OF1- 00 (LD)
17F5 SAL
I7F5 SAIT
L7F7 EAr+l
17F8 EAII
17F9 rBlt
1g0O DUMPI
L873 LOADT
.:..r+-
0
1
2
3
5
7
8
9
l0
l1
0
1
2
3
4
5
6
7
8
9
a
B
0000
0001
0010
0011
0100
0101
0110
0111
1000
1001
1010
1011
F
E
D
c
B
A
9
6
7
6
5
4
L2
13
14
15
c
D
E
F
1100
1101
1110
1111
3
2
1
0
IMERVAL TIT'{ER
pRT to @: /ll
L704
1
1705
8
L706
64
L707 LO24
170c
I
170D
8
170E
64
l70F t024
INT
D
D
D
D
E
E
E
E
READ G
I}N
L7O7 STA?US
L7O6 COUNT D
17OE COTJIfI E
NUL
sox
slx
EIX
EOr
EflO
ACK
seL
03
v\
06
..i
i
00
HT
09
LF
OA
oa
oc
oo
so o
OF
OL t0
tl
r2
oc3 ?f,
Oc. la
l5
SYN r 6
ta l 7
cAr{
t9
Et1 '|l
sua tA
E5C
FS 'E
rc
is
US
xx
0oF9
IE
!F
8o.
as
DISPIAY OI'TPI.TT:
)g
)0(
00FB 00rA
@
0t
7.8'r
Ch,
Chr
No.
CDt
4l
e12
r6l
b6?
?
d&
.65
r66
:?f,
i24
a?5
e26
,21
o{
E4!
F4
ca1
Ba8
t49
{?E
t29
.?a
+29
,2e
i2F
r3l
232
33:l
a34
535
i3a
,37
83i
93!}
.38
,.9n
7 '8'r
K48
Lac
Mao
t.
O4F
P5q
o5r
R52
s53
74
u55
v16
w5t
gl
'x
Y!9
z5a
!58
.3o
150
rlF
..5F
e.0
\eo
t
h6
.69
r6a
r5a
r6c
m60
n6
o6F
FrA
c?l
.t2
rt3
r?a
r75
r7g
r17
r7E
rE
!tA
!a..
6:t
76
AL'
?D
EsC
'E
0eL. tt
EUBOUI
JSRG grFlF
I {UL
KEYBOARD
INPIIT:
I soH
I
srx
JSRG $1F6A
TX
OTTTPUT
TO IIY:
ENO
ACK
tL
char ln A
Jsn@ 91EA0
ss
HT
II{PTIT FROMITY:
JSR@ $1E5A
char lntoA
.'1
NULL
s7anr oF Haorr{c. AtSo 6TAFT
OF MESSAGE
START aF rXlj ALSO OA. E(O
OF AOORESS
eND OF lgxt; also oM, Eil, oF
MESSAOE
EHO OF ?FANSMr39tC{ tENOt
ENOUIRY INORYI- ALSO V'FU
ACXNO4LEOCE,
NU
RINGS TH ALL ^LsO
BACKSPAC
HOAI2OiIIAL TA'
LINE FEED OR LIN SPACE{ilW
LTNEI AOVANCES?A?'A fO
ftxr Lril aGttNrNG oF Lttr
VFRTICAL TA8 (VTAAI
FORM :EED TO
OF NEX'
PAG iPAGE}
'OP
CABRIAG RTUNN
OLE
'rC1
oc4
sYU
r8
CAN
tl
su8
RS
US
sHrFt Out
sHrtt rx
OATA LINX SCAT
DgvrcE coN?roL t
oEvrcE coitleoL
2
cEv'cE coNTBor 3
:tEvrCe CONIPCL a
i/EcAttv Acracfvtlocc
3YIJCHHONOU' IALE ISYfVC'
NO CF rnANSVrSSrON TLOCX
SArrCEL lCALCLl
EwO Of storur,
3Utg?rrutg
scAtE. PilFtx
FILE SEPAiATOI
GFOU' SEPAFATOR
RCOFIOSEPARATOR
UTITSPARATON
6530oo2
I.K ROM
TII,IER
Kf,YBOARD/
DISST.AY
.J
648 RI{U
15 PIO
PAO . PA7
7
gBO . PB7
6s30003
-1K ROt'{
TIMEF.
648 RI{U
PAO - P.A,7
15 PIO
PBO. PB7
DBO - DB7
-rRQ
NlIr
ABO- AB15
TTYITAPE
TNTERFACE
APPLICATIONCONNECTOR
PLUG
TUNCTION
PIN #
PBO
PBl
PB2
P B3 .
PB4
PB5
INT(orange)
PB7*
TTY BAT'DRATECONTROL
FUNCTION
I
2
3
4
5
6
7
8
PI N I
PA7
PA6
PA5
PA4
PA3
PA2
PAT
PAO
l6
15
r4
BAUD
I1O
300
600
1200
2400
4800
l7F1
l7r3
79
02
EA
00
75
00
38
00
18
00
OA
00
l3
t2
l1
IO
9
9600
02
00
M tc
about t his
Itne
-J;)
REMOTE
EKPANSIONCONNECTOR
PLUG
FI'NCTION
F'
t,
PIN #
FIJNCTION
480
A8l
AB2
AB3
K (g ree n)
EIF
I
2
3
4
5
6
027
RAMR/r{
DB7
DB6
DB5
DB4
DB3
DB2
DBI
DBO
PIN #
E A RP H ON E
16
l5
L4
13
t2
11
10
9
__l
(A
-o
7
PR.GRAHMABLE
I/O LINES
PA DATA RECISTER 17OO
PB DATA REGISTER 1702
1=output )
TTY
OATA
ouT
TAPE RECORDER
CONNECTIONS
FIJNCTl,ON
PIN f
GND
AI'DIO IN
AUDIO OTIT
K
L
l.{
COLORCODE
GREY
BLUE
RED
K E Y B OA R O R TU R N
NOTES
GND
FROMEARPITONE
OUTPUT
TO MIC INPUT
-o
7
c
-o
3
4
-o
;;)
TTY
OATA
IN
<H
TTY/CRT CONNECTIONS
FT'NCTION
KEYBDRET.
PRINTERRET.
KEYBOARI)
PRINTER
PIN #
R
s
t
COLORCODE
BRO{rtN
tsR(NN
VIOI.ET
YULLCH
NOTES
(+)
(+)
20 nA current
20 nA current
{_--Loop
loop
KtM --:j
I
L J U MP f R
E X TE R N A L S W ITC H IO S E LE C I
E ITH E R MOD
FOR TTY OP E N A TION
K IM MO NI T O R I MP O RT A NTA DDRE S S E S
OOE F
OOFO
OOFl
OOF2
OOF]
OOF4
OOF5
OOF6
OOFT
US E R P C L O W B Y T E
US E R P C HI G H B Y T E
US E R S TA T US RE G I S T E R
US E R S TA CK P O I NT E R
US E R A CCUMUL A T O R
US E R Y R E G I S T E R
US E R X R E G I S T E R
CHE CK SUM
CHE CK S UM
OOF9
OOFA
OOFB
S TORA G EF O R RI G HT HA NDDI S P L A Y DI G I T P A I R
S TORA GEF O R CE NT E RDI S P L A Y DI G I T P A I R
S TORA GEF . O RL E F T HA NDDI S P L A Y DI G I T P A I R
17OO
P ORT A .DA T A
LTOT
P ORT A D I RE CT I O N CO NT RO LRE G I S T E R
I7O2
P ORT B D A T A
L7O'
P ORT B DI RE CT I O N CO NT RO LRE G I S T E R
L7O4-L707 INTE RV AL T I ME R # 1
LTOC-L7OF INTE RV AL T . I ME R # T
L744-I747
L74C-I74T
I7F2-T7F3
I7F5
L7F6
I7F7
17F8
L7F9
INTE RV A L T I ME R # 2
INTE RV A L T I ME R # 2
S E RIA L T/ O B A UD RA T E CO NT RO L
TA P E DUMPS T A RT I NG A DDRE S SL O W B Y T E
TA P E DUMPS T A RT I NG A DDRE S SHI G H B Y T E
TA P E DUMP E NDI NG A DDRE S S + I L O W B Y T E
TA P E DUMP E NDI NG A DDRE S S + I HI G H B Y T E
TA P E FILE I NDE NT I F I CA T I O N NUMB E R
ITFA
17FB
NMI V E CT O RL O W B Y T E
NMI V E CT O RHI G H B Y T E
LTFE
LTFF
rRQ V E CT O RL O W B Y T E
IRQ V E CT O RHI G H B Y T E
18OO
E NTRY P O I NT F O R T A P E DUMP RO UT I NE
1873
E NTRY P OI NT F O R T A P E L O A D RO UT I NE
ICOO
lC+F
DE S TRUCT I V EMO NI T O R E NT RY P O I NT
IE A O
1E 5A
S E RIA L IN P UT E NT RY P O I NT
l F lF
E NTRY P O I NT F O R DI G I T DI S P L A Y RO UT I NE
IF 6A
E NTRY P OI NT F O R K E Y B O A RDRE A D RO UT I NE
B- 4
APPENDTX
c
C.
Cass R. Lewart
HoI"mde1,N. J.
DISPI,AY ROUTINE
This routine will display any program showing each successive
location and the contents of that location.
The routine is fu1lv
relocatabLe.
By storing in the 17FA and LTFB l-ocations the
starting address of this routine one can use the ST key to start
the program. The display can be stopped by pressing RS and continued
by pressing ST again.
The program starts dispLaying consecutive
locations starting with the location shown in the displ-ay by
pressing ST. The second prograrn MULT controls the displa.v time.
With val-ue 04 it is 0.4 sec per Location.
OO
02
03
04
06
09
0C
0F
11
T2
13
L4
L6
18
1A
1C
e.g.
ll ql
A2 04
8A
48
A9 62
8D 47 L7
20 L9 \F
2C 47 17
10 F8
68
AA
CA
D0 EC
E6 FA
D0 E6
E6 FB
D0 E2
THREE
TWO
ONE
LDX/I
T)(A
PHA
LDAIf
STAG
JSRG
BITG
BlLr
PtA
TAX
DEX
BNEr
INCz
BNEr
INCz
BNEr
MULT
$62
$L7 47
SCANDS
$L747
ONE
.1 sec/cycle
Load timer
Display
Check timer
TI^IO
$FA
THREE
$FB
TI'IO
l+i
i't"",.**11r.*'L.vs$d*f-
c-1
Jim Butterfield
Toronto
DIRECTORY:A KIM-I
UTILITY PROGMI'I
Program DIRECTORYaLlows you 254 program IDs to choose from ... enough
for most program libraries
with some to spare.
The program is fu1ly
reLocatabl-e, so put it anlnohere convenient.
Start at the first
instruction
(0000 in the listing).
IncidentaLly,
000L to 001D of this program are
functionaLly
identical
to the KIM monitor L88C to 18CL.
After you start the program, start your audio tape input.
When
DIRECTORYfinds a prograu, it will display the Start Address (first
four digits)
and the Program ID. Hit any key and it wiLl scan for
the next prograu.
0000 D8
0001 A9 o7
0003 8D 42 L7
0006 20 4t 1A
0009 46 F9
0008 05 E 9
000D 85 F9
000F c9 L6
0011 D0 F3
0013 20 24 LL
00L6 c6 F9
00t8 L0 F5
00LA c9 2A
001c D0 F1
0018 A2 FD
oo20 20 F3 19
oo239s FC
0025 E 8
0026 3A F8
0028 20 lF lF
0028 D0 D3
002D F0 F9
CLD
LDA#
STAG
JSRG
LSRz
ORAz
STAz
cMHl
BNEr
JSRG
DECz
BPLT
$OZ
SBD
RDBIT
INH
INH
INH
$le
SYN
RDCHT
INH
TST
cu"tt
$2A
BNET
LDXtI
JSRG
STAzx
INX
BMIT
JSRG
BNEr
BEQr
TST
$rD
RDBYT
POINTII+I
c-2
RD
SCANDS
GO
SHOI{
Directional
reg
K IM U ser N otes vl
VU TAPE
l t2
Ji m B utterfi el d
Toronto
Program VUTAPElets you actual-1y see the contents of a KIM format tape
going by.
as it's
It shows the data going by very qrrickly, because of the
taPe speed .. but you can at least 'sense' the kind of material on the tape.
In case of tape troubles, this should give you a hint as to the area of
your problem: nothing? noi se? dropouts? And you can prepare a test tape
(see beLow) to check out the tape quality and your recorder,
The test
tape will also help you establish the best settings for your volume and
tone controls.
Perhaps VUTAPE's most useful function,though,
is to give you a
tfeeling'
for how data is stored on tape. You can actually watch the
Processor trying to synchronLze into the bit stream. Once itrs synched,
you'll
see the characters rolling
off the tape
until an END or illegal
character drops you back into the sync mode agaLn. Itrs educational to
watch. And since the program is fairly
short, you should be able to trace
out just how the processor tracks the input tape.
(so you can
VUTAPEstarts at location 0000 and is fu1-J-yrelocatable
load it anyplace it fits).
OOOOD8
START CLD
0001 A9 7F
LDAI|
0003 BD 4L L7
STA@
0006 A9 13
SYN
LDA/f
0008 85 E0
STAz
OOOA8D 42 17
STA@
000D 20 41 1A
JSRG
0010 46 F9
LSRz
0012 05 F9
ORAz
00L4 85 F9
STAz
0016 8D 40 17
STA@
0019 C9 16
TST
CMIVf
0018 D0 E9
BNEr
001D 20 24 LA
JSRG
OO2OC9 2A
CMH|
0022 D0 F5
BNEr
0024 49 00
STREAM In.Ait
0026 8D E9 L7
STA@
OO29 20 24 LA
JSRG
002C 20 00 LA
JSRG
002F D0 D5
BNEr
0031 A6 E0
LDXz
OO33E8
INX
0034 EB
INX
0035 E0 1-5
c?x/f
0037 D0 02
BNEr
0039 A2 09
LDX/F
0038 86 E0
STKz
OVER
OO3D8E 42 T7
SD(@
0040 AA
TAX
0041 BD E7 \F
LDAGx
0044 8D 40 17
STA@
0047 D0 DB
BNEr
$7r
PADD
$13
POINT
SBD
RDBIT
INH
INH
INH
SAD
$16
SYN
RDCHT
$2A
TST
$OO
SAVX
RDCHT
PACKT
SYN
POINT
$15
OVER
$09
POINT
SBD
TABLE
SAD
STREAM
c- 3
to hexadec..
with
0000 A0 BF
0002 8C 43 L7
0005 A9 16
oooT 20 7A 19
0O0A D0 F9
cO
LP
LDy#
$Br
STlf@ PBDD
LDA/I
$rO
JSR@ OUTCH
BNEr
Lp
directionaL..
.,regtsrers
SYNC
..our to rape
Now use program WTAPE. The display should show a steady synchronizatLoa
pattern.
Tty praying with your controls and see over !f,hat range the
stays
l-ocked in.
The wider the range, the better your cassettel
Pattern
recorder.
c-4
Jim Butterfield
Toronto
SUPERTAPE
0100 A9 AD
DIIMPT LDA#
O1O2 8D EC L7
STAG
0105 20 32 L9
JSRG
oL08 A9 27
LDAIF
0104 85 El
STAz
010c 49 BF
LDA/I
010E 8D 43 L7
STAG
OLLL A2 64
LDx/f
0113 A9 16
LDA/I
0115 20 61 01
JSRG
011-8A9 6tDA/f
011A 20 88 0l_
JSRG
011D AD F9 n
LDA@
OI2O 20 70 01
JSRG
0123 AD F5 L7
LDAG
0L26 20 6D 01
JSRG
OLzg AD E6 L7
IDAG
OLaC 20 6D 01
JSR@
OL2E 20 EC L7 DIMPT4 JSRG
OL32 20 6D 01
JSRG
0135 20 EA l.9
JSRG
O].38 AD ED 17
LDAG
0138 CD E7 17
CMP@
013E AD EE L7
LDAG
0141 8D F8 17
SBC@
BCCr
0L44 90 E9
0146 A9 2F
LDA/F
0L48 20 88 01
JSRG
0148 AD W T7
LDAG
OL4E 20 70 01.
JSR@
0L51 AD E8 17
LDAG
JSRG
OL54 20 70 O].
0L57 A2 02
LDKIF
0159 A9 04
LDA/,[
0158 20 61 0lJSRG
015E 4C 5C 18
JI4FG
; subroutines
0161 86 E0
HIC
Sfiz
0163 48
HrCl
PHA
0L64 20 88 01
JSRG
PLA
0167 68
0168 C6 E0
DECz
016A D0 F7
BNEr
RTS
016C 60
op code LDA
$AO
VEB
INTVEB
ser up subrtn
527
GANG
fl-ag to go to SBD
$sr
PBDD
open the channels
send 100...
$64
..SYNC chars
$16
rrrc
send asterisk
S2A
OUTCHT
ID
then the ID
OUTBIT
SAL
followed by
OUTBTC
rhe srarr address
(1ow and hieh)
SAH
OUTBI'C
get memory word
VEB
ouTBTc
and send it
rNcvEB
on to next address
VEB+I
EAL
is the address..
VEB+z
..at the end?
EAH
DUMPT4
no, go back;
$2F
Yes: send end-data
OUTCITT
CIIKL
. . and checksum
OUTBT
CHKII
. .hi and Low. .
OUTBT
send two..
$OZ
EOT
characters
$O+
HrC
DISPZ
and werre finished
here
foll-ow
TIC
count
oUTcHT
TIC
HICL
c-5
send character
..and bring it
do it
again
back
AND/T
CMI{I
c16
BMlr
ADCI|
ITH(I
ADC'T
OUTCIIT I.D'TII
STtz
T.NYNI.
lRY
STYz
T,DXGY
ZON
PHA
BII'G
ZON1
BPLT
LDAay
STAG
LDAz
EOR/I
STAG
STA.z
IID(OUT
CHKT
compute checksum
save the character
..and take its
four left bits..
r,frite rem...
now the 4 right
bits..
HHKOUT
$0F
$oe
HH(T.
$oz
$ :z ifAtoF
$go
$08
conNT
$oz
$ 3 0 if numeric
for the eight bits,.
TRIB
NPUL
CLKRDI
z0N1
TIMG
CLKlT
GAIIG
$80
SBD
GANG
Dm(
send 3 units
starting
at 3600 hertz
number of half cycl.es
keep the character
wait for the previous,.
cycle to complete
get the time to the..
..next pulse ($78 or C3)
flip
between 1 and 0
the cycles?
BNEr zoN1
nope, aend another one
get back the character
PT.A
DECz TRIB
one less unit to send
BEQr stv,
and the last oners here
quit
ROUl
BMIr
none teft?
LSRa
take next bit
BCCr zoN
..and lf ltfs a one..
SETZ
TNYII $oo
switch to 24AA cycLes/sec
return
BEQr z0N
unconditionat
ROUT
DECz COT'NT
one less bit
any more? go back
BNEr TRY
'
RTS
I frequency/density controls
01BE02
NPUL
two pulses; one cycl.e!
.BYTE $OZ
01BFC3 03 7E TrMG
.BYTE $C3,$03,$78
end
Sp eed
X3
X6
Tining
Data: $01BE
04
02
c-6
$01"c0
06
05
Jim Butterfield
L78O L9 27
START LDA/f $27
1782 A2 3F
GO
LDX/f $3F
1784 8E 43 17
STX@ PBDD
L787 A2 07
LDX/I $07
1789 8E 42 L7
STXG SBD
17BC A0 5E
LDY/f 94
l78E 2C 42 L7
BITG SBD
L79L lO 02
BPLr OVER
1793 A0 A3
tDY/l L63
L795 A2 BF
OVER
LDX// $BF
L797 8E 43 L7
STX@ PBDD
L79L 49 80
EORif $80
L79C 8D 42 L7
STAG SBD
L79F 8C 44 L7
STYG CLKIT
LTLZ 2C 47 17 WAIT
BITG CLKSTAT
1745 10 FB
BPLr WAIT
I7L7 30 D9
BMIr cO
recorders
SBD value
register
set directional
input
PB5 (cont) set for input
high frequency
zero or one?
low frequency
register
set directional
output
reverse output bit
and send it
set timer
and wait
start
c-7
to
to
the recorders.
This program
try
reducing
lf4
SEC
LDA.z
$W+
1783 E5 E0
sBCz $ro
1785 85 E6
srAz
$ro
L787 A5 E5
wilz
$gs
1798 E5 EL
SBCZ $Er
L78B 85 E7
STAz $rZ
178D 90 18
BCCr MOVEB
178F 38
MOVEF SEC
L79OA5 E2
IJi.AZ $82
1792 E5 EO
SBCz $rO
L794 L8
TAY
1795 84 E8
slYz
$ng
L797 E6 E8
INCZ $Eg
L799 BL EO
LooPl- LDAiy $80
L79B 9L E4
srAiy $84
179D 88
DEY
T79E DO t^9
BNEr L00p1
17A0 81 E0
LDAiy $80
L7A2 9L E4
srAiy $sa
L7A4 88
DEY
L7A5 30 L4
BMIr
END
L7A7 38
MOVEB SEC
17A8 A5 E2
LDAZ $NZ
17AAE5 E0
SBCz $rO
17Ac 85 E8
STAz $ee
17AE E6 E8
INCz $ee
1780 A0 00
rDYtt $OO
l7B2 81 EO
LOOP? LDAiy $nO
L7B4 9L E4
SIAIy $ra
1786 C8
INY
L 7B 7C4 E 8
c wz
$ rg
t7B9 D0 F7
BNEr LOOP2
17BB 18
END
CI.E
LTBOA5 EZ
LDAz $82
LTBE65 E6
A,DCz $UO
L7c0 85 E2
STAz $pZ
L7C2A5 E3
LDAz $Ug
L7c4 65 9,7
ADCz $E7
17c6 85 E3
STAz $83
L7C8 4C 4F I.C
JMPG START
c-8
0OEO= SAL)
00E1 = SAH) Original
) block of
00E2 = EAL) bytes
00E3 = EAH)
00E4 = SAL) New location
O0E5 = SAH)
00E6 = dif
00E7 = dif
L) Number of spaces
H) block is moved
(signed notation)
00EB = Number of bytes in block
c-9
IiEX DI]MP
b y J.B .
R oss
EsI BITIP
1OO AD P5 17
103 85 FA
1O5 AD r'6 17
108 85 FB
104 20 2F tE
lOD A9 0A
1SF 20 AO LE
LI,z AZ OF
114 SO 9E 1E
117 CA
118 DO FA
114 A2 10
11C A9 FF
1lE 48
11F 20 9E 1E
t22 2A 9E 1E
125 68
126 18
127 69 01
I29 48
12A 2A 38 lE
12D CA
12S DO F2
130 20 2F 1E
133 20 2F lE
136 A2 0B
138 20 9E 1E
1.38 CA
13C DO lA
138 AZ 10
L4O 20 1E 1E
143 20 9E 1E
146 20 9E lE
149 A0 0O
148 81 FA
t4D 20 38 1E
150 20 63 1F
153 A5 FB
1s5 CD F8 1_7
158 90 09
15A A5 TA
15C CD F7 L7
15F 90 02
161. BO 06
163 CA
164 D0 E0
166 18
16? 90 CA
169 20 2f 18
16C 20 ?F 1E
16f 4C 4F 1C
LDAI
,SfAU
LDA@
STAZ
JsR@
LDA#
.rSR@
LDX#
IOOP1 JSR@
DEX
BNEA
L$Xll
LDA#
PEA
JSR@
LOOP2 JSR@
PLA
CLC
ADC#
PFA
JSll@
DEX
BNER
JsR@
LOOpS JSR@
l,DX#
IOOP3 JSR@
DEX
BI\'ER
LDX#
JSR@
.tSR@
LOOP4 JSR@
LDY#
LDAIY
JSR@
JSn@
LDAZ
CMp@
BCCR
LDAZ
C',lP@
BCCR
BCSts
MORE DEX
BNHR
CtC
BCCIT
DONE JSR@
J$&@
JtrP@
SfBt
S17Fg
POINTIT
$17r'6
POINTS
CRLF
'LF'
OUTCTT
$Of
OUTSP
LOOP1
$10
$ff
OttTSP
OUTSP
15 spaces on lett
print headlng:
start wlth A at -1
save A
print
1 space
priot
1 space
restore A
add 1 to A
save A
pRTgYT prlnt A as bex nunber
$01
LOOP?
CRLF
CRLF
$OB
OUTSp
L0OP3
$10
pBfP$?
OUTSP
OUTSP
$OO
F,OINTI
PRTBYT
INCPT
POIN'fg
$17F8
MORE
POINTL
$17F7
MORE
DGNE
LOOP4
LOOPS
CRLF
CRLF
KIU
tr*10
prlnt
print
print
CR/LF
CR/LF
11 spaces oa left
two blank
to monitor
lines
v1
FREQUENCY
COI'NTERROUTINE
This routine counts frequency using input PBO at a maximum rate
of 2O KHz. It counts DATA for I second. To count'for 10 seconds
load $29 into address 60. It uses PB7 for int. req. (connect PB7
to IRQ. ).
0000 A9 01
r_DNt
0002 85 65
STAz
OOO4F8
SED
0005 A9 36
LDA/f
OOOT8D FE L7
STAG
000A 49 00
LDA/r
OOOC8D FF 17
STAG
000F 58
cl,r
0010 00
BRK
OO11EA
NOP
OO12AD 02 L7 CKL6^I LDAG
0015 29 01
ANdt
0017 D0 F9
BNEr
OO].9AD 02 T7 CKHIGH LDAG
001c 29 01
AND/r
0OLE F0 F9
BEQr
0020 18
crc
0021 A9 01
LDNI
OO23 65 F9
ADCz
0025 85 F9
STAz
0027 A9 00
LDLI1
0029 65 FA
ADCz
0028 85 FA
STAz
002D A9 00
Trlill
002F 65 FB
ADCz
0031 85 FB
STAz
0033 4c 12 00
JMP@
0036 48
INT
PHA
0037 49 90
LDAii
OO39 BD 04 L7
STAG
003c 2c 07 L7
BrT@
003F 10 FB
BPLr
0041 A9 F4
LDA/F
0043 BD 0F 17
SrA@
0046 c6 65
DECz
0048 F0 02
BEQr
004A 68
PtA
RTI
OO4B40
OO4CA9 FF
DISP
LDAif
0048 85 66
STAz
OO5O20 lF lF OUT
JSRG
0053 C6 66
DECz
0055 D0 F9
BNEr
0057 49 00
Tr}ilt
$or
lUECNT
INTLOW
$17FE
INTHIGH
$17FF
set int.
PB
check
vector
for
input
lotr
$or
CKLCff
PB
$01
CKHIGH
check for
input high
$or
$F9
$re
$oo
$ra
$FA
$00
$FB
$FB
CKLCI^I
check time
$eo
$r.704
$L704
DEI,AY
$f+
set timer
$170r
II'{ECNT
DISP
$FF
SCANCT
SCANDS
SCANCT
OUT
$00
c- 11
output data
dee. loop count
rept. display till
count Ls zeto
looP
#3
0059 85
0058 85
o05D 85
0o5F A9
0061 85
0063 68
0064 40
0065 05
0066 rF
F9
rA
FB
05
6s
STAz $rg
STAz $m
STAz $TB
rDAtl
$OS
STAz T'{BCNT
PI,A
RTI
*DATA (${ECNT)
*DATA (SCANCT)
c-12
set total
reset
counts to zero
I see timer
Display
0000 A9 FF
0002 8D ol
0005 AD 03
0008 29 sF
000A 8D 03
000D 20 B0
0010 85 F9
0012 20 lF
0015 4C 0D
START
17
17
17
00
LOOP
1F
00
LDA/I $ff
srAG
$1701
LDAG $1703
AND/f $EF
SrAG
$1703
JSRG ADC
STAz $fg
JSRG SCANDS
JMP@ L0OP
Display
0020 A9
0022 8D
0025 AD
0028 29
002A 8D
O02D 20
0030 85
FF
01
03
EF
03
80
E7
START
set PA port
to output
set PA port
display
to output
LDA/f
STAG
LDAG
AND/}
STA@
JSRG
STAz
$ff
PADD
PBDD
$nr
PBDD
ADC
HEDEC-L
0032 !,2 00
r.Dxlt
$00
OO34 86
0036 20
0039 46
0038 86
003D 46
003F 86
0041 A2
0043 86
OO45 20
0048 4C
STXz
JSRG
IDXz
STXz
LDXz
STXz
IJX/i
STXz
JSRG
Jl@
HEDEC.H
HEDEC
call binary to BCD converslon routlne
get BCD result high
$ff
store result in left display
$FB
get
BCD resul-t Iow
$82
store
result in niddle dllsplay
$fe
zero
right display
the
$OO
:
$rg
SCANDS display final BCD value
READ
loop back for more data
17
17
17
00
E6
00 02
Ei
FB
E2
FA
00
F9
lF lF
2D 00
READ
read ADC
set up data for
binary
to BCD conversion
note:
In order to perforrn the binary to BCD conversion, you nust
the IIEDECprogram into the memory starting
at address $0200.
c- 13
load
REAL.TIHE CLOCK
f4
o
,
$0080
$00E1
$0092
$0093
$0084
tb
IIAI,-TIII
0370 A9 00
START IDA# $00
0372 p5 80
STAZ QSEC
0374 A9 F4
IDA# $F4
0376 8D 0F 1?
STAG TIMEF
0379 A5 81
D$PLY I.DAZ SEC
0378 85 19
STAZ $Pg
037DA5 82
LDAZ MIN
0371 85 FA
STAZ $FA
0381 A5 83
I.DAZ HR
0383 85 FB
STAZ $FB
0385 20 6A lF
JSR,@ GETIGY
0388 c9 or
CMP# $01
038A D0 0D
BNER ENDR
038c 20 lp lF
JSRG SCAMS
038F 20 6A 1r
JSRG GETKEY
0 3 9 2 c9 01
cl{P# $0r
0394 D0 03
BNER ENDR
0396 4C .4F tC
JUPG
YOXTR
0399 20 lF lE
JSRG SCAI{DS
0t9c ll
GTf
0t9D 90 br
BGM DSPLT
to lntelrupt
in 1/4 rcc.
get aeconds
eend to rlght dlsplay palr
get rnloutes
cend to rolddle dlsplay patr
get houre
sent to left dlsplsy patr
check for r'1r key pressed
dlsplay tlue and delay
check for "Iil key preised agatn
03A5 48
RTCLK
03A6 8A
03A7 48
03A8 98
03A9 48
.
03AA49 83
03Ac 8D 04 L7
03AF 2C 07 L7 TM
0382 10 rB
0384 E6 80
0386 A9 04
0388 C5 80
038A D0 38
03BC49 00
03BE85 80
03c0 18
03c1 F8
03c2 45 8l
03c4 69 01
03c6 85 81
o3c8 c9 60
03cA D0 28
03cc 49 00
03cE 85 8l
03D0A5 82
03D2 18
0tD3 59 01
O3D5E5 E?
03D7c9 60
03E9 D0 19
03Dl r.9 00
03DDE5 82
03DF45 83
03El 18
0382 69 01
0384 85 E3
03E6c9 12
03E8D0 02
03EAE6 84
03ECC9 13
TH
03BED0 04
0310 A9 01
0312 85 83
03F4 D8
RTN
03F5A9 rA
03178D 0F 17
03rA68
O3FB A8
03rc 68
O3TD AA
03F! 68
otrt 40
PHA
Tt(A
PHA
TYA
PE[
r.DA{f
STAG
BIIG
BPLR
INCZ
r.DA#
CMPZ
BNER
aave A
gave X
$83
TIME4
TI}TES
TM
qSEC
$04
QSEC
RTN
u)A# $oo
S1AZ QSEC
Save Y
ftne adJust tiuring
te8t tlnler status
loop untll tine out
count 1/4 seconds
do four tines before updating lccondl
zero QSECand update clock
cLc
SED
I.DAZ
ADC{I
STAZ
cMP#
BNER
I.DA#
STAZ
I"DAZ
cIc
toGt
stlz
ctot
trat
IDA'
SEC
$Or
SEC
60
RTN
OO
SEC
MIN
eeconds = 60
reset seconds to 00
lncreroent..mlnutes
0l
xtx
60
lu
untll
tlhnter
. 60
rcrot
Elnutcr
to (b
sttz
tEr
I.DAZ
cLc
ADC#
STAZ
cMP#
BNER
INCZ
CMP#
BNER
r.DA#
STAZ
CI.D
LDA#
STA@
FI.4
TAY
PIA
TA:(
PIA
TTI
HR
01
H8,
12
TH
DAY
13
RTN
01
HR
$rl
TI,}MF
lncrenent houra
untll
hours
12
agalo rlth
one
lnttrrupt
.Gc
TIMER (STOPWATCH)
Klm-l User Notes
v, L ll2
Joel Swank/1186
4 6 5 5 S . W. l 4 2 n d
Beaverton, 0R 97005
KET
0
1
2
3
4
c)
I
H
LN
FI.'NCTION
Bt op
s t ar t
r es et
ptlnt tine on terainal
return to KIM monitor
STOPI,IATCH
0300 A9 79
0302 8D F2 17
0305 A9 02
0307 8D F3 17
O3OA49 OO
030c 85 F9
0308 85 FA
0310 85 FB
0312 20 lF lF
0315 20 6A lF
0318 C9 04
031AD0 03
031C4C 64 lC
031r c9 03
0321 D0 lF
0323 A5 rB
0325 20 38 lE
0328 A9 3A
032A 20 A0 lE
O32DA5 FA
032F 20 38 lE
0332 A9 2E
0334 20 A0 lE
0337 A5 19
0339 20 38 I E
033C20 2F rE
033F 38
0340 B0 D0
srA@ $ r 7F2
I.DA# $02
STAG $ 17F3
RESET
900
STAZ INH
STAZ POINTL
STAZ POINTH
Hor,D JSRG SCANDS
JSRG GETKEY
CMP/I $04
BNER NOQUIT
JMPG CLEAR
NoQUIT CMP# $03
BNER NOPRT
I.DAZ POINTH
JSRG PRTBYT
I.DA{I t:t
JSR@ OUTCH
I.DAZ ?OINTL
JSRG PRTBYT
LDA# t.t
JSR@ OUTCH
LDAZ INH
JSRG PRTBYT
JSR@ CRLF
sEc
BCS
HOI.D
zero display
light dlsplay
read keyboard
key 4
return
key 3
to KIM Sonitor
tiroe on terminal
0342 c9 02
0344 F0 C4
0346 c9 0r
0348 D0 C8
034A A9 9C
034c 8D 06 17
O34F 20 IF IF
0352 AD 07 17
0355 F0 FB
0357 8D 00 1C
035A A9 9c
035c 8D 06 t7
335F 18
1360 F8
3361 A5 F9
0363 69 01
0365 85 F9
0367 A5 rA
G369 69 00
0368 85 FA
036D C9 60
036F D0 0B
0371 A9 00
0373 85 FA
G375 45 rB
C'37718
0378 69 01
a37A 85 rB
C37CDB
c 3 7 D 2 0 6A l F
0380 c9 00
0382 D0 cB
0384 F0 8c
NoPRT
cw# $02
BEQR RESET
nMDJI
(111
Yvr
BNER HOLD
r,DA# $9c
STA@ TIMSET
DISPL JSRG SCANDS
D(PCK I.DAG TIMCET
BEQR D(PCK
STAG ROM
I.DA/I $9c
STAG TIMSET
cLc
SED
LDAZ INH
ADCII $01
STAZ INH
LDAZ POINTL
ADC# $00
STAZ POINTL
cMPit $60
BNER CKEY
LDA# $00
STAZ POINTL
LDAZ POINTH
cLc
ADC{it $01
STAZ POINTH
CKEY
CIID
JSR@ GETKEY
cMP/f $00
BNER DISPL
BEQR Hor.D
k ey 2
bac k to z ero
key 1
s et ti ner
dl s pl ay v al ue
c hec k ti ner
w ai t l oop
del ay 4 us ec .
s et ti mer
8et fl ags
dec i mal node
l nc rement
hundredths
tnc rement
s ec onds
s top at 60
z ero s ec onds
lncreroent
mlnutes
read k ey board
k ey 0
6toP
0200 F8
98
48
8A
48
0205 A9 00
A2 06
95 DF
CA
020c D0 FB
E6 E5
02L0 A5 E7
02L2 48
A0 08
0215 68
4A
48
0218 90 0C
42 03
18
OZTD 85 E2
75 DF.
95 DF
CA
0224 DO F7
0226 A2 03
L8
85 E2
75 E2
95 E2
CA
0230 D0 17
88
0233 D0 E0
0235 68
A5 E3
0238 D0 04
A5 E6
023C D0 D4
0238 68
AA
68
A8
0242 D8
0243 60
stack)
(zeros 00 E0 to 00 E5 in a Loop)
(sets X-lndex for 6 operations)
(zero-page, X storing)
(DEY)
(if not zero, back to 02L5 for
(this PLA stack pu1l needed to
(LDA highest converslon factot
(if not zeto, Job ts finlshed,
(Lf zero, Load hl hex byte)
(tf not zero, back to 02L2 for
(restore X, then Y, lndexes)
(clear
(RrS)
decimal node)
c-15
next bit)
equallze PIIAe and PLAs)
location)
eo exit)
blt
testlng)
/f3
MULTIA SUBROUTINE
Program MULTIA (second, revised version) does binary multipl-ication
of tswo8-bit numbers that have been stored (before the JSR to MULTIA)
in 0083 and 00E4 and are destroyed by the operation of the subroutine.
The hi 8 bits of the product are stored in 00E0 and the low I bits in
00E1; the subroutine initiaLLy
zeras these locations, and aLso 00E2.
Operations use LSRs on the mul.tiplier i.n 00E4 to move up to B bits in
sequence into the carry flag.
If the carry is set, the multiplicand
(in 00E2 and 00E3) is double-p::ecision added to the product locations.
If bits remain in the multiplier
(00E4 not zero), the multiplicand
is
shifted left in the 16 birs of 0082-00E3; crherwise rhe subrourine
exits.
Program length: 36 bytes.
Maximun product (FF X fF) is FE01
or decimaL 65025, with execution time about 380 rnicroseconds. Time
declines ta 240 microseconds for 80 X 80" 160 microseconds for 10 X 10,
70 microseconds for 01 X 0l-" 40 microseconds for 00 X 00.
000A A9 00
85 E2
85 El
85 E0
OOL2 46 E4
0014 90 0D
0016 18
45 E].
65 E3
85 El
001D A5 E0
65 E2
85 E0
0023 A5 E4
F0 06
0027 06 E3
26 E2
0028 90 E5
002D 60
(zeros locations
00E0 to 0082)
go to 0023)
stored in 00E0-0081)
c- r 7
H, T. Gordor:
Berkeley, Callf.
SUBROUTINEDIVIDA
Ttris software gives the quotient, to t6-bit or better precision,
of, any hex number from 0001 to FFFF by any hex number
from division
from 0L to FF. It uses 10 Locations from 00E0 to 00E9, The quotient
appears in the lowest 5, with a fixed decinal igfi"d.
betlseen EL and
Er.
The raage of quotlents is from $ 0000,0fffi11@o*
division
of
0001/Ff) to $ FFFF.000000 (from division of FFFF/OI). Quotient Locations
are initiai.ly
zeroed by a JSR. to SUBROUTINE
ZEROER,which must also be
in memory and is coded separateLy for use in other programs. Before
Ttre
the JSR DMDA, 4 locations must be fiLLed by the calLing program.
in
dividend high byte is set in-E6l the lshr bytl in 87, and-the Jivisor
byte'!, with a vaLne from 01 to 05, is sec in
88. The'rprecision
location E9; it is not altered by the programrbut the other 3 bytes
The purpose of the precision byte i.s to alloqz the user to
usualLy are.
control the number of quotient Xocatl.ous to be calculated by DIVIDA.
A value of 01 causes exit after the proper quotient value in Location
E0 (which may be 00) has been calculated"
A vaLue of 02 limlts the
caLculation Co quotient trocations E0 and 8L, and gives frinteger
A val-ue of 03 aLLows only one Locatlon to the right of
arithmetic".
The chief, use is to shorten the execution
the inpl-ied decimal, etc..
time, wirich caa approach 2000 mie.roseconds at a preclsion of 05.
However, DMDA aL',tays exlts when the calcuLated remainder is zeto, since
of higher-precislon
locations ls then unnecessary. No
calculation
8.g., the quotlent of FEFE/FF
operations are included.
"rounding-off!'
is 00FF.FD0000 at a preci.sion of 03, although tt should be 00FF.FE
since the quotient is 00tr'F.I'DFDFDat a preclsi.on of 05.
DIVIDA exits in Less than i.50 uicroseconds if the dividend is 0000.
agalnst a dlvisor
It provides uo protection
of 00, so the caL!.ing
program shouLd guard against thts!
A guard could be i"neerted ln
DIVIDA, but I feel it is better for the cal-ling program to decide
what should be done lf such an error occura,
elngle-btt
Operation of DIVIDA invol"ves addltl^on of a ehiftlng
by the
quotient
to
in
locatLon
05,
the
location
controLted
"Bit-Bytef
The X-register
X-register,
whenever a positive remainder is obtalned.
is not protected by DIVIDA, so it is better to use Y-indexed Loops in
the calLing program (that othenrise wilL have to store and restore the
X vaLue).
T'tte final renainder is i.n location E6 when DMDA exirs.
vaLue is not altered if it is $ 80 or rnore; otherwise
ltre divisor
lt ls left shi.fted by DMDA.
DMDA is very Long (70 bytes, or 78 Lf one includes ZEROER;tf
part of DMDA the length
the zeroing operation were made an integral
It Ls also sLor^l
would be 74 bytes and execution a strade faster).
It ls
but retratlveLy inexpenslve.
compared to hardware arithsretic"
meant to handle data, that are never precise, and not the kind of
Since the ROR
eomplex math for which cai.cul.ators are designed,
is not used, it wi.L1 run in any 6502 system.
instruction
Much of the Length of DIVIDA ls caused by speclal. Logic designed
to reduce the execution tirne---a deli.berate trade-off
of rnore program
bytes for a Lower average time, that has the effect cf proloflgtng the
tlme of divisions
wher no eaxL,g exit is posslble.
c*l_8
c- 19
SUBROUTINEZEROER
0200 A9 00
95 DF
0204 cA
D0 FB
o2a7 60
(rDA/i 00)
(STA zero-page, X)
(DH()
(BMo if * 0, back to 0202)
(Rrs)
SUBROUTIM DIVIDA
(Note that 3 Locations are unused between the end of ZEROERand the
start of DIVIDA. This is to aLl.ow users (if the subroutines are in
RAM) to insert 3 instructions
folLowing the LDA divisor
instruction
ax O2L3. If the divisor
is 0G, DIVIDA is wrong. The instructi.ons
for this a BREAKto 1C00. If something more
D0 01 00 substltute
complex is needed, the 3 ins'tructions
can be a Jl'lP or JSR to a
longer sequence of instructiorts.)
o2oB L2 06
20 00 02
(I,DA/I 06)
(JSR ZEROER, Eo zero 00E0 to 00E5)
021_038
26
02L3 A5
30
o2L7 26
0A
021A D0
85
(sEc)
(ROL sets Blt-Byte to 01 and clears carry)
(LDA dtvisor byte)
(8M1, if blt 7 = L, skip to 021C)
(ROL Blr-Byre)
(ASL, Left-shtft
divlsor
Ln accumulator)
(BNE, Lf. * 0n back ro BMI ar O2L5)
(STA bit-pattern
L)C0( XruO( into dlvlsor
locatlon)
E5
E8
05
E5
F9
E8
021-EA5
B0
0222 D0
A5
0226 FO
85
O22L 86
E8
E6
0F
09
E7
28
E6
EV
(tDA dividend-hi)
(BCS, if carry set, go to subtraction
at O23L)
(BNE, lf * 0, go to CMP at 022D)
(LDA dividend-lo)
(BEQ, dlvldend = 0 so exit to 0250)
(STA dtvidend-lo
into dlvidend-hi
l-ocatlon)
(STK zeros dfvldend-lo)
(INX to shift
to next higher quotient Locatlon)
022D C5
90
0231 E5
85
0235 L8
85
0238 65
95
E8
0B
E8
E6
(CMP dividend-hi
with dfvisor)
(BCC, dl.vlsor too large, bypass to 023C)
(SBC, subtract divlsor
frorn divldend-hl)
(STA renainder Lnto dlvidend-hi)
(CLC for addltion)
(LDA zero-pager X the proper quotl.ent byte)
(ADC the nit-Byte)
(STA zero-pager X back lnto quotient locatlon)
023C 46
D0
O24O Eg
E4
0243 I'0
A9
0247 85
E0
E5
E0
E5
09
E9
0B
80
E5
c-2 0
locatl.on)
T Z -3
(sru)
( ae ua nb as Ssaf fxau JoJ gTZ0 of dl^If)
(l3;;r{s eqt sa}aTduroc1q-puap}^Tp rox)
( r J;qs*+laT pu ap TATp slraf,s oT-prrapT^TpTSV)
09 AEZO
ZO H\ 3V qrzo
9s. 9Z
Ls, 90 6rz0
15 BIT SQUAREROOT
SQUAREROOTSIDROIITINE
aod ylelda
result.
rrttteo
a! elght
blt
lnteger
blnary
by B.E. DuPuy.
rtth
as a subroutlne and
routlne.
8 blt
8 btt
taput (high)
tnput (1ov)
90080
9O0Sl
8 blt
8 blt
output (tnteger)
output (factlon)
900E0
90081
otlter locatioue
Alt
cpu .reglatctr
f o llowe:
I
N)
N
fractlon
coMlnl'cates
blnary
0100 A9 00
0102 85 82
0104 85 E3
0106 49 Fr'
0108 85 E4
010A 85 E5
010c A'9 10
0l0E 85 E8
0110A2 02
0112 06 E r
0114 26 E0
0116 26 E3
0118 26 E2
0114 cA
0118 D0 F5
011D06 E5
011F 26 g+
0121 E6 E5
0123A5 E4
0125 85 E5
0127 A5 E5
oL29 85 E7
0t2B 06 E7
0t2D 26 E6
012F 86 E7
0131 18
0132 A5 E7
0134 65 E3
0136 85 E7
0138 A5 E6
013A 65 E2
013c 85 E6
0138 90 0A
0140 c6 E5
oL42 L5 E7
0144 85 E3
0146 A5 E6
0148 85 E2
0t4A c6 E8
014c F0 03
0l4E 18
014F 90 Br
0151 A5 E4
0153 49 FF
0155 85 E0
0157 A5 E5
0159 49 FF
0t5B 85 El
ouD 60
SQRT
LOOP
SI{FT
LDA/I
STAZ
STAZ
I.DA#
STAZ
STAZ
I,DA#
STAZ
I.DXii
ASLZ
ROLZ
ROLZ
ROLZ
DEtr
BNER
ASLZ
ROLZ
INCZ
I.DAZ
STAZ
I,DAZ
STAZ
ASLZ
ROLZ
INCZ
cLc
$00
$82
$E3
$rF
$84
lnltiallze
extended ergunent
loltiallze
cooplenented result
$10
colrNl
$02
9El
$no
$E3
982
tnltlstlze
loop count
$ns
SHTT
$85
wAz
NOGO
DONE
shift
partlat
shifr
of
result
E2-E3-80-81
left
)e4
$a:
$84
$uo
$Es
$87
987
986
$87
wAz $87
ADCZ
STAZ
IDAZ
ADCZ
STAZ
BCCR
DECZ
LDAZ
STAZ
double lefr
$nr
sh i ft
co p y o f p a r tl a l
rcrult
r e e u l t l e ft
$87
$so
9E2
$86
NOGO
985
$87
$83
$86
$az
cilnn
DONE
STAZ
DECZ
BEQR
cIt
BCCR LOOP
I-DAZ $E/t
EORf $Fr
STAZ 9so
I.DAZ $85
808# $rr
8TAZ
ft8
err
te st 8 u b tr a cti o n r e su l t
tack a zrto onto complenented rerult
replace hlgh order 16 of current
renainder wlth subtractlon rerult
decresent and test
loop count
Juop to loop
conpleloent result
rcturn
rt F
r; tt
ll
l;
+\
lj
[,il u
NT, FUEL
F;;,:E;;.,i;l
ois
iEu E R y
Figure l: A generalblock
diagram of a simple lunar
fander progrom. tt can be
seen thot a tunar londer
program bosicolly breaks
dawn into o number of
updating rautines. Thse
updating routines ore continuously repeated until
the lunor lander has
reachedthe surface.
jtv-u;'(,
14.,ft
|.q!
il il
Jim Butterfield
14 ErooklynAv
Toronro Ontariofol4M?XSCANADA
c-.23
Every0.01second,
add 0.01 of the accelerationto the
veloe
lty;
add 0-01 of the veiocity to the altitude;
subtract0.01 of the thrust frorn the
fuel.
The accelerationis set equal io thrust minus
gravity, and gravity is set at the constant
value 5.
The time period of S.01 s is arbitrary"
Since KIM can oprate in decimal mode,
dividing by 100 becon'resan elementary
operation. Everything would work iust as
well if it were done in.any other srnalltime
incrernent.
Figure 1 shows an elementary block
diagram of tfie program" After setting rhe
we settlinto three main
initial flight valuesu
jobs: updating the flight, lighting the display, and detectinginput from the pilot"
Sctting lnitial Values
An interestingflight ean be obtained by
starting the lunar rnodule at a height of
4,500 feet with 800 pounds of fuel. That's
rnore than rufficient fuel for a safe landing,
but not enough to allow for prclonged
hovering
It's not difficult to 5et all the inirial
values by programmingthern individually.
Howerrer,a faster method is to set them all
togethe!' in rnemory and use a loop to
initialize ali of them" Thls is what I did as
.l
shown in lisring on hexadecimallines 0000
ro 0007.
Updatingthe Flight
Every0.0i s we must updaleour rateof
descent,altitude and fuel. As previously
indicated,we have tc add 0"01 of various
valuesinto the totals.lVe can accornpllsh
this quiteeasilyby usinga gimmick.lnstead
in feet,
of holdingthe allirude,for exarnple,
let's ute two n'lore digits arid store it as
multiplesof 0"{}.1feet"f,lowwe can add rhe
rate of ascentdirectly into the six digit
number;and the divisionby 100 happens
automatically,For dispiay purposcs,of
course,we drop the lastlwo digits,so that
we'rebackto heightin fcet, Usingthes;rrne
techniqueon the otherparameters,
we find
that the updatingjoLi becomesrelatively
easy.
During the updaringtask,we must also
detecI two specialconditions;touchdown
and oul of fuai. T'hiss*effisfairly simnle
Listing t: Atr example luns lander proqran writtn for the Klfrt-l
micropracessar thot uses the flowchart af l'igure I ss s bsse" The input ond
outpat o{ this pragram is handled by rautines thot src inherent to the KIM-l
systcm. The dota display is seenon the keypad ond LED dispfay of the KIM-I
assembly" This disploy continuously shows the rate of descent, und on
tornman,l will display either the qmaufit of fuet left, ar the altitade of the
croft. Keys I through 9 are used t# !ftput thrust commands, while key A
c*ssses the altitude disploy mode and the F hey choases the fuel disploy
tnsde. A!! the numbes in this listing arc in hexadecimal unles otherwise
stsfe#.
Addrcs
$s$o
0p
L.bcl
Optrad
A2 0e
GO
LPl
85
95
eA
'r0
A?
4,0
F8
'!E
85
75
95
eA
8g
10
85
"!o
rqg
?5
95
cA
x0
ss?s
,q5 E2
LDA ALT
G0?8
so?A
s02c
0$28
fi030
ss32
0fi33
**35
f;836
smSs
s$3.4
0s3c
10
.49
A2
gs
95
cA
10
3S
A5
E5
85
A?
8FL UF
I,.DA ffiO
LDX *S2
STii.&Lf"X
STA TF|?,X
s0,40
fii84?
s$li4
E9
95
eA
6Sd7
0{J49
fls4B
004D
0s4F
S0
A9
Alt
95
cA
0s45
'r0
ol
2
E4
2
DIGIT
ro
F6
a2
99
E2
INCR
F",
E5
o8
oo
a2
E2
E8
DD
FC
D
EA
EO
ol
e8
o0
EB
UP
LF2
F7
0e
oo
03
EA
r0
?0
A5
n0
F8
AA OO
EE
OA
0c5g
01158
005n
OfisF
6061
&s63
00s
ss6?
CI*69
s0s8
s060
ilSSF
6)07!
A5
46
Fi)
D0
F0
A5
A6
sii
8S
.A5
30
rx5
F0
?
E3
08
06
,4
EB
&8?5
0s7s
0*?s
3g
A9 80
Hs c!'
f-e 4
CALC
RECAL
init,sliee veldGs;
X:*O5;
Y:*Ol;
ser dcir:al ma&;
clear carry;
l
)' add each digir;
*gn
0050
s0$2
o$gs
$s6?
ss?s o0
Ftt
0s
Gorm*tary
l-Dx sSC
tSA trutT,x
5TA ALT,X
EEX
8FL LPT
LDX *SF
LSY.,*S1
*fi42
0004
0s06
000?
00{rg
0s0s
$#dn
00$E
0fl0F
00r1
$sT3
0s15
ss'r6
00'!?
00rs
ffixg
EStS
s01F
s0?1
c023
0c?.4
ss3tr Es
B8
E2
Mnwmonie
ga<
F8
FA
E5
06
LP3
TANK
cr,g
LDA AI.T"X
AFE ALT+?,X
gTA ALT,X
DX
0Y
BP[-BISIT
LSA ALT+3.X
$FL INCR
ST
.
CD
07
ne
[-sA #sg
eounter:*counter - l;
il counter pgitirr go ta
RCAL;
elsc check it altiarde ir
$'6ititG;
it altiwde positilr{ go to UP;
elr sltitude:*q);
X:*O?
ogx
Bp[ s&
CC
LSA FTJEL+z
sse TF{flLrsT
$!.A FUL+2
LSX.#*1
L*A F{,I*L,X
$80 **S
si'A F{J#L.X
ilx
BPL LF?
geg TAr{K
LS4 #0
LSX *SS
I9TA THSUST,X
DEX
BPL O-F3
J5FI?HfiSET
LSA futI)OE
Si\{ES}'{GFL
sEs $'f"
stvtr $f
gg0 EALO
I"CIAFUL
tS X FU t+ 1
$TA POIru?H
sTX p8iiitTL
LSA X,1&L
Bf,{i sffl /F{
LFA 1l-+X
E#fl FLY
gfl,gFLY
DOWN
I
)
ADS ALT,X
STA ALT,X
DX
EPL RgI{L
tDA A{,'1"
LOX AL,T+i
LINK
SHOFL
Sge
'r-p& #{ffi
s8* vsL+x
II
3et e8r{'y;
tI
uodoto fuel;
i
I
'ea to THflSET;
A:*display rlrods;
il rnode not 0O go to
SFiSFL;
AX :-locaticn of eltituda;
go to $T;
A:*F[.iL;
X ;TFU E L+; l
i
I dlrrlovvaluce;
A:welocityslgn;
if *ignn*grtlvc0o to DOWN;
A;./wlociry/;
I so te FLY:
b
1 vst@city:*Amtoity/;
a
Listing l, continued:
Address Op Operand
ooTc
007E
o080
oo83
oo85
0088
oo88
ooSD
85 F9
A9 02
85 E1
20 t F r F
F0 06
20 6A tF
20 91 00
El
c6
DO FI
008F
0091
0093
FO
c9
DO
DO
15
03
(X)gs
0097
(X)98
oo9A
o09c
009e
00A o.
00Ar
OOA3
ooA4
00A6
ooAS
OOAA
ooAc
OOAD
00AF
0081
0083
00Bs
0087
0088
(n89
ooEA
ooBB
ooBc
00BD
ooBE
00BF
00c!
00c1
ooc2
ooc3
00qr
85
60
C9
DO
A9
85
60
10
AA
A5
FO
86
A5
38
E9
85
A9
E9
85
60
45
00
@
99
8[)
00
99
98
02
08
00
00
00
EE
007A
ro
o5
o0
EE
FO
EA
F8
A
EA
Label
Mnemonic
FLY
FLITE
NO KEY
DO KEY
STA I NH
LDA =O2
STA DECK
JSR SCANDS
8EO NO K E Y
JSR GETKEY
JSR DOKEY
DEC DE C K
BNE F LITE
BEO LI N K
CM P = 15
BNE NAL T
STA MODE
RTS
NALT
CM P: 10
BNE NALz
LDA =OO
STA MOOE
BET1
BTS
NAL2
BPL RET1
TAX
LDA THRUST
8EQ RET l
STX THRUST
THRSET LDATHRUST
sEc
o5
SgC;{)5
STA TH2+1
LOA C)O
FO
00
00
EE
sBcso
STA TH2
RTS
I NI T
Cornmlntary
!
DEcK:=o2; lcounterl
l
look for depressed
key;
i f n o i n p u tg o r o N O K E Y :
elsego to GETKEY;
go to DOKEY;
DECK:-DECK-I:
i{ DECK not egualro 0 go to
FLITE;
elrego to LINK;
A:=fuel mode?;
it not fuel mode go to
NALT;
elseMODE:= fuel mode;
return;
A:raltitude mcdre?;
if not go ro NAL2;
elsemode:=altitudemode:
MODE:-A;
return;
return; fillegalmodel
lseX:-A;
A:-THRUST;
if thru:t:=0 go ro RETl;
elseTFIRUST:*X;
A:.THRUST;
3et carry;
THRUST:*THRUST- O5;
TH2+1:.THRUST;
I
I A:'00;
TH2:-OO;
raturn;
)
)
I
)
I
[inatiatheishrl
[initial-soeedl
| [initi"t acceleration]
iinitial thrustl
)
)
[initial fuell
tmoacl
untif we realizethat both the altitudeand
the fuel gaugewill probablygo right pastthe
zero mark,jumpingdirectlyfrom a positive
to a negativevalue;so a zero test is out.
Instead, we take action the instant the
number goesnegative,restoringit to zero
and then taking whateverother action is
calledfor.
Lightingthe Display
The display is quite straightforward;
in
fact, the KIM-I monitor program has a
to do thejob.
subroutine
on the displaymodeflag,all
Depending
we needto do is to movealtitudeor fuelto
the display area, togetherwith rate of
dcscent.Then we call the slbi2rllins 1t
transferit to the LEDs.
to drop the
Of course,we mustremember
last two digits from the displayedvalues
c-25
Detecting Input
HORSERACE
E ight
whip your
K I M-1 Us e r
Ch a rle s K .
1 9 6 0 6 G a ry
Sunnyvale,
1ap hor s e
horse
to
ra e e a n d y o u e a n b e t h e
g o f a s t e r.
program
the
and
horse
Wh ip p in g
top
mid d le
bottom
at A2 7 F .
jo c k e y
poops o u t .
Track
Prince Charming
Colorado Cowboy
Irish
Rai-r
S tart
Warni.ng--whip
No t e s v 1 # 3
Eaton
Ave.
CA 94086
b u t to n
PC
c
4
B a c e is
e ig h t
la p s .
HORSE RACE
00 01 02 03 0 4 0 5 0 6 0 7 0 8 0 9 0 A 0 B 0 c 0 D 0 E 0 F
0270
0280
0290
0240
0280
02cg
02D0
02E 0
OTFO
OS OO
0110
g32A
0330
05+0
O55O
0160
0370
0580
0t90
00
A2
00
20
85
95
50
06
CA
C6
89
20
B0
03
01
95
91
80
FE
00 00
L3 B D
A 2 0g
5D 1F
99 A 4
7C E 8
t8 D0
95 83
DO F5
8F DO
89 00
68 03
05 A 9
F0 0i
65 9A
8c 95
A 2 04
80 80
B F F7
00
7C
89
A5
99
96
0b
CA
EA
06
F0
29
FF
88
18
86
85
FF
01
00
07
7c
8F
86
8l
A5
10
EA
45
0B
t8
99
98
A6
4c
91
FF
0i
00 00 00
9 5 7 C CA
00 84 FC
Et A2
'803 8 9 9 0
89 90 03
8F F0 28
F6 A2 06
EA EA EA
8T 09 05
20 68 03
85 94 89
86 00 2A
55 89 85
99 75 8C
A9 02 t8
9 5 9 2 CA
FF 80 80
04
c-26
00
10
20
03
03
49
D0
85
EA
85
29
8C
5D
9A
EA
18
10
80
00
F8
4E
CA
35
FF
30
7C
EA
81
tC
00
1F
EA
EA
A5
F9
00
00
A9
lF
3A
7C
15
A2
95
EA
EA
D0
30
A0
EA
EA
92
50
00
00
7F
C8
DE
EA
7C
02
76
EA
EA
18
0B
FF
2D
EA
65
80
00
00
8D
C0
D6
EA
95
l8
A9
EA
EA
99
29
46
68
EA
95
80
80
00
41
05
86
EA
7C
85
80
EA
EA
89
t8
99
0t
EA
65
80
80
00
t7
90
D0
EA
E0
83
95
EA
EA
00
C5
3D
38
EA
96
80
80
D8
A0
F3
F9
EA
05
E9
7C
EA
EA
EA
9A
93
29
EA
85
80
08
ONE.ARMEDBANDI,T
0200 A9 25
co
0202 85 05
0204 20 BA 02
0207 A9 00
0209 85 06
rDA# $25
STAa
Al'ff
JSRG CVA}ff
CHANGETO DISP
LDA# $0O
STAz
ARRCI,J
:
HAII.I DISPLAY LooP
0208 20 8D 02 LPl
JSRG NISPLY
020s D0 FB
EIIEr
LPI
021.0E6 09
ROIL
lNCz
TLI},IBLE
0212 20 8D 02
JSRG DISPIAY
02tr5 F0 r'9
BEqr
I{OLL
02],7 A9 03
LDAII
$03
0219 8 s 0 6
STAa
.qRRCt"t
0218 F8
SED
0?1C38
sEC
021DA5 05
LDAz
AMI
02tF E9 0t
SBC# $01.
CHAR.6E
A BTJCK
0221 8 5 0 5
,iTAz
At-fT
02?3 20 BA 0?
-TSRG C'VAHT
0226 26 09
ROLZ TL&$TJ8
0223 20 8D 02 LP2
JSFLG DISPLY
0??Bc6 08
OECz STALLI
ilAIT
022DD0 19
Bi{Er
l,Pz
02?F A{i 06
Lily;n
An-R.CSf
0?3t. 15 09
IDAZ
TI,JlIEL4
s233 :,9 $6
tu\D#
*36
03:i5 fi9 4ii
$R.e.{l $40
,cF.!-L\}
rtil$rJL'i
0237 95 01
STAZ:- irilr.ilst=-1..1 ?i3 FegFi,p^'i
c?39 45 09
[.SBa
?]ttl'i&LE
0?3s 45 09
L$Ra
?UMBLS
, EEC3 4,RRC+i
0l3D C5 06
O??FDOE7
$Nnr
LPz
; S?.L i*llin$L5 *q'IOPPSD- Cei;l?LrygpAy0?t
0241 A5 04
L0eu
ilINDoJ+q
0243 c5 03
{:t'tPe }III.ID@{+3
0245 DC 37
8)inr
NOMAT
0247 C5 02
CtlPz SLND{nf+g
0249 D0 33
ENEr
NOitfAt
o24B A2 10
024D C9 4C
024F F0 0D
0?5t A2 0B
0253 c9 42
0255 F0 C7
0257 A2 06
a?59 c9 44
0258 F0 01
025D CA
rDx+ $10
cr'tr# $40
BEqr
ilJlx*
cliP#
DEQT
pAy
rsx#
cllP*
$06
$44
BEQT
DEI(
PAY
$08
$42
PAY
J. Butterfleld
ToronSo
gr5 rp 3 $Aes
$10 rF 3 uPs
$5 rF 3 D&'NS
0258 86 07
0260 A9 B0
0?62 B5 08
0?64 20 8t] c2
c267 c6 08
0269 s0 F9
0?68 c6 0.r
0268 FO 9C
026F 18
0270 F8
s27t A5 Crs
0?73 $9 0i ,
0275 s0 94
02?7 B5 05
02?9-20B A 02
02?c Ds S2
4?T,Fifi: $l]
il?fl,j CP 4d,
O?S? F$ DA
&3,i!4 1{! 8D u;
+3Ei ,;J 0S
{r?89 s0 {i0
t2sil $Ll F?
;
A !{INI
PAY AI'toUM. TN :T
FAY
STXz RWD
PAx
rrA#
$80
STAZ STALLI
T,P9
JSR@ DISPIY
DgCz
STALLtr,
BNEU tl'9
DECg RIJD
EDQr Lpl
cLc
SED
LDAz
AMT
Alcf
$01
BCgr
LpiSTAZ Alff
JSRG CVA.}ffi
B}q$r
PAX
:
WllEEl-$ NOf .d]^,t$Al4E " enEffK FOFir3lti,i,t $iIS
i{0i'l,tT Lc$#
$*3
CltPi? $45
CEERRY
sEqr
FAy
L#li
JSRG nlsFr."f
LDAa
Slfi'
bt{Er
t,tri"
EEtlu
ItJ$.
lfrp"aX
SUBII0UTINfl
;
0288 A5 06
028f 1$ 02
029!, F6 02
0293 CA
0294 l0 Fb
s296 i.9 7F
0298 &D 4l J.?
0298 A0 CB
O29D A2 At+
0291' 85 00
02Al 8{ /+? l?
02A4 BD 40 1?
O2A7 D8
O2A8 49 7F
02AA E9 0t
02AC F0 ir{l
02Ai; 8* 42 L?
02Bi Cg
O2B? CE
0283 CA
028{,. 1S g;{,
0286 2S 40 lF"
O2I]9 6G
DISPIJ LoXz
BPLr
OVfiR lttCzx
INB15 DAX
BPLr
LDA#
$TA0
r.Drdi
LIX/I
LITE
LDAzx
s't'\ig
s?AG
CLD
T"DA#
ztrP
stsrii
Bttpjr.
s?,a/i
ItL1:
II.iY
onx
Fpt r'
JS!{r-g
RT$
AARsd
INB1S
WINDtlir+?.
OVEa_
$7F
pr.DD
gilB
${)rr
it')tirx$
SBri
SAt
9?r
$01
i:i}}
Siii-..
1"llt.t
fr-hrijt:-li
I
:
02BAt5 05
02BC29 0F
0?8s &{
OzBFBD E7 },F
02c2 85 00
02c4 45 05
02C6 /rA
02c7 44
02c8 4A
02c9 4A
O2CAAA
O?CBBD E7 l"F
02c0,s5 01
02D060
At'tflUNT
iueo*r
C8trVtii{il
iCH
I.DAz A|$
.A,ND/i $0F
TAX
Illd0x
TAt]1.8
STAa tlINDS,.;
!,DAz
AKI'
i,$Ra
I^SRe
LSR4
LSRa
TAX
I^DA{9x TABLI
STAz rriINDCfi+l
&TS
O2OODB
OaOLL2 OZ
0203 BD 85 02
0206 95 D2
O2O3 CA
0209 10 rB
CI,D
LDX{f 2
3 values
SETUP LDA@x INIT
from init
STAzx |"LZPT.
, . to maze ptr
DEX
BPLr
SEfitP
;--pick out specifLc part of maze
1.1
MAP
lDYii
O2OBAO OB
GEXI,IOR r.DAiy YEPT
6 rows X 2
020D B1 D2
sTAay WORK
O2W 99 D8 00
o2l2 88
DSY
0213 10 FB
BPLr
GEAnOR
to position vertically
;--shift
T-DXlt 10
O2L5 A2 0A
for each of 6 ro'ws, .
NXDIG LDYz
POSIT
shtft Y positions
O2L7 A4 D4
I,DA{i $ff
filling
with rwalls'
0219 A9 FF
REROL S0C
0218 38
..on both sides
ROLzx I{ORK+i.
Ozl.C 36 D9
ROLzx WORK
ro11 'em
02LE 36 D8
ROLa
O22O 2A
O22L 88
DEY
BNEr
REROL
0222 DA E7
segments
;--calculate
AbIrHi 7
0224 29 07
take 3 birs
0226 A8
TAY
& change to
LDAGy T48L
segnent pattern
0227 89 A0 02
STAzx WORK
022A 95 DB
,.and store
DE'X
O22C CA
DD(
022D CA
BPLr
}IXDIG
O22E LO E7
f!"asher
;--test
0230 C6 D5
LIGHT
DECz PLUG
time out?
BPLr
MUG
0232 L0 0A
,.no
0234 Ag 05
LDA{I 5
. ,!e8 e reset
0236 85 D5
STAz
PLUG
LDAz WORK{6
0233 A5 DE
..and..
023h49 40
023C85 DE
START
EOtVl $40
STAz WORK{6
c-28
.,fLLp.,
. ,. flasher..
display
LDA/f $Zr
open the gare
STA@ SADD
r.DYlt $Og
LDXit
10
LDAzx I,JORK
tiptoe thru. .
STAG SAD
. . the seguenrs
STY@ SBD
DECz STALL
...pausing
BN T
ST1
INY
INY
DEX
DEX
BPLr
SHCff
new
key
depression
;--test
JSRG KEYIN
ser dir reg
JSRG GETKEY
key?
CMPz SOK
,.same as l"ast?
BEQT LIGHT
STAz SOK
no, record it
which
key
;--test
5 items in tahle
LDX/I 4
SCAN
CMFGx TAB2
BEQr
FOIIND
DEX
BPLT
SCAN
BMIT
LIGHT
FOI]ND DD(
go key?
BMIr
START
if
wall
;--test
LDY@x TAB3
tDAGy WORK
AND@x TAB4
BNET LIGIIT
; --move
DEX
BPLT NOTUP
DECz POSIT
upr4Tardmove
MLINK BNEr MAP
l-o-n-g branch!
NOTUP BNEr
SIDEI^IY
INCz
POSIT
dormward move
BMT
MLINK
SIDEWY DEX
BMT
LEFT
DECz MZPT
right move
DECz MZPT
BN T
MLINK
LEFT
INCz
WW
left nove
INCz
NIZPT
BN T
MLINK
;--light
023E'A9 7F
MUG
0240 8D 41 17
0243 A0 09
o245 A2 OA
o247 85 DB
SHOI,{
o249 8D 40 17
024c 8C 42 L7
o24F c6 D6
STL
o25L DO FC
0253 CB
0254 CB
0255 CA
0256 CA
0257 10 EE
0259 20 40 lF
o25C 20 6A ].F
o25F c5 D7
026L FO CD
0263 85 D7
02.65A ? a4
0267 DD A 8 02
026A F0 05
026CCA
o26D LO F8
026F 30 BC
027L CA
0272 30
0274 BC AD o2
0277 B 9 DB 00
O27A3D BL o2
027DD0 81
o27F CA
0280 10 04
0282 C6 D4
0284 D0 85
0286 D0 04
0288 E6 D4
028A D0 F8
028C CA
02BDD0 06
o28F c6 D2
029L C6 D2
0293 D0 EF
0295 E6 D2
0297 E6 D2
0299 DO E9
TAB1
TAB2
TAB3
TAB4
O2AO
O2A8
O2AD
O2BL
;--tabL e s (h e x L is t e d )
00 08 40 48 01 09 4L 49
13 09 01 06 04
06 06 04 08
0r. 08 40 40
c- 29
INIT
MAZE
O2B5
O2B8
cursor pointer
5F 04
04 54
00 00
Maze construction:
every two bytes, starting
at MITZE,represents a
complete cross section of the mazei a one bit in any position represents
a wa11.
In the example above, the first
cross sectioa is FF FF (a11 one
bits) - this would be an inpassable section of watL.
The next cross
section (04 03) has only rwo pieces of waL1 in it, at positions 6 and
13. The zeros at the end represent the topen spacet.
c-30
MUS IC MACHINE
F. J. Butterfield
Toronto
Descr iptio n
Run
)
J
Write
yo ur
f or
t he
pr ogaan
is
90200.
To play
by
co n ve r te d
T h e p r o g r a n ca n b e e a si l y
to a su b r o u ti n e
th e
w i th R TS. Th i s a l l o w s
t h e BR K i n str u cti o n
replacing
r p h r a se sr
prograaner
o f m u si c to p r o d u ce
t o p l a y va r i o u s
quite
c o n p l e x tu n e s.
T h o l o w e s t n o te yo u ca n p l a y i s A b e l o s n i d d l e
C.
Yo u ca n
p l s y s h o r t n o tcs a n d l o n g n o te s ( a l o n g n o te i s tw i ce a s
l o n g a s a s h o r t n o te ) .
If yo u n a n t to str e tch
o u t a n o te
e v c n l o n g e r th a n a l o n g n o te a 1 1 o w s, p u t a r p a u se t n o te
it.
So n e o f th e n o te s a xe a s fo l l o w s:
after
niddle
the
own Tune
E ach n ote go es i nt o
a by t e of s t or age,
starting
Eac h t une s hould end w i t h t h e
$0000 of me rno ry.
which sto ps th e pr ogr am unt il
G O is pr e s s e d .
N o te
A --Af
B ----C
c# - - - - D 5 AD A
D#--E
F ----
--
Sh o r t
79 - ----72
6C -----66
60 ------
Long
F9
F2
EC
E6
E0
56 -----51
4C ------
D6
Dl
CC
48
44
40
3D
39
36
33
30
2D
28
26
00
BD
B9
B6
B3
BO
AD
A8
A6
80
--
at location
value $FA
S pec ial
co de s a r e inc or por at ed
in t he p ! o g r a m t o a 1 l o w
cert ain
e ffects
of s peed, t o n e ,
etc.
The codes
- adjus t nent
arc follo weil
b y a v alue whic h s et s t he p a r t i c u l a r
effect.
T he cod es a re list ed
below:
Cod e
FB
FC
FD
FE
FF
E f f ec t
I - nit ially
$30
$0?
$01
$FF
$00
Exanpl.es18 is quick;60
is slow
2 neans tlongrnote
lasts
twice as longras I short I
2 is bass; 4 is deep bass
FF is piano,
00 is clarinet
00 will
take you back to
first
like
tune;
a tjunpt
F or e xa mple ,
you nay insert
a t any t ine
dur ing
a t une,
the
seque nce $ FB $1 8 and t he t une will
begi n t o p l a y a t a f a s t
speed .
Insertin g
c aus e a s w i t c h
to the tune at
$FF $45 will
zero p ag e a dd ress $0045.
The init ial
values shown can be
reset
a t an y tim e by s t ar t ing
at addr es s $ 0 2 0 0 .
N o tu ne sh ou ld ex t c nd bc y ond addr es s
valuc s
arc store d
at $00E0 and up.
$00DF,
rlnce
prog!an
Sanple
0000
0 010
0020
00 30
0040
0050
0060
00 70
0080
0090
-------------------------------
c8
c4
c0
Tgnqq
FB
BD
14
00
5A
iF
56
5A
18
BD
B5
FB
5A
5A
56
56
80
80 4C
FE
BD
B0
28
st
5A
56
4C
FE
56
FF 44
O O 44
80 44
SA 5A
48 44
5A 5A
56 5A
00 C4
00 00
5A s6
51 E6
BD 00
51 c4
51 48
48 5l
5A JA
66 tt
44 4 C
72 5 A
5A E6
E6
44
80
5A
sA
66
80
56
cc
F2
66
3D
80
48
60
72
80
5A
72
80
5A sl 4C C4 C4 C4 Dl
36 33 2D A8 80 80 33
5A 51 E6 EO 80 FA FE
Dl 5A 5A 51 48 DA EO
7e 6C 60 DA DA FA FE
79 E6 E6 80 00 s6 s6
4C 48 4C 4C 4C 4C 56
5A s6 5A 66 56 5A 66
5A cc 72 5L cc 80 BB
FA FF O O
HUSIC M A CHI NE
;
0200
0202
0205
0207
0208
F. J. B utterfi el d
Toront o
lnit ializ c
A2
BD
9s
cA
l0
05
86 02
E0
F8
S T AR T !D X#
$os
LP I
L D A@ X I NI T
S T AZ X W O RK
DEX
B PL R LPI
,
, n a i n ro u ti n e
BF
43 L7
00
E4
E4
FA
04
t I o z2 2
;0 2 2 4
10 2 2 6
, t0 2 2 8
E4
E4
Eo
E0
81
E6
es
B0
ED
0B
FB
GO
NEX T
022A A6
a22C 86
022E A6
0230 A8
o23L 30
0233 A2
0235 86
o 2 s7 2 9
0 2 3 9 '85
0 2 3 8 F0
023D 85
023F As
024L 25
0243 F0
0245 E6
_ 0 2 4 7 C6
0249 A6
0248 A9
0 2 4 D 20
0250 30
A6
A9
20
30
10
EA
27
5D
AF
E2
E0
E7
El
02
01
E6
7F
E9
02
EA
E9
Es
04
EA
E9
E9
47
5D 02
88
, "t
NOTE
0 VER
HU SH
ON
tD A#
ST A E
L D Y#
L D AIY
IN C Z
#
C MP
BN ER
BRK
N OP
B EQR
BCCR
s Bc#
T AX
L D AIY
IN C Z
ST A Z X
B CSR
h e re - W OR Knot resot
up t inlng
LDXZ
STXZ
LDXZ
TAY
BM I R
LDX#
STXZ
1I 9t
STAZ
BEQ R
STAZ
LDAZ
ANDZ
BEQ R
I NCZ
DECZ
LDX#
LDA#
J SRO
BM I N,
$BF
PBDD open o u t p u t c h a n n e l
$00
W O RK+ 4 ge t n e x t n o t e
W O RK+ 4
t os t
for halt
$FA
NEXT
( or R T S i f u s o d a s s u b r o u t i n o )
G0
NoTE
$FB
los une w h e n G 0 p r e s s e d
is it a n o t e ?
if not, d e c o d e i n s t r u c t i o n
and pu t i n t o
X
W O RK+ 4 ge t p a r a n e t e r
W O RK+ 4 an d
W O RK
store
in work table
GO
J un p t o G 0
f or
not e
W O RK t ining
LI M I T+ l
W O RK+ I
lon g n o t e f a c t o !
t es t
aicuraulator
O VER long n o t e ?
nope, g e t s h o r t n o t e
$O f
LI M I T
stoie
length
factor
r enov s h o r t / t o n g
$z r
ftag
VALz
HUSH is it a p a u s e ?
VALI
no, s e t p i t c h
VAt 2
get t ir n i n g a n d
W O RK+ 5 by p a s s i f n u t , e d
ON
VALl
els e f a d e t h e
VALZ not e
V AL2
$A7
SO UND
GO
[D Xf
L D A#
JSR O
BM IR
BPL R
vz
; s u br o u ti n e
020A A9
0 2 0 c 8D
020F A0
0211 B1
0 2 1 3 E6
0215 C9
0217 D0
,0219 00
I 0e1A EA
I 0 2 rD F0
j0 2 1 0 s 0
O O2 1 F E9
, 1.oI z z r r n
0252
0254
02s6
02s9
0258
025D A 4 E 2
025F 84 E B
0261 86 EIJ
0263 E 0 00
0265 D 0 08
0267 A6 EC
0259 C 6 E I
0e6B D 0 F6
026D F0 16
026F 8D 42 L7
4272 C A
0273 C 6 E 8
0275 D 0 IL
0277 C 6 E 7
0279 D 0 E 8
FN
0278
027D ^4
84
027F C 6 E 6
028r D 0 E O
0283 A 9 F F
0285 60
30
02
01
FF
00
00
00E 0
0 0E 6
0 0E 9
OOE A
OOE B
00E c
to
se n d a b i t
S O U ND L D YZ
STYZ
WOR K+2
TIM ER
o cta ve
fl e g
.
sTxz xsAv
s lo oP c P x # $ o o
C O I {T
.
SEX
BN ER
L D XZ
D EC Z
B}IER
tEq R
STAO
D8X
D EC Z
BN ER
D EC Z
BN ER
LD'TZ
STYZ
D EC Z
BN ER
C ON T
ISAV
TIXER ,
SLOOP
g Er
SBD
LDA#
RTS
$rr
; i n i ti a l
0286
0287
0288
0289
026A
0288
vAtl
$27
SOU N D
GO
H U SH
L IM IT+2
SL OOP
L IM IT+1
SL OOP
WORK
L IM IT+ 1
L IM IT
SL OOP
co n sta o ts
i
I work
areas
lfORK
LIMIT
VALZ
VAtl
TIMER
XSAV
*e*
* =*
* =*
* =*
* =*
rrr
+6
+3
*1
+1
rl
tl
r e se r ve d
sp e e d /l e n g th
r a ti o /o cta ve /to n e
ti n i n g
o f n o te
n a r ki n g
a n d sp a ci n g
d u r a ti o n s
o cta ve co u n te r
Klm- 1 Us er
S tan Ockers
R .R . #4 B ox 209
tockport,
I11 6044L
I first
ran across the 1WMPUSin TI{E BEST OF CREATIVE
COMPUTING_
where it is programmed in ba@is
EAGI on- t his pr o g ra m w i tn m o d i f i c a ti o n s so I coul d f i t i he
progratn and messages in the KIM-1 memory. The messages appear
o n the dis play i.n s c a n n j .n g fo rm rv i th " s o rt-of"
al phanumeri c
l e tte rs .
T he I I I I I M P U S
l i v e s l n a c a v e o f 1 6 rooms (l abel ed p - f).
Ea ch r oom has f ou r tu n n e l s l e a d i n g to o ther rooms (see the
n ra p b elow) .
W he n th e p ro g ra m i s s ta rte d , you and the
ar e p! - ac e d a t ra n d o m. AIs o p l a c ed at random are tw o
WU UP US
b o tto mles s pit s (th e y d o n rt b o th e r tb e W U MP U She
, has suckerO , typ e f eet ) and t w o ro o ms w i th S U p E R B ATS ,(a1so no troubl e to
If y o u e n te r a room w i th a pi t, you
. 1. ,WUMP US ,he' s t oo h e a v y ).
fa l l
in and los e.
If y o u e n te r a BA T ' S room you are pi cked
)l
u p a nd f lown at ra n d o m to a n o th e r ro o m. Y ou w i l l be w arned
wh e n B A T S , P I T S , o r th e WU M PU S
If you enter the
a re n e a r by.
ro o m wit h \ r y I t M PU S,
h e w a k e s a n d e i th e r m oves to an adj acent
ro o & or J us t eat s y o u u p (y o u l o s e ).
In order to capture the
and wln, you must use "MOODCIIANGE"gas.
1YUMPUS
When thrown
l n to a r oom c ont a l n i n g th e IYU I,{ PU S,
th e gas causes hi m to turn
fro m a v ic ious s n a rl i n g b e a s t i n to a meek and l oveabl e creature.
Ee w ill ev en c on e o u t a n d g i v e y o u a h u g. B ew are though, you
have only three cans of gas and once you toss a can of gas j,rti)
a room it is contaminated and you cannot enter or you wil-1 be
tu rn ed lnt o beas t (y o u l o s e ) !
T he pr ogr ar n s ta rts a t $ 0 3 0 0 . If you l ose and w ant everyth i n g t o r em aln th e s a m e , (e x c e p t th e rocm you are i n), resart
a t $ 0316. Us e tb e re s e t k e y to s to p th e program because about
h a l "f of page one l s u s e d a n d i f y o u j u st use the S T key the
The
sta ck wlLl ev entu a l l y w o rk i ts w a y d o w n i nto the progri l n.
'b yte at $0229 c o n tro l s th e s p e e d o f th e di spl a;r.
Once you get
u se d t o t he c hara c te rs y o u c a n s p e e d th i ngs up by putti ng i n a
lower number. The message normally given te1ls you what roon
yo u ar e ln and w h a t th e c h o i c e s a re fo r the next roorn. In order
ts flr e t he m oo d g a s , p re s s PC (p i tc h c an) w hen tbe rooms to be
se l e ct ed ar e df s p l " a y e d .
T h e n i n d i c a te the room l nto w hl ch you
wa n t t o pit c h t h e c a n .
It ta k e s a fre sh can of gas to get tbe
COODHUNTING:
WUMPUS(he may move into a room already gassed).
CAVE ITAP
Notes
v. 1 #2
APPENDIXD,
KIM DEMONSTRATION
TAPE
KII{. 1 DEMONSTMTIONTAPE
Index
Entry Point
Address Range
ID'/l
Name
01
DIRECTORY
$1780
$1780-$17AF
02
VU TAPE
$0000
$0000-$oo4e
03
$0100
$oloo-$01c2
04
MOVEA BLOCK
$1780
$1780-$17cB
05
HmEC
$o2oo
$o2oo-$0244
06
ADC DEMONSTRATION
- BINARY
- BCD
$oooo
$oooo-$ooA4
$0020
07
FREQUENCYCOLNTER
$0000
$0000-$0067
08
TAPE DIIPE
$1780
$ 1 7 8 0 -$ 1 7 A e
09
$0370
$0370-$o4oo
OA
STOP WATCH
$o3oo
$o3oo-$0386
10
LI'NAR I.AI{DER
$oooo
$oooo-$ooc6
11
TIORSERACE
$027F
$027r-$0396
L2
ONE ARMEDBANDIT
$0200
$ 0 2 0 0 -$0 2 D 1
13
KIMAZE
$0200
$0200-$0210
T4
MUSIC MACHINE
$o2oo
$oooo-$028c
15
$0300
$0000-$0400
Notes:
Supertape is set for 3X speed. To obtain
location $Ofnr to $02 and $01C0 to $03.
Signal
input
is PB0.
D-1
DI RE CTORY
0 0 0 1 0 2 0t 04 05 06 07 08 09 0A 0B 0c 0D 0E 0 F
D8 A 9 07 8D 4 2 L 7 2 A 4 1 1 A 4 6 F 9 0 5 F 9 8 5 F 9 C 9
16 D0 F3 20 2 4 1 A C6 F 9 1 0 F 5 C9 2 A DO F l A 2 F D
20 F3 19 95 F C E 8 3 0 F 8 2 0 L F lF DO D5 F O F 9
1780
1790
l7A 0
V U TA P E
0 0 0 1 a 2 0 5 04 05 0 6 0 7 0 8 0 9 0 A 0 B 0 c 0 D 0 E 0F
0000 D8
0010 46
0 0 2 0 c9
0050 D5
0 0 +0 A A
A9
F9
2A
46
BD
7F
05
DO
EO
E7
8D
F9
F5
E8
lF
41
85
A9
E8
8D
L7
F9
00
E0
40
A9
8D
8D
15
17
L3
40
Eg
D0
D0
8 5 E 0 8 D 4 2 1 7 2 A 4 1 1A
t 7 c 9 1 6 D0 E 9 2 0 2 4 1 A
17 20 2 4 L A ' 2 0 0 0 1 A D 0
02 A2 0 9 8 6 E 0 8 E 4 2 L 7
DB
S UP E R TA P E ('X )
00 01 02 05 0 r+ 0 5 06 07 08 09 O A O B O C O D O E OF
0 1 00 4 9 A D 8 D E C L7 20
1 7 A 2 6 4 A 9 16 20
0 rl 0
0 1 2 0 2 0 7 0 0 1 A D F5 L7
0 r r 0 E c t7 2 0 6 D 01 20
0140 L7 E D F 8 T 7 90 E9
0150 01 A D E 8 L 7 20 70
0160 18 8 6 E 0 4 8 20 88
9170 48 4A 4A 4A 4A 20
0A 1 8 3 0 0 2 69 A7
0 r80
0190 B E B E 0 1 4 8 2C 47
01A 0 E 1 +9 8 0 8 D 42 L7
0180 30 0 7 4 A 9 0 DB AO
0 1c0 06 7 E
32
61
2A
EA
A9
01
19
01
6D
19
2F
A2
0r . 58
7D 01
69 30
L7 r 0
85 El
00 F0
A9 27 8 5
A9 2A 2 A
01 AD F 6
AD ED 1 7
20 88 0 1
02 49 0 4
c5 E0 D0
68 2A 7 D
A0 08 8 4
FB 89 B F
CA DO E 9
D7 C6 E 2
El
88
L7
CD
AD
20
F7
01
E2
01.
58
DO
A9
01
20
F7
E7
61
60
60
A0
8D
C6
CF
BF
AD
6D
L7
L7
01
20
29
8D
F9
01
AD
20
4C
4c
0F
43
L7
20
EE
70
5C
19
C9
a2 84 Et
44 L7 A5
E1 F0 05
60 04 c3
MOV EA B LOCK
00 01 02 0l
t7 8 0
1790
17A0
1780
L7C0
58
A5
BI
A0
85
A5
E2
E0
00
E2
E4
E5
91
B1
A5
0 4 0 5 06 07 08 09 0A 0B 0c 0D 0E 0F
E5 E0
EO A8
E4 88
E0 91
E3 65
85
84
30
E4
E7
E6 45 E5 E5
E8 E6 E8 B1
1 t + l8 A 5 E 2
c 8 c 4 E 8 DO
85 E3 4C 4F
El
EO
E5
F7
lC
85
91
EO
18
E7
E4
85
45
90
88
E8
E2
18
D0
E6
65
38
F9
E8
E5
HEDEC
0 0 0 1 0 2 0 t 04 05 06 07 08 09 0A 0B 0c 0D OE OF
0200 F8 9 8 4 8 8 A q8 A9 00 A2 06 95 DF CA D0 FB E6 E5
02r0 45 E 7 4 8 A 0 08 68 4A 48 90 0c A2 0t 18 85 E2 75
0220
DF 9 5 D F C A D0 F7 A2 A3 18 85 E2 7' E2 95 E2 CA
02ta D 0 F 7 8 8 D 0 E0 68 A5 E5 D0 04 A5 E5 D0 Dt+ 68 AA
02q0 6B A 8 D 8 6 0
D- 2
ADC DEMONSTRATION
0 0 0 1 0 2 03 04 05 06 07 08 09 0A 0B 0c 0D 0 E 0F
0000
0010
0020
00 t0
0040
0050
0060
0070
0080
0090
OOA O
A9
85
Ag
85
FA
00
00
00
A9
10
EE
FF
F9
FF
E7
A2
00
00
00
80
DO
90
8D
20
8D
A2
00
00
00
00
85
09
E3
01
1F
01
00
86
00
00
00
EE
AD
60
17
1F
17
86
F9
00
00
00
A9
00
AD
4C
AD
E6
2A
00
00
00
00
17
03
0D
03
20
1F
00
00
00
18
38
77
00
L7
00
1F
00
00
00
65
E5
29
00
29
02
4C
00
00
00
EE
EE
EF
00
EF
46
2D
00
00
00
8D
4C
8D
00
8D
El
00
00
00
00
00
9F
03
00
03
86
00
00
00
00
t7
00
L7
00
t7
FB
00
00
00
00
AD
AD
20
00
20
A6
00
00
00
00
02
00
80
00
80
E2
00
00
00
00
17
17
00
00
00
86
00
00
00
00
29
46
0 0 0 1 0 2 0t 04 05 05 07 08 09 O A O B O C O D O E O F
0000
0010
0020
00t0
OO4O
0050
0060
A9
00
18
FB
FB
20
05
01
EA
A9
85
A9
lF
85
85
AD
01
FB
F4
lF
55
65 F8
02 L7
65 F9
t+C L2
8D 0F
C6 6 6
68 40
A9
29
85
00
t7
D0
03
36
01
F9
+8
c6
F9
00
8D
D0
49
A9
65
A9
FE
F9
00
90
F0
00
t7
AD
65
8D
02
85
A9
02
FA
04
58
F9
OO 8D
L7 29
85 FA
L7 2C
40 A9
85 FA
FF
01
A9
07
FF
85
L7 58
FO F9
00 65
L7 10
85 65
FB A9
TA P E DUP E
00 01 02 0 3 0 4 0 5 0 6 0 7 0 8 0 9 0 A 0 B 0 c 0 D 0 E 0 F
1780
1790
r7A 0
A 9 27 A 2 3 F 8 E 4 3 L 7 A 2 a 7 8E 42 17 A0 5E 2C 42
17 10 02 A 0 A 3 A 2 B F 8 E 43 L7 49 80 8D 42 t7 8C
4t+ L7 2C 4 7 1 7 1 0 F B 3 A D9
RE A L.TIME CLOCK
0 0 0 r 0 2 05 04 05 06 07 08 09 0A 0B 0c 0D 0E 0F
0370 A9 00
0380 FA A5
0390 6A lF
03A0 00 00
0 tB 0 0 7 L 7
0 3 c0 1 8 F 8
0lDo A5 82
0 tE 0 8 5 1 8
03F0 A9 01
85
83
Cg
00
10
A5
18
69
85
80
85
01
00
FB
81
69
01
83
A9 F4
FB 20
D0 03
00 48
E6 80
69 01
01 85
85 83
D8 A9
8D
64
4C
8A
A9
85
82
c9
F4
D- 3
OF
lF
4F
48
04
81
C9
L2
8D
L7
C9
lC
98
C5
C9
60
D0
OF
45
01
20
48
80
60
D0
02
L7
81 85 F9 A5
D0 0D 20 lF
1F r .F 18 90
A9 83 8D 04
D0 58 A9 00
D0 28 A9 00
1g A9 00 85
E6 84 C9 L3
68 A8 68 AA
82 85
1F 20
DA OO
L7 2C
85 80
85 81
82 A5
D0 04
68 40
STOP WATCH
0 0 0 1 0 2 03 04 05 06 g7 08 09 0A 0B 0c 0D 0E 0F
0500
0310
0 t2 0
0350
0340
0150
0560
0170
49
85
at
38
B0
lF
F8
0B
d:so c9
75 8D
FB 20
DO lF
IE A 9
D0 c9
IF A D
A 5 F9
A 9 00
00 D0
F2
7F
45
2E
02
07
69
85
cB
t7
1F
FB
20
FO
T7
01
FA
FO
A9 0 2
20 6 A
20
AO '1BE
c4 c 9
FO F B
85 r 9
A5 F B
8C
8D F3 17
lF Cg 04
lE A 9 3A
A 5 F 9 20
0 1 D0 c8
8 D 0 0 lC
A5 FA 69
1 8 6 9 01
A9
D0
20
3B
A9
Ag
00
85
00
st
AO
].E
9C
9C
85
FB
85
4c
lE
20
8D
8D
FA
D8
F9
64
45
2F
06
06
C9
20
85
lC
FA
lE
t7
t7
60
6A
FA
c9
20
2
' 80
18
D0
lF
LUNAR LANDER
00 01 02 03 0 4 0 5 0 6 0 7 0 8 0 9 0 A 0 B 0 c 0 D 0 E 0 F
0000
0010
0020
OO'O
0040
OO5O
0060
0070
0080
0090
OOA O
0080
00c0
A2
E2
E2
95
E9
10
06
E5
20
D0
50
E9
02
0c
75
95
E8
00
FB
F0
F0
lF
c9
10
A9
08
85
E4
E2
CA
95
2O
A5
07
lF
15
FD
00
00
88
95
CA
10
EB
AA
A5
D0
F0
D0
AA
E9
00
95 E2
E 2 CA
r0 E 5
F9
CA '180
OO 45
EB 46
05 38
06 20
03 85
A5 EA
00 85
00 00
CA
88
45
A5
F7
EE
EC
A9
6A
EE
FO
E8
D-$.
10 F9
10 F6
E2 10
ED E5
B0 0C
DO O A
85 FB
00 E5
lF 2 0
6 0 C9
F8 85
60 45
A2
85
0B
EA
49
45
85
E6
91
10
EA
00
05
E5
A9
85
00
E2
FA
85
00
D0
A5
00
A0
10
00
ED
A2
A6
45
F9
C5
05
EA
99
01
02
A2
A2
A3
E3
E5
A9
El
A9
38
80
F8
A9
02
01
95
FO
30
02
D0
00
E9
00
18
99
95
85
EA
08
06
85
Fl
85
05
99
85
75
E2
EB
CA
DO
A5
El
F0
EE
85
98
HORSE RACE
0 0 0 1 02 0 3 0 I + 0 5 0 6 0 7 08 09 0A 0B 0c 0D 0 E 0F
0270
0280
0290
02A0
0280
0 2 c0
02D0
02E0
02F0
0 r0 0
0310
0320
0530
0540
0350
0 t6 0
0370
0 r8 0
O3 9 O
0 0 0 0 00 0 0 0 0 0 0
A 2 t3 B D 7 C 0 5 9 5
0 0 A 2 09 8 9 7 C 0 0
2 0 3 D lF A 5 8 F 3 0
86 99 A4 99 86 85
9 5 7 C E8 9 6 8 3 8 9
30 18 D0 06 A5 8F
0 6 9 5 83 CA 1 0 F 6
cA D 0 F5 E A E A E A
c6 8 F D0 0 5 A 5 8 1
8 9 8 9 00 F 0 0 B 2 0
2 0 6 8 03 2 9 3 8 8 5
B0 05 A9 FF 99 86
0 3 F 0 01 8 8 9 8 5 5
0 1 6 5 9A 1 8 4 6 9 9
9 5 8 C 95 8 6 4 C A 9
9 1 A 2 04 8 5 9 1 9 5
8 0 8 0 8O F F F F F F
F E B F F7 0 1 0 2 0 4
00
7C
84
E3
89
90
FO
A2
EA
0g
68
9A
00
89
75
02
92
80
00
cA
FC
A2
90
03
28
06
EA
06
0t
89
20
85
8C
38
cA
80
00
10
20
03
03
49
D0
85
EA
85
29
8C
tD
9A
EA
l8
r. 0
80
00 00 00 00
F8 A9 7F 8D
4 E lF c 8 c 0
CA l0 DE D6
35 VC EA EA
FF L5 7C 95
30 A2 02 38
7C 95 76 A9
EA EA EA EA
81 EA EA EA
3 C D0 1 8 9 9
00 t0 0B 29
lF A 0 F F 4 6
EA EA 20 68
EA EA EA EA
A5 92 65 95
F9 60 80 80
00 00 00 80
00
41
06
86
EA
7C
85
80
EA
EA
89
t8
99
03
EA
55
80
80
00 D 8
17 A 0
90 F3
DO F9
EA EA
E0 05
83 E9
95 7C
EA EA
EA EA
00 E A
C5 9A
1D 93
18 29
EA E A
95 85
80 80
80 0 8
ONE A RME DB A N DI T
00 01 02 0 3 0 4 0 5 06 07 08 09 O A O B O C O D OE O F
0200
0210
022A
0230
0240
0250
0260
0270
0280
0290
02A0
0280
0 2 c0
02D0
A9 25
E6 09
01 85
06 A5
E7 A5
0D A2
A9 80
F8 A5
c9 4 6
02 F6
00 8C
1 .7 c8
E7 1F
50
8 5 05 20 B A 0 2
2 A 8D 02 F O F 9
0 5 20 BA 0 2 2 6
0 9 29 06 0 9 4 0
0 4 c5 03 D0 3 7
OB c9 42 F 0 0 7
8 5 08 20 8 D 0 2
0 5 69 01 B 0 9 4
F 0 DA 20 8 D 0 2
0 2 cA 10 F B A 9
4 2 17 8D f + 0 L 7
c8 cA 10 E 9 2 0
8 5 00 A5 0 5 4 A
D-5
85 06 20 8D O2 DO F B
85 06 F8 38 A5 05 E9
8D 02 c6 08 DO F9 A6
46 09 46 09 c6 06 D 0
D0 33 A2 10 c9 40 F 0
c9 44 F0 01 cA 86 07
DO F9 c6 07 F0 9C 18
20 BA 02 D0 E2 A2 01
D0 80 FO F7 46 06 r 0
4L L7 AO OB A2 04 85
7F E9 01 D0 FC 8D 42
60 45 c5 29 OF AA BD
tlA 4A 4A AA BD E7 lF 85 01
A9
A9
09
95
c5
A2
c6
85
A5
7F
D8
40
00
03
20
01
02
06
08
05
05
8D
A9
1F
K I MAZE
0200
0210
0220
a2t0
0240
0250
0260
027A
0280
0290
02A 0
0280
02c0
02D0
ozE A
00'0t
02 03 0 4 0 5 0 6 0 7 0 8 0 9 0 A 0 B 0 C 0 D 0 E 0F
D8
D8
2A
c6
8D
D6
D7
BC
l0
D2
00
08
41
71
00
02
88
D0
10
17
FC
CD
30
c6
D2
40
08
5F
01
00
A2
00
88
D5
41
D0
F0
CA
04
C6
08
01
FE
5E
00
BD
L0
17
0A
A0
C8
85
8C
D4
D0
48
40
04
00
00
85
F8
29
A9
09
C8
D7
BC
D0
EF
01
40
51
FD
00
02
A2
A7
05
A2
CA
A2
AD
85
E6
09
84
7D
FF
00
9 5 D2 CA 1 0
0A Ah Dr+ A9
A8 89 AO 02
8 5 D5 A 5 DE
O A 8 5 D8 8 D
CA 1 0 E E 2 0
0 4 DD A 8 a 2
O ? 8 9 D8 0 0
D0 0 4 E 6 D4
D2 E 6 D2 DO
41 r+9 L3 0 9
02 08 FF FF
5D 04 51 B5
o CI 0 0 0 0 0 0
00 00 00 00
F8
FF
95
49
AO
38
D8
40
OB
16
CA
85
+0 t7 8c
40 lF
F0 05
5D 81
DO F8
E9 00
01 06
0,+ 08
5+ 14
00 00
00 00
20
cA
02
CA
00
04
F5
F7
00
00
B1
D9
CA
DE
42
6A
10
DO
DO
00
06
7E
D5
00
00
D2
56
10
A9
t7
lF
F8
BI
06
00
06
15
04
00
00
99
D8
E7
7F
c6
C5
t0
CA
c6
00
04
00
54
00
00
MUS IC MA CHINE
0 0 0 1 s2 0 5 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
OOOO
OO1O
0020
0010
0040
OO5O
0060
007CI
OOS O
0090
FB
BD
44
00
5A
FF
56
5A
F2
80
18 FE
BD BD
83 80
FB 28
5A 51
5A 5A
56 56
-56 4c
B O FE
4C 56
FF
00
80
5A
48
5A
56
00
00
5A
r + 4 51 trb E5
44 BD 00 44
ttq 51 c4 80
5A 51 48 54
44 48 5'1 5A
5A 5A 5A 65
5A 66 D9 80
c4 44 4C 56
00 72 5A cc
56 5A E6 F2
65 5A 5r 4C .C4
5D 36 3t 2D A8
80 5A 5T E6 80
tl8 D1 5A 54 5T
60 79 6C 60 DA
72 79 E6 E6 80
80 4C 48 4C 4C
5A 5A 56 5A 66
7 2 5A CC 72 54
80 FA FF 00
c4 c4 Dl
80 80 33
80
48
DA
56
4C
56
cc
FA
DA
FA
56
4C
5A
80
FE
EO
FE
56
56
66
88
0 0 0 1 a 2 0 3 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
0200
0210
O2 2 A
0 2 t0
0240
0250
0250
0270
0280
A2
00
FB
A8
E9
30
EB
42
E6
05
81
AA
,0
25
88
86
t7
D0
BD 86
E r+E 6
81 E4
02 A2
E3 F0
46 EA
EC E0
cA c6
EO A9
02
E4
E6
01
04
A9
00
E8
FF
95
C9
E4
86
E6
27
D0
D0
60
E0 CA r . 0 1 8 A 9
FA DO 0tr 00 E A
95 H0 BO EO A 5
E6 29 7F 85 E 9
EA C5 H9 46 E 9
20 5D 02 30 A F
08 A5 EC C6 E B
EC C6 E7 DO E 8
50 02 O1 FF 0 0
D- 5
BF
FO
EO
FO
A9
10
DO
A4
00
8D 43 L 7
ED 90 O B
86 E7 A 5
02 85 E A
A7 20 5 D
E2 A4 E 2
F6 FO r 6
E0 84 E 7
AO
E9
El
A5
02
84
8D
C6
80
F8
F7
87
00
02
05
08
0B
80
80
80
EE
BE
89
F3
00
02
03
04
0E
87
89
B8
DC B E
D4 D4
F9 F1
F 9 DE
00 00
00 0 1
01 0 2
03 0 4
05 0 6
84 E D
F 7 D4
DC E D
80
F9
80
80
00
01
03
07
0F
ED
ED
F9
F7
BB
00
F7
00
00
02
06
08
F9
80
80
DO F 9
ED 80
8 0 Dc
80 9C
00 00
03 04
05 06
07 0A
09 0F
DE 8 0
88 Fg
00 80
80 84
B8 F9
DC F 3
BE 87
00 00
00 06
05 08
09 0A
0B 0c
c0 80
Fl F8
DO DC
Dt + 8 0 DE
F 7 DE 8 0
ED 80 c0
F3 BE ED
00 00 00
07 00 09
09 08 0B
0F 0c 0D
0D OE OE
Dc D4 8 8
80 OO 80
DC 8 7 D3
85
F8
80
80
00
0A
0c
0E
OF
EE
EE
80
C0
DC
Fc
80
00
01
0B
0c
OD
80
DC
00
80
85
BE
OO
00
04
07
0A
OD
DB
BE
00
0 0 0 1 0 2 05 04 05 0 6 0 7 08 09 0A O B O C O D OE O F
0100
0110
0120
0 110
0140
0150
0160
at70
80
84
D0
63
F3
EE
F3
87
9C
F8
lE
1E
F9
EE
84
80
BE
80
DO
6C
DO
84
FB
00
87
89
lE
lC
FC
84
80
80
T'
88
DO
BD
F7
Fg
00
DC
BE
DC
].E
DC
F8
F9
80
BE
ED
ED
48
F8
80
F9
BD
F8
85
F9
22
80
ED
80
F7
80
B9 B8
OO 80
0 F tro
E E DC
D4 F 7
Fl F9
ED 80
DC F 1
DC
FC
63
BE
F8
88
84
8O
ED
F7
lE
8O
89
88
D4
BD
F9 00
F8 ED
6C tC
OO 80
F5 80
80 84
8 0 D0
F7 ED
80
80
0F
ED
00
D4
DC
80
r3
89
E6
BE
80
80
DC
00
0 0 0 1 0 2 03 04 0 5 0 6 a 7 0 8 0 9 O A O B O C O D O E O F
0200
0210
0220
0230
0240
9250
0260
4270
0280
0290
02 A 0
0280
0 2 c0
02D0
02 E 0
O? F O
8 tr DE 8 5 DD A 9 0 7
D0 01 60 95 E8 88
2 0 2 8 0 2 A 4 DC 4 C
t7 2 0 1 E 0 2 2 C 0 7
8 D 4 1 I7 A 0 0 0 A 2
c0 0 6 9 0 F 3 2 0 3 D
20
02 FO FB 20
E7 5
'E0 A 5 c 0 D0 0 4
FD FO 05 06 c0 A5
04 D5 CB F0 01 cA
3 0 OD 2 0 8 2 0 2 A D
cB 6 0 A 6 CA 8 5 5 0
B5 80 85 c9 60 A2
01 20 00 02 A0 00
F9 F7 F8 c0 80 EE
B E BD 8 0 F l DO DC
D-7
85
cA
0A
t7
09
lF
3E
E6
C0
10
06
85
03
A9
DC
87
DF
10
02
10
89
60
02
C0
60
F9
17
C6
D5
AC
BE
80
A0
F3
A2
F8
E8
20
FO
DO
05
D8
06
C6
00
8C
F6
F8
05
60
29
B5
c6
20
8O
9C
c0
2s
0t
60
F0
00
BD
BE
A2
18
86
DB
84
tE
20
29
E6
72
AA
85
03
02
F9
87
0 5 B1 DD c 9 0 0
9 8 65 DF 8 5 D C
DB A9 52 8 D 0 7
DO EF 60 A 9 7 F
F C 20 4E L F C 8
02 D O F 8
20
6 A '1F
E c9 1 5 1 0
8 E FO 0 5 0 A 9 0
C0 A5 c 0 6 0 A 2
0 2 29 OF c9 0 4
8 5 c6 85 C B A 5
C7 B5 70 85 C 8
CA 10 F9 6 0 A 0
4 C D4 02 BD D O
F 8 80 F7 8 0 F 6
F 3 BE ED 80 0 0
0500
0310
0320
0 tt0
0540
0 t5 0
0 t6 0
o t7 0
0180
0390
0lA0
0 tB 0
0 tc0
OS D O
O3 E O
05F0
0 0 '0 r
0 2 0 1 04 05 06 07 08 09 0A 0B 0c 0D 0E 0 F
AD 06
85 E0
cA F 0
0t 84
A9 19
20 00
A2 03
00 02
EB A5
30 9A
02 20
3D 20
02 A0
8A 30
1A A4
5C 0'
1 7 8 5 C0
A 0 0 5 10
F 5 C A 10
E l 8 9 C6
1 0 0 A E0
0 2 c6 El
8 4 C 6 89
2 0 5 8 02
C A A 2 04
E 0 0 5 10
9 9 0 2 C5
00 02 +c
0 0 A 9 87
E E A 5 Dl
E O 8 9 E7
A 0 0 2 A9
A9 F F
02 A 0
F9 9 9
00 2 0
0 I 30
A4 E l
E7 lF
C9 1 4
D5 c l.
L7 E 0
CA D0
16 0 5
20 0 0
46 E 0
lF 8 5
DE 2 0
D- 8
A2
00
CA
8F
04
10
95
F0
F0
01
84
A9
02
95
9F
00
O E 9 5 CI
A2 05 2A
00 88 10
02 8A 30
A9 0E 10
DA A r+ CA
2 0 c A l0
4 8 2 0 C5
tt cA 10
10 LD A0
A9 26 20
4 F 2 0 CF
20 58 02
C0 C5 CB
A0 00 A9
02 F0 F7
CA
72
EC
t7
02
89
F6
02
F9
00
CF
02
20
F0
90
A9
IO
02
20
E0
A9
El
A0
85
20
A9
02
A9
C5
L5
20
73
FB
29
82
03
00
1F
0o
CA
8F
26
A0
65
02
C6
00
2A
A9
0F
02
30
A0
85
98
8A
02
20
01
20
85
E0
02
CF
g3
D5
A0
04
01
0C
20
70
8A
q0
A9
CF
Dl
F0
4c
02
APPENDIXE.
APPLICATIONS
SPECIAL
Si n g l e
C hannel
A nal og
SUBROTITINE
ADC - 8 Bit
to D i gi tal
Analog to DigltaL
0080 49 80
ADC
LDAti
00E2 85 EE
STAZ
0084 A9 00
r.DAJt
OOE6lE
MCTBIT CLC
0087 65 EE
ADCz
0089 8D 00 17
STd@
OOECAD 02 17
I.DJG
0088 29 10
allDit
0091 D0 09
BNEr
0093 aD 00 17
r,Da@
0096 38
s8c
0097 E5 EE
SBCz
0099 4c 9F 00
JlcG
OO9CAD OO 17 SAVE I,DAG
OO9F45 EE
SHIFT I,SRZ
0041 90 E3
BCCr
00a3 60
RTs
s80
TRIAL
$00
TRIAL
PAD
PBD
$10
SAVE
PAD
TRIAT
S H IF1.
PAD
TRIA].
lDffBIT
C onversi on
Comrersion
Hardware:
+15 V
Ref. input
-1 0 v
PA7
PA6
PA5
V output
PA4
PA3
-15 V
Pta
PAl
PAO
+uv
2.2 K
+ 5V
w4
V lnput
C@parator
100 K
r l - 'l
output
DEMONSTRATION
AMLOG TO DIGITAL CONVERSION
PROGRAM
Display
0000 A9
0002 8D
0005 AD
0008 29
000A BD
000D 20
0010 85
O0L2 20
0015 4C
FF
oL
A3
EF
03
B0
I'9
lF
OD
Display
0020 A9
oo22 8D
0025 AD
0028 29
OO2A 8D
O02D 20
0030 85
FF
01
03
EF
03
80
E7
START
L7
L7
L7
00
LOOP
lF
00
START
17
L7
L7
O0
READ
LDA/i
set PA port to output
$ff'
STAG $1701
LDA@ $1703
set Pts4 to be input
AND/f $EF
srA@ $1703
call ADC subroutine
JSRG ADC
STAz
store ADC output in right
$F9
JSRG SC^ANDS dispLay data
Loop back for more data
JMPG LOOP
LDAit
$ff'
STA@ PADD
LDA@ PBDD
AND/f $EF
STA@ PBDD
JSR@ ADC
STAz HEDEC-L
0032 A2 00
0034 86 E6
r,Dxit $oo
STXz IIEDEC-H
0036 20
0039 A6
0038 86
003D 4'6
O03F 86
0041 42
0043 86
OO45 20
0048 4C
JSRG
LDXz
STIk
LDXz
STXz
LDX/I
STKz
JSRG
Jl@G
O0 02
El
FB
E2
F'A
00
19
1F 1F
2D 00
HEDEC
$81
$fB
982
$fA
$00
$rg
SCANDS
READ
set PA port
display
to output
read ADC
set up data for binary
to BCD converslo
note:
In order to perform the binary to BCD conversion, you nnrst load
at address $0200.
the HEDECprogram into the memory starting
This program uses.,:.t'h-eircuit and ADC subroutine
MULTICHANNELANALOGINPUT/OUTPUTSYSTEMFOR KII"I.1
by J.B. Ross
A multichannel
ideally
and output.
driving
DAC 0
DAC I
tn
to
PAO
PAI
:::
DAC 7
to
PA7
interrupt
to port
lines
PA--
PB--
timer
Pages.
an NMI
to trigger
the
PBO
PBl
PB2
PB3
PB4
to
to
to
to
to
to KIM-1 via
as follows:
The interface
The circuit
The ruultichannel
to the
suited
system operate,
Routine,
Routine.
Start
properly.
If
starting
begins to flicker,
inrnediately
the program
E-j
Driver
the display
Eight bit
at $0380.
Conversion Subroutlne,
routine
bit
lnput
$oocr.
very
driver
data for
7 is written
into
tocations
is operating,
rnrkes calibration
This feature
$00C8 through
of the Lnterface
convenient.
Since the analog data is
transferred
by the interface
driver
with
the details
be written
of lnterference
50 nSec.
If
driver
driver.
loop is used, it
uses the interval
The driver
for
general
inputs
every
tlnlng
located
at $L704 - $170tr'
the other
timer at
the ptocessor,,
output
is a posalbility
tlnlng,.there
for
a timing
Ttre lnterface
to examine input
by the interface
output
If
so this
software,
E -4
counter
is
in location
serviced,
and
incremented
ANALOGINTERFACEDRIVER ROUTINE
0300 48
O3O1 8A
0302 48
0303 A2 0O
0305 BA
0306 09 0B
0308 8D OZ 17
0308 85 C0
030D 8D 00 17
0310 AD 02 17
o3L3 29 F7
0315 8D 02 L7
0318 49 64
031A BD 04 17
031D AD 07 L7
0320 F0 FB
0322 ID OZ L7
032s 09 0B
0327 BD 02 L7
032A E8
0328 E0 08
032D D0 D6
032F BE OZ L7
0332 20 58 03
0335 95 C0
0337 EB
0338 E0 l0
033A D0 F3
033C A9 30
033E BD 0F 17
0341 E6 D0
0343 18
0344 F8
0345 A'5 D0
0347 29 0I
0349 65 Dl
0349 85 Dl
034D A9 00
O34F 65 D2
0351 85 D2
0353 D8
0354 68
0355 AA
0356 68
0357 40
START
PHA
TXA
PHA
LDX/f
OUTPUT TXA
OM/f
STA@
LDAzx
STAG
LDAG
ANDdI
STA@
DELAY LDA/f
STAG
WAIT
LDAG
BEQr
LDAG
oRA#
SrAG
INX
CPX/I
BNEr
INPUT STXG
JSRG
STAzx
INX
CPX/I
BNEr
EXIT
LDA/I
STA@
fNCz
CLOCK CLC
SED
LDAz
AMif
ADCz
STAz
LDA/I
ADCz
STAz
CLD
PLA
TAX
PLA
RTI
6ave A
$00
$08
$L7AZ
$C0
$1700
$1702
Sr7
$L702
$64
$1704
$1707
WAIT
$L7OZ
$08
$1702
$Oa
OUTPUT
$1702
ADC
$CO
$10
itlpUf
$30
$170F
COUNT
COUNT
$01
TIME-L
TIlm-L
$00
TII'{E-}I
TIME-H
E -5 .
save X
clear X
get channel number
disable output multiplexer
select output channel
get nunber from memory table
send it to DAC
enable output multiplexer
increment channel in X
check for maximum X=8
if less than rnaximum, rePeat output
select input channel
convert analog V to binary
save number in memory table
increment channel.in X
check for naximu* 11=$10
if less than maximum, repeat input
reload interval
timer with refresh
value (rnsec)
increment sample count
clear caxry before addition
switch to BCD mode
get count number
ur.askall buc low bit
add bit to low order time
save result
clear A
add carry to high order time
save result
return to binary mode
restore X
restore A
return from interrupt
LDA#
$80
STAz
TRIAL
lDA/l
$OO
MCIBIT CtC
ADCz TRIAL
STA@ DAC
DECz $fS
IJA@
COMP
ANDii
$fO
BNEr
SAVE
LDAG DAC
SEC
SBCz
TRIAL
CLC
BCCr
SIIIFT
SAVE
l,DA@ DAC
SHIFT
LSRz
TRIAL
BCCr
NXIBIT
RTS
INITIALIZATION
0380 A9 FF
0382 8D OL
0385 49 0F
0387 8D 03
038A' 49 00
038C 85 D0
0388 85 Dl
0390 85 D2
0392 8D gA
0395 A9 03
0397 8D FB
0394 AD 0E
039D 4C 4F
INTLZ
t7
17
L7
17
17
IC
ADC
LDA#
STA,G
LDAtf
STAe
IJA/F
STAz
STAz
STAz
STA@
tDAilf
STAG
LDAG
JIC@
$FF
$1701
$0f
$1703
$00
COUNT
TIUE-L
TIME-H
NMI-L
$Or
NMI-H,
$170E
$1C4F
E -6
enter trial
number
save it
clear A
clear carry before addition
add trial
value to A
send trtal
value to DAC
naste 5 microseconds
get comparator status
mask to recover bit 4
save result
if comparator = I
too big, get number from DAC
set carry before subtraction
nurnber
subtract trlal
Jr.mp to shift
get nuober from DAC
divlde trial
number by 2
done if carry is 1
return wlth finaL valud in A
set PA port
to output
vector
6l
5l
4 \ourPr,rr
3 f Foflr
aI
rl
o)
IC4
IPF
IC t2
LM 3II
IC5
IO
PORT
tc?
\ 6 ro o o p F
h
|t,
rt
*
./tt
IC
-'
r ooopF
I TO8
ca3r30
-3y
-r5Y
Number
1 ro8
I
10
1l
12
13
T yp e
+ 5V
cA3 130
16.
cD4051
't6
cD4051
MCt408L-8 13
LM 311
LM 318
GND - 15 V
+1 5 V
-5V
4
1
I
a
2
I
4
4
8
B
E -7
APPEI{BtTiF.
KIr{16500
TNFORI\4AfIONSOURCES
KIM SOFII^IARE
SOURCES
NJ 08035
of FOCALfor $40, 2.5K assesrbler (nonstapdard
for $30, 6K assembler/text editor (standard
for $60. Send 92.00 for literature.
6502 PROGRAMEXCHANGE
2920 l{oana
Reno, Nevada 89509
4K FOCAL (FCL-65),. scientific
routine package (writren in
FOCAL), games and general software for 6500 systems using
the KIM and TIM monitors.
Send $0.50 for program list.
THE COMPUTERIST
P.O. Box 3
S. Chelmsford, MA OL824
High quality software.
PLEASEgame package fot KIM-I:
(cassette).
HELP
text editors and word processing
$10.00
programs-send for description-$15.00
per cassette.
MICROCHESSChess playing program for KIM-L: $15.00.
PYRAMID DATA SYSTEMS
6 Terrace Avenue
New Egypt, NJ 08533
rrXIMil extended I/O nonitor package
for KIM (requires
than lK of memory) $12 for manual and cassette.
more
MICRO-h7ARE
LTD.
27 Firstbrooke Road
Toronto, Ontario
Canada M4E 2L2
Assembler, dissassembler, and text editor for 6502 with
4K memory. Manual and KIM cassette: $25, source listing:
$eS. Well documented.
IGnneth I.l. Ensele
1337 Foster Rd.
Napa, CA 94558
Source for Tom Pittnans 2K TINY BASIC on KIM cagsette.
Specify st,artlng address $0200 or $2000. $9.50 for
tape plus $1.00 handltng and postage.
F-1
oPa
P .O. B o x 3 1 1
Argonne, IL
60439
THE FIRST BOOKOF KIM by Stan Ockers, Jim Butterfield,
and
Eric Rehnke. The book includes a beginners guide to KIM,
several tutorials
on hooking things up to KIM, and a large
number of game and utility
type programs.
180 pages,
8 Ll2 X 11 fornat: $9.00 plus $0.50 postage.
Johnson Comput.er
P.O. Box 523
DIedlna, Ohio
44258
4.5K assembler/text
editor
for current information.
T- 2
and other
65O2 sof&rare.
I,Irite
6500 MICROPROCESSOR
SUPPLIERS
MOSTechnology
950 Rittenhouse Rd.
Norristown, pA 19401
Rockwell Microelectronic
P. O. Box 3669
Anaheim, CA 92903
(2L5) 666_1950
Devices
Synertek
3050 Coronado Dr.
Santa C1ara, CA 95051
eL4)
632_3729
(40g) 9g4_g900
6500 BASEDMICROCOMPTIfER
SIIPPLIERS
Apple Computer Inc.
20863 Stevens Creek Blvd.
Bldg. B3-C
Cupertino, CA 950L4
(40g) 996_1010
(4L5) 326-4000
ECD Corp.
196 Broadway
Cambridge, I,rA A2L39
Ohio Scientific
LI679 Hayden
Hiram, Ohio
(6tt1
44234
F -3
66L-440O
NorJ\fwrro,{ldrtrcldtrLlgJsurvdsNnS'o
0 xtoNlrddv
?.
3.
A LL RE A D OP E RA T I S I { SO N T HE T I |, 1 E -O UTF L A G (O DD A DDRES S E S }
LE A V E THE lI.{TE FT RUPETI . { A g L ERE G I S T E R UNT O UCHE D.
4.
5,
6.
A LL COUI..ITEUR
R I TE O P E Rf iTI O HS CL E f iR T HE T I ME -O UT F L A G .
B. PRE -S CA LE R B IT$'
1.
?.
3.
C 0NSEGUE NCE2S
1.
?.
o P E li: A T i 0 H .
' rrRI T E
E NA B LI NG THE I HTE RP ' " I P TP E CI U
i P E S f 1 ld RI T E 0 P E RRTi 0 N A T A D i l R E S S E S
L7OC,_1.7@F,
F
E
A
'
,
OH A
O P E F : A T I O IA
{ T E I T HE R L 7 A C, O R t , 7 b E .
S E TTII'{G TljE P RE -S CA L E RE iT S RE 0 UI RE S A
3.
4.
G -1
(\.)
rl
EXPER
IT4ENT
I NTERRUPT
@a 6 0
@A O E
ooo5
6 @0 7
g , @O A
OOOD
0o6F
A @f t .
OO15
@0 1 6
@o 7 ?
aa19
OO1B
OO1D
AO1F
6IA?A
bq??
g @? 4
80A6
OOE8
807.f1
OO?B
eo?D
Oq?F
@9 3 1
QO34
@0 3 6
OO38
A9
8D
A9
8D
8D
Ag
8D
8D
58
F8
A9
85
85
85
38
AA
85
69
95
90
E8
DO
A9
85
EO
C6
DA
FO
4g
FE
oo
FF
C I3
FF
6t
6F
L7
1 .7
1"7
L7 ,
L7
0g
F9
FA
FB
FD
I--C
00
FC
03
F5
?0
80
1F
80
F9
E5
LF
L DA# g40
S TAE fi1"7F8
.
LDA* g.CIo
S TA@FLTFF" --.) IRO VECTORINSTALLED
J
PORTB INPUT
S TAS fiX.703
}
L DA* $FF
,
t^,,t'',s
poRt A oUTPUT
S TA@#1.7OtJ
* '* i '
n
S TAB *DAF ' e*- - *' *9TARTUP TIMER 1pi{ i"'r
C LI
ENABLEINTERRUFTS
sED
DECIMALM ODE
L DA{ I $00
S THZ $F9
S TAZ SFA
S TAZ $FB.
ZEROOUT DISFLAY DIGITS
S TC
USE CARRYTO DO THE IN C R EM EN T
NOTEIIRAP- AROUND
INDE XIN G
L DX$ $FD
L DAZX $FC
TO GET TO LOEATI ON F9 F I R ST
A DCS*AO
S TqZY,$FC
I,JRITEBACK UPDATED
DIG IT PAIR
B CC SO3
FALL OUT IF NO CARRY - OU T
IJPDATEI NDEX I F NEEDBE
I NX
FALL OUT IF ALL DIGIT S D ON E
S NE $F5
L DA' $' $e6
S TAZ #BA
USE LOC. 8CI AS DISFLAY LOOPC T R ,
JSR@$lF1F
EALL TO DISPLAY DITIITS
CoUNTD0tdt'DISpLAY
t
CA LLS
trfcz SB0
E NE $F9
DO ANOTHER
DISPLAY CA LL
E EO f E5
UPDATEDI SPLAY CONTEI'IT S
,
N O t dT H E I N T E R R U F T -D
IV
RE N P R' ) GRAhl
@O 4 O
a6+1
O @4 4
OO 4 5
OO 4 6
CI048
OO 4 A
Ot ) 4 0
O O SO
-fJO51
48
nD
OA
AA
DA
A9
8D
EE
68
40
02
t7
OA
FF
q F fi
Oq T ,7
F HA
L DAo #t702
A SL A
A gL A
B NE $OA
L D AS $FF
5 T NE $X7OF
I N ';@#i7A@
PLA
R TI
SAVE ACCUIdULNTOR
GET Sh|ITCHES
SHIFT UF
TIdICE
iF fiLL $I^' ITUHES
ARE ZE R O
USE $FF FOR DEFAULT
RESTARTTIM ER
UPDATEPORTA
RITRI EVE ACCUbIULATOR
RETURNFRO} ' I NTENRUF T
N O T ES :
1.
GR 0 U N D IN G
S IAITf C H E SLr ILL SPEEDUP THE UPDATES0N P0RT A.
?,
G-2
I.]ON CiIART
CODECO|'IPAN
DECII-{AL
,+-BIT
I]INARX
_ = 1)
T5
I 111
o 1111
1 1 1 1 1.
O 1111
o 1111
14
1 110
1 1 r. 1 0
0 1110
o 1110
r)
1101
o 1110
o 1101
o1000
o1001
1 1101
0 1101
o 1101
o1011
L2-
1100
1 1100
0 1100
o 1100
11
1011
o '1 1 0 0
o 1011
1 L011
0 1011
o 1011
10
101o
o 1010
1 1010
0 1010
o r,o10
o1010
01110
01111.
1001
o 1001
1 1001
0 1001
o 1001
olto1
1000
o 1000
1 1000
0 10oo
o 1000
01100
0111
1 0111
0 0111
o 0111
00100
0110
o 0111
o 0110
1 0110
0 0110
0 0110
00101
0101
0 0101
1 010r.
0 0101
0 0L01
00111
I+
o 0100
1 0100
0 0100
0 0100
00110.
0 0011
t 0010
0 @10
1 0001
0 0@1
oooo
o
o
o
o
-1
o ool_t
o oo10
o oool
o ooco
1 0co1
L 001L
o100
oo11
oo10
oool
o 1111
1 11tO
1'11L1
10000
-?.
1 0010
o 1110
1 1101
L 1110
10001
-3
L 0011"
0 1101
1 1100
1 1101
10011
-l+
1 0100
0 1100
1 L011
L 1100
10010
-5
-6
-7
-B
1 0101
o 1011
1 1010
1 1011
10110
1 0110
0 1010
I 1001
r 1010
10111
1 0111
0 1001
1 1000
1 1001
10101
1 1000
0 1000
1 0111
I 1000
10100
1 1001
0 0111
1 0110
L 0111
11100
1 1010
0 0110
1 0101
1 01.10
11101
1 1011
o 0101
L 0100
1 0L01
11111
-12
-1,3
1 1100
o 0100
1 0011
1 0100
11 1 1 0
1 1101
0 0011
1 0010
1 0011
11010
- 1l}
1 1L10
0 00to
I 0001
1 0010
11011
-1 5
-1 6
1111.1
o 0001
1 0000
1 0001
11001
1 0000
11000
3
2
-9
-10
-1 1
loooo?ffi
o 0000
oo11
oo10
oool
oooo
00010
ooo11
ooool
ooooo
signal,
In additlon to the
we uiIl
position
bit
of the addends:
Az
+2L=+2
+2o=+L
Bz
+20
ilHH
EH i l i l
need
the contents
strate$r
bit
welghts for
all
bits
we ti-I}
locations
In the
Two factors
signed arithmeti,c:
1. The term l.'lSB(rnost significant
we will
bit
O or bit
a positive
rvei6ht (c.-)
1 of
sig,rredaritltnctic
p. 2
Cir,=O;
A o=Oi
Bo =Q
OOO
B.
O 1 O
+2
Addition
O01
+1
n u mb e rs .
O11
+3
No o v e rf lo lt , n o u n d e rf lo w
A o -0;
Bo=1
(o rA o = 1 ;
O 1 0
+2
Addition
1 O 1
'3
111
-1
lilo o v e rf lo x , n o u n c ie rf lo ri
Cirr=O;
Bo=O)
000
C.
C.-=O;
Lno
000
A o=1;
-3
11O
-2
Un d e rf lo w
011
-5
Co h a s a we ig h t o f
111
Cirr=1;
negative.
1 O 1
is reCistributed
111
and a
Bo=1
111
D.
of a rosi-tive
A o=O;
2 x -l+ ,
rr' hi c h
Lo 14, a,rd So
-L + -1
Bo=0
000
0 01
B.
Cin=1;
0 1 1
+3
OO1
+1
O v e rf lo w
100
+t+
S o a s f o rme d . h a s a rie ig h t o f
000
+4+0
v rh j-c h is mo v e d t o M,
A o=O;
Bo=1
(o rA o = 1 ;
nunbers.
+ !. ,
Bo=O)
0 00
O 1 O
t'?.
Adrji.l;lon of
110
-2
nurnber.
OOO
.!_q
a positj-ve
ancl a negaLive
llo o v e rf lo ' , v , n o u n d e rf lo w
llote that the weigtrt of Co is zeroi
Co is pro<iucr:dby t'addllion" of C.r,
p. 3
signed arithmetic
Cir, = 1;
F.
Bo = 1
0OO
1 i. O
-2
111
-1
n u , ' n b e rs .
101
-3
No u n d e rf lo v t rn o o v e rf lo w
Again Cr* neutralizes
sign bits.
one of the
re:pPears as 5o.
fn sumnary:
1.
If
carry-in
1s generated, theri
If
a carry-out
then
underfLow occurred.
3.
If
no earries
l+.
ff
a carry-in
produces a carry-out,
this
operations.
annountsto neutralization
So must be compLernented,
Co,rr=0, M must
If
arifhmetic
be incremented.
fn logical
terms, spill-out
the spilI-ouf
l'ihen all
is given b/ Co,rt,
additions
of the spll1-oub
into posifions
renresenting
string
must be climinated
corresponcling to their
positions
assigned weight,
slrll{s 3cNlrulrJlu
lu.
H Xl0NSddv
TTL REFEREI'ICESHXET #1
7402
7474
!Bl
FUI\ICTIONTABLE
LH XX
HL
H LXX
LH
LLXX
H H T II
HL
lr u
t..ilil
hh
LH
7490 DECADECOT'NTER
i
|
i
I
2!
.j r-
ooq
H H LX
ill
lr!
lf\
2q
:rF
oo
H H IL
7408
lcx
OUTPU'S
INPUTS
PR ESET C LEAR C LO C X
7t+04
!!t
il
I
i
7432
II I J _ r l-
'.I_
---.
t7
lL
I
I
ya
16
15
COUIYT
Oo
Qc
Oa
IASLE
FESE',/COUN''RUTH
OUTPU'
R0(il
Oa
R ESTT N PU T S
O U rp U r
Ror2l
Q6
i
R9{',il F9{21 Q6
LLLL
LLLH
LLHL
t{
LLHH
X
L
LLLI
LLLL
HLLH
COUNT
COUNT
COUNT
COUNT
LHLL
LHLH
LHHL
LHHI{
HLLL
r.r
r,{
74L38
1-OF-8 DECODER
INPUTS
EN AELE
GI
XH
INPUTS
oo
OG
L
Ll{
HL
X
H'
qt
OUTPUTS
os
60
06
0
I
G?'
OUTPU'S
SELEC T
Yl
Y2
c 8A
YO
xxx
xxx
HHHHHHI{H
HHHHHHHH
LX
| tL
LLL
LHHI.IHH}IH
HL
LI.H
HLHHHHHH
HL
HL
HL
LHL
HTILHTIHHH
LHH
HHHLHIIHH
HLL
IIHHHLHHH
HT
IILH
IIHHHHLHH
HL
HHL
HHHHHHLH
HL
HHH
HHHHHHHI
ol G
.Gt- G ?A.G r E
Y3
Y4
Y5
Y6
Y7
Oa
TTL REFERENCE
SHEET#2
74148 PRIORITY E.NCODER
74L53 MUI.TIPI"EXER
-^-
Gno
sTqoBf :E
IG sLct
oa?a rttuts
TAALE
FUilCTTOil
SELEC"
sTnoSE ouTn r
OATA I'I?I'TS
INPUTS
!trrgtt
DArA lN?lrls
A
stRcgf
vcc
lG stlEcr
co
ct
cil
c:l
x
x
x
x
x
x
x
x
x
L
L
L
H
*l
idgur!
S.rH
hi$ fi.f,
H
-
x
x
x
x
x
x
tl
x
x
x
x
x
x
x
x
x
x
x
lo bolh
c066on
A afrd La
i.rdffi
X'
ld
lst,
t
-
tatalrtaraa
L
L
outrur3
$tPt Ts
H
EI
xx
A2
AI
AO
(;:3
t{
l"l
ll
tl
HH
tl
xx
xx
xx
xx
xx
xx
x
x
x
x
x
x
x
x
x
x
x
x
l{
XL
L
L
L
tt
clisr
ll
L
il
|l
lt
t{
t{
t{
H
H
rtt
tt
7545L
75453
75452
REI"AY DRTVERS
+v
75454
-v
.d l r r d q a
- r .d 6 r a a
d r yl d
DC
DS3686
DS36E7
L489
1488
L
L
L
L
tl
x
H
X
!!
st3ltHsA0010NHc3r
SoH
I xtoNtddv
PRELIifiIIUABY
OATA
H
moa
SHEET
TE Gf{X OLOOY . t X C.
MAY. 19?6
MC$6500
iilCROPF0CE||So
BS
TheMC$6500,Microprocesor
FamilyConcept
--The l-1CS6500
Series Microprocessors represent the first totally software compatible
r nic r o p ro c e s s o r fa n i l y .
T h i s f ani Ty of products i ncl udes a range of softw arL com pat ible
m ic r o p ro c e s s o rs w h i c h p ro v i d e a sel ecti bn of addressabl e nenory range, i nterrupt input
oP t io n s a n d o n -c h i p c l o c k o s s c i l l ators and dri vers.
A l l of the mi croprocessors in t he
II{CS6500
grouP are software cornpatibl.e within the group and are bus compatible with the
M 680 0p ro d u c t o ffe ri n g .
T he f a mi l y i n c l u d e s fi v e m i c ro processors w i th on-board cl ock osci l Lators and dri v er s
and f o u r m i c ro p ro c e s s o rs d ri v e n by external cl ocks. The on-chi p cl ock versi ons a r e
ained a t h i g h p e rfo rma n c e , l o w cost appl i cati ons w here si ngl e phase i nputs, crysr al
ur . ' RU rrrp u L s p rl u v i r.-l eL l re L i u re base. The er.ternal cl ocl : versi ons arc geared for the
nult i p ro c e s s o r s y s te m a p p l i c a ti ons w here naxi num ti ni ng control i s mandatory. All
v er s io n s o f th e m i c ro p ro c e s s o rs are avai l abl e i n 1 MH z and 2 MH z (" A t' suffi x
on product numbers) rnaxinun operating frequencies.
of theMCS6500
Features
Family
S ingl e fi v e v o l t s u p p l y
N c ha n n e l , s i l i c o n
g a te , d eplet io n
l o a d te c h n o l o g y
E ight b i t p a ra l 1 e 1 p ro c e s s i ng
56 I n s tru c ti o n s
Deciural and binary arithmetic
T hir t e e n a d d re s s i n g m o d e s
True indxing capability
Progranmable stack pointer
V ar lab l e l e n g th s ta c k
I nt er r u p t
c a p a b l l i ty
Non-maskable interrupt
Use with any type or speed memory
B i- dire c ti o n a l
D a ta B u s
Instructi on
decodi ng and control
Addressable memory range of up to
65K bytes
"Ready" input
Direct memory. acce.ss capabillty
Bus compatible with MC6800
C hoi ce of external or on-board cl oc ks
IJl{dz and 2tl}lz operation
On-the-chl.p cLock optlcns
* External elngle clock input
* RC time base input
* Cryetal tine base lnput
40 and 28 pln, package veraions
P i pel i ne archi tecture
Members
of the Family
Microprocessors with
On-BoardClock 0sci1 lator
Microprocessors with
External Two Phase
Clock Input
MCS6s02
|- ucsosrz
MCS6s03
l-"rrur*
I
f-r'rcsosr+
MCS6s04
MCS6505
I
l- ucsosrs
MCS6s06
L 1 -l
on the DataSheet
Comments
to review first
the basic "Comnon Characteristics"
- th o se
Th e da ta sheet is c ons t r uc t ed
Subsequent to a
whic h ar e c om m on t o t he g e n e r a l f a m i l y o f m i c r o p r o c e s s o r s .
fea ture s
wl1l be sections devoted to each member of the group
c har ac t er is t ic s
review of t he f anily
of eac h.
f eat ur es
with sp ecif ic
COMMO
N CHAHACTERISTICS
.-
CONTROL SECTION
RgctsT[RsEcTtoN
Pg
rtrq rta
ABO
A8 |
AB2
ABJ
A8,l
AB5
IN5TRUCTION
DECODE
A86
A8?
ADDRESS
BUS
AB'I
A I}.,
grrrrrI
A 810
e r {t n r
MC S 6512,13,14.15
ABI I
aroa* I
MC S 6502,3,4,s ,r
rNPr.r
J
A8t2
f1 oUr
ABI]
fi:-
ABI4
ABI 5
DB'
D BI
DA2
oB3
D84
D B'
lr86
D61
fl =,,,,,,n,
|
= r nr r r - r r ir
re
Arehitectu
| nternal
MC56500
'1,.1-2
OATA
8US
HISTICS
COMMON
G}IARACTE
INSTRUCTION
SET_ ATPHABETIC
SEOUEHCE
ADC
AN!)
ASL
DIC
oEX
DIY
ECC
BCS
BEQ
Btl
BMI
8NF:
lrPt.
BRK
BVC
8VS
Ilrdurll
granch
on Cdrry C I ear
0n C arry set
lirdnch o0 R esui! Zero
Test IJ.its in }{ercrt wlth Accumulncor
Branch on Result Hlnus
Br,rDch on R esult not Zero
Brailclr oo Result Plus
Forcc Break
Erench on overflou
C1(ar
IJLdnch un Overflou
S(t
UOR "lixc1!sive-or'r
CLC
C!-D
CLI
C,,V
CMP
CPX
CPI
Ciear
Clear
Clear
(llear
Carry FlaS
DeciMl
Hode
Interrupt
D.isable 8i.t
Overflou
llag
Conpare Hemcrt and AccuDulator
Conpar(' !lem(,r! rnd lndx X
Cohpare ilemry
and lndex Y
Decrenent
Decrehent
Dcrenenl
ln_C Increnent
Ir_X Incranenc
Il{Y Incremett
lretury by Ooe
Index X by one
lndex Y by One
Menory rith
?LP
ROL
Rotste
Otrc Blt
ROR
Rotate
Retulo
Return
Accuhulatot
Menory by 01e
Index X by 0n
Inde}: Y hy One
{Tt
RTS
s8c
JMP
JSR
LDA
LDX
LDY
LSR
Lo6d Accunulator
uith Memory
Load Indea X wlth Mercr)'
Load Index Y sith llemort
Shift ooe 8ir Rlghr (Itercry or Accwulator)
liOP
lio operatlon
Savlng
on S:ack
Acc@ulator
Proceasg! Status on Scack
froh stack
Acc@slator
Proceesor Status fron Stack
Pusb
Puah
Pull
Pull
FHA
PHP
Relurn
Address
STA
STY
Accuulator
rxA
TXS
(Ue@ry
or
or
Accuelator)
Accuhulator}
TAX Transfer
TAY trrnafer
L.f!
Tlaasfer
franfer
TranEfer
Trsafer
!u fndet x
Accmulalor
to lndex Y
Accaslator
to Index x
Stack Polnter
Index X to AccuNlator
Indcx X to Stack Polnter
lnd.a Y to Accdqlator
MODES
ADORESSIilG
A u c U ! 4 U L A TUlt
ADDRESSING
o f a ddres6i ng l s repreaenred w l th
- lh ls.fo r m
op e r a lio n o n th e a ccu m u la to r ,
ln
l rnpl ytng an
ABSOLUTE
apecl fl es the l ght 1o* ordc r
A DDRESSINC
- In a b so lu te a d d r e s si ng, rhe second byte of the l nstruct{on
T hus ' th
blts o f th e e ffe ctlve
a d d r e ss nhLl e rhe thl rd byte epc{fl ee the el ght hl gh order bl tE .
eb so lu te a d d r e Be ln g m o d e a 1 lo ws acceeE to the entl re 65K bytee of addreaesbl e nemory.
zERo PACE ADDRESSING- The zero page lnstructlone
allord for ehorter code l.ld excstlon tlns
C areful
th e e e co n d b yte o f th e ln str u ctl on
and aseunl ng a zero htgh addreee byte.
pa g e ce n r e e u lt ln slg n iflca n t
l ncrease l -n code effi cl ency.
by only fetchtng
use of the z ero
INDEXEDZEROPAGE ADDRESSING- (X, Y indexlng) - Thls forur of addresalng 18 u6d ln conjunctton ttlth the lndex
eddrese i s eal c ul ated'
re g iste r a n d ls r e fe r r e d to a s "Zei o P age, X " orttzero P age, \".
The effectl ve
S l nce thl e l e a forn of "Zero P age"
by a d d ln g th e o e co n d b yte to the contenrs of the l ndex t.l l "t"r.
due to
A ddl tl onal l y
ad d r e se in g , th e e o n te n t o f th e second byce references a l ocagi on l n page zero.
che "Zero Page" addreesing nature of this node, no carry la edded to the hlgh order I blts of ntet:ory
a n d cr o se ln g o f p a g e b o u n d a r le s doe6 not occur.
.
INDEXEDABSOLUTEADDRESSINC- (X, Y lndexing) - This form of addresslng lB used ln eorijuoction with X end Y
addre ae l s
ln d e x r e g le te r a n d ls r e fe r r e d to as rrA bsol ute, X rr, and "A baol ute, Y 'r, ?he effectl ve
formed by addlng the content.s of x or Y to the addrese contalned 1Ir the gecond and thlrd bytes of the
ln str u ce lo n .
T h ls m o d e a llo we the i .ndex reg{ster to concai n l he l ndex or count vaX uc and t he l nreff,e$clng and
structlon
to contaln the base address.
Thls type of Lndexlng a1lo!r8 any locetlon
th e in d e x to m o d i.fy m u ltip le ft el ds resul ti ng In reduced codl ng and executl on tl fte.
I H P L I E D A DDRESSING
- In th e lm p lie d a d d r eesl ng mode, the addresB contal nl ng
ln th e o p e r a tlo n co d e o f th e ln8tructl on,
R E L A T I V EA DDRESSING
- Re la tlve a d d r e sa ln g i s used onl y w i th
fo r th e co n d ltlo n a l
b r a n ch .
ttl ted
a der tl ns t{ on
[Offlct't
sdded !o qhc contentd of
The second byte of the lnetruction
becones the operand rhlch la .n
The
th e lo we r e lg h t b lts o f th e p r ogran counter w hen the counter l s set at th next l ni tructf*fl "
r a n g e o f th e o ffse t 1 g - 1 2 8 Eo +L27 bytes from the next l nE tructl on,
I N D E X E DI N DIRECTADDRESSINC
the geeon d by te of
- In in d e xe d l ndi rect addresei ng (referred to as (Ind{rec!,X )),
'
Th a re8ul t
th e in str u ctlo n
is a d d e d to th e contents of the X l ndex regl ater,
dl rcardl ng the earry.
o f th ls a d d ltlo n p o ln cs to a h emory l ocal i on on page zero nhose contents l s tha Lol r ordcr el ght bl te
bltr
of the effective
address.
The next menory location in page zero contalns the high order ltht
o f th e e ffe ctlve
a d d r e ss.
Bo th nemory l ocatl ons specl fyl ng the hl .gh and l on order bytes of the
e ffe ctlve
a d d r e ss m u st b e 1 n p age zero.
(Indl rcg)rY ),
thc t.coad by t.
I N D I R E C T I NDEXEDADDRESSING
l ndexed addres8tng (referrcd to..
- In ln d lr e ct
p o ln ts to a $emory l ocatl on l n page zero.
of th e ln r tr u ctio n
thc contcnta of ghl s aql ory l oc atl on
ia a d d e d to th e co n i n t8 o f r h e Y l ndex regi srcr,
i he rerul t bol ng th6 l ol t order el tht bl tt of tha
effe ctlvc
r d d r e ss.
T h e ca r r y from thl s addl tl on 1g addrd to thc contcnta of th. naxt prS c ti ro
eddr.l r'
n.n o r y lo cr tio n ,
th e r a su lt b e lng the hl gh ordar el ght bl tr of thr rffctl vc
ABSOLUTEINDIRECT - The tccond byce of the inatrucrlon
contalna thc low ordrr Gttht bltc of r ttremory locatlon'
Th e h lg h o r d e r e lg h r b its o f r har memory l ocarl on l e contai ned l n the thl rd byte of the l nst ruc tLon'
addr.ee'
Th e co n ce n ts o f r f,e fu lly sp e clfl ed mernoryl ocatl on Ls the l ow order byte of the effectl ve
rddrcst rhl ch l s l oeded
Th e n e xt m e m o r y lo ca tlo n co n ta lns the hl gi order byte of thc cffectl ve
in to th e slxtce n b ltr o f th e p rogram counter.
1r ,
Eorroq
I c0MM0N UHARACTERTSTTCS
I
PHOGNAMMING
MOOET
PROCESSOASTATTJSf.ic
r--T-:-_l
ACCUMULATOR
r---;------l
INDEX REGISIER
I = RESUL; ZEBO
INDEX REGISTER
PROGFA[,?COUNTEB
8l
r.r_l+
lr
I I " Jl
IRO DIS,ABLE
]=DISASL
DECIM.AL I!4ODE
1= TRUE
BRK COMMAND
- .l
S-IACK FOJNTER
OVRFLOW
NTGATIVE
ltusrBusrlslu
sET- sp sODEs,
fxecution
Time"
Mennory
Requlrements
rNSttwTtdE
t
,t
i
;
t
f
TSX
it
YI
u)
aoo
rzr
Aoo 1 t c
Aoo,
lo
{!r
CAir Y
1 ro
N. rr pac6
r"
N
NOT,
touN06y
: s c F o s s {D
r: tFANch
occ!nt
to tAtuja raa
anANCH OCCUFS ?O OrraiF!r
'f
3OAfiOw
ri6!
4
A( r r 'u L ;i ^ i i r e
i{ir
. rr (
[ . 1 -8
r l r r \i t
''
\fi
rr, ! Y
B'i
--*_-J
r 40
Vaa
RDY
61( OUT)
I RO,
N.C,
ttMl
RES
e Z(OUTI
s.o.
oq(ltr)
rt
f9
N.C.
N. C.
R/W
0 Bo
o8r
o82
D8 5
DB4
o B5
DB6
DA7
a 8 t5
ABI4
AAr 3
ABI 2
20
2l
v3S
6!5
s Yl{ c
Vcc
480
A8l
482.
93?
ro
5l
il30
AB3
484
aa5
A8 6
a87
a8s
AB
AEtO
ABII
t6
t7
2a
24
M CS650 2
Feafiresof il{C$6b02
R-3
t2
Vcr
227
m6'
NMI
Vc c
A BO
AB I
AA ?
A B3
A B4
A B5
A8 6
AB 7
A B8
425
5?4
623
722
821
rol
ill8
t2
t3
l4
O2(a0Tl
oq( lN)
R /W
080
DBI
DB2
o B3
D84
D85
D86
D ts 7
t7 A BI I
16 A B IO
A B9
l
MC S 6 5 0 3
* 4K Addressable Bytes of
Memory (A800-A'811)
* On-the-chlp
CLock
* EQ' tnterrupt
't m
Interrupt
* 8 Bit Bi-Dlrectional-
Data 8us
Featurss
ot [tCS6503
MGS6504
- 28 PinPackage
RE
Vss
Ir
l2
TFT 3
Vc c
AB O
AB I
A82
A B3
AB 4
A8 5
AB 6
A B7
A88
A89
6
7
I
9
lo
ll
12
t3
t4
?8
27
26
23
24
23
z2
2ll
201
rel
r8l
t7l
16l
t5l
MC S 6 3 0 4
o2@UTl
O O (lN,
R/W
080
DBI
oa2
083
DB4
DB5
o86
oa7
AB12
ABII
ABIO
* 8K Addressabl-e Bytes of
Memory (A800-A812)
* On-the-chip
Clock
* TEQ.rnterrupt
* 8 Btt Bl-Dlrectlonal Data
Featuruof MCS6504
ItlCS6505
- 28 PinPackage
RE
bZ@UTl
0 9 (l N )
R /V t
DBO
DBI
082
D83
D84
085
D B6
DB7
AB II
A8 to
489
Vss
RDY
rm
Vc c
A BO
A BI
A B2
483
A B4
A85
A86
A B7
A8 8
4K Addressable Bytes of
Memory (A800-A811)
On-the-chip Clock
TQ
rnterrupr
RDY Signal
8 Bit
Bi-Directional-
MCS 6505
Data Bus
of &tiG$$505
Features
ryqqq506
- 28 PinFackage
R ES
vs5
O r (O UT)
tRc
Vcc
AB O
ABI
A B2
AB 3
AB 4
A B5
486
AB7
AB 8
I
z
3
4
E
6
7
t
28
27
26
25
24
23
22
2l
2A
t9
t8
t..
t5
a2(aUTl
9o(lN)
R/w
0Bo
4K Addressable Bytes of
Memory [A800-A811]
0n-t he-chip Clock
DBI
082
DB3
D B4
D B5
D86
oa7
AB II
AB IO
/t B9
m0Interrupt
Trrrophases off
8 Bit
MCS 6506
Bi-Directional
Data Bus
sf MS$6506
Feetuyes
MCS65I1-40 PinPackage
6 5 K Addressa!:1eBytes of Memor,v
TN'E
Interrupt
mnInterrupt
RDY Signal
8 Bit
Bi-Directi"onal
Dat a Bus
SYNCSignal
Two phase input
Data Bus Enable
of MS$S51f
F*at$res
Lt- 10
MCS65|3
- 28PinPackage
Vss
A1
rF-o
ffii
Vcc
A80
AB I
AB ?
AB 3
A84
A85
A8 6
A A7
A B8
2
?
4
5
6
7
I
9
ro
tl
t2
,3
t4
28
27
26
?5
24
23
22
?l
20
l9
t8
t7
t6
t5
RES
A2
R /W
DBO
DBI
D82
o B3
D B4
D85
oB6
0 ts 7
A BI I
Ats IO
A99
4K Addressable Bytes of
Menory (A800-AB11l
* Tvo phase clock input
* TRQ Interrupt
* ffi
Interrupt
* B Bit Bi-Directional
MCS 65 | 3
Data
Features
of lbtCS65f3
ll,lg$0514
- 28 PinPackase
Vsg
A1
iRE
Vc c
ABO
ABI
AAz
AB3
A8 4
A85
AB6
AB 7
A B8
A A9
HE3
tza
227
3
425
524
6?3
722
azl
920
lo
l{
12
t3
t4
26
19
r8
t7
16
15
O2
R /W
080
DBI
D82
DB3
084
085
D B6
0 ts 7
AB Iz
AB II
AB IO
* 8K Addressable Bytes of
Mennory(A800-A812)
* T\+ophase clock input
* IIQ Interrupt
* 8 Bit Bi-DirectionaL Data Bus
of MC$65N4
Fcatures
M CS 65 t4
MCS6515
- 28PinFackage
Vs s
RDY
O1
I.FN
Vcc
A BO
ABI
ABE
A83
AB 4
A85
128
227
326
425
524
623
722
a2l
920
ro
il
t2
t3
14
19
t8
t7
t6
t5
RES
6Z
R /W
080
DBI
DA2
D B3
DB4
085
D86
087
4K Addressable Bytes of
Menory (A800-A811)
* Troophase cLock input
* TIQ Interrupt
* I Bit Bi*Directional
MCS 65r 5
of MC$6515
Fosturss
Il -11
Data Bus
TIMEtsASEGEf{EhnTIfiNffiF;ru$}g.r
OLCIrK
trl|CS6502
MC$6SSS,
M$$65SS
ry.g$gLff?,
ryf;$q504,
sYsTEil{
02
S Y S TF[,IC ,
0o (l N )
0: (ourl
fl cnvsrnl
r'Rvsrnl
SYST EM O ]
@ ,, ( l N )
O: (OUT)
Oscillator
MCS 65 A3_,4,5,6 S eries M ode Crystat
Controlled Oscillator
S Y S TE MOJ
SYSTF,M
0,' (l N )
0: (ouT)
PROCIUCT
lBl&$
rtcl tB N o LooY.
not
ANiTOUNCEMETUT
BUU-ETtt
tltc.
v^rtEy FofiGtcoRpoRAT
ctxTER(2ll) 6c8.t9t0
tto RrrTtf,flousE
R0A0.flonnlsTor,t.pA. t9a0r
Ig?S
SEPTEMBEB,
MCE652OPERIPHERALADAPTER
9ESCRTPTTON
The MCS6520Peripheral Adapter is designed to solve a broad range of peripheral
control problens in the inplementation of microcomputer systerns. This device allows
a vety effective
trade-off
between software and hardware by providing significant
l{hen coupled with the power and
capability
and flexibility
in a low cost chip.
speed of the MCS6500family of rnicroprocessors, the MCS6520allows inplementation
of very conplex systems at a nininum overall
cost.
through two 8-bit bi-direcControl of peripheral devices is handled prinarily
tional ports.
Each of these lines can be prograrmed to act as either an input or
atr output.
ln addition,
four peripheral contnol/interrupt
input lines are provided.
these lines can be used to interrupt
the processor or for rhand-shakingrr data
between the processor and a peripheral device.
load technology,
MCS652O
control
lines.
f",,,
I I,ATAlus
MtcnoPnocEssoRs
I
Hcr6snx
?TIPIIEn^L
..
DEVTCES
1
|
OAPLAYS.ETC,
'RINTERg.
-r.r.o,
vss
PAg
PAl
PA2
PA3
PA4
PA5
PA6
PA7
PB9
PBI
PB2
PB3
PB4
P85
P86
P87
cBt
cB2
vcc
Sosic NC5653o
Intcl\<'(
Dioglaa
4A
39
38
5
6
36
34
I
9
l0
31
1t
ll
JU
72
13
14
15
l6
1'7
l8
TY
2A
LJ
28
aa
at
26
25
.,4
CA1
wnL
rm,-A
i RiiB
RSg
RSl
RES
D9
D1
D2
D3
D4
D5
D6
D7
02
CSi
csz
CSfi
R/ft'
SUMMARYOF MCS652O
OPERATION
See MOS TECHNOLOGY MicrocomputerHardwareManualfor detaileddescriptionof MCS6520operation.
cAl/CBt CONTROT_
cR4 tc_RB)
B it I
IRQA (IRQB)
Act i ve T r a - n si ti o n
o f In p u t Sig n a l*
Bi r 0
l":s::gPlqgg:E
n e g a tive
D i sabl e--renrai n
n e g a tive
p o sitive
Oi sabl e--remai n
p o sitive
E nabl e--as
*Note:
Bit
^l tr r dl^>r
. ^1
Bir 4
set
hi gh
expl ai ned
above
i by an acti ve transi ti on
of B i t 0 i n C R A (C R B ).
of
the C A _t
Bit 3
rRQA(lRQB)
Interrupt Output
Active T r a n siti on
o f In o u t Sicnal *
00 0
n e g a tlve
i )i sabl e--remai ns
00 1
n e g a tive
0 t0
p o sitive
D i sabl e--renai ns
0 11
p o sitive
E nabl e--as
* Note :
Bit
hi gh
set
by
hi gh
expl ai ned
above
1 by an acri ve transi ti on
of B i t 3 i n C R A (C R B ).
of the C A 2 (C tsZ)
CAz OUTPUTMODES
CRA
Bit
by,
cA2lCBz II\|PUTMODES
CRA (CRB)
Bit 5
hi gh
Bit
Mo<ie
!:-:Jl:1:igl
Pu lse Ou tp u t
M a n u a l Ou tp u t
C A 2 set
M a n u a l Ou tp u t
C A 2 set hi gh
"ila n d sh a ke "
o n Re a d
l ow
CBz OUTPIJTMODES
CRB
Bit 5
Bit 4
Bit 3
t0 0
Mode
' r Ha n d sh a ke "
o n Wr itc
Il es cri pt i on
C B 2 i s set l ow on ni croprocess<.rr "l {ri te
B D atai l operati on
and
i s set hi gh by an acti ve transi ti on
of the C B I i nterrupt
i nput si gnal .
l hi s
al i ow s posi ti ve
control
of data trans fers
from the mi croprocessor
to the peri pherai
devi ce.
Pu l- se Ou tp u t
C B 2 goe.s l ow for
D ata[ opr:rati on.
devi ce i hat. data
M a n r r a l Ou tp u t
C B 2 set
l ow
M a r r u a l Ou tp u t
C B 2 set
hi gh
tn1
t.L'2
S ymbol
V al ue
su p p ly vo lta g e
V cc
-0-3 to +7,0
vdc
In p u t Vo lta g e
Vin
-0.3 to +7.0
V d.
o p e r a tin g
T4
T e n Pe r a tu r e Ra tr g e
Sto r a g e T e m Pe r a tu r e Ra n se
Trtg
U ni t
0 to +70
oC
-55 to +l s0
oc
S ymbol
Mi n
+2.0
-0.3
0.8
vtH
V IL
V tt
I It't
N0 T F :
FIGU R E
1 _ R EAD
fl ow ,
TIM IN G
Max
vcc
+.8
2.0
'i H
+2.0
+ l0
pA d c
-100
-250
uA d c
_1.0
- 1.6
nA d c
IIL
vott
1A
+0.4
Vdc
IoH
-100 -t000
-1.0 -2.5
pA d c
mAdc
l0
500
mA dc
uAdc
mW
PF
IoL
l off
P9
ci n
1.6
-
1.0
2OO
IU
7.0
1A
C out
posi ti ve
l0
fl ow .
2.4 V
Oai6
2.4 V
Ortr Bur
0.4 v
2,4 v
o.a v
z,a v
cal
o.a v
2,4 V
aav
t.L3
Vdc
Vol
o.4 v
CA?
(ri."d Shrr.)
v dc
V dc
V dc
+2.5
C H AR AC TER ISTIC S
ca2
(Puts Out)
Uni t
pAdc
.1.0
Typ
l)F
FIGURE 2 - W F IT E T IM T N G C H AF AC T ER IST IC S
Addrss
o.4 v
2-a v
Rod/Write
o.4 v
2.4 V
oab
Bus
o.4 v
_
TPDw
_vcc_
30%
2.4 V
Priph6ral Data
o.4 v
2-4 V
cB2
(Pul* Outl
o.4 v
2.4 V
cBl
o.4 V
rnsz
?.1v
cB2
( Hand
Shrko)
o.4 v
A . C . C H A M CT ERIST ICS
Read Timing
Ch a r a cte r istics
( F ig u r e
.1, Lcadi ng
Ch a r a cte r r stics
transi ti on
D e l a y T i m e, Ad d r e ss va lid to En a b le p osi ti ve
tr a n sitio n
to D ata val i d on bus
D e l a y T i n e , En a b le p o sitive
Da ta Se tu p T in e
Peripheral
D a t a B u s Ho ld T in e
to C A 2 negati ve transi ti on
D e L a y T i m e , En a b le n e g a tive tr a n sitio n
to C A 2 posi ti ve
D e l a y T i n e , En a b le n e g a tive tr a n sitio n
transl tl on
R i s e a n d Fa ll T im e fo r CAI a n d CA2 in p ut si .gnal s
D e l a y T i m e fr o n CAI a ctivc tr a n sitio n
to C A 2 posi ti .ve transi ti on
R i s e a n d Fa ll T iin e fo r En a b le in p u t
Write
Timing
Ch a r a cte r istics
( F ig u r e
Max Unlc
-ns
395
ns
TnS t
tr,tf
TR S Z
trE ,tfE
-ns
1.0
1.0
1.0
2.0
25
us
us
us
us
us
Synbol M i n 't y p
Max Unit
TnfW
180
TE Oq
TP D S U 300
TH n
l0
'IC A .Z
2)
Cha r a ct e r i st i cs
E n a b l e P u l se Wid th
D e l a y T i r n e, Ad d r e ss va lid to En a b le p o si ti ve
transi ti on
D e l a y T i n e , Da ta va lid to En a b le n e g a tive transi ti on
D e l a y T i m e , Re a d /l{ r ' ite n e g a tive tr a n sition
to E nabl e posi ti ve
transition
D a t a B u s Ho ld T im e
D e l a y T i r n e , En a b le n e g a tj.ve tr a n sitio n
to P eri pherdl
D ata valici
D e I a y T i m e , En a b le n e g a tivc tr a n sitj.o n
to P eri pheral
D ata Valid,
(vcc - 30e,)
cMos
PA0- P A 7 ,C A z
Dela y 'lime, Enable pos it iv e t r ans it ion t o C B 2 n c g a t i v e t r a n s i t i o n
0e iay Tirn e, Per ipher al Dat a v alid t o CB z n e g a t i v e t r a n s i t i o n
Dela y Tine , Enable pos it iv e t r ans it ion t o C B 2 p o s i t i v e t r a n s i t i o n
Rise a nd Fall Tine f or CB. l and CB2 inpu t s i g n a l 5
De lay Timc, CBI ac t iv e t r ans it ion r a C8 2 p o s i t i v e t r a n s i t i o n
1.2-4
TF
Terw
Tosu
Twe
Ttll,l
TpOW
TCMOS
TCAI
TOC
TRSi
t1,tf
TRSZ
a.470
180
300
130
25
us
l t5
10
-ns
I 'o
2,O
us
us
I .0
1.5
1.0
I .0
2.0
lis
us
us
lrs
us
-ns
PBELIf,IIIUARY
rB&@ffi
xo a
OATA
SHEET
lr c.
ilARCH,tt73
vAu.EvfoRGcoffrofiATE
ccfirtF (2r51
66c-t9t0
t50 ElTTfr{}rousE
80A$, r088rsT0!Yfl.
PA. rtaSl
(MEMORY,I/0,
MCS653(!
TIMERARRAY}
The MCS6530is designed to operate in conjunction with the MCS650XMicroprocessor
Farnily.
It is comprised of a mask progranmable L024 x 8 ROM, a 64 x B static
Ml"t,
software
controlled B bit bi-directional
two
data ports allowing direct interfacing
between the microprocessor unit and peripheral devices, and a software programmable
interval
timer with interrupt,
capable of riming in various intervals
from
L co 262,L44 cLock periods.
x 8.bit bi*directional
D ata Bus for direct
with the microprocessor
communication
*1024x8ROM
x 64 x 8 static
* Two 8 bit
RAM
bi-directj-onal
daLa ports
* Programmable Intervai
Timer Interrupt
* Peripheral
pins with
Direet
lnterface
Daca Dlrectlon
* Programmable Interval
for
to peripherals
Regist.ers
lines
DATA
C O NT RO L
R E GI S T E R
A
OATA
BUS
BUF F E R
P47
PERI PHE R A L
DATA B U F F E R
A O D R E SS
D E C OD ER
decoding
INTERVAL
TI ME R
P E R IP H E R A L
D A TA B U FFE R
B
C H IP
S E LE C T
R /W
MAXIMUMRATINGS
Supply Voltage
-. 3 ro + 7 . 0
I nput / O ut pu t
-.3
O per aLing
S t or age
Vo l ta g e
T e m p e ra tu re
Te m p e ra tu re
to +7.0
Range
Range
-55 to +150
High
I nput
Low Vo l ta g e
STMBOL
VolLage
VtH
vrr.
rru
rrs
I nput
Capaci ta n c e
O ut put
C a p a c i ta n c e
Capa c i ta n c e
P ower Dis s ip a ti o n
r.3-2
IJNIT
\/
It
1.0
2.5
PA
t1 .0
r1 0 . 0
uA
-3 0 0 .
-1 . 0
UA
-1.6
MA
Vott
v
vss+2.4
VSS+1.5
1ot
rot
cctt
v s s + .4 v
-100
-3 . 0
-1000
-5 . 0
UA
UA
1.6
MA
30
pf
ctt't
10
pf
cout
10
pf
Po
*W hen pr og ra mme d a s a d d re s s p i n s
A 1l v alue s a re D .C . re a d i n g s
I'{N(.
vcc
v s s+ .4
vot
-1 0 0 .
rri,
High Vo l ta g e
TYP.
vss+2.4
vsr-'3
rttt
MIN .
500 1000
MW
ISTICS
WRITE TIMINGCHARACTER
CHARACTERISTIC
Cioc k
Tcvc
Pe ri o d
Ris e
& Fal1
Times
TR, TF
Cloc k
Pu l s e
Wi d th
T\J
R/ W v al i d
A ddr es s
p o s i ti v e
b e fo re
valid
b e fo re
Dat . a B u s v a l i d
b e fo re
p o s i ti v e
of
valid
NS
470
NS
NS
of
TACW
180
NS
TDCW
300
NS
10
NS
transi ti on
negati ve
25
180
cl ock
of
cl ock
THI{
a fte r
uS
TWCW
transi tj -on
n e g a ti ve
10
cl ock
Time
P er iphera l
d a ta
of c l o c k
P er ipher a l
of clock
tr ansi ti on
transi ti on
d a ta v a l i d
a fte r
negati ve
transi ti on
dri-ving
CMOS (Level=VCC-302)
TCPW
uS
uS
TCMOS
READTIMINGCHARACTER
ISTICS
CITAMCTERISTIC
R/ W v ali d
A ddr es s
p o s i -ti v e
b e fo re
valid
P er iphera l
of c lo c k
b e fo re
d a ta
Dat a B u s v a l i d
Data
SYI''IBOL MIN .
Bus Hold
valid
a fte r
tra nsi ti on
p o s i ti -v e
b e fo re
p o s i ti v e
cl ock
TWCR
180
NS
of
TACR
180
NS
transi ti on
TPCR
300
NS
of
TCDR
of
transj -ti on
posi ti ve
transi ti on
cl ock
cl ock
Tine
EQ (fttt.rval
Timer Interrupt)
valid
positive fransition
of clock
before
I.3-3
395
NS
THR
10
NS
TIC
200
NS
Tcyc
l*-"
CL O C K INP UT
Twcw
R/W
2 . 4V
o.8v
o.4v
Tncw
?.4 V
ADDRE
SS
o.4 v
THw
2 . 4V
D ATA BUS
o.4 v
Tcpw
Tocw
Vcc
- 3 0 o /"
2.4 V
PERIPHE RA L
DATA
o.4v
Tcuos
WHITETIMINGCHARACTERISTICS
Figure
2
CL O C K IN PUT
R/W
Twcn
T
AD D RE SS
Tpcn
PE R IPH ERA L
DATA
Tcon
2 .4 V
DATA BUS
o. 4v
PB7(TRO)
2 . 4V
o.4 v
B E A DT I MI NG
CHA RA CT E B I S T I CS
Figure3
t.3-4
INTERFACESIGIVALOESCRIPTION
( BES)
Eeset
a Logic "0" on the RES input will cause
During system initialization
This in turn will eause aLJ' I/O
IIO
registers.
four
of
all
a zeroLng
buses to act as inputs Ehus protecting external comPonents from possible damage
and erroneous data while the system i; being configured under software control'
Interrupt
The Data Bus Buffers are puE int-o an OFF-STATEdtttttg Reset'
The RES signal must be held
is disabled with the REF signal.
capability
low for at least one clock Period when reset is required'
Input Clock
The input clock is a system Phase Two clock which can be either a
Urr, > 2.4', or high level clock (VtL < 0'2.
low level g.lgck (Vtl .0.4.
Read/Write ( R /W )
The R/W signal is supplied by the nicroprocessor atray and is used to
control the transfer of data to and from the microProcessor atray and the
MCS6530. A high on Ehe R/I,I pin al1ows the processor to read (with proper
addressing) the data supplied by the MCS6530. A low on the n/W pin allows
a write (with proper addressing) to the MCS6530.
InterruptRequest(lRO)
This same pin'
The IRQ pin is an interrupt pin from the interval timer.
(PB7). When
pin
I/O
can be used as a peripheralif not used as an interrupt,
data directlon
by
the
used as an interrupE, the pin shouLd be set up as an i-nput
from
interrupt
an
The pin will be normally high with a low indicating
register.
if
colleccor-OR'd
the MCS6530. An external pull-up device is not required; however,
with other devices, the internal pullup may be omitted with a mask option'
0ata Bus ( D0-07)
data pins (D0-D7). These pins
The MCS6530has eighr bi-directional
connect to the systemt" a"ta lines and allow transfer of data to and from
The output buffers remain in the off state except
the microprocessor attay.
when a Read operation occurs.
P_egghelq!
DataPorts
[iaclt
't'l rtrMCS6530lras I6 yrlns av{rllablc for perlpheraL I/A operatlonc.
or
8n
lnpur
an
pln is lncllvldually e<.rftwareprogrammable to act as ellher
PB0-P87.
'l'he 16 plns are divlded lnto 2 B-bit ports' PAO-PA7and
ourpur.
pB5, PlJ6 and PB7 also have other uses which are dlecussed 1n later aectlone.
The pins are set up as an input by writing a "0" lnto the corresponding blt
A rrlrt inEo Che data dlrection reglster w111
of the data direction regi-ster.
Wtren in the input mode, the
cause its corresponding Uit to be an output.
r.3-5
per ipher al
o u tp u t b u ffe rs
a re i n the " 1" state and a pul l -up
devi ce acts a s
data l i nes.
On a R ead operati on,
les s E han o n e T T L l o a d to th e p eri pheral
pi n.
u n i t re a d s the peri pheral
W hen the peri .pheral
t he m ic r opro c e s s o r
fro m th e MC S 6530 i t recei ves data stored
dev ic e geL s i n fo rm a ti o n
i n the
T h e mj -c ro p ro c e s sor w i l l
dat a r egis te r.
read correct
i nformati on
i f the
per ipher al
lines
a re g re a te r
th an 2.0 vol ts
for a " 1" and l ess than 0.8
pi ns are al l TTL compati bl e.
P i ns P A O
f or a " 0 " a s th e p e ri p h e ra l v olt s
and P B O are a l s o c a p a b l e o f s o urci ng
3 na at 1.5v, thus maki ng then capable
of Dar lingt o n
d ri v e .
L ines(A 0- A 9)
Ad d r e ss
In addi ti on
to these 10, there i s the
T her e a re 1 0 a d d re s s p i n s .
The above pins,
A0-A9 and ROM SELECT, are always used as
ROM SELECT pin.
pins.
pi ns w hi ch are mask prograrnmabl e
T h e re a re 2 a ddi ci onal
addr es s ing
individually
or together as C H IP S E LE C TS . They are
and c an be u s e d e i th e r
pins P B 5 a n d P B6 . Wh e n u s e d a s peri pheraL
data pi ns they cannor be used a s
c hip s elec ts .
INTERNAIOBGANIZATION
r.3-6
rr0 rt w ri t.te n
pin.
i n to the D D R i nhi bi ts
A
the output buffer
from trans r nit t ing
d a ta to o r fro m th e I/0 R egi ster.
For exampl e, a " 1" l oaded int o
dat a d i re c ti o n
pi n P A 3 as a n
re g i -s te r A , posi ti on
3, sets up peri pheral
out put .
If a " 0 " h a d b e e n l oaded, P A 3 w oul d be confi gured
as an i nput
and r e ma i n i n th e h i g h s ta te.
The tw o data I/O regi sters
are used ro
lat c h d a ta fro m th e D a ta Bus duri ng a W ri te operati on
unE i l the peri pher al
dev ic e c a n re a d th e d a ta s uppl i ed
by the mi croprocessor
array.
D u ri n g a re a d o p e ra ti o n
i s noE readi ng the I/O
the mi croprocessor
Regis t e rs
For the
b u t i n fa c t i s re adi ng the peri pheral
data pi ns.
per iphe ra l
d a ta p i n s w h i c h are programmed as outputs
the rni croprocessor
The onl y way
will
re a d th e c o rre s p o n d i n g
data bi ts
of the I10 R egi ster.
W ri te oper at ion.
t he I / 0 R e g i s te r
d a ta c a n b e changed i s by a mi croprocessor
pins.
T he I / O R e g i s te r
i s n o t a ffe cted
by a R ead of the data on the peri pheral
!nleryglljrnet
Th e T i rn r:r r;c c L .i o n o f th e )fC S 65 30 contai nn f h ree bas i c parts :
pr elim in a ry
and
programmabl e B -bi t
divide
d o w n re g ister,
regi ster
int er r up t
T h e s e a re i l l ustrated
1ogic.
i n Fi gure 4.
T h e i n te rv a l
ti m e r c a n be prograul rned to count up to 255 ti me i nterval s
w here T
E ac h t i m e i n l e rv a l
1T, B T, 64T or LO24T i ncrements,
c a n b e e ither
i' s t he s y s te m c l o c k p e ri o d .
h' hen a fu11 count i s reached, an i nterrupt
f lag is s e t to a l o g i c
fl ag i s set the i ntern al
A fter
the i nterrupt
" 1 ."
c loc k b e g i n s c o u n ti n g
d o v m to a maxi -mumof -255T.
Thus, after: ti te
int er r up t
fl a g i s s e t, a R ead of the ti mer w i l l
te1l how l ong si nce th e
f lag w a s s e t u p to a ma x i mu m of 255T.
T h e 8 b i t s y s te m D a ta Bus i s used to transfer
data to and from the
r- he
I nt er v al
T i me r.
I-f. a c o u n t at 52 ti me i nterval s
w ere to be counted,
i nto Ehe
pat t er n
0 0 1 I C I 0 0 v i o u l d be put on the D ata B us and w ri tten
I nt er v al
T i me re g i s te r.
Ti mer, Lhe
to the Interval
A t E h e s a me ti m e th a t data i s bei ng w ri tten
c ount ing
i n te rv a l s
o f 1 , B, 64, 1-024T are decoded from address l i ne:; A0 an<. i
the i nter r upt
A 1.
D u ri n g a R e a d o r Wri te operaE i on address l i ne A 3 conLrol s
IRQ on
c apabili ty
o f P B7 , i .e .,
A" = 1 enabl es IR Q on P B 7, A " = 0 dl sabl es
ti m er
i nterval
P B 7.
W h e n P B7 i s to b e u s d d as an i nterrupt
fl ag w i td-E he
it s hou l d b e p ro g ra mme d a s a n i nput.
If P B 7 i s enabl ed by 43 and an
to the
int er r up t
g o 1ow . W hen the ti mer i s read pri or
o c c u rs P B7 w i l l
remai ni ng w i l .l be
int er r up t
fl a g b e i n g s e t, th e number of ti ure i nterval s
/+
9
,
r ead, i .e .,
e tc .
5 1 , -5 0 ,
W h e n th e ti m e r h a s r:o u nted dow n to 0 0 0 0 0 0 0 0 on the next count
t im e an i n te rru p t
will
< -rc r.c urand the < :ounter w i l L read I I I I I I I I
by " 1" ral c ( ) f
A f t er i n E e rru p t,
th e i t.i m e r r egi str:r
decrements at a di vi de
t he s y ste m c l o c k .
fJ : a fc e r i nterrupt,
the Li mer i s read and a val ue tlf
l he val ue re ad
1 I 1 0 0 I 0 0 i s re a d , ttre ti me si nce i nterrupt
i s 28T.
is in tw o ts c o m p l e me n c .
Valueread=11100100
Complement=00011011
ADD 1.
= 0 0 0 I I r 0 0 = 28.
a t th e to ta l
el apsed ti me, merel y do a tw ors compl ement add
T hus , Lo a rri v e
ti m e w ri tte n
i nto the ti mer.
A gai n, assume ti me w ri tten
as
t o t he o ri g i n a l
W i th a di vi de by 8, total
ti me to i nterrupt
is
0 0 1 I 0 1 0 0 (= 5 2 ;.
( 52 x 8) + 1 = 4 L 7 T .
T o ta l el apsed ti me w oul d be 416T + 28T = 444T, ass um i n te r rupt
w as I l i l
0 0 1 0 0.
ing t he v a l u e re a d a fte r
th e i n te rru p t,
w h enever the ti -ngr i s w rl tten
After
or read the i nterr upt
However, the reading of the timer at the same tirne the interrupt
is reset.
n o t re s e t th e i n te rrupt
fl ag.
W hen the i nterrupt
fl ag i s read on
oc c ur s w i l l
(D BO thru D B 6) go to tr0r' .
DB 7 aLL o th e r D B o u tp u ts
F ig u re
R/W
5 i l l u s tra te s
a n exarpl e
of
i nt' errupE .
D 7 D6 D5 D4 D 3D 2U
A3
DO
R/W
AO
D IV ID E
PR O GR A MMA E LE
R EGIS TE R
IRQ
AI
D OW N
D6 D5 D4 D3 D2 DI DO
4
B A S IC
0S
F I NT E RV ATt I ME R- F is u re
E LE ME N T
Jt'n-l'- L/-"t--J.'1
02 tN
WRITET
rRo
5
Figure
1. Data written
inEo interval
timer
ls 0 0 1 1
5. Data in Interval
0 I 0 0 = 5219
25to
oro
= 84to
an i nterrupt,
W hen re a d i n g th e ti me r a ft er
43 shoul d be l ow so as to
T h i s i s done so as to avol d fuE ure Lnterrtrpts
t h e IR Q p i n .
unti l
dis able
al' t er ano th e r Wri te Ei m r:r tl D e r i rtl -on.
r.3-8
ADI}RESSING
A d d re s s i n g
many vari ati ons
o f th e MC S6 530 offers
to the user for
gr eat er
fl e x i b i l i ty .
T h e user may confi gure
hi s system w i th R A M i n l ower
m em or y , R OM i n h i g h e r m e m o r y, and I/O regi sters
w i th i nterval
ti mers b et ween
(A 0-A 9).
E he ex Ere me s .
In addi ti on,
T h e re a re 1 0 address l i nes
there is
t he po s s i b i l i ty
o f 3 a d d i ti o n al
address l i nes
to be used as chi p-sel ects
and t o d i s ti n g u i s h
Tw o of t he
b e tw e e n R OM, R A M, I/O and i nterval
ti mer.
addit ion a l
I and 2 (C S 1 and C S 2).
The chi p-sel ect
lines
a re c h i p -s e l ects
pins ca n a l s o b e PB 5 a n d PB 6.
W hether E he pi ns are used as chi p-sel ects
or
per iphe ra l
w hen orderi n g
f/O p i n s i s a m a sk opti on and must be speci fi ed
t he pa rt.
B o th p i n s a c t i n dependentl y
of each other i n that ei ther
or bot h
pi- ns m a y b e d e s i g n a te d
a s a chi p-sel ect.
The thi rd
addi ti onal
address line
is RS O . T h e MC S6 5 0 2 a n d MC S 6530 i n a 2-chl p systern w oul d use R S O to d ist inguis h
b e tw e e n R O M a n d n o n* R OM seC ti urrn of uhe I' {U S 6530. W i th E he
addr es s i n g
pins available,
a total
of.7K conti guous
R OM may be addresse d
wit h no e x te rn a l
decode.
B el ow i s an exampl e of a l -chi p
and a 7-chi p
M CS 653 0 A d d re s s i n g
Sc -h e i n e .
0ne- C h i pAd d re s s i n g
F ig u re
6 i l l u s L ra te s
a l -chi p
system
decode for
the MC S 6530.
s're!-c$p-.1Al!!1esr!s
I n th e 7 -c h i p s y s te m th e obj ecti .ve w oul d be to have 7K of conti guous
ROM, with RAI'I in low order memory.
The 7K of ROM could be placed between
addr es s e s 6 5 1 5 3 5 a n d IA2 4 .
For E hi s case, assume A 13, A 14 and A 15 are all
1 when addressing
ROM, and 0 when addressing
RAM or I/0.
This would place
t he 7K R O M b e tw e e n Ad d re s s e s 65,535 and 58,367.
The 2 pi ns desi gnated
as c hip-s e l e c t
pi ns.
o t I/O w o u l d be rnasked programmed as chi p-sel ect
P in RSO w o u l d b e c o n n e c te d to address l i ne A 10.
P i ns C S l and C S 2 w oul d
be c onn e c te d to a d d re s s l i n e s A l 1 and A 12 respecti vel y.
S ee Fi gure 7.
The two examples shown would allow addressing of the ROMand MI"I;
however, once the I/O or timer has been addressed, further decoding is
necessary to select which of the I/O registers are desired, as well as
the coding of the interval
timer.
l/0 Register
- TimerAddressing
Figure B illustrates
the address decoding for the lnternal
elements and timer programming. Addrese llnes A2 dlatlngulshes L/O
registers from the tinter.
l,JhenA2 is high and I/O tlmer select is hlgh, the
l/o registers are addressed. Once the I/O reglsters are addressed, address
lines A1 and A0 decode the desired register.
W he n th e ti me r i s s e l e c te d
A 1 and A 0 decode the
T his de c o d i n g i s d e fi n e d
i n Fi gure 8.
In addi ti on,
us ed t o e n a b l e th e i n te rru p t
fl ag E o P B 7.
di vi de
by macri x.
A ddress 43 i s
IN T. T IME R S E L.
A3
IN TE R V A L
AI
TIME R
A9
I/O T IM ER SEL .
r/o sEL.
Al
uo
A9
R A M S E L.
rI
A5
I
I
I
I
I
I
I
I
I
I
I
44
A '3
A2
AI
A9
R OM SE L.
A9
A8
A7
A6
A6
A5
A4
A3
A2
AI
A9
A.
X indicatesmaskprogramming
i.e. ROM select= eSloRSO
RAM select = gSloRSObA9.A7.A6
MCS6530
0neChipAddresEncoding
Diagram
Figure
6
r.3_10
RAM
T h e a d d re s s i n g
would
of
th e R OM sel ect,
R A M sel ect
and I/O
Ti mer
sel ect
lines
b e a s fo l l o w s :
MCS6530/11,
v1cs6530ll2,
M C S6 s30
/i3,
M CS6s30/t4,
MCS6530/15,
MCS6530/16,
MCS6530//7,
* RAMselect
cs2
csl
Rso
A72
A11
A10
A9
A8
A7
A6
ROM SELECT
0 0 lx
XX
]1'
RAM SELECT
0000
00
I/O
0001
00
ROM SELECT
010x
XX
RA,MSELECT
0000
00
I/O
0001
00
ROM SELECT
0 1 lx
XX
RAI'{ SELECT
0000
01
I/O
0001
01
ROM SELECT
100x
XX
RAI.{ SELECT
0000
01
I/O
0001
01
ROM SELECT
1 0 lx
XX
RAI.{ SELECT
0000
10
I/O
0001
10
ROM SELECT
110x
XX
RAM SELECT
0000
10
I/O
0001
10
ROM SELECT
111X
XX
RAM SELECT
0000
T1
I/O
0001
11
T IM ER
TII'fiR
T Im R
T IM ER
T IME R
T IM ER
T IME R
MCS6530
Seven
GhipAddressing
Scheme
Figure
7
I.3"1I
AD D R E S S IN G OE C OD E
R O M SE L EC T R A M S E LE C T
RE A D RO M
W RI T E RA M
RE A D RA M
W RI T E O DRA
RE A D DDRA
W RI T E DDRB
RE A D DDRB
W RI T E P E R.R EG.A
RE A O P E R. RE G .A
W RI T E P E R.R EG.B
RE A D P E R.RE G .B
o
o
o
o
o
o
o
o
o
o
I
I
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
I/O TIME R S E LE C T
o
o
o
A3
AI
A2
AO
xxx
XXX
XXX
xoo
xoo
xol
xot
xoo
xoo
xol
xol
o
o
o
o
) ( to
o
I
o
I
o
I
o
I
X
I
I
I
W RI T E T I M E R
+lr
+87
+ 647
+ to24T
READ TIMER
READINTERRUPT
FLAG
*
A s = | E n o b l e s IR Q to P B7
A 3 = O Di s o b l e sIR Q to PB 7
o
o
o
o
t (lo
* rl
xrr
x
x
tffi";J
ltrcLrt sss
.6OOmox.
(15.24mm)
I
td-
-T-
Vss
40
PAO
39
PA2
o2
38
PA3
RSO
37
PA4
A9
36
PA5
35
PA6
A8
,l 55 mox.
(3 93mm)
.l 90 mox.
(4.82mm)
.3lOmor.
(7.87mm)
( r .6 5 ).o 6 5
i l .o r ) .o4 0
.l OOml n.
(2.54mm)
( . 551 , O 22
( . 45) . O r 8
lOomor.
2 .O 2 O m o x .
(5 1 .3 0 m m )
.Ol Omi n.
(.25mm)
A7
M
c34
A6
633
PA7
s
6
l/w
5
o
A5
A4
DBO
32
3l
30
o8'2
D83
f328
AI
t4
AO
f326
DB7
FEs
f625
PBO
IRQ/PS7
cst/ PB6
cs2l PB5
Vcc
t2
t7
29
DB4
DB5
27
DB6
24
PBI
19
?2
PB3
20
2l
PB4
P8?
f823
P IN D E S IGN A TION
t.3-12
D8l
A3
A2
P in N o .I i r i n l o w c r l c fl c o rn cr w tcn
s y m b o l l z o ti o n i s i n n o rmo l o rl c n foti on
PA C K AGE O U T L IN E
PAI
PROOUCT
fl
ro l
m
w
T C cl .tH o loov.
AililOUNCEMENT
BULLETIN
txc.
SEPTEMEER
, 1976
b i- d ir e ccio n a l
* Ed g e Se n se In te r r u p t
* I2 8 x I sEa tic
* T wo 8 b it
D aca B us for
di rect
w i th
coruruni caE i on
the mi croprocessor
P rogrammabl e)
Ra m
daca porrs
b i- d ir e ctio n al
* T wo p r o g r a m m a b le
I/0
P eri pheral
for
i ncerface
D ata D i recti or
to perl P heral s
R egi srers
* Pr o g r a m m a b le ln te r va l' Ii m(.r
* Pr o g r a m m a b L e ln te r va l
Ti mer
peri pheral
t Pe r ip h e r a l
p in s
with
D i rect
* HiSh lm p e d a n ce T h r e e - S taLe
l nl errupt
l i nes
Transi sror
D ri ve
C apabi l l E y
D ata P i ns
Vss
MCS6532INTERFACEDIAGRAM
I
IRAM
TO
PROCESSOR
I
I
TO
PIRI PTIERAL
DEVICES
4U
2
3
4
5
6
7
8
9
10
1i
t2
39
.3 8
37
36
55
A5
A4
A3
A2
AI
AO
PAO
PAI
PA2
PA3
PA4
PA5
PA6
PA7
P87
PB(r
PB5
PI}4
14
l5
l(;
t7
t8
i9
22
vcc
zt)
?l
/\o
62
CSl
LJ Z
F5
R/iv
l (l ; )
s3
32
3t
30
:v
28
27
26
l5
24
DBO
DBl
DB2
I)11.5
UIJ4
Dll5
t)l]6
DltT
na
PBO
Pr]I
Pt]2
PB3
MCS6522VERSATILEINTERFACEADAPTER
fcatures
Coupatible uith
Eight-bit
Tno eight-bit
'
Data Direction
output.
Interrupt
intcrrupt
Interrupt
chip.
Handshake control
Data latching
Two fully-programable
Eight-bit
Shift
'
Forty-pin
plastic
bi-ditcctional
bi-directional
Registers allou
logic
each peripheral
to peripheral
the microprocessor
to deternine
on pcripheral
ports.
ports.
interval
timers.
interface.
t.4-2
devi.ces.
an input
or an
the source of an
of interrupts
data transfer
within
the
operntlons.
Arfdvu0otlsts
ulrndilocou3ru,
r iloNltddu
BU GB OOKrII
by Rony, Larsen, & T it u s
published
by X. & L. Instruments
b o o k $ 1 5. 0 0
A complete inLroduction
prograrlming and
to operation,
interfacing
of an 8 0 8 0 b a s e d mic ro c o mp u t e r"
T e x L is k e y e d t o
the use of the E. & L. IvlD-I microcomputer,
but is a very
useful
reference
for all seeking hardware information
about
8080 based systems .
BUGBOOKV and BUGBOOKVI
by Rony, Larsen, a n d T it u s
published
by E. & L. Instruments
books
book $9.95
J -1
books $7.50
each
MICROCOMPUTER
APPLICATI0NSHANDBOOK
by David J. Guzeman
Iasis Inc.
815 W. Maude Avenue
Sunnyvale, CA 94085
A complete deseription
of hardware and software
Iaslsts single borad microcomputer.
M I C R 0 C 0MP UDTEESRIGI,I
by Donald P, Martin
7976
pp. 400
Martin Research
3336 Comnerci.al Avenue
Northbrook, IL 60062
'
handbook
for
book $25.00
M i C R 0 C 0 MP UATNEDRMIC R 0 P R OCESS0R
by Hilburn and Julick
Copyrlght 1976 by Prentice
pp. 375
book
Ha11, Inc.
'
& MICROCOMPUTERS
MICROPROCESSORS
by Branko Soucek
Wiley-Intersc j.ence
1976
pp. 607
b o o k $ 2 3 . 00
A general lntroducclon
to digltal
systems and mlcroconputers
nlth detalled descripElons of popular 4,8112 and 16 bit rnicroprocessorg lncludlng
rhe 6800, 8080, and LSI-11.
J-2
'MICR0PR0CESSORS:
NI}'J DIRECTI0NSFOR DESIGNERS
Edited by Edward A. Torrero
L97 5
PP. 135
seleeted
artlcles
reprinted
MANUALS
SCELBI S0FTI,IARE
Machine Language Prograrnmiag for
Scelbi Co4uter Consulting Ine.
7322 Rear Bostcn Post Rd.
CT 05460
ltilford,
pP. 170
collected articles
$8.95
Design Magazine.
frou @
book
Inc.
discussion
Includes
Intro.
to assernbly language Programlng.
of biuary and fl"oating point arlthmetlc.
SCELBi S0FTI,IAREMANIjALSB0B0
8080 Monitor Routines
An 8080 Assembler Program
An 8080 Editor Prograur
Scelbi Couputer Consulting
$1e.e5
the 8008
all
three
books
$f1.95 ppd
$f7.95 ppd
$14.95 PPd
for $39.50 ppC
SCELBI'S
book
$9.95
DATAB00K
HANDBooK
APPLICATI0NS
- I4ANUFACTURER
sc/MPMICRoPR0CESS0R
Serniconductor Corp.
pubJ-ished by National
2900 Seulconductor Drive
Santa C1ara, CA. 95051
from loca1 National Sernicooductor TechnicaL
available
Hardwane and softward
applicatlons
of
representative
the SC/l@'
J._3
book
$9.95
F ORMIC R OP R 0 CESS0R5
S O F i l AR D E S i GN
book $12'es
TTL C00KB00K
by Don Lancaster
book
$8.95
r974
pp. 335
published
T V T YP E b J R ITCE0R0 K B 0 0 K
by Don Lancaster
L976
publlshed by Howard W. Saurs& ConrpanyrInc.
*e"#'*vs"
*r*"'""pe'
* ?'4'+{"l''+
k'f,o* '*-*"gr*-'a
r l'1
0 n \}*
v
'j
11
- .(
l/, . L,{J
livl ' t
a:
,i r'*'0"*'
l'riv
I
'
',t
tll
r tfl,
l-.r.r
dr"i|"'
f\*'r"f:"{"L'
f 1.ru
'
.4'
{t-
J-L
B.
PERIODICALS
AMERICAN
LABORATORY
BYTE
publlshed
monthly by.-
Byte Publlcatlons,
fnc.
70 Maln Street
Peterborough, N'H'
03458
COMPUTER
DESIGN
published
free
eonthly
to quallfied
CONTROL
ENGINEERING
publlshed
free
nonthly
to qualifled
Contains useful
lndustrial
by - Control
Englneering
address '
p.."ori"tb"eriptlon
artlcles
control
on appllcatlons
666 Fifth
New York,
Avenue
NY 10019
of nlcrocomputers
to
DIGITAL
DESIGN
publi.shed nonthly by - Benwlll Publlshing Corp.
Clrculatl.on Dlrector
DIGITAL DESIGN
167 Corey Road
Brookllne, l,tA 02146
lfree
card
computer company
Box E
Me n lo P a rk ' c A 9 4 0 2 5
$L2.oo per year
Devoted to publlcatlon
TIIIY BASIC.
J-5
EL EC T R ONDIC
E S IGN
publj.shed biweekly
if
Ifree
qualified,
othensise,
ELECTRONIC
DESIGN
NEI,IS
published
nonthly
by - Cahners Publishing
to qualified
[free
persons;
Company
EL EC T R ONEIC
N GIN E E R IN
G ES
T II4
published
free'to
biweekly
qualifled
by - CMPPublications
suscription
address - Electronic
Englneeri.ng Tirnes
280 community Drive
persons
Great Neck, IIY 11021
products.
ELECTRON
IC5
published
biweekly
by - McGraw-ltill,
suscriprion
Inc.
address - ELECTR0NICS
McGraw-Hi11 BuiLiing
L22L Avenue of the Americas
New York, lfY 10020
persons
IN T E R F AC E
published
Ifree
wlth
Eonthly
by - southern
cal-l.foruia
computer society
INTERFACE
AGE Inewmagazine
by publisherof origina't INTERFACE]
published
nonthly
INSTRUMENTS
& CONTROL
SYSTEMS
published
Ifree
J-6
Dept,
str'|uil01snAlNom}{oc
J0 Auvssolg
x xtoNsddv
GIISSARY OF COMMONI,Y
USEDI,ECNOPROCESSOR
TER,}4S
ABSOLUTEADDRESSI}Xi -
operating
on the
ADDRESS
BUS - A multiple-bit
from the CPUto the rest
transmittir
an ad.dress
the solutj.on
Interchange.
or an eight-
K-1
or not exhibiting
'rsEE R.S,DIX!r.
information
can
BIN.C.Hf - The base two nunber systems. All nunbers are eryressed as
polrers of two. ls a consequeneer only two symbols (0 & 1) are
requ,ired to represent any nunber.
BIT
- .{ seqrrence of eight
unit.
Clr.L
K-2
operates upon as a
:i
, .,'-'1
--/
in uhi-ch
CASC.A'TE
- An arra.ngement of two or more similar circuits
provides the input of ihe next.
the cutput of one circuit
CLOCK - A device ctr a part of a device that generates all the timing
system. System clocks
pulses for the coorciination of a digital
usually generate i:wo or more clock phases. Each phase is a separate square wave pulse train output.
CODI}IG - ?he prccess of pnepari;rg a prograln from the flow ehart
defining an algorithm.
COIIPILER - A language translator wh.ich converts individual- source
A compiler
statements into multipie machine instructions.
translates the entire progialn before it is executed,
CCMPLII{EbIT
- Re'rerse aIL binary bii
becomeones).
of a comparison
Detect, lccate,
DEBOUNCED
- Refers to a switeh or relay that
tact bor:nce.
K-3
tn
a program or hardnare.
longer exhibits
con-
element
1, or from logic
Ln
a sequence of operations
ilP.tl{SION - The process of inseriing
representea bI a macro nane when the macro nagre is refereneed
in a trrrogran.
FALL TIME - The tirne requi.red for an output voltage of a digital
clrcult to change from a loglc I to a logic 0 state'
K*ll
An area of an instruction
A collection
mnenonic.
as a single u-nit.
ruFO (I'IRST IN, F'IRSI 0UT) - ?he terrn applies to the sequence of
enteriag data into and retri.eviag dat,a from data storage"
data entered is the first
The flrst
data obtaiaable wi.th FIFO.
FT,AG - A status bit which indicates that a certaln condition has
arisen during the cource af aritlmetic
or logical marriprrlations
or data transmission between a pair of digi.tal. electronj.c
devices" $ome flags uray be tested and thus be used for determfnlr subsequeat, actlons"
ELlo RffiISTER -
A reglster
consisting
of the flag
flip-flops.
of tbe algorithn
required
to
simultaneous
eleetrlcal.,
or electronic
K-5
bits
in ttre 15-bit
* (f)
(wrmaetnn
elRcuII)
A conrbination of i:rterconaected
circui.t elements inseparably associated on or rj.t&1n a con(a) ^Anyelectronic derrice in which botb
tjrmous substrate.
active and passi.ve elements ae contained in a single package.
In dii.ta: el"e*tronies, tire term ehiefly applies io circuits
c ontaisliag senriconductor eleraents.
IMMEDIJITEADDaESSE'I* instruction,
rather
that stipulates
IMPilm .ADDRESSI]&3- A one-byte instruction
an
operation i:rternal t,o the processor.
DOESNOTrequire ary
addltlonal" operand"
INCRET{E$IT- ?o inerease the value of a binary
to iacrease the vaiue by 1,
word"
Typically,
*-o
an operation
The resister
^+^+^
DU(LUq.
LnaDING mGE
the transi"tion
of a oulse ihat
K-7
oecurs first.
t@
that
ernits light
when
either logi.c
or completes
Tlre digit
and
- (1) The science deal.ing wlth the basic princlples
gatlng, etc.
(2) See
applications of truth tables, orltchingl
Icglcal Deslgn. (3) 41so called symbolic logic.
A nathenatical
approach to the soluti-on of complex situations
by the use of
spnbols to defile basic concepts. The three basic logic syrnbols
l{hen u,sed in Boolean algebrap these synbols
are AND, oR, and [gt.
(L) fn
are somewhat analogous to addition.and nultiplication,
conrputers and fufornation-processing
networks, the systematic
nethod ttrat governs the operati.ons perforned on lnformatlon,
(5)
usually with each step influencing
the one that follows.
The systenatlc plan that, defines the iateractions
of slgnals
in the design of a system fe automatic data processlng.
K-B
bits
ln the 16-blt
..Iategrated circuits
contain
tirat perforro
l"0O to 2r0O0
a specifled
bits
from
I,IEI{0RI - "kry derrice that can store logic 1 and logic C bits ln such
e ma:rner the.t a singj.e bit or group of bits can be accessecl
and retrieved*
M$,{OBI IDDRFSS - A 16-bit bJ"nary number that speclfies
the precise
menory location of a nemory wcrd among the 65,536 different
possible memory locations.
MEMORICEIJ. - A singl* storage element of memory, capable of storing
one bi"t of digieal jnformation.
!r _Q
MICROCOI{PUIER
- A courputer system based oa a nicroprocessor and
contains al1 the memory and interface hardware necessary to
perforrn calculat,ions and specified j-nformation transformations.
MICROPBOCESSOR
- A central
integrated circuit.
as one
MICROP8OGRAM
- A cwrputer progran written i^n the most basic
iastructions
or subcoumands that can be executed by the
cwrprter.
tr?eguently, it is stored in a read-only nenory.
MNEONIC - Syabols representing
to allcm easy identification
designed
machine instructions
of the functions represented.
UODIILO - The nodulo of a counter is simply ne the number of distinct states the counter goes ttrough before repeatLng.
A
fos-611
biaary counter has a rnodulo of 16; a decade counter
has a uodulo of 10; arrd a divide by-? corrnter has a nodrrlo
of 7" In a varia.ble urodulo cor:nter, n can be a-qy value within
a ranae of values
UONIIOR - Sofbcare or hardware that observes, supervises,
. or verifies
sysLem operation.
coatrols,
* rhe dlglt
rith
NgiATfqE-EDOE ?nl(nEnm
- Fansfer of infomation
negative edge of the clock pulse.
occurs on ttre
of srrbroutines
K-10
wlthout
retr:rning
half a byie, is
NIBBLE - A sequsr:.ceef fcu:r acija*ent bits,
ribble"
*, hex*-decimal- m FCF ciieit can be represented ilr
a s:ibbl"e.
NON-OVEEI.AFFSIG
TI{#*FHA$Hel,(]Str *
clock pulses of *I:e indiv-idual
See TTPAGRAM
e0U$?ERtt
PIe
PERIPHER"AI,- A devi*e sr subsystem external
additional sysiem capablliti.es.
Retrieving
ciaf."afron a stack.
PORT
A device or netnork through wh-ich data raay be transferred
sr where device or network variables may be observe<i or measured.
The tnansition
POSI?fVE EDGE
pulse.
fronr logic
0 to logtc
1 in a clock
occurs on tbe
voltage
POSITfYE IOOIC - A feur of logic irt rhich the more positlve
level represents logic 1 and the nor negative 1evel represents
logic 0.
PRIORIIY - A preferentiaL ratlng.
Pertains to operati.ons that
given trrreferenc
otheq system operations.
PROCESSOR-
are
rhtch
a memory address.
.C,read-or'}y..nenortrr,that:.is
PROP.{GATION
DETAI
A measure of t'he tlme required fe a logi.c
slgnal to travel thnough a logic devlce or a seri-es d J.ogic
devices. It occurs as the result of four types of cLrcult
delays - storagep riser fe]], srd turn-gn-delay - and is
the tir:e betseen when the inprrt signal crosses the threshold voltage point aad when the responding voltage at the output
crosses the same voltage point.
PSEIIDO-INSTRUCTION A mnemonic that modifies
t'j.on but does not produce an object code.
the assenbler
opera-
K-T2
Puiii
eiJIX
Fut,t--r:g ia:;
j-nlc a st,ec<,
marks
fire tot,al nwrber of ii.siinct
- Aisc cal-led the base.
since the
o:" e;'rnbcls usec i-n a n';ilberi-'rg sysiern" For exarple,
c.ecirnaL nun'oe:'xlg systen uses ten synbois, *,he raciix j.s lC.
in tne bi-nar-v n';rbe:i-ng systenr the radi.x is 2, because there
a:.e onry iwc na.:'ks cr synboL" (O ana t).
In lhe octal numberllg systen, ihe raiix
is 8, anci in the hexaciecimaJ" nunibering
< r r cto n
eJ J ev r .r ,
+v .^vh e
f a
s r dtd :X
!
iS
+J
16.
:v.
in semiconciuctcrs:
To transmit da+.a frcm a semiconductor
memory to sone othe:' digital
device"
electronic
fhe term,
frreaCfl aisc applies lo computers and other types of memory
I
cievices.
required
to generate
all
ihe refresh
store
data.
are
| (
is used tenporarily
of one
to the syntax
SFLIT D^{IA BiF - Is two data buses, one for lncoming commutdcations aBd one for outgoing corrunulrications. An 8-bit data bus
in split data bus system talces 16 llles.
STACK - A speclfied section of sequential neaory Locations used
as a LIFO (fast T.a, !'irst Out) file.
The last elenent entered
is the fjrst
one agaiLabLe for output,. A stack is used to store
program datae subroutine return arlrt'ess6s, processor statusl etc.
Sti0f
f-Ir
ST.AIEMA{I -
An instruction
ia source language.
A series
fcn
of values.
string
used to represent
a Iabel,
menonic,
The jrstanee
such
to a second
K-l:5
A ca]]
Lustructlon
that
to the speclfic
is uncondltional.
ItNcqilErrro$.qr, fiffP
I connputer instruction
tbat iaterrupts
the
normaL process of obtai-njng the inst,ructlons
in an ordered.
sequence and specifi.es the address frosr whlch the ne:cb
instruction
must be taken.
:r
UNCOIIDITIOilALRE'IIAN nsl
A retrrrn
instructlon
that
ls unconditional.
VOIATIIE I{El"l0RI
A seniconductor memory derrLce ln lrhich t}p
digital
data is lost when the power is remwed.
stored
K-16
WORD - lre naxilmn ntnber of bjoary dlgits that can be stored ira a
sLngle addressable nemory locatlon of a given conputer system.
fAnS
ZERO-P{}E
The lonest 256 address locations ln neuory. Where
the highest 8-bits of address are alrays Ots and the loner
onlY
8-bits identif,y any location flour O to 255. lbereforer
a single byte is needed to address a locatiou in zero-Page.
ZUnO-f.Cg .|DDBEIISING - I.he second byte of the instruction
taLns a zero-page address.
con-
ZEnO-P.CCE
INDEXEDOnnbSSUqi - The second-byte of the Lnstaruction
(X or I) to form a zeto-page
is added to ttre index register
is drcpped.
effective
address. The carry (i-f
"tqf)
K-I7