You are on page 1of 55

6 INO

INTERRUPTPROCESS

Section 6 d€sciibeg 6{steo Ections foi the vatious interrupt


c e u g i n g o v e n t E , d e f i n e s t h c n a n g R A I i Iv € c t o r E a n d p r o v i d e E
r.ecoonendad procedur.es for de€ling uith intet'rupt9.

The 69Oa microcomputer proEes6a6 three g€n€raI inter.iupt tgpeE:


Ehir-reeet, nonn€st€bIe interrupts (Nl'lI, and mEEteble i'1te.rupts
(IRO'. The IRG inteirupt tgp€ can be enebled and disabled using
the 6502 CLI end gEI inrti.u€tiotr5. The Nl'lI tgPe .ennot be
diEabted at the oroces6or leveL but the NltI interruptE other
. ESETI keg can be disabled at the ANTIC chip.
t h a n I S Y S T E HR

The sqstem €v€nts thet cen cauEe interrupts are list€d belot:

ch ip-reset - po { r e r _ u p

Nl'tI - Dirpleg li6t interr'!pt (!nuEed bq OSI


ver.tiee I-b lant ( 5 0 1 6 0 Hrl
[SYSTEI'{. RESETI keg

IRO - 56fi.I buF output reEdg


sar ia I buE output coftptete
S e ai a 1 b u s i n 9 ! t " e a d g
Serial bus pro€eed lina (unused bg Eg6ten)
SeFiil bus inter.upt line (unu6ed bg 5q6teo)
POKEY timer's 1, 2 and 4
Kegboard ketJ
IBREAKI *eg
65Oa 8RK inEttuction (unused bg OS)

Figut'e 6-l List of Sqste -Interrupt Events

OPERATINGSYSTEI'ICO16559 -- SeEtion 6
102
T h e c h i p - r e s e t i n t e r r u p t i . s v e c t o r € d v i s l D c s t i o n F F F C t d E 4 7 7'
u h e l . e e J l v l Pv e c t o r t o t h e p o u e r - u p r . o u t i n € i s 1 o . : t e d . All NHI
intertuptE a.e vectored via locatioh FFFA to the Nl,lI inteitupt
servite routine et E784, a'ld €11 IRQ interrupts are vectoied
via location FFFE to the IRC i.nterruot seivice routine at E6F3,
at that point the casse of the interrupt nuEt be determined bV
€ serieE of teEts. For sone ot the events there ere built in
dronitor actions and for other eventE the ro.responding
inte?rupts 3re di6abled or ignored. The Egstsm provides RAM
vectot6 so that gou can intercept interfupts uhen
nec€59€rg.

The OS genei'ateE chip-reset in responsE to e pouer-up condition.


The s{Eteo i5 coop!etelg initialized (see Section 7).

NONITIASKASLEINTERRUPTS

Whenan NMI intenrupt occuts, control. iE tranEferred thr.ouqh


t h e R O Mv e c t o r d i r e r t l { to the sggternNHI interrupt Eervice
routine. A ceuEe for the interrupt i5 deterlnined bq era$ining
h B r d q , e r e r € g i E t e r N f , l I S T t D 4 O F l . T h e N l 4 I n a k e s E J U r n pt h r o u g h t h e
9 l o b a l R A | 1v e c t o . V D S L S T t O e O O l i f a d i E p l a g ! i E t i n t e r r . u p t i s
pending. The OS doeE not !Fe displaq list interrupts, Eo VDSLST
i5 initi.atized to point to an RTI in6truction, End gou rnost not
€ h a n g e i t b e f o r e V D S L S Tg e n e r a t e s a d i 6 p l a g i n t e r r u p t .

I+ the interrupt is not a displag-li6t interrupt, then e ts6t ig


f t e d e t o 6 e e i + i t i E e I S Y S T E MR . ESETI kerJ interrupt. If so, then a
JUmp i s m a d e t o t h e E V E t e mr . e s e t i n i t i a l i z E t i o n r o u t i n e (see Section
7 f o i d e t a i l s o f s g s t e m r s s e t i n i t i a I i r e t i on ) .

I+ ths interr.upt is neither' e dirpteg list interr.upt nor E


[ s Y S T E M .R E S E T ] k e g i n t e r r u p t ; th€n it is asEUmedto be e
verti{e1-blank ( V B L A N K }i . n t e r r u p t , a n d t h e + o l l o u i n g a c t i o n g
o c c tl :

RegiEterE A,X end Y are puEhed to the stecft.

The interrupt request i.s cleared ( N l ' I I R E St D 4 O F l ) .

A Jlop iE tnadethrough the "immediate" v€itic€1-blan* global


R A I ' Iv e c t o r V V B L K I f 0 2 2 2 1 t h a t n o r m a l l U p o i n t E . t o the Stag€ 1
V E L A N Kp . o r e r s o r .

The +ollouing action6 occur:rEgu.|ling that gou have not chEnged VVBLKI.

OPERATINGSYSTE|1CO16559 -* Se€tion 6
103
T h e E t a g e 1 V B L A N Kp r o c e s E o r i i exacuted.

The OS teits to 5ee i+ a rFitiE8l code g€Etion has been


inteiruptad, If Eo, then alI regieteis €r6 restored? end en
RTI ingtr.uetion ieturn6 from the interruot to the aritical
sectiofl. A c!.itical sertion ii determined bV examining ihe
CRITIC +1ag [OO42], €nd th€ procesEol. I bit. If either are
$et, then the interrupted Fection ii asEUoedto be aritical.

I + t h e i n t e r r u p t u r a En o t f r o n a c r i t i c a l 6ection, then the


6 t a g e 2 V B L A N Kp r o c e E s o r i s e r e c u t e d .

The OS then Jumpi thtouqh the r'detcried" vertical-blanl


global RAH vactor VBLKD t0224l, that nor'onllq points to the
V B L A N Ke r i t r o u t i n € .

The +ollouing aations ocrui a6g!oing th€t gou have not ch€nged VVBLKD.

o The 650A A,X €nd Y r.egist€iE ara r'estor.ed.

o An RTI instiuction is ereauted.

NOTE: You c.n alter the defer!'ed and ifioediate


V B L A N KR A M v a a t o r E , b u t s t i l l eneble nornal Erjiiteo proae6ies, or
restore original vectors !rithout having to save thern. The
instruEtion et E45F is a Ji'lP to the stage 1 V8LANKpro€esEori the
addresE at EE46O,21 is the velue norlrlellg +ound in VVBLKI. The
inEtruttion a t E 4 6 2 i s e J l ' l P t o t h e V S L A N Ke x i t ? o u t i n e ; the
address at tE463,21 iE the value t|or.mdllg found in WBLKD. TheBE
R B M v € c t o r s t o s t a g e l V B L A N Kp r o r e i s o r e n d t o t h e V B L A N Ks x i t
ioutine uill accompli5h gour go{tl.

NOTE: Everq VBLANKinterrupt Jui[pE through vector vvELKL OnIq


V 8 L A N Ki n t e r r u p t s f r o o n o n c r i . t i c a l c o d e s e c t i o n s J u n p t h r o u g h
vector VVBLKD.

Stag€ 1 VBLANK Proc eEs

The +olIot ing stag€ 1VBLANK proce6Eing iE perforned at everg


VBLANKin teF.up t:

T h a s t a g E l V B L A N Kp r o c e e s i n c r e m e n t s t h a 3 - b g t e f r a | | l e
countei RTCLBK !OO12-OO14J, RTCLOK+O is the l4SB and RTCLOK+2
i 5 t h e L S B . T h i E c o u n t e i u r a p E t o z e r o & r h e ni t o v e r + l o u 5
( e v e r q 7 7 h o u r " Eo r . s o ) , a n d c o n t i n u e 6 c o u n t i n q .

The Attr'€Et mode v€riebleE are pr.t6es6ed (Eee Appendix L,


410- le ' .

T h a s t a g € l V B L A N Kp r o r e g s d e c r e r n s n t s t h e S g s t e n T i f t e r 1
CDTtM tO218,21 if it i6 nonzero; if the ti|ne. ooes fiom

I O16555 --
O P E R A T I N GS Y S T E I ' C Se€tion 6
104
n o n z e i o t o z e r o t h e n a n ind ireE t JSR iE perforned via CDTl.tAl

S t a g e 2 V B L A N KP r o c e E s

T h e s t a g e 2 V E L A N Kp r o r € E s i n g p e r f o ? m s t h e f o l l o u i n g f o ? t h o s e
V B L A N Ki n t e r l ' u p t s t h a t d o n o t i n t e r r u p t c r i t i c a l sectionE:

T h e s t € g e 2 V B L A N Kp r . o c e s s € I e E r s the 6502 processor I bit.


ThiE enables the IRG inter.urte.

T h e s t e g e 2 V B L A N Kp ? o c e s 6 u p d a t e s v a r i o u 6 h e f d u a f e
r e g i s t e r E u i t h d e t € + r o n t h e O S d e t a b E g e , a s s h o u j nb e l o u :

D a t e B EE e Hat durare R e es o n f o r U pd a t e
I ten Register

5DL5TH to231 l DL ISTH t D4031 D i s pl a g I i E t 6t:rt


SDLSTL t0230l DL ISTL t D4021
SDtlCTL EO22F 1 Df'IACTL tD400J
CHSAS EOZF41 CHBASE tD409l
CHACT to2F3l CHACTL cD401l
OPRIOR PR I T]R cD o1 s :
coLoRot o2c4l COLPFO t D o 1 6 1 A t t i a c t m o de .
coLoR1 t ozc5l COLPFl c D o 1 7 l
CALBRE t o z c 6 l COLPFA t D o 1 8 l
coLoRS toecTl COLPF3 t D o1 9 l
coLoR4 t02cBl COLEK t D o l A l
PCOLRO t ozcol c oLPr'10EDOl2l
PCOLRl t o 2 c1 l c oLPt'rI ( D O1 3 l
PCALR2 t o z c 2 l Ct]LPM2 t D o 1 4 l
PCOLR3 to2c3l coLPi,{3 t o o 1 5 l

Constant = B C o N S A Lt D O t F l C o n s o1 e s o e a k e r o f + .

T h e s t € g e 2 V B L A N Kp r o c e 6 s d e E r e m e n t 5 t h e S g E t e m T i m e r 2
C D T H V zt 0 2 1 A , 2 l i f i t i s n o n z e i o r i f t h e t i m e i g o e s f r o m
nonzero to zero, then an indiref,t JSR i5 oerfor|ned
throug h CnTHA2 tO22E'27.

T h e s t a g e 2 V B L A M Kp r o c e E g d e c r e o e n t s g u g t e m T i o e r s 3 , 4 a n d
5 i+ theg are non!ero; the corresponding +lag5 ai. ret to
zero for each timer th€t chanoeE fron nonzero to ,e?o.

B P E R A T I N GS Y S T E | IC O 1 6 5 5 5 - - Section 6
105
T i r n e r T i m e r V E1 u e Tifter F 1a9

3 C D T H V 3t O 2 1 C , 2 l C D T M F 3C O 2 2 Ar,l
4 CDTHV480 21E,21 CDTMF4tO22C, I l
5 CDT}4VSt02eo,2l CDTMFStoeeE, 1l

A c h a r a c t e r . i s r e a d f r o n t h e P O K E Yl e { b o r r d F e g i 6 t e r and
Etor'ed in CH IOAFCl, if €uto reDE:t iE sctive.

T h e 6 t E g e 2 V B L A N Kp r o r e E E d e c r e f i e n t s t h e & e g b o d r d d e b o u n c e
counte? if it i€ not equal to zero, end if no te{ iE

T h e E t e g e 2 V B L A N Kp r o c e s s p i o c e s r e s t h e & e V b o a r d a u t o
r e p e a t ( s e e A p p e n d i xL , E B ) .

T h e s t e g e 2 V A L A N Kp | . o E e g s r e : r d 6 g € l n e c o n t r o t l e r data fionr
the ha.d0rdre to the FAM date b€se, as shourn belo!r:

HatduEre D€ta BaEe F u n ct i o n


R € gi 6 t e r I tem

PORTA tD3OOI S T I C K Ot o z 7 A l JoUEtirtE and


STICK1 to279l
PTRIeOIO27C] Paddle Controller.s
PTRICl IO27D]
PTRIC2 IO27E]
PTRIO3 [O27F1
PORTB tD30t I STICKz tO27Al
STICK3 CO27B l
PTRIC4 IO2BO]
P T R I G ST O 2 A 1 1
P T R 1 0 6T O 2 B 2 ]
PTRIOT [0243]
POTO tDzOOl P A D D L O[ O 2 7 O ] P a d d l e C o n t r . o I l € r . E
POT 1 tD201: P A D D L 1r 0 2 7 1 l
POT 2 tD202l P A0DLa CQ2727
POT 3 tD203l PADDL3 t0273l
PoT 4 tD204t PADDL4 to274l
POT 5 TD2OsI PADDLSIO279]
POT 6 tD206t PADDL6 to276l
POT 7 TD2O7] PADDLT 84277 7
TRfGO CDOOIl S T R I e OI O p a 4 l JogEtick triggerE.
TRIOl rDOOat STRIGl t0295l
TRIO2 tDOO3l STRIGz to2a61
TRIG3 tDOO4l STRTC3 toe87l

OPERATINGSYSTEH CO1655S -- Section 6


106
MASKABLEINTERRUPTS

A n I R C i n t e r ' r . u p t . a u E e E c o n t r o l to be tr€n6ferred th!'ough the


i m n e d i a t e I R O g l o b a I R A I ' Iv e c t o i V I H I R O t c 2 1 6 l . O r d i n e i i l q t h i s
v e c t o r p o i n t E t o t h e s t l e t e f t I R { l H a n dI e r . T h e H a n d l e r p e r + o r m s
th e6e fo I I ouing actions:

The IRG Handler determines a aause for the intertugt b{


eramining the IROSI €DzOEl register and the PIA statuE
r€giEteri PACTL ID3O2] and PBCTL tO3O3l. The interrupt stetus bit
is clear€d uhen it is found. One interruDt event i5 cleared and
proaers€d for each interrupt-6ervice entrg. If fiuItipl€ IRCE ere
pending, then a gepa.ate inter'.upt uill be generated for 6ach
pending IRO, until aII at'e 6e!'viced.

The sgEteo IRO interrupt service routine de:ls uith each of the
po6sible IRC cauEinq event5, in the follouing uagB:

The 6502 A register i6 pushed to the etac&.

lf the intel.r.upt is d!e to sst'ia1 I / O b u s o u t p u t r e a d ! ,


then clear the inteirupt end JUdlpthrough global RAI'I
veE tor VSEROR IO2OCL

I+ the interrupt iE due to Eerial I/B buE input readq,


t h e n c l e a r t h e i n t e r r u p t e n d J U m pt h r o u g h g l o b € 1 R A H
v e { t o r V S E R T Nt o z o A l .

I+ the interr.upt is du6 to EeriaI I/0 bus orrtput


EoflpIete, then Elear' the interrlpt t s n d J U r n pt h r o u g h
o l o b a l R A l , tv e c t o r V S E R O Cl O 2 O E l .

If the interiupt i s d u e t o P O K E Yt i { t l e r { t 1 , t h e n c l e e r t h e
interrupt E n d J U r n pt h r o u g h 9 1 o b a l R A I ' Iv e c t o t V T I I ' l R 1 t 0 2 1 O l .

I f t h e i n t e r r u D t i s d u e t o P O K E Yt i n e r * a , t h e n c l e a r t h e
interiupt and Jldrp through global RAMveEtol' VTIMRa t0212l.

I f t h e i n t e r r u p t i E d u e t o P O K E Yt i m e r * 4 , t h e n c l e 5 r t h e
interrupt. The service routine conteins a bug, aod +€lIs
inio the +ollouring test.

If presEing a keqb06rd keg caused the inteirupt (other


than tBREAKI, ISTARTI, IAPTIUNl, or ISELECTI)t then cle€r the
interrupt a n d J U m p t h r o u g h g l o b a l R A M v e E t o r V K E Y B Dt O 2 O E l .

I+ pre6Eing the IBREAK] ke! caused the interrupt, then


clegi the inteirupt. S e t t h e B R E A K+ l a g B R K K E Yf O O l 1 l t o
rero, proceed to clear the follouing:

Star t/stop flag SSFLAo CO2FFI


C u r s o r i n h i b i t f l a g C R S I N Ht O 2 F O l
Attra.t m o d e f l e g A T R A C Tt O O 4 D l

O P E R A T I N eS Y S T E MC O 1 6 5 5 5 - - Section 6
107
Return +roo the interrupt aftel' r.estoiing the 690A A
re9 ister +roin the Etack.

o I+ the interropt iE due to the sel.ial I/0 bus proceed linei


then clear the interrupt, €Dd J!,np through globaI RAHvector
VPRCED tO202L

o If the interrupt is du€ to the ssiiel I/O bus interrupt


l i n e , t h e n c l e a r t h € i n t e r r u p t a n d J U m pt h r o u g h g l o b e l R A M
vector VINTER CO2O4l.

o If the inter.upt iE due to a 6502 ARK instFu.tion, then Jlnp


t h r o u g h g l o b a l R A M v e c t o r V B R E A Kt O 2 O 6 l .

o If none of the ebove, iegtore the 6503 A "eqigter. and aeturn


f r{ro the inteir!pt (RTI}.

I N T E R R U P TI N I T I A L I Z A T I O N

T h e i t l t e r r . u p t s u b s g s t e d rc o o p l e t e l q r . e i n i t i e l i z e s itsel+ uhenever
t h e e q s t e m i 6 p o u e r e d u p o r t h e I g Y S T E MF . ESETI kerJ iE pres6ed.
The BS cleer6 the harduare negiEters, and sets the interr.upt
g l o b a l R A t ' lv e c t o r s t o t h e + o l l o u i n g c 6 n f i g u r a t l o n s :

Vector Tlpe Function

VDSLSTfO2OOl NMI RTI -- ignore interiupt.


VVBLKI toze2l .r Sgsteo stage 1 VgLANh.
CDTHAI f0226l " 5IO timedut tiftlFr..
C D T M A 2f o ? z A l ,, No 6usten +unction.
VVbLKD tG?241 " S ' fs t e m r e t u r n f r o m r n t e r r u p t .

VIMIRO to216l IRC SrrBted IRG processor.


vsERoRtozocl ,, s Io.
VSERIN TO2OA] " 5IO.
vsERactozoEl ,, s Io.
V T I M R 1l o 2 l o l " PLA,RTI -- ignore interFupt.
V T l t 4 R 2t o 2 1 2 l n PLA,RTI -- igno?e inter.!.upt.
VTlt'lR4 to214l { +.F.FdoeEnrt mEtter ***
V I { E V B Dt O z O A l ,, Sgsten keqboerd
i n t e r r u p t h e n d1 € r .
V P R C E Dt O 2 O 2 l ,, PLA,RTI -- ignore int€rrupt.
V I N T E Rf O 2 O 4 1 " PLA,RTI -- ignoie interr.upt.
V B R E A Kt O 2 O 6 l 8RK PLA,RTI -- ignore interropt.

Figure 6-e I n t e r f o p t R A t ,V
l ector Initi€liration

OPERATINOSYSTEI'ICO1655$ -- Section 6
104
Sg6tem initiel ization sets the interrupt ensble Etatus
as fo I Io{rE:

NMI V B L A N Ke n € b l e d , d i 6 p l a U l i i t di6ab1€d.
IRO IBREAKIteg and data teg ioterrupte enabled, a1l others
di6abled.

9YSTEH T IIIERS

Th€ OS contains +ive gen€r'aI purpose softua"e timers, plus an


OS-supported +reme .ounter. The tifters are a bgtes in length
( 1 o , h i ) a n d t h e + r . a { r | et o u n t e r R T C L O Kt O O 1 2 l i 6 t h r e e
bqteE in
length (hi.,nid,lo). Th€ tifter6 count dounuerd from enV
nonzero velue to zero. Up6n ieechiflg zero, theg either clear.
an eE6ocieted f1eg, or JSR through e RAll vectoi. The freme
counter €ount5 up{rerd, {,rapping to aero uhen it overflous.

The follolring t€b1e Ehorrs the tiflers and the f!.a|ne counter.
c h e r € ct e r i s t i eE :

Tinei. Nalne FIag/Veator Use

cDTf,lV1 tOz 1Bl C D T M A 1t o a 2 6 l 2 - b g t e v e c t o r - - S I 0 t i n e o u t .


C D T H V 2t O ? t A I C D T M A at o e ? 8 : 2 - b q t e
CDIHV3 f O?1Cl CDTI.1F3[O22A] 1-bste f l a g
cDTr.tv4t oelEl CDTI'iF4 tOe2Cl 1-bgte f 1 e g
CDTHVSt0e20l C D T H F St O ? z E l 1 - b q t € f l € g
RTCLOKtOO1"1 3 - b gt e f f € m e c o u n t e , ,

These tuo tiners aie maintained ac part o+ ever! VBLANK


inte.rupt (Et€ge 1 process'. The other timers ere subJect to
the cr.itic€1 section test (sta9e-2 proceis), th€t can defer
t h e i r u p d € t i n g t o a l a t e r V B L A N Ki n t e r i u e t .

USACE NOTES

This subsection d€6cribes the techniqtres gou need to *nou in


order to utilire interrupts in ronJunction trith the operating
5!6ten.

O P E R A T I N GS Y S I E H C O 1 6 5 5 9 - - Section 6
109
P O K E Y I n t e r r u p t M a sk

ANTIC (diEp16'r-li6t and vertiEal-blenl) and PIA (interr.upt a.d


proceed lines) interr'upts cEn be fnesled dir€ctIV (see the
Haid{rare Hanual }. Ho{rrevei, eight biti of a 6ingle bqte IRGEN
tDzOEl oast the PO(EY interruptG (IBREAKI keg, dat€ keg,
9€ti31 input re€dq, seri€I output reedg, serial output done
and tinerg 1,2 €nd 4).

IROEN is a url^ite-onlV register'. ThuE, llre nu6t naintain a


current v€lue of that regiEter in RAMin order to update
individuel m€st bitg selectivelg, urhlle not changing other bitE.
Ths name of the vaiiable u s e d i e P O K M S K! O O 1 O 1 , a n d i t i s u e e d
es shouin in the era|nples belour:

; EXAMPLEOF INTERRUPTENAELE

SEI t T O A V O I D C O N F L I C T[ , I T H I R A . . .
LDA PIIKMSK , ... PROCESSORWHICH ALTERS vAR.
ORA *trx ; E N A B L EB f T ( s ) .
STA POKI.{SK
STA IROEN , TO HARDWARE REG TOA.

, EXAHPLE T]F INTERRUPTDISAELE

SEL T O A V O I D C U N F L I C Tt r I T H I R G . . .
LDA POKHSK ; . . . PROCESSORWHICH ALTERS VAR.
AND { + $ F F - rx ; D I S A B L E B I T ( S ) .
STA PT]KI'ISK
STA IROEN , TO HARDWARE REOISTER TOU.

Figuie 6-3 POKEYInterrupt MaEk Exanple

N o t e t h a t t h e O S I R O s e ? v i r e r o u t i n e u s e e a n d a l t e r s P O I ( | ' I S K s, o
Elt€iations to the variable ou6t be done u,ith interruptg
inhibited. If done et the interropt level there is no problem, as
the I bit iE elreadg set; if done at a baclground level then the
SEI end CLI i.nBtruction€ should b€ u6ed as, shoun in the exallrD1eE.

Setting Interrupt and Timer Vector6


g e c E U s ev e r t i c a l - b l a n k inte"r.!pts are gener.allg kept enabled so that
t h e f r a m e c o u n t e ! . R T C L O Ki E o a i . n t a i n e d a c c u r a t e l ! , there is e
probleo uith setting t h e V B L A N Kv e c t o i e ( W S L K I a n d W B L K D ) o r
the tioei v E l u e s ( C D T M V I t h r o u g h C D T M V S )d i r e c t l r J . A VBLANK
inteaiupt Eould occur uhen onlg one bgte of the tuo-bgte value had
b e e n u p i l a t e d , l e € d i n 9 t o u n d e s i r € d c o n s e q u e n c e E .F o F t h i s r e E 6 o n ,

O P E R A T I N eS Y S T E MC O 1 6 5 5 5 - - Section 6
110
the SETVBVtE4$Fl rootine i6 Frovided to perfoifi the desired
update in gafe mdnner. The cslling gequence is shoun belo{r:

A = update ite indicgtor


1 - S f o i t i n e t € 1 - 5 .
6 f o r i f i m e d i a t e V B L A N Kv E E t o r W B L K I .
7 f o r d e f e i r e d V B L A N Kv e e t o i v v B L K D .
X = I'ISBof value to store.
Y = LSB of value to etore.

JSR SETVBV

The A, X and Y regi5ter.6 can be sltered.


The diEpleg IiEt interrupt rrilt eluarJ6 be disabled on
return, even if enabled upon entrtJ.

It iE possible to full'l process a vertic€l-blank interrupE


dur ing a aal l to this routine.

lrhen uorting uith the SVstem Timer6, the vectorg for tifteis l end
2 end the flag6 for tirrere 3,4 and 5 slrould be 6et uhile the
associated ti&er is equal to rero, thsn the tiner should be Eet
*o its (nonzer.o) ve1ue.

\_ Stack Content at Inter!.lpt VeEtor pointE

The +ollooing t a b l e s h o u , 6t h e s t a c k c o n t e n t a t ever.{ one of the


RAll interrupt vec tor. points:

OPERATINGSYSTEiI COt6555 -- Section 6


111
RAII STACK CONTENT

INTERRUPT VECTOR DESCNIPT ION OS RETURNCONTROL

VDSLSTlO2OOl Displa'J list return, P


WBLKI tO222, * V E L A N Ki m f l e d i a t € return, P, A, X, Y
C D T I ' | A !t o 2 2 6 l Sqstem Tifter I return, P, A, X, Y, ieturn
C D T I { A at o 2 2 g l Sgstem Timer 2 r€turo, P, A, X, Yr return
VVBLKDtC2241 * V B L A N Kd e f e r . retur.n. P, A, X. Y

VII{IRO 10216I * IRC imnediate ?eturn, P, A


V S E R O R[ O 2 O CI * Serial out read{ retur.n, P, A
VSERIN [O2OA] * Setial in readq return, P, A
V S E R O Cl O e O E l * Seri€l out colnpare return, P, A
VTItlRl toalol P O K E Yt i m e r 1 return, P, A
VTIMR2 to2lel P O K E Yt i n e r 2 return, P, A
VTII'iR4 [Oe14, P O K E Yt i n e . 4 return, P, A
V K E V B Dt o 2 o E l * Keqboard data ieturn, P, A
V P R S E Dt o 2 o z l Serial paoceed r€turn, P, A
VINTER tO2O4l Serial int€.ruot ietuin, P. A
V B R E A KE O 2 O 6 I gRK initruEtion return, P, A

Figure 6_4 Interrupt and Timer vector RAMStEEt Cont€nt Table

* The OS initialires t h e B e e n t r . i e s a t p o u r e r ' - { . r pI .o p r o p e r l g


ch6nging these vecto?i uill aIte. sgstem perforoanae.

M i s € e 1l a n e o u s C o n i i d e r € t i o n E

The +ollouring paragraphs list 6 set of igcelleneous


conside?ations for the urlter o+ an interroot EerviEe routine.

RestrictionE on CIeBring

Displag IiEt. iflmediate vertical-b1Enk and Sgstem Timer {fl


ioutines Ehould not cleer the 650A I bit- If the NMI le€ding to
one of the6e roLitineg occurred uhile an IRO rres being processed,
then cle€ring the I bit !rill ca!ee the IRO to re-interrupt uith
a n u n k n o L J nr e s u l t ,

T h e g S V B L A N Kp r o c e E e 6 r c a r e f u l l ! 6heckE this condition efte!' the


Etage 1 proce5s end before the gtage 2 proceEE,

I n t e r " t u pt P r o c e E s T i m e R e g t r i c t i o n s

You Bhould not ur.ite en inter?uDt routine thet exceedE 4Oo m6ec.
u h e n a d d e d t o t h e 6 t a q e 1 V B L A N I , (i,f t h € s e . i a l I/O ie being
u6ed. The SI0 6ets the CRITIC flao uhile seriel bu€ I/O is in
Prog?e95.

i U16555 --
O P E R A T I N cS Y S T E I ' C Sectidn 6
InterruFt Dela! Dus to "t"rAIT FUR SYNC"

[,lhen€ver E teg i.s read +rom the tegboer.d, the Keqboard Handler
sets l^lsYNC ID4CA] repetstedlg uhile generating the audible rlic*
on the EonEole gpeak€r. A ptoblem occurE lrhen interrupts are
gen€rated during the u€it-for-EgnE period; the processing of such
interruptE rriII be del:qed bV one horizontal scan line. IhiG
condition cannot be prevented. You can uor* ar.ound the condition
b g e t a n i n i n g t h e I i n e c o u n t V C O U N TC D 4 O D Ia n d d e l a g i n g i n t e r l . u p t
p r o c e s 6 i n g b g o n e I i n e { r h e n n o t l S y N Cd e l a g h e s o c E U r r e d .

FLOI"'CHARTS

The +d1Io{rin9 pages contain proceEs floucherts sho{rin9 the m€in


events thet oc€ur in the Nl'lI Bnd IRC interrugt DroreEssE.

O P E R A T I N GS Y S T E HC U 1 6 5 5 5 - - gection 6
113
OPERATINe SYSTEM CO16595 -- Section 6
114
NMI INTEBRUPTPROCESS

OPERATINcSYSTEIIc016559 -- S.ction 6
7 SYSTEd INI T IAL I ZATION

Section 7 diEf,usses the detsils of the po{rer-up and


5 9 5 t e t n i e s e t p r o c e s s e s . T h e p o r r r e r - u pp r o c e S S u r i t l b e e t p l a i n e d
first, and then the sgsteo reset process uitl be explained in
teros of its difference6 +rom the pouer-lJp pro.eEs.

Eoth poure.-up (elEo calted coldEt€rt) end pressing CSYSTEM RE. SETI
(uar.tn5tait) rrill cauEe 6gstem initiatization: In addition, ther€
ate vectoi5 for. these p?ocesseE at E474 tEg6teft reEet) and E477
(polrer-up) so thet theV can be uEer-initieted.

The pouei*rp initializ€tiDn pro.€ss is a suoerget of rne


sgstem reset initj.alizstion process_ porrer-up initializeE both
t h e O S a n d u g e r R A Mr e g i o n s , u h e r e a s E g E t e m r e s e t i n i t i a l i z e E
o n l g t h € O S R A Mr e g i o n . I n b o t h c a s e s , t h e O S c a l l s t h e o u r e r
level softnsre initialization entrg point6 eIloU the applicdtion
to initialire its oun vari€b1es.

P r e s 6 i n g t h e I S Y S T E HR
. ESETI teg p.oduc€s en NMI interrupt. It
doeE not perfor{rl a 6502 chip-ie5et. I+ the processor is locked
u p , t h e I S Y S T E MR. E S E T I k e g c a n n o t b e s u f + i c i € n t t o u n l o c k i t , e h d t h e
6q€tem rnuet have pousr cgcled to clear the problelll.

PAHEF-UP INITIALIZATION (CoLDSIART) PROCEDURE

The OS perfor{t5 the follouing functj.onE i.n the ordeF shorrn, es


pert of the pouer-up initiElizEtion proceEs:

1. The follouing 650A proceEsor stateE are Eet:

o IRO interrupts a.e diEebled using the gEI in6truc tion.

o The de( irnal flag iE c le€red using the CLD i.nstruction.

o The itack pointer is set to iFF.

The OS eets the uermst:rt flag h | A R M S T| O O O B I t o O ( f a I E e )

OPERATINCSYSTEI'ICO16955 -- Section 7
116
The OS tegts to see i* a diagnostic cartridge is in the A slot:
Ca.tridqe Bddregs BFFC = OO?

Th€ ftemorg et BFFC i5 not RAM?

Ait 7 ot the bgt€ at BFFD= 1?

If all of the above teEts are true, then control ic Dassed to


the diegnoEtic certt'idge via the vectoi et SFFE. No return iE
erPecte{t.

4 . T h e U S d e t e r f t i n e s t h e l o u e s t m e m o r qa d d r e s 6 c o n t a i n i n g
non-RAH, bU teEting the first bgte of ev€r{, 4K ,,block', to see
if the content cen be codrpleoented. If it EEn be compl€anented,
then the oritinal value iE restored End testinq continues. I+
i t c a o ' t b e c o n F l e m e n t e d r t h e n t h e c o n t e n t i s i s E u t t l e dt o b e
the first n o n - R A l . ,al d d r e 6 E i n t h e E g B t e n . T h e | 4 S B o + t h e
addreie iE Eto?ed tenpofa!ilq i n T R A M S Zt O O O 6 l .

5. Zero iE stored to all of the harduare reg ist6r EddresEe6 ghoun


b e l o u ( m o s t o f t h a t a r e n . t d € c o d e d b 9 t h e h a r d u r € r et :

DOOO thl'ough DOFF


DeOO t h. o'rg h DaFF
D3OO through DSFF
D 4 O Ot h F o u g h D4FF

The OS cle:rs RAh fio.n location OOO8, t o the a d dr e g g


deteioined in step 4, dbove

7. The def6ult value for. the,,nonrattr.idge" control vector


D O S V E CI O O O A I i s s e t t o p o i n t t o t h e b 1 € € t b o a r d r o u t i n e . A t
the end of initiali!ation, control is Dessed throuoh this
vectol. i+ a cartridge does not tEke Eontrol.

B. T h e r o l d s t a r t flag C B L D S Tt 0 2 4 4 l i6 Eet to -1 (Iocet use).


T h e s c r e e n o a i g i n 6 s r e E e t : l e f t . n t s r g i n= 2 , r i g h t n € r g i n =
39, for a 38 charaeter phgiical tine. The nsxi.munlinF gize of
40 f,hal.€.ter5 can be obteifled bV setting the marqin6 to O and
39. The OS insef,s the Ieft Dargin beceug€ the turo left|l}osr
columns of the vid€o picture on meng television 6et6 ai€ not
entirelg vi6ible on the Ecreen.

1O. The interrupt R A I ' Iv e c t o r s V D S L S T t O e O O l t h r o r r g h V V B L K D C O e Z 4 l


ere initiali!ed_ See Section 6 for the initialization values.
1 1 . P o r t i o n s o l t h e O S R A l , la r e s e t t o t h s i i r.equired nonzero velues
a s s h 6 u n b eI o u :

O P E R A T I N CS Y S I E M C O 1 6 5 5 5 - - Se€tion 7
LL7
o T h e I B R E A K I k e ' J f l E g S R K K E Yt O O l 1 l = - 1 (+alse).

o The top of meftorg pointer MEI'ITOP toeEsl = the louresE


n o n - R A l , le d d r e E s ( f r o step 4), HEI'ITOP
uill be alter.ed
lete? {rhen the Screen Editor i.6 opened in step 19.

o The bottom o+ oenor! pointer MEhLO tOZE7l = O7OO, MEl,lLO


can be €h€nged later if there is either a diskett€- or
cac6ette-boot oDerEtion,

o The +ollouing reEident ioutineE are called for. initialiration:

S c t ' e e n E di t o r
D i B p l a { H a n dl e r
K a g b o a r d H a n dl e r
P r i n t e r H a n dI e r
C a g s e t t e H a n dI e ! '
Centi€ I I/O Monito" (CIO)
Seiial I . / O l . l o ni t o r ( S I O )
Int€rr.up t p.oc egsor

o Th€ tSTARTI teq is chec*ed, and i+ preEEed, the cassEtte-boot


request *lag CKEY tOO4Al iF set.

12. 69 0A IRO inte"ruptE €re enabled using thE CLI instruction.

1 3 . T h € d e v i c e t s b l e H A T A S Sl O 3 1 A l i s i n i t i € 1 i z e d to point to the
r€sident handlers. See Section I +or inform6tion r.€latino to
th€ Device Handlei'tEbte.

14- The Eer.tiidge slot dddresseE fo. certiidges I and A are


era|nin€d to deterfiine if cartridge6 E?e ingerted, if RAMdoes
not ertend into the c€itridge eddt.eBsEpece.

If the ronteDt of location 9FFC is re.o, then e JSR is


ete,t!t€d through the v€ctor at 9FFE, thus initiElizing
aartridge (8". The cartridge is expected to return.

If the content of location BFFCiE refo, th€n e JSR is


erec!ted through the vector. at BFFE, thus initi:lizing
ceitiidge "A". The cart.idge is expect€d to r.eturn.

1$. IOC8 l+O is iet op for an BPEN of the Scr€en Editor (E) and
t h e O P E Ni s p e r f o r m e d . T h e S c r e e n g d i t o r u i 1 1 u s e t h e h i g h e s t
p o r t i o n o + R A M+ o r t h 6 s c i e e n e n d u i l l adJUst ilEHTUp
aErordinglq. If thi6 oper.ation shoutd fail, the entire
initialization proeesg is repsated.

1 6 . A d e l a { i s a f f € c t e d t D a s s u r e t h a t a V B L A N Ki n t e r . u p t h e s
occrrr.ed. This is done Eo th€t the Ecreen uill be e6tabliEhed
be + o r e c o n t i n ! i n g .

17. lf th€ r€6sett€-boot request flag is set (6es Etep 11 :bove),


then e cEEsettr-boot opsiatlon is etteinpted. See Section 1O

OPERATINe SYSTE}.{CO16955 -* Section 7


118
for details of the caE6ette-boot operetion.

18. If €nrj of the thrse conditionE 5t€ted belou exists, an


attempt iE ftade to boot frotn the disk.

IheFe €re no c€rtridges in the 91otg.

Cartiidgs B iE inEerted Bnd bit O of 9FFD is 1.

Cartridqe A i5 in5erted and bit O o+ EFFD is 1'

See Section 1O for' deteils of the di5tette-boot operetion'

1 9 . T h e c o l d s t € r t f 1 6 g C O L D S Ti E i e t e t * o i n d i c a t e that the
coldstert process uent to cotnpletion.

20. The i'liti€li2ation procesE is nou,cotrplete. €nd the


co'ltr'olling application i5 nou,determined via the temeining
Etep5.

If there i6 sn A Eaft?idge inserted End bit-2 of BFFD is 1'


then a JMP i6 sxecuted thr'ough the vector at BFFA

Ur, if there is 3 B cartridqe inscrted .nd bit-e of 9FFD iE


gFFA'
1, then a JMP is executed through the vector at

o t ' , € J u m p i s e t e c u t e d t h i o u g h t h e v e € t o r D O S V E Ct h e t c a n
ooint io tha blEc&boa.d routine (default case)' caEsette
booted 6oftuere or diskette booted to+tuate. D O S V E Cc a n b e
eltered bq t h e b o o f , e d E o f t u r a i e € s e x p l € i n e d i n SeEtion 1O'

SYSTEM RESET INITIALIZATION ( I^IARI'ISTART


I PROCEDURE

T h € f u n c t i o n s l i E t e d b e 1 o u ,a r e p e r f o i i n e d , i n t h e o r d e r s h o u n ' a 5
pert of the 6!rten r€set initializetion procesE:

A. Same aE po[rer-i]p 6tep l'

B. The {rai&5tart + 1 e g t ^ r A R l ' 1 St O


TOOSl is 5et to -1 (true}.

C. Same a6 pou,er_up stePE 3 thtough 5.

D. os RAH is zeroed +r'on locations OeOo-o3FF and oolo-oo7F'

E- S€fte a9 pouer_up 6tepE 9 through 16.

F. If a casEette_boot uas EUcaessfullq toopleted during the


polrer-up initialization, then a JSR i5 exeEUted thtough the
veEtor CASINI t O O O 2 l . S e e Section 10 for details of the
c€69ette-boot p l ' o c e 5 5 .

O P E R A T I N eS Y S T E MC O 1 6 $ 5 5 - - Section 7
119
e. Sameas pouer-up step 18, €xcept in6terd of bootinq rne
diEkef,te Eoftu€re, a JSR is executed thrrugh the vector DUSINI
tOOOCIif the diskette-boot uaB succeEsfuttg co|npleted during the
Poorer-upiniti€lization. See Section 10 +or details of the
diBkette-boot pror€ss.

H. Sa,neas pouer-up steps 19 End 20.

Noto that the initializEtion pioEedures €nd n€in entrie6 fo? all
softual.e entities aas executed €t ever.g sgsten reEet as uell aE
at polr€r up {EEe stepE 14, t7, 1A, 2O, F end G}. If the
u s a r - g u p pI i e d i n i t i E l i z € t i o n / 6 t s r t u p c o d e m r , s t b e h a v e d i f f e r e n t l q
in l.ecponse to sqstem reset than it doe5 to po{rer-up, then the
0 r a i . n s t E r t f l a g W A R I I S Tt O O O E l s h o u t d b e i n t e r r o g a t e d ; I I A R H S T= O
fteang pouer-up entr.V, else sgsteft r€set entr.!.

OPERATINe SYSTSI'{COl6555 -- Seition 7


120
B FLOATING POINT ARITHIIETIC PACKAEE

This section describeg the 8CD flo€tinq point (FP) p6ctage that
i.s resident in the OS 80l'l in both th6 dodels 4OO and 8OO.

The floating point peckage m€intainE numbers inter.natlg es 6-b{te


quantitieE: a 5-bgte (10 BCDdigit) n€nti6sa uith a 1-bqte
erpon€nt. B C D i n t e r n a l r e p r € s e a t a t i o n t r r a Ec h o l i e n s o t h a t d e r i o a l
divi9ion {rould not leEd to the rounding er.rors tqpiEEllV found in
b ina!'U repre€€ntat i on inplernentations.

The paakage pr.ovides the follouing operetion6:

ASCII to FP conversion-
F P t o A S C II c o n v e r s i o n .
Integ er to FP converEion.
F P t o i n t e g e i c o n v e r si o n .
FP add, subtr€ct, |nrrltiplq, dnd divide.
FP logar'ithm. erponenti6tion, and polrrnofiial evaluation.
FP zero, load, stor€, €tnd move.

A floating point operation iE pei+orned bq csllinq one o* the


provided routines (eEch et E +ired address in ROM'€fter having
set one or more flo€ting point pseudo register6 in RAM. The
resolt o+ th€ desired operation uill also iovolve +loating point
pseuda register6. The prinerg pEeudoiegi6ter's are describ€d
belou €nd their eddreEses given {rithin the s{uere brac|(€ts:

I I P E R A T I N Gg Y S T E H C O 1 6 5 5 9 - - SEction E
F R O C O O D 4 I= 6-bqte inteinal foim of FP nuftber.
FRl IOOEOI = 6-bqte interntsI foin of FP nuftber-
F L P T R T O O F C := ?-bgte pointer (1o,hi) to e FP.
nufib et,
I N S U F Ft O O F 3 l = z - b q t e p o i n t e r ( l o , h i ) to an AScII tert
brr+fer.
CIX [OOF2l = 1-brJte index, used a€ offEet to b!f+e!'
pointed to bg INBUFF.
L B U F F C O S A O I= r e € u l t b u f f e r f o r t h e F A S C i o r r t i n e .

FUNCTIONS,/CALL I NE SEOUENCES

Desrriptions of the6e +IoEting point routines a9€lme that


a pseudo regi6ter i9 not alteied bg a given routine. The
nlmberE in Equare brdctets Irxxx] are the ROI'e
I d d r e E E e Eo f t h e
ro!tineE.

AgCII to Floating Point Conveision (AFP)

Function: Thig r.outine ta&es en ASCII BtI.ing as input and


pioduEei e floating point number in intErnal fofn.

C a I l i n 9 s e q u e n ce :

I N S U F F= p 6 i n t e r t o b u f f e r c o n t e i n i n g t h e A S C I !
r a P a E E e n t a t i o n o f t h e n u f t be r .
CIX = the buffer offset to the fi"st bgf,e o+ the ASCII
nu bet.

JSR AFP TDBOO]


BCB first bqte of ASCII number is invalid

FRO= flo€ti.ng point n{]mber.


CIX = the buffer o+f5et to the first bgte s+ter the ASCII
n u D be r .

AIgorithfn: The routine t€kes bqtes frofl the buffer until it


encountets e bgte thEt cannot be peit of the number. The bqtes
scenned to that point €re th€n €onverted to € +loating point
number. I+ the first bgte encount€red is inval id, the carl.g bit
iE s€t as € flag.

Floating Poirt to ASCII C!nver.sion (FASC)

FL,nction: ThiE r'orrtine converts a floatinq point nunber from


i n t e i ' n a l f o r o t o i t E A S C II r e D r e s e n t a t i o n .

O P E R A T I N eS Y S T E I ' cI o 1 6 5 5 5 - - section E
Calling 6equenre:

FRO= fl06ting print nunber'.

JSR FASC IDAE6]

I N B U F F= p o i n t e i t o t h e f i r s t bgte o+ the ASCII nutnber..


The lEst bgte of the ASCIT repfesantation ha5 the most
eignificant bit (Eign bit) set, no EOL follorrs.

Algoiithm: The routine converts the nu ber froo its internel


floEting point r€pisEentation to a pr.inteble for.m (ATASCII). The
p o i n t e . I N B U F F' r i l l p o i n t t o p € r t o f L B U F F , u h e r e t h e r e s u l t i E
5tor.ed.

Integei to Floating Point Conversion (IFP)


_' Function: This routine converts a a-bgte unsigned integer (O to
65535) to floatir|g point internal represent€tion.

C a1 1 i n 9 E e q u e n ce :

FRo = integer ( F R O + O= L S B , F R O + I = H 5 8 ) .

JSR IFP [D9AA]

FRO= +loating point repreEent€tion of inteqer..

Floating Point to Integer Conversion (FPI )

Function: This io!tine €onvertg a positive floeting point numb€r


fr'om its inteinal repreEent€tion to the nearest 2-bgte integer.

C€l I ing sequence:

FRO= +loeting point number.

JSR FPI TD9D2]


BCS FP number is flegative or >= 65535.5

FRo = z-bqte integer ( F R O + O= L S B , F R O + I = t v { 5 )8.

Algoritho: The r.o!tine peffoTmE tr.ue rounding, not truncation,


dur'ing th€ aonver€ion pioce6s.

1 O16555 --
U P E R A T I N eS Y S T E T C Section I
t23
Floatitlg Pr int Addition (FADD)

Function: This routine edds trro floeting point nuftbers end check6
the resul.t for dut-of-r€nge.

C e l l i n O s e q u e n re :

FRO= floating point nunber.


FRr.= floating point numbei.

JSR FADD IDA66]


BCS out-of-range resu I t.

FRO = reEult of FRO + FR1.


FR1 iE e l tered.

Fl oeting Point Subtraction (F$UB)

Function: Thi6 i-outine subtraEts tuo ftoating point nuobers and


checls the l'eirlt +or out-of-ran9e.

CaIling s e { u e nc e :

FRO= floati.ns point tninuend.


FR1 = flosting point subtrahend.

JSR FSUB TDA6O]


ECS o!t-of-ranqe result.

FRO= r€sult o+ FRO- FR1.


FRt i3 €ltered.

Float ing Point l . l uI t i p 1 i c a t i o n (FMUL)

Function: Thii ioutine multiplj.eE tuo floating point nufibers end


checkE the re!ult for out-of-range.

Calling Ee q l e n c e :

FFO= floating point multiplier.


FR1 = floating point multiplicand.

JSR FMUL TDADB]


BCS out-of-ran9e r esu 1t.

FRO= result o+ FRO* FR1.


FR1i5:Itered.

O P E R A I I N OS Y S T E MC O 1 6 5 5 5 - - Sertion I
124
Fl oet ing Foint DiviEion (FDM

F 0 n c t i o n : T h i E r o u t i n e d i v i d e 6 t u o f l o a t i n g p oi n t n u m b e r s a n d
checl6 for division bq rer-o and for result out-o+-rtsn9€.

Calling s e q u e n ce :

FRO= +loating point dividend.


FR1 = floeting point diviEor.

JSR FDIV CDBzA]


BCS out_of-iang e r e 5 u I t or diviEor iE z€ro.

F R O= r e s u l t o + F R O. / F R 1 -
FR1 iE al tered.

Floating Point Logal.ithm6 (LOG snd L8e1O)

Function: TheEe ioutine5 tale th€ natlrel or bese 10 logerithms


of a floating poirlt nunber.

C a I I i n g 6 e q u e n €e :

FRO= +loating point numbe..

JSR LOC IDECD] for naturBl logarithm

LOGlO tDEDll +or baEe 1O logarith!r


gc5 neget ive nurnber or overflour.

FRO= floating point logari thm.


FRI is al tered-

Alqorith|n: Both logarithfn! €re +i.l.st computed es baEe 1O


1o!€rithm6 uging a 1O tet'm polqnomial approxiflation; the nBtur.al
logarithm is computed bV dividing ths bsse 10 result bV rne
€onstant LOO1O(E).

The logaFithln of a number Z is coflputed eE fo11o{rrs:

F n ( 1 C t, r + Y ' = Z u r h e r ' e1 < = F 4 1 0 ( n o r m a t i z a t i o n ) .


L = L C I C l O ( F )b g l O t e r m p o l g n o m i e l e p p r o x i n a t i o n .
LOOIO(Z) = Y + L. LOO(Z) = LOOrO(Z) / LOclOre).

NOTE:This routine doeE not ?eturn eh error' if the numbei inout


i6 rero; th€ LOClOr.eEUIt in thi3 EaEe is spproxinatelq -1e9. S,
uhich is not uEeful.

O P E R A T I N OS Y S T E MC O 1 6 5 5 5 - - Section B
1?5
Floating Point Erponentiation (EXP and EXPIOl

Flnction: T hi E r o u t i n e exponentiates.

C a l I i n g s e q r e n ce :

FRo = floating point exponent (Z).

JSR EXP IDDCO] for e n* Z

JSR EXP1O IDDCCI for 10 *+ Z

FRO= floeting point result.


FR1 is a I tered.

Algor'ithm: Eoth erponentials are comPutsd internallg as base 10,


{rith the ba6e e erponential uEing the identitg:
e ** X = 10 ** ( X ir LOClO(e) ).

The beEe 10 exponential is €valu€t€d in turo parts using the identit!:

10 ** X = 10 ** (I + F' = (1O ** 1) * (1O *+ F' -- uhere I i5 the


integer portion of X and F i9 the fraction.

The teim 1O +tt F iE evaluated using a polgnomiel epproxi.nation,


€nd 1O r*tt I is a stiai.ghtforuard modi+ication to the +loating
point exponant,

Flodting Point Polgnooial Evaluation (PLYEVL'

Function: This routine p e F f o l . m sa n n d e g r ' e e P o l g n o n i € 1


ev8luation.

C e l l i n g r e { u e n Ee :

X,Y = pointer (x = Lsa) to 1i5t o+ FP coef+i.lentE (A(i))


ordel'ed frorn high orde'. to Iou otder (sir blrtes Per'
coefficient).
A = nu{nbero+ EoefficientE in 1i5t.
FRO= floating point independent vdriable (Zl.

JSR PLYEVL TDD4O]


BCS over+1orr or other eriot.

FRO= reEult of A(n)*Z*t+n + A(n-1)*Z**n-l ... + A(1)*Z +


A(O).
FRl i6 altered.

A l q o r i t h m : T h e p o l g n o n i e l P ( Z ) = S U H ( i = Ot o n ) ( A ( i ) * Z * * i ) i5
cooputed u6in9 the Etendard oethod shoun 6elou,:

P ( Z ) = ( . . . ( A ( n l r + Z+ A ( n - 1 ) ) * Z + . . . + A(1))*Z + A(O)

O P E R A T I N eS Y S T E I IC O 1 6 5 5 5 - - Section g
Clear FRO ( ZFRO)

.- Function: This roltine 6et6 the contents of psesdo register FRO


to all zero6.

Calling Eequence:

JSR ZFRO TDA44]

CIear Page Zer.oFloating Point Number (ZF1)

Function: ThiE routine 5et6 the contents of a .ero-page floating


point nuober to alI zeioes.

C€Iling gequence:

X e Zero-page eddress o+ FP number to cl.ear.

JSR ZFI TDA467

Zero-page FF number.(X) = zero.

Loed Floating Point N u m b e r t o F R o ( F L D O Re n d F L D O P )

Funrtion: The6e foutines load pse!do regi:ter FRo rrith ti:e


floatihg point nunber Epecified bg tha.alling sequence.

C € l I i n 9 Ee q u e n ce E :

X,Y = pointer' (X = LgB) to FF number.

JSR FLDOR IDD89]

FLPTR = pointer to FP nunber.

JSR FLDOP TDDAD]

FRO= flo8ting point nunber (i.n either ca6e).


F L P T Ra p o i n t e r t o F P n u m b € r ( i n e i t h e r c e ; e ) .

T]FERATINGSYSTEM c016555 -- Section I


Loed Floating Point Numb€r to FRI (FLDIR snd FLDIFI

Function: These routines Ioad p6eudo register FR1 tith the


f l o e t i n g p o i n t n o m b e rs p € r i + i e d b g t h e c a l l i n g E e q u € n c e .

Calling sequences:

As in prior deEcription, except the result goe6 to FR1


inEtead of FRO. FLD1R tDD9Bl and FLD1P [DD?C1.

Stot'e Floating P o i . n t N u n b e r F t o n F R O ( F S T O R € n d F S T O P)

FunEtion: These routines stor€ the contents of pse!do I'egi6ter


FROto th. addr.esespecified b! the caIli.ng 56qu€n€€:

C:IIing E € q u e n ce :

As in prior des€riptionE, except the floeting poi.nt nuobe?


is 6toFed from FRO rether thin loaded to FRO. FSTORtDDATl
ANd FSTOP [DDAB].

l'love Floating Point Nuober Fiom FRO to FR1 (FMOVE


)

Function: This ioutine nrovesthe floating point numbei in FRo to


p s e ! d o r . e gi s t e i F R l .

Call ing sequence:

JSR FHAVE IDD86]

FRt = FRO ( F R Or e m a i n s u n c h a n g e d ) .

RESOURCEUTIL I ZATION

T h e + l o a t i n g p o i n t p a c k e g e { r E e Et h e f o 1 1 o { r i n g R A H l o E e t i o n s i n
th€ Eour6e of perforfiing the functionE desEribed in thig section:

OOD4th.ough OOFF
ut /E tnfouon u ) t -t -

A11 of these locationi ate av€ilable +ot piogram toding


i+ goui progrem does not cell the floating point p€Ekage.

OPERATINo SYSTEI4CO16555 -- Section I


L2E
I MPLEI'IENTAT
I ON DETAILS

Floating point nu,nb€i6€re oaintained internallg €s 6-bgte


quantities, uith 5 bqteE (10 BCDdigitF) of nanaiEEa and 1 bgte
of erponent. The rn€ntisEa i9 allrags noroa!ized such thtt the
most Eignificant bgte iE nonzero (note ,,bgte,,and not ,,BCD
di9it").

The rnost 6ignificant bit of the exponent bqte provideg the sign
+or the trt5ntiEsa; O $or po6itive and 1 for_negative. The
iemai.ning 7 bits o+ the exponent bgts provide the exponent in
excess &4 notation. Ihe r€Eulting n l m b € r l ' e p f e ! i e n t E p o u r e r , so f 1 O O
decimal (not poorersof lO,. This storage format allolrs the
mentiEs€ to hold 10 BCDdigits {rhen tha value o+ the erponent ig
an even pou,er of 10, and I gCO digitg uhen the velue o+ the
exponent iE an odd pouer o+ 10.

The implied decimal point is al0rags to the inneiliate right of the


fir'Et bgte. An erponent leEs th€n 64 indicates a number less than
1. An sxponent equal to or gre6tei than 64 represents a numbei
equel to or greatei than 1.

Zero is repreEented brJa zefo nantiBsa and a zero etponent. To


test for a rEEUlt from €nrJ of the stenddr.d routines; test either
tne exponent or. the first nahtissa bUte for zero.

The abEol!te value o{ f1o€ting point n|JobersmuEt be greater than


10t'*-98, and less thsn 10**+98, or be equBl to zero. There iE
per+ect sgfit|letrg betueen positive and nigative nuobers |llith the
erEeption that negetive zero iE nev€i generated.

The preciEion of aIl computetion6is nsintained at 9 or 10


deci al digits, but sccuracA iF sooeuhat t€E9 +or those +unctiohs
invo),ving polqnomial epp?ori|nations ( logarithm €nd
erponentiationl. Aleo, the probleos inhereflt in €11 floating
pornt 6qstems are preEent hel.er for exa|nple: Eubtraeting
tu,o verg
neerlg eqlEt nu bers, adding nulnbers of disparate oagnitude, oa
€ucceEsirnE of an{ operation, urilI a1l res,Jlt in a liss of
5!gni+i€ant digitE. An analqsis of the deta renge and the order
o+ evaluation of etprs6sions fllsq be iequired +oi some t{peE of
a p p1 i ( a t i o n 6 .

The €xaftples belou conpal.e floeting point numbers {rith tn€ir


inteinal rep!.essnt€tions, aE €n eid to undsrEtanding storege
foirnat. All nunber6 pr.ior to thiE point hevs been eipreesed in
decimal notation, but these exanples !ri1l use hexadeiimal
n o t a t i o n . N o t e t h € t & 4 d e ci f l a l ( t h e e x c e s E n u | n b e r o f t n e
erponent) iE 40 uhen exFressed in hsxadeciftel:

N u m be r : + O .0 2 = 2 * 1 O + * - 2 - 2 * 1 O O * * - l
Stored: 3F Oe 0O 0O OO OO (FP exponent = 40 - 1)
N u f l be r : -O. OA = - 2 * 1 O + * - 2 = - 2 * 1 O O * + - 1
Stored: F F O e O O OO O0 OO (FP exponent = BO + 40 - t)
O P E R A T I N GS Y S T E i 4C O 1 6 5 5 9 - - Se.tion g
Nuftber +37.O = 3.7 * 1O**1 = 37 * 1OO**O
gtored 40 37 OOOOOOOO {FP exponent = 40 + O}

Nunber - 4 . & O 3 1 2 4 8 ' b* 1 0 * + 1 . 1= - 4 6 . O 3 . . . * 1 O O + + 5


Sto.ed CS 46 03 01 24 A5 (FP €rponent = 80 + 40 + 5)

N u m b e r: o . o
Stored : OO OO OO OO OO OO (sPecial Eese)

O P E R A T I N OS Y 9 T E H c o l 6 5 5 5 - - gettion I
130
9 ADDING NEW DEVICE HANDLEfiS/PER
IPHERALS

T hi 9 s e c t i o n d e s c r i b e s t h e i n t e i f d c e r e q u i r e n e n t E + o r a
noniesident Device Handl€r. thet i5 to be accesEed via the Centr"€l
I/O utilitg (CIO). The S€rial bus I/O otilitg (SIO) interface is
defined +or thoEe hendlers thet utitize ths Seriel I/O buE.

The I./O iubEgEtem iE organized uith three 1eve1s of softuare


b e t u r e e ng o u a n d U o u r h a r d u a r e : T h e C I O , t h e i n d i v i d u a l d e v i . c e
h e n dI e l . 9 , a n d t h e S I 0 .

The CtO p€r+orrn6the follouing functiong:

Logical devire name to Davi.e Handler |n€ppin9 ton OpEN).

L/O Cont"ol gloct (IOC8t fteintenanre.

Logical record handIing.

U s e r b u f f e P h e n dl i n g .

T h e d e v i c e h e n d l e r s a r e b e 1 o u ,C I O . T h e g p e r + o r f i t h e
follotring +un.tionE:

Oevice initialization o n p o u r e r - u pa n d 6 g 5 t e o r e s e t .

Device-dependent 6upport o f O P E Na n d C L O S E E o f l m a n o s .

BrJte-€t-a-time data input and output.

0€vi ce-dependent Epecial operations.

D e v i E e - d e p e n d s n t c o l n f n € n ds u p p o r t .

Devi Ee data buffei nanage.nent-

The SIO is at the bottom level (for Serial I/O bus peripheral
handlerE). It p e r f o r . | ' l st h e + o 1 l o u i n g f u n c t i o n 6 :

Control of a1t Ser.ial bus I/O. conforoing to the bus


taotocol.

8us operation fetries on errors.

Retsrn of uni+ied er.or'st6tus€s on €rior conditions.

O P E R A T I N OS Y S T E MC O 1 6 5 5 5 - - Section I
131
A 6eDttate €ontro! Ett'rrcture is uied +ot communic.tion at each
interface, as f ollotlB:

User/CIO I/B Control Block (IOCB)

Clo/Handler zero-psg€ I A C E ( Z I O C B'

Handle./$IO Device Control EIock (Dc8)

OPERATINGSYSTET'ICA16$55 -- Section 9
13e
I uger I
i p r'og rEn I --------------*-----*------+

+---------+
! IOCB.E

I DCB | **++*t1* |
+---------+ +---------+ * |
l*
.*
+---------+ * i
I zlocB I lDevice I iDiE* Filel * i
+---------+ i lable i +---- i Manager l-----+ !
i +---------+

+------------+------+------+--+--

+---------+ +---------+ +---------+


_ t P r i n t e r i i C a s E e t t e l i . . . i I K e gb o a r d i i DiEk i
i Handler i i Handler I I Hand l er i I H a n d1 € r i i Handler. I
+--*------+ +---------r +---------+

I DCB l****r++r+ j{.+

! SIO I
i Uti I itq I
+---------+

l^lhere: ---- shouE a control psth.


shous th€ data structure re{uired for a path.
Note the +ol1ouing:

1 . The Kegboard,/Displag/Screen Edito? hsndlerg don,t use


sIo.
The Diskette Hendler cannot be called directlg fr.om CIO.
Tha DCE iE shoun tuice in the di€qreo.

Figuie 9-1 I/O Subsgsteft Flou Didgram

OpERATINc 9YSTEtl CO16555 -- Section 9


DEVICE TABLE

T h e d e v i c e t a b l e i s e R A f ' l - ! . e s i d e n tt a b l e t h a t c o n t a i n s t h e
single*cha.arter' device name {e. g. K, D, C, etc). and the
handler eddress foi each o+ the hendlerE knoun to CIO. The
table is initialized to contain entries +oi the foltouj.ng
resident handlersr Kegboerd (K), Displag (S), Screen Editot'
(E', Cassette (C). end Print€r. (P) at pouer-!p and 6{Etem reset. To
i n s t a l l € n e u h E n d I e r , g o r n ep r o c e d u r e m u s t i n s e r t € d e v i ! e t e b l e entiq
a+ter the teble iE initialized.

The teble +ornat iE shourn belour:

+----------------+ -+
H A T A B S[ O 3 1 A ] i devi.ce nams i I
r----------------+ :
I handler vector I +- one entrg
+ + i
i table eddress I i
+*---------------+ -+
I mor'e I

I entiie6 i

i zero +ill to !

i end of table I

Figure 9-2 D€vice Table Foift€t

T h i s 3 8 - b g t e t a b l e u i 1 1 h o l d € n € x i , n u | no + 1 2 e n t r i e E , u , i t h t h e
last 2 bgtei being zero. CIO EcanE th€ table from the end to
the beginning (high to Iou addresE), so the entrg nearest the
end of the table 0rill teke precedence in Eese of nultiple
o c e { r t l e n c e 6 o f a d e v i r e n a m e .-

The device naoe +or etsch entr! is e single ATASCII rharaeter, end
the hendler addres€ points to the hendler's vecto1. tab1e, thet
tri.II be de6cribed in the +ollo0rino section.

CIO/HANDLER INTERFACE

This 5e€tion de5€ribes the interface betueen the Centl'al I/0


utilittJ and the individrral device handlerE thet are repreEented
in the Device Tabl€ (a6 deE..ibed in the preceding Ee.tion).

| O16555 --
O P E R A T I N CS Y S T E I ' C Section 9
C a1 1 i n g H e r h a n i s m

E a c h h a n d1 € r h e 6 a v e E t o r table a E shoorn bElour:

+ O P E Nv s . t o r - + ( lo|l, ed d l.ess l
+---------*------+
+ CLUSE vec tor +
+----------------r
+ OETBYTE vector +
+----------------+
+ P U T B Y T Ev e c t o r +
+----------------+
+ OETSTAT vec tor +
+----------------,
+ S P E CI A L v e c t o r +

+ JMP init code +


+ + (high eddressl
+------------'---+

Figure 9-3 Handl€i V€ctor. Table

The devi{e tabts entr.U +or the handter pointE to the first
brJte of the vectoi table.

The firEt €ir entries in the tabte aie vectors (to,hi) that
c o n t a i n t h e € d d r e s s - 1 o f t h e h t s n d 1 e ?r o ! t i n e t h a t h a n d l e s
the indicated fun€tion- The seventh entrg is a 650A JMp
instl"uction to the hendler initiali!ati.on routine. CIO uEeE
onlq the addresses conteined in this table +or handler. entrg_
g a c h u s e r . / C I 0 E o m m a n dt r a n g l a t e g t o o n e o r m o t e . s l t s to one
of the handle. entrieE de+ined in th€. veEtor tab1e.

T h € v e e t o f t a b l e p r o v i d e s t h e h a n d l e r a d d t . e s E e €f o r c e r t e r n
fired functions to be perfo.med to CIO. In addition, ooerarlon
paramet€rs also oust be pa66ed foi most +unction6. patamerer
pEssing i6 acconplished using the 6902 A, X. and y reqister6
and an IOCB in page O narned ZIOCB tOOaOl. In oeneral., l.eoister
A is used to paEE dat€, r-egiBter X containE tf,e index to the
originating IOCB, and regiEter y i6 {rsed f,o pe66 statuE
infordlation to CIO. The zero-page IOCB, iE a .op! of tne
originatinq IOCB, but in the coui6e of grocessino sotne
comm€ndE? CI0 can alter the buffer addr.essend b;f+er length
per'€n€terE in ZIOCB, but not in the origin€ting IOCB (Eee
Section 5 for information relating to the ot.iginating IOCB).

5€e Appendix B fo? the standa?d status bgte values to be


ieturned to CIO in regi6ter y.

OPERATINe gYSTEt'l C016555 -- Section 9


135
The +ollotrinq EectionE describe the CIU/handler interfEce for
eE€h of the veEtors in the handler vector tabIe.

H a h d1 € r I n i t i a l i r € t i o n

NOTEi This entrg doesn't appear to heve en{ function for


nonreEident handlers due to a bug in the curr.ent OS -- the
devi€e teble iE rle€red iD reEponse to sU6tefi reset as
urelI as pouef-up. This pr.evehts this entrg point fron ever
being €€l1ed. The rest of this gection discu6ie6 the
intended use o+ this entr{ point. Confof ation uould be in
oider to EIloll, cofipetibilit'J uith posEible co?r-ected
versions of the OS in the +uture.

The entrg u€E to heve been called on all dc€urrenEes o+


p o u r e r - u pa n d s g s t e m r ' s s e t , t h e h e n d l e r i s t o p € r f o r m
initieliration o * i t 6 h a . d ! r a r - e a n d R A l . ld a t 6 u s i n g a l . o u t i n e
f , h a t a s g u r . E s p r o p e r p r o c e s s i n g o f e l l C I O c o n r n a n d gt h a t f o l l o u r .

F u n ct i o n 6 S u p p o r t e d

This section deEcri.bes the functionE asEocieted {rith the first


sir vectorE fro{n the handler vector. tabl€. This section also
presents a brie+, device-independent descr.iption of the
C I 0 / h a n d l e r i n t e r + e c e € n d r e c b f l r m e n d e ad c t i o n s + o i e € c h f u n c t i o n
vect or.

I]PEN

T h i E e n t r q i s c e l l e d i i 1 i e g p o n € e t o a n O P E Nc o m m e n dt o C I o . The
h a n d l e r i s € x p e c t e d t o v a l i d a t e t h € O P E Np a r a d e t e l ' E a n d p e r f o r m
ang !'equtred device initialization €sEocieted {rith a device OPEN.

At handler entr.!, the follouring parameterE can be of intereEt:

X = index to o"iginating IOCB.


Y = S92 (EtEtus = flnction not implemented b9 handler).

I C D N A Zf O O 2 1 l = d e v i c e n u f t b e r ( 1 - 4 , f o . n u l t i p t e device
h a n dl e r E ) .
I C B A L Z . / I C B A H Z[ O O 2 4 , / O O 2 5 l= a d d r e s s o f d e v i r s , / + i l e n a m e
specificEtion.
I C A X l Z / I C A X 2 Z t O O a A . / O O A B= I d e v i c e - s p e c i f i c information.

T h e h a n d l e r e t t 6 m p t s t o p e r f o r m t t r e i n O i c a t e d O P E Na n d
indicates the statu6 of the operation bq the value of the Y
r e g i s t e i . T h e r e 5 p o n s i b i l i t V + o r c h e c k i n g f o t . f t u l t i p l e O P E N gt o

O P E R A T I N GS Y S T E i 4C O 1 6 5 5 5 - - ge.tion 9
13h
the sane deviEe oi fi1e, ohere it is illeoal, lies o,ith the
h e n dI e r .

T h i s v e t t o r t a b l e e n t r g i E c a l l e d i n r " e s p o n s e t o s C L O S Ec o m m e n d
to CIO. The hendler iE expected to r.elease ang hetd reso!,r.ee5
that r€lete gpecificallrJ to that device/fil.enarhe, and for. output
fileE to:

1) send ang dat: rem€ining in handler bufferE to the device,

2) oart th€ end of +i1e

3) upd€te ang a€societed directories, allocation fiaps! etc.

At handler entrg, the folloaing paraneters csn be of inte.est:

X = index to originating IUC8.


Y = |l92 (statug = function not ioplemented bg handler).

I C D N O ZC O O 2 1 1= d e v i . c e n u o b e l . ( 1 - 4 , f o r n u l t i p l e device
handlers).
I C A X I Z / I C A X ? Z T O O A A / O O 2 B =l d e v i E e - E p e c i + i c infor|natioh.

T h e h a n d l e r . a t t e m p t s t o p e . f o r n t h e i n d i ( e t e d C L O S Ea n d
indi.ates the 6tatu5 of the operation brJ the value of the Y
ieg i s tel'.

CIB relerges the associeted IOCBa+tei- the handler returns,


?egaidleis of the operstion 6tatus vaIue.

GETBYTE

.-- Thig vector. table entrU is c€11ed in r.esponseto a GET


C H A R A C T E RoSr C E T R E C O R D€ o m d l e n dt o C I O . T h e h a n d l e r i E
expected to r.etuin a Eingle bqte in the A regi6ter, or ieturn an
e?ior gtat!6 i.n the Y regiEter.

At handler entrg, the follou,ing peremeters can be o+ intere6t:

X = index to originating IUCB.


Y = $9? (€tatug = *unction not ioplemented bq handler).

I C O N O Zt O O 2 1 l = d e v i c e n u m b e r ( 1 - 4 , f o . m u l t i p l e d e v i c e h a n d l e r E ) .
l C A y . l Z/ I C A X ? Z t O O A A / O o a B l = d e v i c e - s r e c i f i c i n f o r n t s t 1 o n .

T h e h a n d l e r u i 1 1 o b t a i n a d a t e b q . + €d i ! . e c t l ' J f . o m t h e d e y i c e o r ' f . o r n s
h a n d l e r ' _ m a i n t a i . n e db u f f e r 6 n d i e t u r n t o C I 8 u i t h t h e b u t e i n t h e
A r'egistei and the operation Etatui in the Y register.

O P E R A T I N CS Y S T E I 4C U 1 6 5 5 5 - - S€ction 9
137
Handlers th6t do not h€ve shoit timeouts asEociated urith the
ieading of deta (such a5 the Keqboard end CaEEettE Handleisl,
m u s t n o n i t o r t h e I B R E A K I k e g f l a g B R K K E Yl O O 1 1 l a n d r e t u r n u i t h a
stetu6 of $8O uhen a tBREAKIcondition occufs. See Appendir L,
85, and Section 1e for a discuision of,CBREAKItel, fionitoring.

CIO checkE for reads fron device/fiIeE th€t heve not baen o!ened
or have been opened for. output onlgi th€ handlet' {ri11 not be called in
t h o s e c€ s e s .

PUTBYTE

T h i s e n t r g i E € a 1 1 6 d i n r e 5 p o h s e t o e p U T C H A R A C T E RoSr p u f
RECORD c o m f l l e n dt o C I O . T h e h e n d l e r i 5 e r p e c t e d t o a E c s p t a s i n g t e
bgte in the A registei oi return an error Etetus in the v
ieg i 9ter.

At hendler entrg, the follouing p a r " B m e t e r . c6 a n b e o + i n t e r e s t :

X = inder to origin€ting IOCB.


Y = S 9 2 ( s t a t u s = f u n c t i o n n o t i m D I e t l r e n t e db t h : n d l e r ) .
A = det€ bgte.

I C D N O Zf O O 2 l l = d e v i c e n u m b e r ( 1 - 4 , f o r r n u l t i p l e d e v i r e
h a n dl e r s ) .
ICAXIZ/LCAX?Z [O02A/OO28J= device-specific information.

The handler Eendg the data bUts dir€ctlU to the devi.e, or to e


hendler-naintained buffer, and r€turns to CIO orith the oper€tion
statu6 in the Y regieter. If a handler-maintained bu+fer fi11s,
the h€ndIei uill Eend the bvffer€d dst€ to the device b€fore
r e t u r n i n 9 t o CI O .

C I O c h e c l s f o r W R I T E st o d e v i c e , / t i l e s t h a t h a v e n o t b e e ' l o o e n e d .
or have baen opened for input onlg. The handler. u,ilI not be call€d in
t h o s e ca g e E ,

N o u , t h t s t t h e n o r m € 1 o p e r a t i o n o f P U T B Y T Eh a s b e e n d e f r n e s , a
speciel case nu6t be added. Ang handler that ui11 op€r€te l|rithin
the enviionnent of the ATARI AK BASIC lang!a9€ interpreter has a
diffefent E€t of ruleE. Because BASIC c€ln ce11 the handler
P U T B Y T Ee n t r r J d i f e c t l g . uithout going through CIO, the zero-page
IUCB (ZIOCB) can or mag not have a rslation t o t h e P U T B Y T Ec a l 1 .
Thei'efor€, the handler must oEe the outer level IOCE to obtain
ang inforoation that uould noimallg be obtained f.om ZIBCB. Note
E l s o t h a t t h e O P E Np l ' o t e . t i o n n o r m a l l q p r o v i d e d b r t C I O i s
b{paEsed (i.e. P U T B y T Et o e n o n - O P E N d e v i c e / f i l e € n d P U T B Y T Et o a
.ead-on 1g OPEN,.

O P E R A T I N CS Y S T E MC O 1 6 5 5 5 - - S€€tion g
134
EETSTAT

This entr.q iE c€I1ed in respon6e to a OET STATUS codnend to CIO.


The handler is expeEted to return foui bltes of statuE to melnor"q
or return 6n erior statls in the Y reqistef.

At handler entrq, the follouing p a . a t n e t e r ' 5c e n b e o f intereEt:

X = ind€x tg otiginating IOCB. Y = $92 (stEtus = function not


iop l enented bg handler ).

I C D N 0 ZI o o 2 1 l = d e v i c e n u n b e r ( 1 - 4 , f o r m u l t i P l e d e v i c e h € n d l e r s ' .
I C B A L Z / I C B A H Z t O O a 4 , / O O 2 5 l= € d d r e 5 3 o +
d€vice/+ i 1enafiespeci+icetion.
tcAxlz/ rcAxzz
I O 0 " A / O O ? B 1= d e v i c e - E p e € i + i . inf ormation.

Ihe handler 9et6 device 9t€tui information fro$ the deviae


cont.ollei a n d p u t s t h e s t a t ! 6 b g t e s i n D V S T A Tt O A E A I t h r o u g h
' D V S T A T + 3 ,a n d f i n a l t q r e t u r n s t o C I O u i t h t h e o p e r € t i o n E t e t u s
in ieg ister Y.

The IOCBneed not be opened not Elossd in order for gou


t o r e q u e g t C I O t o p e r + o t m e e E I S T A T U So p e r a t i o n ; the handlet.
ougt chec* uheie t h e r e a?e r e s t r i c t i o n s . S e e g e E t i o n I foa a
di6crrssion of the CIO sctiqn5 i n v o l v e d ! r i t h a G E T S TATUS
opetstiDn u6ing both open a n d e l o s e d I O C B ' E , a n d n o te the ifipact
of thi6 oDeration on the uee o f t h e b u f f € r a d d r e s E p arameter.

SPECIAL

This hsndler. entrg i5 !eed to suppoit e11 fun€tioni not hEndled


bg th4 other entr{ points, EUch as disl€tte f i l e R E N A H E ,d i s P l a g
D R A W ,e t c . S p e c i f i c € l l g , if the 1OCB c o l n t n e n db g t e v a l u e i E
greater than tOD, then CIO orill uEe the SPECIAL €ntrq point. The
h a n d l s r n u s t i n t e r r o g a t e t h e c o n r n a n db g t e t o d e t e f m i n e i t t h e
'- requ€sted operation i5 suPported.

At handtei entr{, the follouing patam.teiE tan be of int€r'€5t:

x = inder to originating IOCB.


Y = $92 ( s t e t u 6 = *unction not impleoent€d bg handleI.).

I C D N A Zt O O 2 1 l = d e v i c € n u m b e . ( 1 - 4 , f o r ultiple d€vit€
handlersl
I C C U M Zt o o z z l = c o o o a n d b g t e .
ICBALZ/ICBALH IOO24/OOas] = bu+fei addre55.
ICBLLZ/ICELHZ tOOaA/OO29! = buffer length.
ICAXIZ / ICAX?Z |OO?A/ OO2B1 = ilevi€e-3p ec i f i c inf oifiati on.

OPERATINGSYSTEM CO16555 -- Section I


135
The handler uill perfoifn the indicat€d opei.ation, if po6sible,
and return to CI0 uith the oper€tion gtet!s in register y.

Ihe IBCB need not be opened nor cloged in oider for uou
t o r e q u e s t C I O t o p e r f o r i n s S P E C I A Lo p e r a t i o n , t h e h i n d t e r
tnu6t che€k {rh€ie th€pe ar"e r.estriction5. See gection S for
e
discuEEion o+ the CIO ections involved uith a SFECIAL
op€tatiof| uEing both open and closed IOCB.s, and note the
inpact of this on the u6e of the buffer address pitraoetei.

E r r d r . H a n dI i n 9

E r r o r h a n d l i n g h E s b e e n E i m p l i f i e d E o m e u h e tb q h € v i n 9 C I O h 5 n d l e
o u t e r l 6 v e l e r r o r . s a n d h € v i n g S I 0 h s n d1 e S e r i € l b u 6 e r r o . t ' s ,
l e a v i n g t h e h a n d l e . t o p r o r e E s t h e r e m ai n i n g e i . r o r E . These
efiot s inc l ud€:

out-o+-renge par'ameterE
TBREA(l teg abor t.
Inv€ I id command.
Read after end of file.

The curren t hahdlel's reEporld to error s uging t h e + o t l o u i n g


guidelines:

Theg leep the racoverg simple (end therefore predictable and


r€teatablel.

Theg Do not inteiect diiectlg uith Uou +or resoverg


instruEtionE.

Ther, Iose es little datE as pogsible.


Theq nEke a1t 6ttempts to naintain the ifltegritg of fite
or i ented devic€ storags -- t h i s i . n v o l v e s t h E i n i t i a l desion
o f t h e E t r u . t u i € 1 e l € f l p n t q e6 {rell a5 ef!.or }ecovei!
teEhniques.

Resoufc e Al location

Nonre6id€nt handle!.6 needing code end/or data spEce


i n R A F Is h o u t d
u6e the techniq!e6 !isted belour, to 65sure nonconflict {ri€h other
partE o+ tfre OS, inrl!ding o t h s r n o E i e s i d e n t h e n dl e r s .

OFERATINOSYSTEH c o r 6 5 5 5 - - SBetion 9
140
Zero-P€qe RAM

Z e ? o - p € g e R A I ' Ih € s n o s p a f e b g t e s , a n d e v e n i f t h e r e u e r " e , t h € r e
_
i5 no €tlo.etign s€hefle to Eupport nultiple p.ogrE$:ssiqnfienf, of
the spare!i, There+ore, the nonresident htsndler must seve i|nd
regtore the bgtei of zeio-page RAMit iE going to ure. The bgtes
to u5e muEt be chosen c€re+ullV, €{rording to the *ollouing
€riteria:

The bqteg .annot be ec€eE6ed bg an interrupt ro{Jti,ne.

The b9te6 csnnot be acceEs€d b{ eng noninterr.upt code


betueen the time the handl€r modi+ieE the bgtes and then
reEtor.es the origin€1 values.

A simple seve/r.estor.€technique uould utilize the stack in a


oanner 5imilar t o t h a t s h o { r r nb e l o u r :
LDA COLCRS , (for Eranple)
PHA ; SAVE ON STACK.
LDA COLCRS+1
PHA

LDA HPOINT r HANDLER'S POINTER.


9TA COLCRS
LDA HPOINT+1
STA COLCRS+1

XXX (COLCRS),v r D O Y O U RP O I N T E R T H I N G .

PLA ; RESToRE ULD DAIA.


5TA CBLCRS+1
PLA
STA COLCRS

Note that the Displaq HandIer.ol Screen Editor Ehould not be


c a l l e d b e f o r e r e s t o r i n g * h e o r i g i n a l v a l u e o f C O L C R S ,b e t a u s e
C O L C R Si s s v a r i e b l e u 6 e d b u t h o s e r o u t i n e s .

N o nz e r o - P a g e R A H

There is no allocation schemeto support the assignflent o+


+ i x e d r e g i o n 6 o f n o n z e r o - p a 9 e R A I ' 1t o e n q s p e . i f i c process, Bo the
h a n dI e r h s E t h i e e r h o i c e s :

1. l,lake a dgnamic alloc€tion at initieliretion tifie b9


a ] ter in9 MEt'lLO
tO2E7l.
3. Include the variables urith the handler for RAM-Tesident
handler'8. This still involveE slterino H E H L Oa t t h e t i r n e
t h e h a n dI e r i 6 b o o t e d .

3. If the handlei ieplaces one of the regident handlel.E (bq


removint the resident handl€I.'5 entrg in the device
table), then the neu handler €an u5e anu RAlilthat the

O P E R A T I N CS Y S T E MC 0 1 6 5 5 5 - - Section ?
141
former.lg !'€s i dent hend I er tlou I d h€ve uged

S t a r I S p a Ee

In no5t caseE, there are no restrictions on the use of the Etac&


bg e h€ndler. Hotl,ev€r, if the handler planE to push more th€n a
touple dozen bqteE to the 6tacki then it should do e 6tack
overf lo{r,test, and aluraUs leave gtacl gpace for interrupt
pfocessing.

HANDLER,/SII] INTERFACE

ThiE section describes ths interface betue€n Eerial buE devire


handlers €nd the serial bu6 L/O utilitq (SIA). SIU coflpleteIg
handle5 all bos transactions folIouing the device-independent bug
pr"otocol. S10 i6 re6pon5ible for the fol1ouin9 functionE:

Bus detE +or|net and tining fron computer efld.

Error deteetion, retries enal statuEes.

Bus timeout.

Tr€nsfel o + d a t a b e t u r e e nt h s b u s € n d t h s c a l l e r . E buffer.

Calling Hechanis

SIO has a Eingle entrg point SIUV tE459l for eII oDeretionF. The
devi ce contro I blork (DCB) tO3OOl containE all pareneters oassed
to SIB. The DCE c o n t a i n s t h e f o t l o l r j . n g b g t e s :

D E V I C E B U S I D -- DDEVTC to300l

The bu6 ID of th e device is Eet bV the h€ndler. p.ior to celling


S I O ( s e € A p p e n d iI l r .

DEVICE UNIT * -- DUNIT IO301l

ThiE bgte indi€stes that of n unitE of d given d€vi ce EqPe to


arceEs, and is set b{ the handler. prior to cElling SIO. This
v a l u e u s u a l l q c o m e s f r o m I C D N O Z .S I D a c r e E s e s t h € b
llrhose addr.es: is equal to the value of DDEVICotui D U N I T m i n u s 1
(the louegt unit nunber iE normtsllg equal to I ).

-.
DEVICE COHI.IAND DCOMNDTO3OE]

The handler Eets thii bVte prior to celling SI0. It ui 1l be sent


t o t h e b u 6 d e v i c € a s p a r t o f t h e c o r n o a n df r a m e . g e e A p p e n d i x I
f o r d e v i c e c o { | r d r a n db g t e v a l u e s .

O P E R A T I N CS Y S T E MC O l 6 g g S - - Section
DEVICE sTATUs -- DSTATS tO3O3]

This hgte iE bidiiection€1. T h e h e n d l e t u r i I I u s e D S T A T St o


indicEt€, to SIO 'rrhat to do eftei the rommend +r6me iE sent €nd
a c k n o { r 1 e d g e d .S I O u r i l l u E e i t t o i n d i c e t e t o t h e h a n d l e r t h e
stetu6 of the requested operation.

Prior to an SIO ca1li

7 o
+-+-+-+-+-+-+-+-+
lWlRl (J'tused i
+-+-+-+-+-+-+-+-+

Wh€re: W,R = O,O indicate5 no data tran6fer. iE agsociated 0rith the


operation.
O,1 indicates a deta +rame i6 expected frol|| the deviae.
1,O indiEate6 3 date fr.ane is to be sent to the deviEe.
1,1 is invalid

A +t e r a n S I O c e l l :

7 o
+-+-+-+-+-+-+-+-+
I statuE code i
+-+_+-+-+-+_+-+-+

See Appendir C for the Fossible SIO operation 6tatus EodeE.

HANDLER BUFFER ADDR€SS -- DEUFLO,/DSUFHI TO3O4/O3O5]

Th€ hendler sets this 2-bqte point€r. It indicatei the Eource


or dastinstion buffer for device data of st€tur infoiflation.

DEVICE TIFIEOUT _- DTIMLO 10306]

Ihe hendle? sets thi5 bqte. It specifier the device timeout time
in units a+ b4/6O o+ d second. For exatnple, a count o+ 6
speci+ies a ti.neout of 6.4 secondE.

BUFFER LENGTH/BYTE COUNT-- DEYTLD./DBYTHI[O3OA,/O3O9]

The handler sets this 2-b!te count for the EUirent


o p e t a t i o n , € n d i n d i c a t e s t h € n u . F n b eor f d a t e b g t e E t o b e
ttan6fer.red into or out of the buffer. This paranetei is not
t'eqlired i + t h e S T A T U Sb l t e t J a n d R b i t s e r ' e b o t h z e r o . T h e E e
valuei indirete that no dat€ tr'EnEfet is to tale rlace.

I ' { A R N I N G :T h e r e i s a b u g i n S I O t h e t c a u s e s i n c o r r e c t
e E t i o n s { r r h e nt h e 1 a 9 t b g t e o f a b u f f e r i s i n a o e m o r {
addr.esE endinq in $FF, such as 13FF, 4eFF, etc.

T]PERATINOSYSTEII COl6555 -- 5e€tion 9


143
AUXILIARY INFORHATION.. D A U X 1 / D A U X E TO 3 O A / O 3 O B]

The handler setE these E-brJte6. The SIO inrludes thelll in the bu5
condand +rade, theg have device-specific meaning€.

F u n c t i o n 5 S u pp o r t e d

S I O d o e s n o t e r € d i n e t h e C O H M A NbD{ t e i t 6 e n d s t o t h e d e v i c e ,
becau5e el1 bur transactions ere expectsd to ron+orft to e
univarg€l pr.otorol. Ths protocol includ€s three forfts, stated
belou, (as 5een fiom the rofiouter ):

Send comm6ndfnefie.
gend commandfraoe and gend dats fram€.

S e n d c o t n f t a n d+ r : m e e n d r e c e i , v e d a t a f r € r f l e .

The velues of the t, and I bits in the statug bgte Eelect the
c otlftand f or.m.

Error H a n d1 i n g

SIO hendleE moEt o+ the Eeriel buB errorE foi. the hdndler,
as ind i cated belolr:

8 u 9 t i n e o u t - - S I O p r o v i d e s e u n i f o r . m E o m m e n df r : t n e a n d d a t a
ft'ame ACK bvte timeout oe L/6O oC € seEond - O / + 1/he.
T h e h € n d l e f E p e c i + i e s t h e n e x i m u m C O M P L E T bEg t e t i t n e o u t
value in DTIHLO.
gus errors -- SIO dete.ts snd ?eports UART overrun and
fTeming errorE. The sen6ing of thess e!-rors in €rnl received
bgte uill c€use the entire assoc;ated +rame to be conEidened
bed.

D€ta +rem€ rhesksufi error -- SIO validate5 the cherk6um on


all ieceived data +raoes and qenerate6 a checksuo for €Il
tr€nEmi tted fralnes.

Invalid ?esponse +rofi device -- in addition to the er.ror


conditions etated €bove, SI8 chec*E that th€ ACK end
CDI'{PLETEie6ponses Ere pr.oper (ACK = S41 and CBI,IPLETE=
$43,. ACK €tands +or a.lnouledqe.

8us op€rEtion retrieE -- 5IA lrill attempt one cornplete comnand


retrg if the fiiEt attempt iE not err.or +ree, urherea complete
conoand trV conslEts o+ up to l4 etteopts to send (end
a c l n o d l e d g e t a c o l n m 5 n df ? a m e , f o l l o o e d b q € s i n g l s a t t e m p t t o

I 016595 --
O P E R A T I N GS Y S T E I ,C Section 9
144
rereive the COI'IPLETE
code and Fo5siblq a dste fraoe.

NOTE: There is a bug in the retrg logi€ for deta {trites,


6 ! c h t h a t i f t h e r o m m a n d+ i a l n e i 6 € c * n o u l e d q e d b g t h e
rontroller, but the datd +relne is not €cknouledged, then SIO
0rilI retrq indefinitel!.

Unified eil.or 6tatus code6 -- gIO provides device_indep€ndent erioi


c o d e s ( 5 e € A p pe n d i r C ) .

SERIAL I/O BUS CHARACTERISTICSAND PROTOCOL

This 6ertion describe6:

o The ele€trical .h€racteristiEE o+ the ATARI 4OO


e n d A T A R I 8 O O H o r n eC o m t u t e r s E e r i a I b u E

o lhe uss o+ the bug to send bUtes of dete,

o Ihe organiztstion of the bqteE a5 r'frafte5" (records),

o T h e o v e r a l l c o r D n a n ds e q u e n c e E t h e t u t i l i z e frames
and i'€5ponie .b9tes to ptovide coftPUter/periphertsl co nonication.

H € r d u e r e / E l e Et r i c a I c h € i a c t e r i 9 t i c s

The ATARI 4OO and the ATARI eOO Homs Codputers


c o r n m u n i c a t eu r i t h p e r i p h e r a l d e v i c e s o v e r ' 3 1 9 , a O O b a u d
asqnchronous seiial port. The 5eria1 port consists of a !eri€I
D A T AO U T ( t r a n E m i E s i o n ! I i n e , a s e r i a l D A T A I N ( r e c e i v e t ) I i n e
end other mi.6cellaneolE control lines.

Data is tiansmitted and received tss I bitE o+ serial data (LSB


6ent firEt) pteceded bq € logi€ zero start bit and succeeded
b g a l o g i c o n e e t o p h i t . T h e s e r i a l D A T AO U T i 5 t r a n s m i t t e d a g
poEitive loqic (+4v = one,/true/hi9h, Ov = zero/+alEe/Iou' The
Eei'ia1 SATA OUT Iine alu,egE assuroes its nFU 6tate uhen the
e e t i a l C L O C KO U T l i n e g o e g h i g h , C L O C KA U T t h e n g o e e l o ! , i n
t h e c e n t e i o f t h e D A T Ao U T b i t t i m e .

An end vieu of the ge!'i.el buE connector Et the computer or


peripherel is Ehoun belou (thE cable connectors u,o!ld of
course be a nirrof image):

I O16595 --
O P E R A T I N oS Y S T E I ' C gection I
2 4 6 A 10 1?
o o o o o o

o o o o o o o
1 3 5 7 I 11 '3

uhere: 1 = c o d r F u t e i C L O C KI N .
2 s Eooputer CLOCI,(UUT.
3 = conputer DATA IN.
4 = OND.
5 = computer DATA OUT.
5 = GND.
7 = C0HMAND-.
a = HOTORCONTROL.
I = PROCEED-.
1O = +5v,/READy.
11 = ro.nputer AUDIO IN.
12 = +72v.
13 - INTERRUPT-.

FiguFe 9-4 Serial 8us Connector Fin 0€s€riptions

C L O C KI N i s n o t u 6 e d b g t h e p r e 6 e n t O S e n d p e r i p h e r 6 l s . T h i e
l i n e E a n b e u B e d i n f u t u r e E g n c h r . o n o u sE o m m u n i c e t i o n s E € n e m e t i .

C L O C KU U T i s t h e E e r i € 1 b u 5 c 1 o c k . C L O C KO U T g o e E h i q h a t t h e
s t a r t o f e E E h D A T AO U T b i t E n d r e t u r n s t o ! o { , i n t h e n i d d t e o f
each bit.

DATAIN is the Eerial bu5 data line to the conputer.


Pin 4 CND is the Eignal/shield ground tine.

D A T AO U T i s the serial bus dEts Iine fron the computer.


Pin 6 CND is the Eignal/Ehield 9l.ound 1i.ne.
C O i ' l t ' l A N Di 9
- normallrJ hiqh end 9oe6 lou uhen e command$raoe i6
b e i n g s e n t + r . o mt h e . o m p u t e r .

MOTOR C O N T R A Li s the c6ssette notor control Iins (high=on,


lou= of +).

P R O C E E Di-6 n o t u s e d b 9 t h e p r e e e n t O S a n d p e r i p h e r a l s , thi5 tine


is pulled high.

+ 5 V , / R E A D iYn d i c a t e s t h a t t h e c o m p u t e r r 9 t u r n e d o n e n d r e 6 d q . T h i E
line can a16o b€ used as a +g volt gupplrJ of soma Eurrent rating
foi ATARI periph€raIs on1g.

A U D T Ot N a E c e p t s a n a u d i o B i g n a l f i o f i the casEette_

OPERATINOSYSTEI'ICC116599-- Section 9
L46
+12V is € +12 volt s u p p l { o f u n k n o u n c u r r . e n t .at ing for A T A RI
per iphera I s onlg.

I N T E R R U P T -i s n o t u s e d b g t h e p r e s e n t OS and p e r i p h e r a1 5 , t h i s
l ine iE rulIed hioh.

There ere no pin rees6ignments made in the Serial bus ceble,


5o pin 3, the conputer,E DATAIN line, i9 the 9el.irher.al.9
date output Iine, snd sinilarl'J +or pin S.

Seria 1 Fort Etectric€1 gpecificationg

Periphe.al input:

VlH = 2. Ov rnin.
VIL = O.4v lrlex.

ItH = eo!e. n€x. @ V1H = 2. Ov


Il.L = 5ua. fitsr. e VlL = .4v

Periphel'al output (open col lector bipolar ':

V O L = O .4 v m € x . @ 1 . 6 m a .
VOH = 4. 5v min. urith external lOOKohn putl-up

VccIREADY inp ut:

V1H = a. Ov min. e I1H = 1oa. mar.


V 1 L = O . 4 v l n €x .
Input 9o€s to Iogic zero uhen open.

B U E C o m m a ngd

T h € b u s p r o t o r o l g p e c i f i e s t h a t a I t c o m m a n d sf t o E t o r i g i n a t e + r o m t h e
computer, and th5t peripherals uill present deta on the buE onl{ rlhen
c o i n m a n d e dt o . E v e r ' g b u s o p e i a t i o n 0rill go to coopletion before
another bus oper.tion iE initieted (no ov€rlepl. An error detected at
ang p o i n t i n t h e c o o o a n d E e q u e n c eo i l l aboit the entiae Eeqoence.

A bus operEtion consist6 of the +o11or!in9elelnentE:

Comnend frame from the comrute.t..

Artnouledgeftent (ACK) +rom the peripher.al.

Optional data f"e e to or. from the rodrputei.

O p e r e t i o n c o m p l e t e ( C A H P L E T E f) r o m t h e p e r i p h e . a l .

O P E R A T I N eS Y S T E I iC O 1 6 5 5 5 - - Section 9
147
Coflnr3nd Ffafie

The eeriel bus protocol provides for three tVpe6 of connandst l) data
s e n d , 2 t d . t a r e c e i v e a n d 3 ) i r n n e d i s t e ( n o d e t a - - c o m m a n do n l u ) .
T h s r e i B € c o f t m o ne l e n e n t i n € 1 1 t h ? e e t g p e 6 , e c o m m a n df F a m €
conEisting of five bqtes o+ infornation sent froln the compuxer
u h i l e t h e C O M H A N D l-i n € i 6 h e l d l o r ! . T h e $ o i m € t o f t h e c o m o € n d
+ralne ls
5ho{rn b e Io{r:

+----------------+
! device ID !

I coonand i
r_________-______+
i aurilia!"g *1 I

i EUxiliarg *e !
+----------------+
I chec&surl I
t----------------+

Figure 9-5 Seridl Bus Comntsnd


F?ame For,ne t

The device ID specifies thet of the 6eiial !us deviceE iE being


address€d (E€e App€ndix I +or a liEt of device tDs)-

T h e c o r n m a n db g t e c o n t E i n s E d e v i c e - d e p e n d e n t aommand (Eee
Appendir I for € list of deviEe commsnds).

Ths €uxiliaig b9te9 contain more deviEe-dependent infornation.

T h e E h e c k s u n b q t e c + n t a i n s t h e € r i t h | n e t i E E U mo f t h e f i i s t four
b g t e s ( u t i t h t h e c a r r V a d d e d b a €f t e f t € r e v e r g € d d i t i o n )

C o n , n a n dF r a o e A r l n o u r l e d g e

The peripherel being addrerEed uould normallg r.espondto a


c o m m a n df r a m e b g g e n d i n g a n A C K b g t € ( A 4 1 ) t o t h e c o n p u t e r , i *
there is a probleo uith the romn€nd fr3tns, th€ peripher.al should
n o t ? 6 s Do n d ,

Data Frafie

APERATINe SYSTEI.ICO16555 -- Section 9


144
Follouing the Eommand f?amE (and ACKI can be an optionel date
fiame thEt i.E forltl€tted a€ shourn belou:

i but€s i
I
+----------------+
i c h e c* E u m i

This deta fretue can originate €t th€ computer oa at the device


contioller, depending upon the comnand.Curient device
controllerE expact fired-lenqth data frames aE does the co||lputer',
tlrhereth€ d6ta frame lenoth i6 a fired function of the device
-
tqpa End ro|nmand.

The €he€ksuo value in the deta fl'Etnei9 the arithfietic sum sf all
of the frane dat€ pre€eding the che€kFUm, '!ith the carrg +rofll
e a E h a d d i t i o n b e i n o a d d e d b € E l ( t h e E a m ea E f o l . t h e c o o o e n d
frame).

In th€ case of the cofllplter sending a d€ta fr€me to e peripheral,


th€ peripheral is experted to gend an ACK i.f the data frEme i6
€cceptable, and Eend a NAK (S4E), or. do nothing i+ the date frame
is unacceptable. See the +ir5t flouchar.t in Section 9.

O p e r a t i o n C o n pI e t e

A peripheral is:1so e r p e c t e d t o 6 e n d a n o p e f a t i o n - c o M P L E T Eb g t e
( 9 4 3 ' 6 t t h e t i m e t h e c o n m a n d e do p e r € t i o n i s c o n p l E t e . T h e
I o c a t i o n o f t h i s b g t e i n t h e c o t n m a n ds e q ! e n c e f o t e a c h c o o h a n d
- trtpe i.i Eholrn in the tioing diagranE in Section 9. If the
oPeration cannot go to notmal, etror-+tee coopletion, the
p e r i p h e r B t e h o ! 1 d r e s p o n d u i t h a n E R R O Rb ' r t € ( $ 4 5 ) i n E t e a d o f
COMPLETE.

O F E R A T I N eS Y S T E MC O 1 6 5 5 $ - - Section 9
149
Bus Titning

This section p.ovideE tifiing disgia|ns for the three tgpes of


to|nln€ndi€quence6: data send, data re€€iv€, end innediate.

DATA SEND Ee{uanc e:

coMhAND- I I
+--------+

+------+ +--- / /---+


DATA OUT i cnnd I I data I
----+frame +------/ /--+ +raoe +-------

+-+ +-+ +-+


DArAIN ':--rr--:
I .l------------ -----: :-
ACI( ACK CHPL
| | l t I i | | i i i
to tl t2 t3 t4 t5
D A T AR E C E M s e q u € n ce :
.\''/

cot'$tAND- i I
+--------+

DATA OUT I rlnnd i


----++iafie

+.-+ +-+ +----/ /----+


DArAIN
: :--,,--; i-i -l::: l--------
ACK CI'IPL

OPERATINGSYSTEM CO16555 -- Se.tion I


190
I H M E D I A T Es e q u e n ce I

c{]flMAND- i i

+------+
DATA oUI i cinnd I
----+irafie +--------------

+-+ +-+
DArA IN '' '*.--...--..-..--t
t-----l ,;----------
ACK CHPL

t0 t1 t2 t5
Fi.qute 9-6 Serial Bus Tirning Diagran

The conputer gene.ateE a delaq (tO) betureen the louering of COMI'IAND-


a n d t h e t r r n s m i E s i o n o + i h e + i r s t b u t e o f t h e r o d t h a n df ! a m e .

computer tO (oin) = 75O nicroEeE.


conputei. tO (mext = 1600 microsec.

periph€ral to (min' = ??
peripheiel t0 (max) = ?t

The cornputer gener€te6 € delaq (t1) betueen the tr€nstniEsion of


t h e l a e t b i t o f t h e c o f t d r a n d+ t ' a m e a n d t h e r . a i s i n d o f t h e C O M I . I A N D -
I i ne.

tornputer tl (oin) = 650 flic.oEec.


c o m p u t e r t 1 ( m a x) = 9 5 O f t i c r o s e c .

peripheral t1 (mifl) = ??
per.ipheral tl (ftar l = ??

The peripheral gsneret€r € delag (tA) betueen the r€lEin9 of


C O t l t 4 A N Da- n d t h e t r a n s m i E s i o n o f t h e A C K b t r t e b 9 t h ! p e r i p h e r a l .

EoopLrtert2 (tnin) = O nicroEeE.


co|nputer tZ (mexl = 16 ftEec.

per'ipheral t2 (ftin, = ??
peripheral t2 (&ar' = ??

O P E R A T I N OS Y S T E MC O 1 6 5 5 5 - - Section 9
151
The co|nputer g€nerateE a delaq (t3) bstureenthe i.eceipt of the
le6t bit of th€ ACK bgte and the transmission of the first bit of
the data frafte bl the tornpoter.

co|nDute. t3 ( m i n ) = 1 O O 0m i c r o s e c .
conpLrte. t3 ( n e x ) = 1 E } O On i c r o s e c .

peripher€1 t3 (minl = ?D
peripheral t3 (rnar' = ??

The periphetal generates a delsq (t4' betueen the transrnie6ion o+


the last bit of the date frame and the receiot o* the fiist bit
of the ACK bgte bg the co{rputer.

co$Dutea t4 (oin) = B5O nicrosec.


conputer t4 (mar) = 16 mEec.

peripher€1 t4 (min) = ?t
pe?ipheral t4 (naxl * ??

The Peiipheral gener€teE a d€t€g (tS) bet{reen the the receipt of


the last bit of the ACK blte End the fir6t bit of the COI4PLETE
bgte bg th€ romputer.

conputer tS (min) = aso fticfosec.


corDputertS (fierl = 255 sec. (handler-dependent)

peiiphe|,al t$ (oin) = ??
peripheral t5 (rlar) = N/A

HANDLER ENVIRONHENT

Nonresident handler6 can be ingtall€d in at lEest three di+feTent


oannefE:

1. 46 booted goftuare fron di5&ette or EaEEette.

e. Resident in e Eartridge (A or B'.

3. Dou,nloEd€d+rom € seritsl b!s device.

This seation uill d i s r r . r 6 Et h e b e s i c o e c h s n i 6 l n s f o r h e n d l e r


installation +or the6e envi.ronftents. In oider to fullq utilize the
infoFflation in thi€ section, uolJ mugt heve iead €nd onderstood the
follouing seations:

Prografi environoentE Sect ion 3


R A Mr € g i o n SeEtion 4
l'lemorq dgnamics. Serti6n 4
S!6ten initial i 16tion. Section 7
Adding neu deviEe hendleri/peripherali Section 9
P r o g ! ' a me n v i r o n { r e n t a n d i n i t i a l i r a t i o n gection 10

UPERATINC SYSTEI,ICO16555 -- Section 9


B o o t a b l e H a n dI e "

The distette- or ceEsett€-booted ioftlrare rrril1 insert the


handler'6 vector table oointei and naoe to the device table
uhenevei the booted Eoftlra?e'6 initializEtion entig point i9
ente?ed (on pour€r-up end s!5te|n !'e6et). Remeflber th€t both
poue?-up and cgEtem ?es€t c1€ai the device table of all but the
r e s i d e n t h a n dI e r e n t r ' i € 5 .

Cartr i dge ReEident Hendler

The cartridge Eofturare uilI inseit the handl€r'E vectoi table


pointeF and nafie to the devit€ t:ble uhen€var the certridge"
initialiration entrg point i9 ent€red (on po{rer-up and
sgstem reset'. R e l n e & b e r .t h a t b o t h p o u , e r - o p a n d € ! E t e | n r e t e t
clEat' the device table of all but the reEident h€ndlei €ntrie5,
thei€fore the device table .nuEt be r'€e6tEblished b'J the
handler-initielization procedure upon everg entirj.

FLOT.ICHARTS

The follduing pageE contain process flouahartg rhouring th€ SIO


and p€ripherel actions for the Serial bus conrand forng.

{ O16555 --
O P E R A T I N CS Y S T E T C Section 9
153
PERIPHERAL'SCOMIVIAND
FFAME PROCESSiNG

OPERATINGSYSTEH C416553 -- gieEtion 9


154
DATA FRAMETO PERIPHEFAL

OPERATINOSYSTEI'IC O 1 6 5 9 5- - 6sction I
DATA FRAI\'IETO COMPUTER

OPERATINo SYSTEI'iCO16595 -- giection g


156