an sla realization of the 6502 microprocessor...simpoe inputs o o o o o o o o o o 7 3 4o ahpl...

262
An SLA realization of the 6502 microprocessor Item Type text; Thesis-Reproduction (electronic) Authors Tsuyuki, Kenju Publisher The University of Arizona. Rights Copyright © is held by the author. Digital access to this material is made possible by the University Libraries, University of Arizona. Further transmission, reproduction or presentation (such as public display or performance) of protected items is prohibited except with permission of the author. Download date 11/06/2021 04:10:45 Link to Item http://hdl.handle.net/10150/557891

Upload: others

Post on 29-Jan-2021

0 views

Category:

Documents


0 download

TRANSCRIPT

  • An SLA realization of the 6502 microprocessor

    Item Type text; Thesis-Reproduction (electronic)

    Authors Tsuyuki, Kenju

    Publisher The University of Arizona.

    Rights Copyright © is held by the author. Digital access to this materialis made possible by the University Libraries, University of Arizona.Further transmission, reproduction or presentation (such aspublic display or performance) of protected items is prohibitedexcept with permission of the author.

    Download date 11/06/2021 04:10:45

    Link to Item http://hdl.handle.net/10150/557891

    http://hdl.handle.net/10150/557891

  • AN SLA REALI ZATION OF THE 6502 MICROPROCESSOR

    by

    Ke n j u Tsuyuk i

    A T h e s i s S u b m i t t e d to t he F a c u l t y o f t h e

    DEPARTMENT OF ELECTRICAL ENGINEERING• ' X .

    I n P a r t i a l F u l f i l l m e n t o f t h e R e q u i r e me n t s For t h e Degree of

    MASTER OF SCIENCE

    ; I n t h e G r a d u a t e C o l l e g e

    THE UNI VERSI TY OF ARIZONA

    1 9 8 1

  • STATEMENT BY AUTHOR

    T h i s t h e s i s has been s u b m i t t e d in p a r t i a l f u l f i l l ment o f r e q u i r e m e n t s f o r an advanced degr ee a t t h e U n i v e r s i t y o f A r i z o n a and i s d e p o s i t e d in t he U n i v e r s i t y L i b r a r y t o be made a v a i l a b l e t o b o r r o w e r s under r u l e s o f t he L i b r a r y *

    w i t h o u t s p e c i a l per mi ss i onp p r o v i d e d t h a t a c c u r a t e acknowl edgment of s o u r c e i s made* Re ques t s f o r p e r m i s s i o n f o r ext ended, q u o t a t i o n f rom or r e p r o d u c t i o n o f t h i s m a n u s c r i p t in whol e or i n p a r t may be g r a n t e d by t h e head of t h e maj or d e p a r t me n t or t he Dean o f t h e G r a d u a t e C o l l e g e when in h i s j udgment t he p r oposed use o f t h e m a t e r i a l i s i n t h e i n t e r e s t s of s c h o l a r s h i p * I n a l l o t h e r i n s t a n c e s , h o w e v e r , p e r m i s s i o n must be o b t a i n e d f rom t h e au t hor *

    B r i e f q u o t a t i o n s f rom t h i s t h e s i s a r e a l l o w a b l e

    S I N G E D ? ^

    APPROVAL BY THESIS DIRECTOR

    T h i s t h e s i s has been appr oved on t h e da t e shown bel ow

    F r e d r i ck^ F r e d r i c k j ^ H i l l P r o f e s s o r of

    E l e c t r i c a l E n g i n e e r i n g

    Dat ey f j j

  • ACKNOWLEDGMENTS

    I would I i ke t o exp r e s s deep a p p r e c i a t i o n to

    P r o f e s s o r F r e d r i c k Jo H I U f o r h i s g u i da nc e and a d v i c e

    d u r i n g t he p r e p a r a t i o n o f t h i s t h e s l s o

    I a l s o wish to t hank a l l t h os e who p a r t i c i p a t e d

    t he ha r dwar e d e s i g n l anguage r e s e a r c h p r o j e c t f o r t h e i r

    c ooper a 11 on o

  • TABLE OF CONTENTS

    L I S T OF I LLUSTRATI ONS. o' 0 o o O o 0 O

    P age

    0 v i i

    L I ST OF TABLES 0 0 = 0 0 ° 0 0 0 0 0 0 v i i a

    ABSTRACT 0 0 0 .0 0 0 0 ° 0 0 0 0 0 0 5 x

    INTRODUCTION. . . 0 0 ° 0 0 0 0 0 1

    THE 6502 MICROPROCESSOR 0 0 0 . 0 0 0 0 0 6

    Har dwar e O r g a n i z a t i o n . c 0 0 0 0 . 0 o 6I n p u t s and Out p ut s 0 0 0 0 0 0 p 7I n t e r n a l B u s e s . . 0 0 0 0 0 0 10I n t e r n a l R e g i s t e r s 0 0 0 0 0 0 13

    I n s t r u c t i o n S e t . . . 0 . 0 0 0 0 0 0 17Fundament a l I n s t r u c t i o n s 0 0 0 0 0 21A d d r e s s i n g Modes . 0 0 0 0 0 0 0 . 24

    INTERNAL OPERATIONS ANALYSIS 0 0 0 0 0 0 30

    Hy pot heses . . . . 0 0 ' 0 0 0 0 0 31Gener a l Sequence . . 0 0 0 0 0 0 0 32A d d r e s s i n g P a r t s . . 0 0 0 0 0 0 0 . . . 37

    I m m e d i a t e . . . 0 0 0 0 0 0 0 . 37A b s o l u t e . . . . • 0 0 0 0 0 0 38Z e r o Page . . . 0 0 0 0 0 0 0 41A c c u m u l a t o r . . . Q 0 0 0 0 0 0 41I m p l i e d . . . . O 0 0 0 0 0 0 42I n d e x e d I n d i r e c t . O 0 0 0 0 0 0 43I n d i r e c t I n d e x e d . 0 0 0 0 0 0 0 45Z e r o Page I n d e x e d . O 0 0 0 0 0 0 0 47I n d i r e c t . ; . . . O 0 0 0 0 0 0 48A b s o l u t e I n d e x e d . O 0 0 0 0 0 0 0 4 9R e l a t i v e . . ' . . 0 0 0 0 0 0 0 51

    E x e c u t i o n P a r t s . . . 0 0 0 0 0. 0 0 54Ar i t h m e t i c . . . 0 0 0 0 0 0 0 . 54L o g i c . . . . . 0 0 0 0 0 0 0 * . 62Load 0 . . . . 0 0 0 0 0 0 0 6 3S t o r e . . . . 0 0 0 0 0 0 0 0 64d URi p 0 0 0 . 0 0 0 0 0 0 0 64S e t / C 6 e a r . . . 0 0 0 0 0 0 0 . 66T r a n s f e r 0 . . . 0 0 0 0 Q 0 0 66

    i v

  • V

    TABLE OF CONTENTS — C o n t i n u e d

    Page

    StackO O O O O O O O O O O O O 6 7I n p u t s o o o o o o o o o o o o o o 6 9

    I n t e r r u p t I n p u t s o o o o o o o o o 70 SimpOe I n p u t s o o o o o o o o o o 7 3

    4 o AHPL DESCRIPTION o o o o o o o o o o o 77

    Dec l a r a t i ons o o o o o o o o . o o o o 77D a t a F e t c h C y c i e o o o o o o o o o o 78I n s t r u c t i o n Decodi ng o o o o o o © o © 80OP CODE F e t c h C y c l e o o o o o o o o o 88I n t e r n a l O p e r a t i o n s 0 o © 0 © © © 0 © 93

    Scheme Ao o o © © © © © © o o o 93Scheme B© o © o © © © © © © © © 97Scheme C© © © © © © © © © © © © 99S ch em e D © © © © © © © o © © © © 10 0Scheme E© © © © © © © © © © © © 104Scheme F© © © © © © © © © © © © 107E x e c u t i o n s ! O p e r a t i o n s © © © © © © © 109

    End of Sequence© © © © © © © © © © © 115Des i gn o f C o m b i n a t i o n a l L o g i c U n i t s © © © © 117

    ALU o o o © © 0 0 0 o o o o o 116INC o o o o o o o © o o o . o o 119DEC © O O 0 0 . 0 O O O O ' O 0 0 119

    5 © SI MULATION o © © © © © © © © © © © © 120

    HPSIM2© © © o o o o o o o o o o o 120M o d i f i c a t i o n s f o r S i m u l a t i o n © © © © © © 121R e s u l t s 0 © 0 0 0 . 0 0 0 0 0 © © © 126

    6 © SLA REALIZATION© o © © © © © © © © © © 131

    I n t r o d u c t i o n t o a S t o r a g e Log i c A r r a y © © © 131A l g o r i t h m f o r an SLA R e a l i z a t i o n © © © © © 134Ex pec t ed Ou t p u t s o f SLA T r a n s l a t i o n © © © © 138

    7© DISCUSSION AND CONCLUSION © © © © © © © © 141

    APPENDIX As 6502 INSTRUCTION SET SUMMARY © © © 145

    APPENDIX B s SUMMARY OF CYCLE BY CYCLEOPERATION OF INSTRUCTIONS © © © 152

  • TABLE OF CONTENTS — C o n t i n u e d

    APPENDIX

    APPENDIX

    APPENDIX

    APPENDIX

    APPENDIX

    APPENDIX

    LI ST OF

    Page

    C s INTERNAL OPERATION SEQUENCESOF INSTRUCTIONS 0 . o . o . 0 161

    Ds INTERNAL OPERATION SEQUENCESOF INPUTSo o o o o o o o o 210

    Es KARNAUGH MAP OF OPERATION CODES o . 216

    Fs 6502 AHPL DESCRIPTION o o 218

    G? COMBINATIONAL LOGIC UNITDESCRIPTIONSo 0 o o o „ o 226

    Hs EXAMPLE OF SIMULATION 0 o o . o 230

    REFERENCESo o o o o o o o o o o 252

  • L IS T OF ILLUSTRATIONS

    F i g u r e Page

    l o P i n C o n f i g u r a t i o n o f t he 6502 o o o 0 o „ 8

    2o 6502 I n t e r n a ! A r c h i t e c t u r e „ 0 =• = . 0 o 0 14

    3 o B i t C o n f i g u r a t i o n o f T y p i c a l R e g i s t e r s 0 o o 25

    4 o Genera 1 Sequence f o r I n s t r u c t i o n s o o o » o 34

    5.o Gener a l Sequence f o r I n t e r r u p t I n pu t s o o = 0 71

    6 o F l o w c h a r t f o r I n s t r u c t i o n Decodi ngo 0 o = o 89

    7o F l o w c h a r t f o r OP CODE F e t c h C y c l eand Scheme A o o o p o o o © o o © 92

    8© F l o w c h a r t f o r Schemes Bj> Cs> and D © © © © © 98

    9© F l o w c h a r t f o r Schemes D and E © © © © © © 105

    10© F l o w c h a r t f o r Scheme F andE xe cut i on a i O p e r a t i o n s © © © © © © © © 110

    11 © F l o w c h a r t f o r Execut i ona8 O p e r a t i o n s © © © © 116

    12© . F l o w c h a r t o f 8 - b i t M u l t i p l i e a t i on © © ©. © © 128c

    13 © 8 -5-b i t M u l t i p l i c a t i o n Program© © © © © © © 12 9

    14© Cl ock ed S t o r a g e Logi c A r r a y © © © © © © © 133

    15© Ou t p u t Fl ow o f SLA T r a n s l a t i o n © © © © © © 139

    v i i

  • L IS T OF TABLES

    Summary of i n p u t s and O u t p u t s 0 o o o

    I n p u t and O u t p u t C o n n e c t i o n s ofR e g i s t e r s and CLU°s o o o o o o 0

    Summary o f Ad d r e s s i n g R e g i s t e r s o o o o

    S p e c i f i c a t i o n o f t h e A r i t h m e t i c - L o g i c U n i t

    C l a s s i f i c a t i o n o f I n s t r u c t i o n s byA d d r e s s i n g Modes and Fea t ur es , , „ „ o

    v i i i

  • ABSTRACT

    The f a b r i c a t i o n o f a c o mp l e t e m i c r o p r o c e s s o r on a

    s i n g l e VLSI c h i p is now s t a n d a r d p r a c t i ce

  • CHAPTER 1

    INTRODUCTION

    I n r e c e n t l y p u b l i s h e d books' and magaz i nes on

    comput er s and d i g i t a l sys t ems* t h e t e r m* d e s i g n a u t o ma t i o n

    can o f t e n be e nc ount e r ed , , The d e s i g n a u t o ma t i o n as w e l l as

    t he t e r m* c o m p u t e r - a s s i s t e d d e s i g n g e n e r a l l y i m p l i e s des i gn

    method or a t o o l t h a t can a s s i s t d e s i g n e r s in d e s i g n i n g or

    d e v e l o p i n g p r o d u c t s in v a r i o u s f i e l d s such as d i g i t a l

    har dwar e sys t ems* comput er s of a l l s i z e s * and i n t e g r a t e d

    c i r c u i t s in t he f i e l d o f d i g i t a l syst em d e s i g n The des i gn

    a u t o m a t i o n can be a p p l i e d t o a l mo s t a l l a r e a s o f des i gn

    p r o c e s s e s because i t i s d e s i r a b l e t o s h o r t e n t h e t u r n a r o u n d

    t i me of des i gno .

    E s p e c i a l l y * f o r t h e d e s i g n o f v e r y l a r g e s c a l e

    i n t e g r a t i o n ( V L S I ) used in d i g i t a l sys t ems* t h e use of t he

    r e g u l a r i t y of p a t t e r n s f o r communi ca t i on bet ween a c t i v e

    e l e me nt s i s a b s o l u t e l y e s s e n t i a l t o i mpl ement a des i gn

    a u t o m a t i o n systemo A l t hough r e s u l t a n t p r o d u c t s r e a l i z e d by

    t h e d e s i g n a u t o m a t i o n system t e n d t o have r e d u n t a n t r e g u l a r

    p a t t e r n s * t h i s r edundancy can be j u s t i f i e d by t h e

    f e a s i b i l i t y of t he d e s i g n a u t o m a t i o n syst em* t h e s h o r t e r

    t u r n a r o u n d t i me of d e s i g n * and t h e s i m p l i c i t y o f des i gn

    1

  • pr ocesso

    For t h e pur pose of t h e d e s i g n o f d i g i t a l har dwar e

    s y s t e ms , har dwar e d e s i g n l anguages have been i n v e n t e d o The

    use o f a ha r dwar e d e s i g n l anguage i s one o f t h e i m p o r t a n t

    e l e me n t s of a d e s i g n a u t o m a t i o n systems A Ha r d wa r e

    Pr ogr ammi ng Language ( AHPL) , e x t e n s i v e l y d e s c r i b e d i n

    r e f e r e n c e 1 has been w i d e l y in use t o d e s i g n d i g i t a l

    syst ems = Some c o m p i l e r pr ogr ams have been i mpl ement ed in

    or der t o a i d t h e d e s i g n of t h e d i g i t a l systems d e s c r i b e d i n

    AHPL s i n c e AHPL was i n t r o d u c e d * However , a new m u l t i - s t a g e

    c o m p i l e r has been w r i t t e n in c o n n e c t i o n wi th, s e v e r a l new

    n o t a t i o n s and c on c e p t s added i n t h e e x i s t i n g AHPL*

    T h i s u n i v e r s a l AHPL w i l l be a u s e f u l t o o l f o r no t on l y t h e

    d e s i g n of c o n v e n t i o n a l d i g i t a l sys t ems b u t a l s o a VLSI

    imp I e m e n t a t i on *

    Anot her i m p o r t a n t e l ement of a d e s i g n a u t o ma t i o n

    sys t em d e s i gn e d f o r a VLSI i m p l e m e n t a t i o n i s t o use a

    r e g u l a r p a t t e r n f o r a b a s i c e l ement s A S t o r a g e Log i c A r r a y

    ( S L A ) , a d e q u a t e l y d e s c r i b e d in r e f e r e n c e 2 has been exami ned

    f o r t he use o f a VLSI i m p l e m e n t a t i o n , and t h e s t u d y of a

    c o m p i l e r c a p a b l e o f t r a n s l a t i n g f rom an AHPL d e s c r i p t i o n t o

    a VLSI i m p l e m e n t a t i o n in t he f or m of t h e SLA has a l s o been

    c a r r i e d out * As a r e s u l t , i t has been pr oved t h a t t h e

    c o m p i l e r i s f e a s i b l e and t he use of c l o c k e d D f l i p - f l o p s as

    t h e s t o r a g e e l e me n t s in t he SLA is more n a t u r a l *

  • 3

    I n t he SLA c o m p i l a t i o n p r o j e c t s an a l g o r i t h m

    ( s t a g e 3) t o t r a n s l a t e t h e o u t p u t of s t a g e 2 o f t h e new

    c o m p i l e r i n t o t he d a t a used f o r an SLA r e a l i z a t i o n must be

    devel oped, , I n a d d i t i o n s some d e s i g n exampl es sho u l d be done

    so t h a t t he r e s u l t s o f t h e exampl es can be f e d back t o t he

    d e s i g n of t he a l g o r i t h m * For t h i s reasons t h e 6502

    m i c r o p r o c e s s o r s as an exampl e o f an SLA r e a l i z a t i o n s was

    s e l e c t e d *

    S i n c e t he a d v e n t o f t h e f i r s t m i c r o p r o c e s s o r in

    1971s many m i c r o p r o c e s s o r s have been d e v e l o p e d * I n s p i t e o f

    t h e c o m p l i c a t e d o p e r a t i o n s of t h e m i c r o p r o c e s s o r s s t he y ar e

    u s u a l l y d e s i g n e d by menas of a random l o g i c t e c h n i q u e * The

    6502s an 8 - b i t m i c r o p r o c e s s o r s is a s o p h i s t i c a t e d d i g i t a l

    syst em i t s e l f and has many p o w e r f u l i n s t r u c t i o n s *

    T h e r e f o r e s t he d e s i g n exampl e of t he 6502 w i l l be a b l e t o

    s a t i s f y most of t he r e q u i r e m e n t s on e s t a b l i s h i n g a des i gn

    a u t o m a t i o n syst em aimed a t t he SLA r e a l i z a t i o n * The 6502 is

    a l s o s u f f i c i e n t l y c o m p l i c a t e d to c o n f i r m t he c o mp l e t e n e s s o f

    t he d e s i g n a u t o m a t i o n syst em*

    I n i mp l e me n t i n g t he 6502 m i c r o p r o c e s s o r in t he f or m

    of t he SLA; t h e f o l l o w i n g t a s k s must be wor ked o u t :

    1) D e t a i l e d A n a l y s i s of t he i n t e r n a l o p e r a t i o n s of

    t h e 6 5 0 2 .

    2) The s y s t e m a t i c d ev e l o pment o f a 6502 AHPL

    d e s c r i p t i o n *

  • 3) S i m u l a t i o n of t he 6502 w r i t t e n i n AHPL«

    4) T r a n s l a t i o n f rom t h e 6502 AHPL d e s c r i p t i o n t o an

    SLA form by e i t h e r manual work or a c o m p u t e r »

    Thr ough t h i s paper * t h e f i r s t t h r e e t a s k s a r e d i s c u s s e d w i t h

    empha s i s * An i n t r o d u c t i o n to t h e SLA and t h e s t a g e 3

    a l g o r i t h m is b r i e f l y me n t i o n e d i n c o n j u n c t i o n w i t h t h e t a s k

    o f t h e t r a n s l a t i o n *

    C h a p t e r 2 p r e s e n t s a b r i e f d e s c r i p t i o n o f t he

    har owar e o r g a n i z a t i o n of t h e 6502 to p r e p a r e t h e backgr ound

    f o r t he d i s c u s s i o n i n l a t e r c h a p t e r s * Ch a p t e r 3 a n a l y z e s

    t h e i n t e r n a l o p e r a t i o n s of t he 65 02* and a 6502 AHPL

    d e s c r i p t i o n is de v e l o pe d s t e p by s t ep in t h e f o l l o w i n g

    c h a p t e r * I n Ch a p t e r 5* t he p r e p a r a t i o n f o r s i m u l a t i o n and

    t h e r e s u l t s of t he s i m u l a t i o n a r e e x p l a i n e d * C h a p t e r 6

    ment i ons an i n t r o d u c t i o n t o an SLA a l ong wi t h an a l g o r i t h m

    f o r an SLA r e a l i z a t i o n b r i e f l y * The r e s u l t s o f a des i gn

    exampl e a r e d i s c u s s e d in t h e l a s t c h a p t e r .

    F i n a l l y * Append i x A p r o v i d e s a 6502 i n s t r u c t i o n s e t

    summary* and Append i x B p r e s e n t s a summary of c y c l e by c y c l e

    o p e r a t i o n of i n s t r u c t i o n s * Appendi x C l i s t s i n t e r n a l

    o p e r a t i o n s of t y p i c a l i n s t r u c t i o n s * w h i l e Appendi x D

    d e s c r i b e s i n t e r n a l o p e r a t i o n s of i n p u t s * A Kar naugh map of

    o p e r a t i o n codes i s i n c l u d e d in Appendi x E * Ap pend i x F shows

    a c o mp l e t e 6502 AHPL d e s c r i p t i o n * w h i l e Appendi x G l i s t s

    c o m b i n a t i o n a l l o g i c u n i t d e s c r i p t i o n s ^ The l a s t app end i x *

  • Append i x Hj> d e mo n s t r a t e s an exampl e o f si mu I at i on o

  • CHAPTER 2

    THE 6502 MICROPROCESSOR

    The pur pose of t h i s c h a p t e r i s to g i v e t h e r e a d e r an

    o v e r v i e w of t he 6502 so t h a t t h e r e a d e r can p r oc e e d t o t he

    f o l l o w i n g c h a p t e r s w i t h an equal knowl edge of t he 6502» I n

    o r d e r t o p r e s e n t a c l e a r d e s c r i p t i o n ^ t h i s c h a p t e r i s

    d i v i d e d i n t o two s e c t i o n s ; Har dwar e O r g a n i z a t i o n and

    I n s t r u c t i o n Se t f o r d e s c r i p t i o n s of a ha r dwar e as p e c t and a

    s o f t w a r e a s p e c t ; r e s p e c t i v e l y .

    S i n c e t he f i r s t m i c r o p r o c e s s o r a ppear ed on t h e

    ma r k e t of d i g i t a l h a r d w a r e sys t ems; many have been

    i n t r o d u c e d . The 6502 t h a t i s one o f t he t h i r d g e n e r a t i o n

    m i c r o p r o c e s s o r s was i n t r o d u c e d a f t e r t he 6800 m i c r o p r o c e s s o r

    had Been put on t he m a r k e t . Because of t he t i m e of

    a p p e a r a n c e ; t he 6502 has many s i m i l a r f e a t u r e s t o t he 68.00 .

    Har dwar e O r g a n i z a t i o n

    The har dwar e o r g a n i z a t i o n and t he i n s t r u c t i o n s e t o f

    t h e 6502 ar e ve r y s i m i l a r t o t h o s e of t he 6 8 0 0 . The is due

    t o t he f a c t t h a t t h e de s i g n of t he 6502 was based on t he

    6 8 0 0 . L i k e many 8 - b i t m i c r o p r o c e s s o r s ; t h e 6502 has a l s o an

    8—b i t d a t a bus and a 1 6 - b i t add r e ss bus. T h i s i n d i c a t e s t h e

    c a p a b i l i t y o f a d d r e s s i n g 64 Kbyt es ( 8 b i t s ) of memory. I n

  • a d d i t i o n t o t h e d a t a bus and a dd r e s s bus, t h e r e a r e n i n e

    i n p u t s and f o u r o u t p u t s used in t h e 650Zo A i l i n p u t s and

    o u t p u t s a r e pu t t o g e t h e r i n t o a 40—p i n d u a l - i n - l i n e package, ,

    T h e r e a r e t h r e e unuseo p i n s on t h e packege* The p i n

    c o n f i g u r a t i o n i s shown in F i g u r e 1„

    I n p u t s and Out put s

    The i n p u t s and o u t p u t s c o n s i s t of an 8 - b i t da t a bus,

    a 1 6 - b i t add r e s s bu s , I RQ, NMI , RES, ROY, P HI 0 , S „ 0 o, R/.W,

    SYNC, P H I 1 , PHI Z , two Vss° s, and Vcco The i n p u t s and

    o u t p u t s have t h e i r own d i s t i n c t - oper a t i ons , . T y p i c a l

    f e a t u r e s and o p e r a t i o n s of t h e i n p u t s and o u t p u t s w i l l be

    b r i e f l y e x p l a i n e d as f o l l o w s :

    ADBUST0 : 1 5 3 ■— The 1 6 - b i t o u t p u t bus i s used to

    addr e ss l o c a t i o n s a l l o c a t e d in memory and p e r i p h e r a l s and i s

    c o m p a t i b l e w i t h TTL„

    DBUS CO:73 — The 8 - b i t b i - c i r e c t i onal bus w i t h t h e

    t r i - s t a t e o u t p u t i s p r o v i d e d as a medium of t r a n s f e r r i n g

    d a t a o For exampl e , t h e m i c r o p r o c e s s o r put s d a t a ont o t he

    d a t a bus f o r w r i t e o p e r a t i o n s and g e t s d a t a f r om t he bus f o r

    r ead o p e r a t i o n s . '

    IRQ — The IRQ i n p u t i s one of t he i n t e r r u p t i n p u t s

    p r o v i d e d in t he 6 5 0 Z „ The TTL l e v e l i n p u t r e q u e s t s an

    i n t e r r u p t sequence in whi ch t h e Program Co unt e r (PC) and t h e

    Pr o c e s s o r S t a t u s R e g i s t e r ( P) w i l l be s t o r e d i n t h e s t a c k .

    At t h e end o f t h e se q ue nc e , t h e d a t a f rom t h e l o c a t i o n FFFE

  • 8

    1 Vss RES 40

    2 ROY PH I 2 ( OUT) 39

    3 P H I 1 ( OUT) S. O. 38

    4 IRQ PH 1 0 ( IN ) - 37

    5 N. C. N.C . 36

    6 NMI N.C . 35

    7 SYNC R/W 34

    8 V cc DBUS £ 0 3 33

    9 ADBUSCO] D BUS£13 32

    10 ADBUSCU DB US £ 2 3 31

    11 AD BUS £ 2 DM 650 2

    DBUS £ 3 3 30

    12 ADBUSC33 DBUS£ 4 3 29

    13 ADBUS £4 3 DBUS £ 5 3 28

    14 - AD BUS £ 5 3 DBUS£63 27

    15 ADBUS £ 6 3 DBUS£ 73 26

    l b ADBUS£73 ADBUS£153 25

    17 ADBUS £ 8 3 ADBUS£143 24

    18 AD BUS £ 9 3 ADBUS£133 23

    19 AD BUS £ 10 3 ADBUS£123 - 22

    20 ADBUSU13 Vss — 21

    N. C. * No Connect i on.

    F i g u r e 1 . Pin C o n f i g u r a t i o n of t he 6502

  • 9

    and t he d a t a f rom t h e l o c a t i o n FFFF w i l l be l oa de d i n t o t he

    pr ogr am c o u n t e r low ana t h e program c o u n t e r h i g h ,

    r e s p e c t i v e l y f o r t h e s t a r t i n g l o c a t i o n o f an i n t e r r u p t

    r o u t i h e o Th i s i s a l e v e l s e n s i t i v e i nput o

    NMI ■— The NMI i n p u t i s a l s o used f o r an i n t e r r u p t .

    The o n l y d i f f e r e n c e f rom IRQ i s t he use of t he v e c t o r

    l o c a t i o n s FFFA and FFFB, a n o n - ma s k a b l e i n t e r r u p t sequence ,

    and an edge s e n s i t i v e i n p u t .

    RES — The RES i n p u t is used to r e s e t or s t a r t t h e

    6502 f rom a power down c o n d i t i o n . As in t he i n t e r r u p t

    sequence , t h e s t a r t i n g l o c a t i o n f o r program c o n t r o l w i l l be

    l oaded f rom t h e v e c t o r l o c a t i o n s FFFC and FFFD.

    ROY — By t h e RDY i n p u t , a l l c y c l e s e x c e p t w r i t e

    c y c l e s can be h a l t e d . T h i s f e a t u r e a l l o ws t he

    m i c r o p r o c e s s o r t o be c o n n e c t e d w i t h a low speed memory.

    PH 10 — T h i s PHIO i n p u t i s used t o g e n e r a t e a two

    phase n o n - o v e r l a p p i n g c l o c k . An i n t e r n a l c l o c k g e n e r a t o r i s

    s u p p l i e d i n s i d e t he 6 5 0 2 .

    S. O. The o v e r f l o w b i t i n t he p r o c e s s o r s t a t u s

    r e g i s t e r can be se t by a n e g a t i v e go i ng edge on t h e Set

    O v e r f l o w F l a g ( S . O . ) i n p u t .

    R/W — The R/W o u t p u t i s used to d i s t i n g u i s h bet ween

    t hos e c y c l e s in which t h e m i c r o p r o c e s s o r i s do i ng a read

    o p e r a t i o n and t hose c y c l e s in whi ch t he p r o c e s s o r i s doi ng

    a w r i t e o p e r a t i o n . T h i s o u t p u t can a l s o be used t o c o n t r o l

  • 10

    r e a a and w r i t e op er at i ens of memory modul es and p e r i p h e r a l

    d e v i c e s .

    SYNC — The SYNC o u t p u t i s p r o v i d e d t o i d e n t i f y

    t hos e c y c l e s i n whi ch t h e m i c r o p r o c e s s o r i s do i ng an OP CODE

    f e t c h .

    P H I 1 £ PHI 2 — The phase 1 c l o c k and phase 2 c l o c k

    o f t h e two phase n o n - o v e r l a p p i n g c l o c k g e n e r a t e d in t h e 6502

    ar e o u t p u t on PHI1 and PHI 2 ; r e s p e c t i v e l y t o be used by

    o t h e r d e v i c e s .

    By now; a l l o f t h e i n p u t s and o u t p u t s have been

    b r i e f l y d e s c r i b e d exc ept f o r Vss and Vcc t h a t a r e used f o r

    power s u p p l y . The i n p u t s and o u t p u t s a r e summar i zed in

    T a b l e 1 f o r c l a r i t y . D e t a i l e d i n f o r m a t i o n c o n c e r n i n g t he

    i n t e r n a l o p e r a t i o n s of IRQ.? NMI jp and RES and t h e e x a c t

    t i m i n g of t he i n p u t s and o u t p u t s sh o u l d be r e f e r r e d t o in

    r e f e r e n c e 3 f o r f u r t h e r u n d e r s t a n d i n g .

    I n t e r n a I Buses

    The d a t a bus and addr ess bus are p r o v i d e d in t he

    6502 so t h a t t h e m i c r o p r o c e s s o r can communi cat e w i t h o u t s i d e

    d e v i c e s . On t h e o t h e r hand* i n t e r n a l buses a r e empl oyed i n

    or oer t h a t d a t a can move i n s i d e t h e m i c r o p r o c e s s o r . Ther e

    ar e t h r e e i n t e r n a l buses* namel y t he I n t e r n a l Address Bus

    ( I ADBUS) * t h e I n t e r n a l Da t a Bus ( I DBUS) * and t h e Argument

    Bus (ARGBUS) . These buses w i l l be s i m p l y e x p l a i n e d in

    c o n n e c t i o n w i t h t he h a r d wa r e o r g a n i z a t i o n .

  • T a o l e 1 . Summar y o f I n p u t s and O u t p u t s

    S i gna l Name I n p u t / O u t p u t F e a t u r e s

    ADBUSLO:15 ] Ou t p u t TI L Comp a t i bl e«

    DBUS tO : 7 ] I n p u t / O u t p u t B i d i r e c t i o n a l Bus w i t h T r i - s t a t e O u t p u t .

    T rqI n p u t L e v e l S e n s i t i v e .

    NMII n p u t Edge Sens i t i v e .

    RESI n p u t Leve l S e n s i t i v e .

    RDY I n p u t TTL Comp a t i b l e .

    PHIO I n p u t TI L C o m p a t i b l e .

    S . 0 . I n p u t TTL C o m p a t i b l e .

    R/W Ou t p u t TTL Comp at i b l e .

    SYNC Out put TTL C o m p a t i b l e .

    PHI 1 Outp ut TTL Compa t i b 1e .

    PHIZ Ou t p u t TTL C o m p a t i b l e .

  • 12

    IADBUS CO s15 ] — The i n t e r n a l addr ess bus c o n s i s t s o f

    two 8 - b i t bases t IAD BUSC Os 73 and IADBUSC8 s1 5 3 0 The bus is

    c o n n e c t e d t o t h e ADBUS t h r o u g h t he addr ess b u f f e r s so t h a t

    i n t e r n a l i y g e n e r a t e d a d dr e sses can be s e n t to t he 'ADBUS„

    F u r t h e r m o r e , t h e bus i s used t o r o u t e d a t a t o t h e I n c r e m e n t /

    Decr ement R e g i s t e r ( I N R ) or t h e I n c r e m e n t e r / D e c r e m e n t e r

    ( INC / DEC) o The d a t a w i l l be used i n l a t e r o p e r a t i o n s , , The

    o u t g o i n g d a t a on t h e IADBUS w i l l come f r om i n t e r n a l

    r e g i s t e r s such as t h e Da t a La t c h ( DL) , t he T empor a r y

    R e g i s t e r ( TR) , I NR, PC, t h e ALU R e g i s t e r ( ALUREG) , and t he

    St a c k P o i n t e r (SP) t o make up 1 6 - b i t addresses put onto t he

    ADBUSo Onl y t h e IADBUS[8 5 15 3 can be c o n ne c t e d t o t he

    ARGBUS, so t he da t a on t he IADBUSC 85 153 can be an argument

    of t h e ALU f o r a r i t h m e t i c o p e r a t i o n s o

    IDBUSCO 8 7 3 — U n l i k e t h e IADBUS, t he i n t e r n a l da t a

    bus i s c on nec t ed t o a l mos t a i l i n t e r n a l r e g i s t e r s * The

    IDBUS is m a i n l y used as a medium of t r a n s f e r r i n g d a t a

    bet ween t he r e g i s t e r s * The d a t a on t he IDBUS can be l oaded

    ont o t he DBUS t h r o u g h t h e d a t a bus b u f f e r * The d a t a coming

    f rom o u t s i d e must be l a t c h e d i n t o t h e d a t a l a t c h f i r s t *

    ARGBUS CO s7 3 — The 8 - b i t argument bus i s p r e pa r e d

    f o r r o u t i n g t he d a t a f rom one of t he s o u r c e s , t h e I ndex X

    R e g i s t e r ( X ) , t he I n d e x Y R e g i s t e r ( Y ) , and t h e IADBUSC8s153

    to t h e ALU» The ARGBUS i s one o f t he f o u r a r gument s of t he

    ALU* , .

  • 13

    These buses a r e c l o s e l y con nec t ed to t h e i n t e r n a l

    r e g i s t e r s and c o m b i n a t i o n a l l o g i c u n i t s ( C L U ' s ) f whi ch w i l l

    be e x p l a i n e d ne x t o A p i c t o r i a l r e p r e s e n t a i o n o f t he

    i n t e r n a l buses can be seen in F i g u r e 2o

    I n t e r n a l R e g i s t e r s

    The i n t e r n a l r e g i s t e r s as we l l as t h e i n t e r n a l buses

    a r e q u i t e s i g n i f i c a n t to t he h a r d wa r e o r g a n i z a t i o n * El even

    r e g i s t e r s have been u t i l i z e d to c a r r y out t he i n t e r n a l

    o p e r a t i o n s of a l l i n s t r u c t i o n s and i n p u t s i g n a l s *

    AS a l r e a d y n o t i c e d , t he p i c t o r i a l v i ew o f 6502

    i n t e r n a l a r c h i t e c t u r e is shown i n F i g u r e 2* . However , t h i s

    f i g u r e i s no t c o m p l e t e l y t h e same as those a v a i l a b l e in

    manuals and books on t h e 6502« T h i s is because t h ose

    p i c t u r e s do no t r e f l e c t r e a l d e s i g n and some m o d i f i c a t i o n s

    had to be done f o r t h e 6502 AH PL d e s c r i p t i o n t o be d i s c u s s e d

    in t h i s paper * Even among t h o s e p i c t u r e s , t h e r e ar e s t i l l

    some d i f f e r e n c e s * A ma j or d i f f e r e n c e bet ween F i g u r e 2 and

    t h e o t h e r s is t h a t t he t e mp o r a r y r e g i s t e r i s d e p i c t e d in

    F i g u r e 2* An o t h e r i s t h e e x p l i c i t l y i n d i c a t e d ARGBUS *

    I n d i v i d u a l r e g i s t e r s w i l l be e x p l a i n e d i n b r i e f as f o l l o w s :

    DL — The d a t a l a t c h i s used to l a t c h i ncomi ng da t a

    on t h e DBUS f o r d a t a f e t c h e s * The DL w i l l a l s o load t he

    d a t a ont o e i t h e r t h e IDBUS f o r t r a n s f e r s or t h e DBUS f o r

    w r i t e o p e r a t i o n s * The d a t a f e t c h e s w i l l occur depend i ng

    upon t he i n s t r u c t i o n b e i n g p e r f o r me d by t h e p r o c e s s o r * The

  • 14

    cu0)3CQCDCO0)k735

    r-0 1_i1§d

    PCL | PCH

    __INR ___INC^DEC

    J T

    TR

    DL

    T T

    C

    InterruptLogic

    ControlLogic

    Instruction Decoder

    RESIRQM I

    PHIOPHI1PHI 2R/WSYNCRDYS. O.

    IR

    ’L r

    DATABUSBuffern

    DBUS[0i7] DBUS

    Figure 2. 6502 Internal Architecture

  • 15

    d a t a s t o r e d in DL w i l l be used e i t h e r as h a l f p o r t i o n s o f

    a dd r e s s e s or i n l a t e r o p e r a t i o n s , ,

    TR — The t e m p o r a r y r e g i s t e r is p r o v i d e d to save

    d a t a t h a t w i l l be used as h a l f p a r t s of a d d r e s s e s in l a t e r

    oper a t t ons

    IR — The d a t a f e t c h e d f rom o u t s i d e d e v i c e s in t he

    OP CODE f e t c h c y c l e w i l l be s t o r e d in t he i n s t r u c t i o n

    r e g i s t e r , , The d a t a w i l l i n t u r n be s e n t t o t h e i n s t r u c t i o n

    dec oder t o g e n e r a t e a p p r o p r i a t e c o n t r o l s i g n a l s *

    P — The pr ocessor s t a t u s r e g i s t e r is p r ov i ded to

    i n d i c a t e the c u r r e n t s t a t u s of t he pr ocessor * The P

    r e g i s t e r is f u r t h e r p a r t i t i o n e d i n t o the Car r y ( C ) , Zero

    ( Z )* I n t e r r u p t D i s a b l e ( I ) » Decimal Mode ( D)» Break Command

    ( b ) p Over f l ow ( 0 ) j> and N e g a t i v e ( N) f l a g s to be used by

    branch i n s t r u c t i o n s , a r i t h m e t i c and l ogi c o p e r a t i o n s , etc *

    INR — The i n c r e me n t / de cr eme nt r e g i s t e r s t o r e s data

    f rom e i t h e r INC/DEC or IADBUS* Data st or ed in INR w i l l

    u s u a l l y be used f or addr ess i ng*

    PC The pr ogr am c o u n t e r i s made up o f t h e program

    c o u n t e r low and pr ogr am c ou n t e r h i g h * L i k e I NR, Dat a s t o r e d

    i n PC w i l l be used f o r a d d r e s s i n g *

    AC The a c c u m u l a t o r , as t he name i m p l i e s ,

    a c c u mu l a t e s most of t he computed d a t a f rom t he ALU* The

    c o n t e n t s o f t he a c c u m u l a t o r can a l s o be an ar gument o f t h e

    ALU f o r a r i t h m e t i c and l o g i c o p e r a t i o n s *

  • 16

    ALUREG — The ALU r e g i s t e r is a t e mp o r a r y s t o r a g e

    f o r t he d a t a comi ng out of t h e A l U o The ALUREG w i l l be

    r e f r e s h e d e v e r y c y c l e o T h e r e f o r e , ALUREG can not s t o r e d a t a

    f o r more t han one cycl e, , The c o n t e n t s of t he r e g i s t e r can

    be h a l f p a r t s o f addr esses put ont o t he I A D B U S „

    SP “ = The s t a c k p o i n t e r is used t o p o i n t t o and save

    t h e l o c a t i o n c u r r e n t l y used in t h e s t ack o I n o r d e r t o s e t

    t h e s t a c k p o i n t e r , t he d a t a on t h e IDBUS can be s t o r e d in

    SP.

    X — The i ndex X r e g i s t e r i s p r e p a r e d f o r t he

    a d d r e s s i n g modes a s s o c i a t e d wi t h t he X r e g i s t e r . Thi s

    r e g i s t e r can be used as a t e mp o r a r y s t o r a g e f rom

    pr ogr ammer s* v i e w p o i n t . The d a t a in t he X r e g i s t e r can be

    l oaded ont o e i t h e r t h e IDBUS or ARGBUS,

    Y — The i ndex Y r e g i s t e r i s p r e p a r e d f o r t he

    a d d r e s s i n g modes a s s o c i a t e d w i t h t h e Y r e g i s t e r . Th i s

    r e g i s t e r can be used as a t e m p o r a r y s t o r a g e as w e l l , The

    d a t a in t he Y r e g i s t e r can be l oaded ont o e i t h e r t he IDBUS

    or ARGBUS,

    The buses and r e g i s t e r s p r o v i d e d i n s i d e t h e 6502

    have been d e s c r i b e d , y e t a d e s c r i p t i o n of t h e c o m b i n a t i o n a l

    l o g i c u n i t s , t h e ALU and INC/DEC is not p r e s e n t e d . The I N C /

    DEC w i l l not need an e x p l a n a t i o n a t a i l because i t i s a mere

    i n c r e m e n t e r / d e c r e m e n t e r u n i t t h a t w i l l i n c r e me n t or

    dec r e ment addr e ss d a t a on t he IADBUS, However , t h e ALU w i l l

  • - 17

    r e q u i r e a' c omp r e h e n s i v e s p e c i f i c a t i o n o I n Ch a p t e r 3s> t he

    ALU w i l l be d i s c u s s e d in c o n j u n c t i o n w i t h a r i t h m e t i c and

    l o g i c oper a t ionso

    D e t a i l e d i n f o r m a t i o n about t he i n p u t and o u t p u t

    c o n n e c t i o n s o f t he r e g i s t e r s and C LU0 s i s p r o v i d e d in T a b l e

    2 o T a b l e 2 w i l l compensat e f o r t he l i m i t a t i o n o f t he

    i l l u s t r a t i o n o f F i g u r e 2» Thus* e x a c t c o n n e c t i o n s sh o u l d be

    l ooked i n t o in T a b l e 2» I n f a c t ; T a b l e 2 has been updat ed

    as t he AHPL d e s c r i p t i o n f o r t h e 6502 has been m o d i f i e d .

    I n t h e ne x t c h a p t e r , t he i m p l i c a t i o n of t h e s e c o n n e c t i o n s

    w i l l be c l a r i f i e d , and F i g u r e 2 and Tab l e 2 w i l l o f t e n be

    r e f e r r e d t o f o r f u r t h e r d i s c u s s i o n .

    I n s t r u c t i o n Set

    The 6502 m i c r o p r o c e s s o r has a p o we r f u l i n s t r u c t i o n

    s e t , whi ch i s v e r y s i m i l a r to t h e 6800 m i c r o p r o c e s s o r ' s

    i n s t r u c t i o n s e t . Because o f t h e c omp l e t e n e s s and

    s i m i l a r i t y , t he user can w r i t e e f f i c i e n t pr ogr ams and

    t r a n s l a t e a program f o r t h e 6800 i n t o a pr ogr am f o r t h e 6502

    e a s i l y . The 6502 i n s t r u c t i o n s e t c o n s i s t s o f 151 o p e r a t i o n

    codes (OP CODE' S) , and t h e s e OP CODE”s can be c l a s s i f i e d

    i n t o two c a t e g o r i e s , i n s t r u c t i o n and a d d r e s s i n g mode, 56

    k i n d s o f i n s t r u c t i o n s and 11 a d d r e s s i n g modes a r e be i ng

    used, A b r i e f d e s c r i p t i o n of t h e i n s t r u c t i o n s and

    a d d r e s s i n g modes w i l l be g i v e n bel ow f o r t he d i s c u s s i o n in

    Ch a pt e r 3,

  • 18

    T a b l e 2 • I n p u t and O u t p u t C o n n e c t i ns o f R e g i s t e r s and CL U ' s

    Reg i s t e r or CLU I np u t / O u t p u t C o n n e c t i o n s and T r a n s f e r s

    I npu t Da t a L a t c h (DL )

    I n p u t DL

  • 19

    T a b l e 2 . — C o n t i n u e c

    R e g i s t e r or CLU I n p u t / O u t p u t Co n n e c t i o n s and T r a n s f e r s

    A r i thme t i c Log i c U n i t (ALU)

    I n p u t( Ar gment )

    ALU : IDBUS ALU : ARGBUS ALU : OP ALU : PS

    Out put ALUREG

  • 20

    Ta o l e 2 . - » Con t i nue d

    R e g i s t e r or CLU I n p u t / O u t p u t Co n n e c t i o n s and T r a n s f e r s

    I n cr ement er / De c r e me n t e r

    ( I N C / DEC ) ;

    I n p u t( Ar gme nt )

    INC i IADBUS DEC : IADBUS

    Ou t p u t I N R [ 8 : 1 5 3 < =INC [ 8 : 1 5 3 ( I ADBUS)

    I NR[ 8 : 1 5 3 < =DECC8S153( I AD B US )

    INR

  • Fundament a l I n s t r u c t i o n s

    For a more c o n c i s e d e s c r i p t i o n , t he 56 i n s t r u c t i o n s

    can be f u r t h e r d i v i d e d i n t o n i n e f u n d a me n t a l i n s t r u c t i o n s o

    They a r e a r i t h m e t i c , l o g i c , l o a d , s t o r e , b r a n c h , j ump,

    s e t / c i e a r , t r a n s f e r , and s t a c k i n s t r u c t i o n s . The

    i n s t r u c t i o n s w i l l be d e s c r i b e d in t erms o f t h e f un da me n t a l

    i n s t r u c t i ons =.

    A r i t h m e t i c I n s t r u c t i o n — The a r i t h m e t i c i n s t r u c t i o n

    uses t h e ALU, so t h a t t h e d a t a s t o r e d in AC and DL w i l l be

    e i t h e r added or s u b t r a c t e d , , The c a p a b i l i t i e s o f a d d i t i o n

    and s u b t r a c t i o n a r e p r o v i d e d in t he ALU f o r such

    i n s t r u c t i o n s as ADC, CMP, CPX, CPY, DEC, DEX, DEY, I NC, I NX,

    I NY, and SBC o Some f l a g s of t he P r e g i s t e r w i l l be

    r e f r e s h e d as a r e s u l t of an a r i t h m e t i c o p e r a t i o n , ,

    Logi c I n s t r u c t i o n — The l o g i c i n s t r u c t i o n a l s o uses

    t he ALU t o p e r f o r m a l o g i c o p e r a t i o n on t he d a t a i n AC and

    DL o The f u n c t i o n s of AND, OR, e x c l u s i v e OR, s h i f t , and

    r o t a t i o n a r e f u r n i s h e d in t h e ALU as we I I „ The l o g i c

    i n s t r u c t i o n a l so a f f e c t s t h e P r e g i s t e r , , The i n s t r u c t i o n s

    c l a s s i f i e d i n t o t h e l o g i c i n s t r u c t i o n ar e AND, ASL, B I T ,

    EOR, L S R , ORA, ROL, and RORo Not e t h a t t h e s h i f t and

    r o t a t i o n f u n c t i o n s a r e c l a s s i f i e d i n t o t h i s i n s t r u c t i o n f o r

    t h e s i m p l e d i s c u s s i o n in Ch a p t e r 3 , a l t h o u g h t h e f u n c t i o n s

    ar e no t l o g i c f u n c t i o n So

    Load I n s t r u c t i o n — The l oa d i n s t r u c t i o n imp I i e s

  • 22

    t h a t d a t a t r a p p e d by DL w i l l be s t o r e d in t h e X r e g i s t e r * Y

    r e g i s t e r , or a c c u m u l a t o r . I n a d d i t i o n , t he z e r o and

    n e g a t i v e f l a g s of t he P r e g i s t e r may be changed dependi ng on

    t h e c o n t e n t s of t he d a t a . The i n s t r u c t i o n s p l a c e d under t h e

    l oad i n s t r u c t i o n a r e LDA, LDX, and LDY.

    S t o r e I n s t r u c t i o n — The p r o c e s s o r w i l l e x e c u t e t he

    s t o r e i n s t r u c t i o n by l o a d i n g d a t a s t o r e d in t h e X r e g i s t e r ,

    Y r e g i s t e r , or a c c u mu l a t o r ont o t he DBUS. The STA, STX, and

    STY i n s t r u c t i o n s a r e c a t e g o r i z e d i n t o t he s t o r e i n s t r u c t i o n .

    Branch I n s t r u c t i o n — The pr o c e s s or w i l l br anch t o

    t he l o c a t i o n where t he n e x t OP CODE f e t c h w i l l be e xe cut ed

    i f a br anch c o n d i t i o n is s a t i s f i e d . The br anc h i n s t r u c t i o n

    makes use of t he c a r r y , z e r o , o v e r f l o w , and n e g a t i v e f l a g s

    f o r a br anch c o n d i t i o n . The br anc h l o c a t i o n , i s c a l c u l a t e d

    i n t he ALU. The i n s t r u c t i o n s c l a s s i f i e d under t h e br anch

    i n s t r u c t i o n a r e BCC, BCS, BEQ, BMI , BNE, BPL, BVC, and BVS.

    Jump I n s t r u c t i o n — By t he jump i n s t r u c t i o n , the

    p r o c e s s o r w i l l jump u n c o n d i t i o n a l l y to t h e l o c a t i o n where

    t he n e x t OPCODE f e t c h w i l l be d o n e . U n l i k e t h e branch

    i n s t r u c t i o n , t h i s i n s t r u c t i o n i n c l u d e s r a t h e r c o m p l i c a t e d

    o p e r a t i o n s f o r w r i t i n g da t a in t h e s t a c k and r e t r i e v i n g d a t a

    f rom t h e s t a c k . The i n s t r u c t i o n s put under t h e jump

    i n s t r u c t i o n a r e BRK, JMP, JSR, R T I , and RTS. Onl y t he JMP

    i n s t r u c t i o n does not r e q u i r e t h e use of t h e s t a c k .

    S e t / C l e a r I n s t r u c t i o n — The s e t / c l e a r i n s t r u c t i o n

  • 23

    i s f u r n i s h e d t o mod i f y t h e P r e g i s t e r o By t h i s i n s t r u c t i o n ,

    t h e c a r r y , dec i mal mode, and i n t e r r u p t d i s a b l e f l a g s can be

    s e t or c l e a r e d , w h i l e t h e o v e r f l o w f l a g can o n l y be c I e a r e d o

    The o v e r f l o w f l a g w i l l be s e t in case t h a t an o v e r f l o w

    c o n d i t i o n occur s as a r e s u l t of an a r i t h m e t i c o p e r a t i o n o

    The o t h e r f l a g s a r e not a c c e s s i b l e t o t he programmer 0 The

    i n s t r u c t i o n s , c l a s s i f i e d i n t o t he s e t / c l ear i n s t r u c t i o n a r e

    CLC, CLD, C L I , CLV, SEC, SED, and SEXo

    T r a n s f e r I n s t r u c t i o n — The t r a n s f e r i n s t r u c t i o n i s

    p r o v i d e d t o t r a n s f e r d a t a f r om one o f t he f o u r r e g i s t e r s ,

    t he X r e g i s t e r , Y r e g i s t e r , s t a c k p o i n t e r , and a c c u mu l a t o r

    i n t o a no t h e r r e g i s t e r of t h e s e « Onl y s i x c o m b i n a t i o n s o f

    sou r c e and d e s t i n a t i o n r e g i s t e r s a r e imp I ement edo The

    i n s t r u c t i o n s p l a c e d under t h e t r a n s f e r i n s t r u c t i o n a r e TAX,

    TAY, TSX, TXA, TXS, and TYAo A l l t he i n s t r u c t i o n s e x c e p t

    TXS a f f e c t t he z e r o and n e g a t i v e f l a g s .

    S t a c k I n s t r u c t i o n - - The s t a c k i n s t r u c t i o n uses t h e

    s t a c k p o i n t e r i n o r d e r t o pu t d a t a in t he s t a c k or r e t r i e v e

    d a t a f rom t h e s t a c k » Th i s i n s t r u c t i o n i s s i m i l a r to t he

    l oad and s t o r e i n s t r u c t i o n s but uses t he s t a c k p o i n t e r

    i n s t e a d of t he program c o u n t e r f o r add r essi n g o However , t he

    s t a c k i n s t r u c t i o n u t i l i z e s PC once t h e c u r r e n t l y used s t a c k

    addr ess has been s e t i n PCo The i n s t r u c t i o n s c l a s s i f i e d

    under t he s t a c k i n s t r u c t i o n a r e PH A, PH P, PLA, and PLPo

    The r e a d e r s h o u l d r e f e r t o r e f e r e n c e 4 f o r f u r t h e r

  • i n f o r m a t i o n because t h e above d e s c r i p t i o n i s n o t i n t e n d e d to

    p r e s e n t a c o mpl e t e e x p l a n a t i o n o f t h e i n s t r u c t i o n s e t .

    A l t h o u g h each f u n d a me n t a l i n s t r u c t i o n does no t d e s c r i b e

    e x a c t l y t he e x e c u t i o n p a r t o f t he i n t e r n a l o p e r a t i o n f o r

    each i n s t r u c t i o n , i t w i l l he l p t o u n d e r s t a n d d e t a i l s of t he

    i n s t r u c t i o n s e t o A 6502 i n s t r u c t i o n s e t summary has been

    p r o v i d e d in Appendi x A f o r r e a d e r s " c o n v e n i e n c e and w i l l

    i t s e l f e x p l a i n t he e x e c u t i o n p a r t of each i n s t r u c t i o n more

    a c c u r a t e l y . . T y p i c a l i n t e r n a l r e g i s t e r s a r e i l l u s t r a t e d in

    F i g u r e 3 t o i n d i c a t e t h e b i t c o f i g u r a t i o n ado pt e d in t he

    6502 AHPL d e s c r i p t i o n *

    Addr ess i ng Modes

    As s t a t e d b e f o r e , t h e 6502 was i n t r o d u c e d a f t e r t he‘ ' t

    6 800 * As a ' r e s u l t of t he l a t e a p p e a r a n c e , v e r s a t i l e

    a d d r e s s i n g modes and e f f i c i e n t i n s t r u c t i o n c y c l e s were

    i mp l ement ed* Programs such as a program t h a t m a n i p u l a t e s

    t a b l e s and ar r ays can be w r i t t e n v e r y e f f e c t i v e l y by means of

    t h e s e a d d r e s s i n g modes* M o r e o v e r , t he m i c r o p r o c e s s o r can

    e x e c u t e i n s t r u c t i o n s f a s t e r because o f s h o r t e r e x e c u t i o n

    t i me * S i nc e a f u l l d e s c r i p t i o n of t he a d d r e s s i n g modes has

    been l e f t t o t he n e x t c h a p t e r , each a d d r e s s i n g mode w i l l be

    s i m p l y d e s c r i b e d in ac c or da n c e w i t h t he pur pose of t h i s

    c h a p t e r *

    I mmed i a t e ~ The i n s t r u c t i o n s w i t h t he i mmedi at e

    a d d r e s s i n g mode c o n t a i n two byt es (8 b i t s ) , an OP CODE and a

  • 25

    AC Ac c u mu l a t o r

    I ndex R e g i s t e r X

    I n de x R e g i s t e r Y

    7 8 15

    PC( Hi gh) PC(Low ) Program Count er

    MSB LSB

    SP S t a c k P o i n t e r

    0 7

    N V B D I Z c

    P

    Pr o c e s s o r St atusReg i s t e r

    F i g u r e B i t C o n f i g u r a t i o n o f T y p i c a l R e g i s t e r s

  • 26

    c o n s t a n t v a l u e » The OP CODE s p e c i f i e s t he i n t e r n a l

    o p e r a t i o n and a d d r e s s i n g mode, and t he c o n s t a n t v a l u e is

    used in a program, , T h i s mode a l l o w s t he programmer t o

    s p e c i f y v a l u e s n e c e s s a r y f o r t he program, . The OP CODE and

    v a l u e a r e f e t c h e d f rom c o n s e c u t i v e J o c a t i o n s o f program

    memo r y „

    Aoso I u t e — The i n s t r u c t i o n s us i ng the a b s o l u t e

    a d d r e s s i n g mode use t h r e e b y t e s „ The f i r s t b y t e c o n t a i n s an

    OP CODE f o r s p e c i f y i n g t h e i n t e r n a l o p e r a t i o n and a d d r e s s i n g

    modeo The second b y t e i n c l u d e s t he low o r d e r b y t e of an

    e f f e c t i v e a d d r e s s , w h i l e t h e t h i r d b y t e i n c l u d e s t h e h i gh

    o r d e r b y t e o f t h e e f f e c t i v e addr e s s „ Thus, a f u l l 1 6 - b i t

    addr ess can be s p e c i f i e d by t h i s mod e o The e f f e c t i v e

    a d d r e s s , a f u l l 1 6 - b i t a d d r e s s , w i l l be used to address a

    l o c a t i o n a t whi ch d a t a w i l l be r e t r i e v e d and s t o r e d *

    Zero Page — The i n s t r u c t i o n s w i t h t he z e r o page

    a d d r e s s i n g mode a r e made up of two b y t e s „ The f i r s t by t e i s

    an OP CODE as b e f o r e , t h e second b y t e c o n t a i n s an e f f e c t i v e

    addr ess in page z e r o o f memory * The m i c r o p r o c e s s o r

    g e n e r a t e s a l l 0 ' s used f o r t he h i gh or der by t e of a f u l l

    1 6 - b i t address * T h i s mode w i l l a l l o w t h e programmer t o

    s h o r t e n bot h memory space ano e x e c u t i o n t i m e * Onl y

    l o c a t i o n s in page z e r o can be used f o r r ead and w r i t e

    opeat i o n s „

    A c c u m u l a t o r — The i n s t r u c t i o n s h a v i n g t h e

  • 27

    a c c u m u l a t o r a d d r e s s i n g mode i n c l u d e on l y an OP CODE t h a t

    i n d i c a t e s t he i n t e r n a l o p e r a t i o n and a d d r e s s i n g modeo T h i s

    mode can be c o n s i d e r e d t o be t he same as t h e i m p l i e d mode

    d e s c r i b e d bel ow because bot h t h e i n s t r u c t i o n s c o n t a i n on l y

    an OP CODEo However * t he a c c u mu l a t o r a d d r e s s i n g mode is

    c a t e g o r i z e d d i s t i n c t l y because o n l y t he a c c u m u l a t o r o f t h e

    r e g i s t e r s a c c e s s i b l e t o t he programmer is u t i l i z e d f o r t he

    i n t e r n a l o p e r a t i o n s of t h e i n s t r u c t i o n s u s i n g t h i s mode.

    I m p l i e d — As me n t i o n e d a b o v e ; t he i n s t r u c t i o n s w i t h

    t he i m p l i e d a d d r e s s i n g mode use o n l y an OP CODE f o r

    s p e c i f y i n g t he i n t e r n a l o p e r a t i o n and a d d r e s s i n g m o d e o Some

    i n s t r u c t i o n s u s i n g t h e mode r e q u i r e more t ha n 2 eye I es *

    E x p l a n a t i o n s o f t h e s e i n s t r u c t i o n s ar e beyond t h e scope of

    t h i s c h a p t e r o

    I n de x e d I n d i r e c t — - The i n s t r u c t i o n s u s i n g t h e

    i ndexed i n d i r e c t a d d r e s s i n g mode c o n t a i n an OP CODE and a

    base addr ess i n page z e r o „ F i r s t ; t h e base a d d r e s s i s added

    t o t he d a t a s t o r e d in t h e X r e g i s t e r . The r e s u l t a n t by t e

    becomes a n o t h e r addr ess i n page z e r o t h a t c o n t a i n s t h e low

    o r d e r b y t e o f an e f f e c t i v e a d d r e s s ; w h i l e i t s c o n s e c u t i v e

    addr ess c o n t a i n s t h e h i gh o r d e r b y t e o f t h e e f f e c t i v e

    a d d r e s s . The e f f e c t i v e addr ess w i l l be used f o r read and

    wr i t e o p e r a t i o n s .

    I n d i r e c t I n d e x e d — The i n s t r u c t i o n s w i t h t h e

    i n d i r e c t i ndexed a d d r e s s i n g mode c o n t a i n an OP CODE and an

  • i n d i r e c t a dd r e ss in page z e r o * The i n d i r e c t ad dr ess

    c o n t a i n s a base a d d r e s s low* and t he nex t c o n s e c u t i v e

    addr e ss o f t h e i n d i r e c t address c o n t a i n s a base address

    hi gho Whi l e t h e base addr ess h i gh i s be i ng f e t c h e d * t he

    base addr ess low i s added t o t he d a t a s t o r e d i n t h e Y

    r e g i s t e r , , The r e s u l t a n t b y t e becomes t h e low o r d e r b y t e o f

    an e f f e c t i v e a d d r e s s * I f a c a r r y i s g e n e r a t e d f rom t he

    a d d i t i o n * t h e c a r r y * as b i n a r y one* i s added t o t h e base

    addr e ss h i gh t o i n c r e m e n t t he addr ess by 1 , The r e s u l t a n t

    b y t e becomes t h e h i gh o r d e r by t e of t he e f f e c t i v e a d d r e s s *

    The base addr e ss h i gh w i l l be used as t he h i gh o r d e r by t e i f

    no c a r r y *

    Zero Page I n d e x e d The i n s t r u c t i o n s w i t h t he z e r o

    page i ndexed a d d r e s s i n g mode i n c l u d e an DP CODE and a base

    address low * Whi l e d a t a i s b e i ng f e t c h e d f rom t he [ l ocat i on

    s p e c i f i e d by t h e base addr ess low i n page z e r o * t he base

    addr ess low is added t o t he da t a s t o r e d in e i t h e r t h e X

    r e g i s t e r or Y r e g i s t e r in o r d e r t o ge t an e f f e c t i v e addr ess

    i n page z e r o * . The d a t a f e t c h e d is no t used in l a t e r

    o p e r a t i o n s * No page c r o s s i n g is a l l o w e d in t h i s mode*

    I n d i r e c t — The i n s t r u c t i o n s w i t h t h e i n d i r e c t

    a d d r e s s i n g mode c o n t a i n t h r e e by t es l i k e t hose w i t h the

    a b s o l u t e a d d r e s s i n g mode* The second b y t e c o n t a i n s t h e low

    o r d e r b y t e of an i n d i r e c t a d d r e s s * w h i l e t he t h i r d by t e

    c o n t a i n s t he h i gh o r d e r b y t e o f t he i n d i r e c t a d d r e s s * Once

  • 29

    t h e i n d i r e c t addr ess has been s e t upj> t h e low o r de r b y t e and

    h i gh o r d e r b y t e of an e f f e c t i v e addr ess ar e f e t c h e d f rom t h e

    l o c a t i o n s s p e c i f i e d by t h e i n d i r e c t address and i t s

    c o n s e c u t v i e a d d r e s s , r e s p e c t i v e l y , , The e f f e c t i v e address

    wi I I be used f o r t he n e x t OP CODE f e t c h o

    A b s o l u t e I n de x e d — The i n s t r u c t i o n s us i ng t h e

    a b s o l u t e i ndexed a d d r e s s i n g mode i n c l u d e t h r e e b y t e s , an

    OP CODE, a base address low, and a base a d d r e s s hi gho The

    f a c i l i t y to add t h e base addr ess low to e i t h e r t h e X

    r e g i s t e r or Y r e g i s t e r i s p r o v i d e d t o compose t h e low o r de r

    by t e of an e f f e c t i v e addresso To c a r r y out a page c r o s s i n g ,

    t he t e c h n i q u e to add a c a r r y to t he base a dd r e ss h i gh is

    used o

    R e l a t i v e — The i n s t r u c t i o n s w i t h t he r e l a t i v e

    a d d r e s s i n g mode c o n s i s t o f an OP CODE and an o f f s e t o An

    e f f e c t i v e a dd r e ss is c a l c u l a t e d by means of t h e address of

    t h e l o c a t i o n where t h e n e x t OP CODE f e t c h w i l l be pe r f o r me d

    i f a br anch is not t a k e n and t h e o f f s e t . The page c r o s s i n g

    can occur in t h i s modeo

    F u r t h e r i n f o r m a t i o n r e g a r d i n g t h e a d d r e s s i n g modes

    i s e x t e n s i v e l y d e s c r i b e d in r e f e r e n c e 4«

  • CHAPTER 3

    I NTERNAL OPERATIONS ANALYSI S

    I n t h e p r e c e d i n g c h a p t e r » a b r i e f d e s c r i p t i o n of t he

    6502 m i c r o p r o c e s s o r has been p r e s e n t e d , , Whi l e t h e

    d e s c r i p t i o n wi . i l g i v e t he r e a d e r a b a s i c k nowl edge of t h e

    6502.P i t w i l l not be enough f o r t h e d e v e l o pme n t o f a 6502

    AH PL d e s c r i p t i o n , . S u f f i c i e n t i n f o r m a t i o n c o n c e r n i n g t h e

    e x t e r n a l b e h a v i o r o f t h e 6502 must be o b t a i n e d so t h a t t he

    i n t e r n a l o p e r a t i o n s of t h e 6502 can be a n a l y z e d f o r t h e

    devel opment , . The i n f o r m a t i o n can be f ound i n r e f e r e n c e s 3

    and 4 o A summary o f c y c l e by c y c l e o p e r a t i o n o f t h e 6502

    has been pr oduced f rom t h e i n f o r m a t i o n a v a i l a b l e i n t he

    above r e f e r e n c e s and has been a t t a c h e d i n Appendi x B„

    Appendi x B w i l l be h e l p f u l in a n a l y z i n g t h e i n t e r n a l

    o p e r a t i o n s of a l l i n s t r u c t i o n s o

    The pur pose o f t h i s c h a p t e r i s t o a n a l y z e t he

    i n t e r n a l o p e r a t i o n s o f a i l i n s t r u c t i o n s and i n p u t s in o r d e r

    t h a t a 6502 AHPL d e s c r i p t i o n can be e f f i c i e n t l y and

    s y s t e m a t i c a l l y dev e l opedo Ho we v e r s> i t w i l l no t be an easy

    t a s k t o a n a l y z e t h e i n t e r n a l o p e r a t i o n s o f a l l i n s t r u c t i o n s

    i n d i v i d u a l l y because t h e i n s t r u c t i o n s e t has as many as 151

    OP CODE0 s o S i n c e t h e i n t e r n a l o p e r a t i o n o f each i n s t r u c t i o n

    30

  • 31

    c o n s i s t s o f an a d d r e s s i n g p a r t and an e x e c u t i o n p a r t y t he

    i n t e r n a l o p e r a t i o n s of a l l i n s t r u c t i o n s can be co mp a c t ! y

    a n a l y z e d i n t er ms o f t h e a d d r e s s i n g p a r t s and t h e e x e c u t i o n

    p a r t s o f t he i n t e r n a l o p e r a t i o n s o.

    Hy pot heses

    B e f o r e p r o c e e d i n g w i t h t he a n a l y s i s o f t h e i n t e r n a l

    o p e r a t i o n s # s e v e r a l hypot heses w i l l be d e f i n e d , i n o r der to

    make t he 6502 AHPL d e s c r i p t i o n c l o s e r t o t h e a c t u a l ha r d wa r e

    o r g a n i z a t i o n of t he 6502o These hy p o t h e s e s must be t a k e n

    i n t o acc ount i n a n a l y z i n g t h e i n t e r n a l o p e r a t i o n s # because

    t h e AHPL d e s c r i p t i o n w i l l be based d i r e c t l y on t h e r e s u l t s

    o f t h i s a n a l y s i s o The hy p o t h e s e s w i l l be d e f i n e d as

    f o l l o w s :

    The Co n n e c t i o n s t o ALU *=— The ARGBUS must a l ways be

    co n n e c t e d t o argument 1 of t he ALU# w h i l e t h e IDBUS must be

    c o n n e c t e d t o a r gument 2« T h i s i s because o f a v o i d i n g t he

    n e c e s s i t y of a d d i t i o n a l i n t e r n a l buseso The o t h e r two

    ar gument s a r e c on nec t ed t o t he P r e g i s t e r and i n s t r u c t i o n

    decodero The c o n n e c t i o n bet ween t h e ARGBUS and ar gument 2

    and t he c o n n e c t i o n bet ween t he IDBUS and ar gument 1 ar e n o t

    P e r m i s s i b I e o

    ALUREG — The ALUREG can n o t s t o r e d a t a f o r more

    t hanone c y c l e 0 T h i s means t h a t ALUREG can not be used as a

    t e m p o r a r y r e g i s t e r u n l e s s t h e da t a w i l l be s t o r e d in ALUREG

    aga i n d u r i n g t he n e x t eye I eo Onl y t h e d a t a f rom t h e ALU can

  • be s t o r e d in ALUREGo

    The Use o f TR Owing t o t h e h y p o t h e s i s o f t he

    c o n n e c t i o n s t o t he ALUs> t h e use o f t h e t e mp o r a r y r e g i s t e r i s

    assumed t o save d a t a used f o r a d d r e s s i n g in l a t e r

    op e r a t e o n s „

    I ADBUS[8 s153 t o ALU — The d a t a on t he IADBUSC8S15]

    i s a l l o w e d t o be t r a n s m i t t e d t o t he ALU over t h e ARGBUS f o r

    an a r i t h m e t i c o p e r a t i o n * The c o n n e c t i o n be t ween t h e

    IADBUSC OS 73 and ARGBUS i s not a l l o w e d .

    These h y p o t h e s e s a r e a l s o d e f i n e d i n F i g u r e 2 and

    T a b l e 2 . S i nce t he o t h e r c o n n e c t i o n s and o p e r a t i o n a l

    f e a t u r e s no t i n c l u d e d i n t h e h y p o t h e s e s can be e a s i l y

    d e r i v e d f rom t h e i n f o r m a t i o n a v a i l a b l e in r e f e r e n c e s 3, 4j>

    and 5s> t h e s e c o n n e c t i o n s and o p e r a t i o n a l f e a t u r e s were

    d e f i n e d i n advance w i t h o u t q u e s t i o n . By add i ng t he

    hypot heses^ t he c o n n e c t i o n s bet ween t h e i n t e r n a l buses*

    i n t e r n a l r e g i s t e r s * and CLU°s have been c o m p l e t e l y d e f i n e d .

    Now* t h e i n t e r n a l o p e r a t i o n s can be a n a l y z e d by means of t h e

    c o m p l e t e l y d e f i n e d i n t e r n a l a r c h i t e c t u r e .

    Genera I Sequence

    As a l l i n s t r u c t i o n s have common o p e r a t i o n c y c l e s

    such as t he OP CODE f e t c h c y c l e and t h e f o l l o w i n g d a t a f e t c h

    c y c l e * i t i s p o s s i b l e to b u i l d a g e n e r a l sequence o f t h e

    i n t e r n a l o p e r a t i o n s o f a f l - i n s t r u c t ions. . An i n t e r n a l

    o p e r a t i o n sequence o f each i n t e r n a l o p e r a t i o n can be w r i t t e n

  • 33

    by u s i n g t h e g e n e r a l sequence as a b a s i c formo The g e n e r a l

    sequence os g i v e n in F i g u r e 4 o To p r e p a r e f o r t h e l a t e r

    d i s c u s s i o n on t he a d d r e s s i n g p a r t s and e x e c u t i o n p a r t s * each

    c y c l e o f t h e g e n e r a l sequence w i l l be e x p l a i n e d as f o l l o w s :

    TO — The TO c y c l e i s t h e OP CODE f e t c h c y c l e and i s

    common t o t he i n t e r n a l o p e r a t i o n s of a l l i n s t r u c t 5o n s 0 To

    f e t c h an OP CODE f rom pr ogr am memory* t he f o l l o w i n g

    o p e r a t i o n s must occ ur : F i r s t * t h e p r oc e s s or p u t s a 1 6 - b i t

    addr e ss on t he IADBUS* and p l a c e s l o g i c 1 on t h e SYNC and

    R/W o u t p u t l i n e s t o i n d i c a t e t h e e x e c u t i o n of t h e OP CODE

    f e t c h c y c l e and a r ead o p e r a t i o n , , Then* t h e OP CODE on t he

    DBUS is t r a p p e d i n t o I R 0 Du r i n g t he c y c l e * t h e address on

    t he IADBUS is t r a n s f e r r e d i n t o INC ° The addr ess i n c r e me n t e d

    in INC i s s t o r e d in INR f o r l a t e r o p e r a t i o n s * I n t e r n a l

    r e g i s t e r s t h a t ar e t o p r o v i d e an addr ess on t h e IADBUS w i l l

    be d e t e r m i n e d by t he p r e c e d i n g i n s t r u c t i o n * The PC i s

    s e l e c t e d i n t he TO c y c l e w i t h o u t any meani ngs*

    The above o p e a t i ons ar e c o n c i s e l y d e s c r i b e d in AHPL

    i n F i g u r e 4* I n i n t e r n a l o p e r a t i o n sequences* owi ng t o t h e

    naming c o n v e n t i o n o f t h e HPSIM2 s i m u l a t o r C63* c l o s e l y

    r e l a t e d symbol names a r e adopt ed f o r t he a c t u a l i n p u t and

    o u t p u t * For i n s t a n c e * t h e R/W o u t p u t s i s named RW h e r e *

    I n a d d i t i o n * t he IADBUS i s i m p l i c i t l y c o n nec t ed t o t h e

    ADBUS * The above c o n s i d e r a t i o n i s because t he i n t e r n a l

    o p e r a t i o n sequences d e r i v e d f rom t h e g e n e r a l sequence can be

  • 34

    TO:

    T l :

    T n - 1 :

    Tn:

    Tn+1:

    TOCOVLP] :

    T1COVLP3:

    1 ADBUS « PC; IR

  • 35

    d i r e c t l y u t i l i z e d f o r t he d ev e l o pment o f t he 65 0 2 AHPL

    d e s c r i p t i o n o

    I I — The T1 c y c l e i s t h e d a t a f e t c h c y c l e f o l l o w i n g

    t he OP CODE f e t c h and i s a l s o common t o t he i n t e r n a l

    o p e r a t i o n s o f a l l i n s t r u c t i o n s o F i r s t ? t h e add r e s s s t o r e d

    i n INR i s p l a c e d on t h e IADBUS f o r a d d r e s s i n g o At t h e same

    t i me? t h e p r o c e s s o r put s l o g i c 0 on t h e SYNC l i n e and l o g i c

    1 on t he R/.W l i n e t o i n d i c a t e t he e x e c u t i o n o f a non-OP CODE

    f e t c h c y c l e and a r e a d o p e r a t i o n , , Next? as i n t h e TO cyc l e ?

    t h e addr ess on t he IADBUS i s i n c r e m e n t e d in INC and t hen

    s t o r e d in I N R 0 Be f o r e d e l e t e d by t he new a dd r e s s f rom INC?

    t h e addr ess p r e v i o u s l y s t o r e d i n INR must be t r a n s f e r r e d

    i n t o PC t o be used in l a t e r op er a t i ons o

    Tn- 1? Tn? and Tn-H — These c y c l e s s t a r t a t t h e T2

    c y c l e and end i m m e d i a t e l y b e f o r e t he TOCOVLP3 eye 1e 0 The

    number of t h e c y c l e s v a r i e s d e p end i ng upon each i n s t r u c t i o n ?

    For example? t h e i n s t r u c t i o n s u s i n g t he i mme d i a t e a d d r e s s i n g

    mode do not need such c y c l e s ? w h i l e t he i n s t r u c t i o n s

    empl oyi ng" t h e i n d i r e c t i n d e x e d a d d r e s s i n g mode r e q u i r e a t

    l e a s t t h r e e c y c l e s ? These c y c l e s a r e p r o v i d e d t o s p e c i f y

    o p e r a t i o n s f o r an a d d r e s s i n g p a r t and e x e c u t i o n p a r t ? Some

    i n s t r u c t i o n s such as t h e JMP i n s t r u c t i o n and b r a n c h

    i n s t r u c t i o n s do not r e q u i r e any o p e r a t i o n s f o r t h e

    e x e c u t i o n p a r t s of t h e i r i n t e r n a l o p e r a t i o n s ?

    T0E0VLP3 — The T0E0VLP3 c y c l e i s t h e OP CODE

  • f e t c h c y c l e of t he n e x t i n s t r u c t i o n and I s e x a c t l y t h e same

    as t h e TO eye 1 eo However * t o d i s t i n g u i s h t he OP CODE f e t c h

    c y c l e of t he n e x t I n s t r u c t i o n f rom t h e OP CODE f e t c h c y c l e

    of t h e c u r r e n t i n s t r u c t i o n ? t h e space f o r s p e c i f y i n g

    o p e r a t i o n s f o r t h e a d d r e s s i n g p a r t and e x e c u t i o n p a r t

    d e f i n e d by t h e c u r r e n t i n s t r u c t i o n has been p r o v i d e d in t he

    TOEOVLP3 eye 1eo W i t h r e s p e c t to t h e a d d r e s s i n g p a r t in t h e

    T0C0VLP3 c y c l e ? r e g i s t e r s to s u p p l y a . 1 6 - b i t f u l l addr ess t o

    t h e 1 ADBUS a r e d e t e r m i n e d by t h e c u r r e n t i n s t r u c t i o n o Some

    o p e r a t i o n s f o r t he e x e c u t i o n p a r t can o v e r l a p t h e TOE0VLP3

    c y c l e i f n e c e s s a r y o However? t h e c o n f l i c t on t h e i n t e r n a l

    b u s e s ? i n t e r n a l r e g i s t e r s ? and CL.lHs must be avo i de do The

    IDBUS i s u s u a l l y a v a i l a b l e f o r t h e e x e c u t i o n p a r t d u r i n g

    t h i s cyc l eo

    T1C0VLP3 — The T1E0VLP3 c y c l e has t h e same

    o p e r a t i o n s as t h e T l c y c l e has o The T1E0VLP3 c y c l e can a l s o

    be o v e r l a p p e d by t he e x e c u t i o n p a r t o f t h e p r e c e d i n g

    i n s t r u c t i o n ? as in t he T0EDVLP3 eye Ieo

    Si nce i t is assumed t h a t t he OP CODE f e t c h e d d u r i n g

    t h e TO c y c l e i s t he f i r s t i n s t r u c t i o n and no i n s t r u c t i o n

    pr e c e d e s t h a t i n s t r u c t i o n ? t he TO and T l c y c l e s c ou l d not be

    o v e r l a p p e d by an e x e c u t i o n par to T h i s is t he r eas on t h a t

    o n l y t he T0EOVLP3 and T1E0VLP3 c y c l e s can accommodate

    o p e r a t i o n s f o r an e x e c u t i o n p a r t o The T0E0VLP3 c y c l e can

    s p e c i f y r e g i s t e r s used f o r a d d r e s s i n g as w e l l o The

  • 37

    a s s umpt i on me n t i o n e d above i s a l s o a p p l i e d t o t h e summary of

    c y c l e by c y c l e o p e r a t i o n of a l l i n s t r u c t i o n s i n Appendi x B

    and t he i n t e r n a l o p e r a t i o n sequences o f t y p i c a l i n s t r u c t i o n s

    i n Appendi x C 6

    Address 8 ng P ar t s

    Because t h e r e a r e s t i l l more t han 35 d i f f e r e n t

    a d d r e s s i n g p a r t s of t he i n t e r n a l o p e r a t i o n s o f a l l

    i n s t r u c t i o n s ; t he a d d r e s s i n g p a r t s w i l l be d i s c u s s e d in

    t e r ms o f t h e a d d r e s s i n g t e c h n i q u e s used in t he 6502 f o r a

    more c o n c i s e d e s c r i p t i o n 0 The a d d r e s s i n g t e c h n i q u e s in

    a c c o r d a n c e w i t h t h e a d d r e s s i n g modes me n t i o n e d i n Ch a p t e r 2

    w i l l cover t h e most o f t h e a d d r e s s i n g p a r t s s u f f i c i e n t l y ;

    and a r e i n t e n d e d t o a n a l y z e o n l y t h e o p e r a t i o n s used f o r t h e

    a d d r e s s i n g p a r t s o I n advance o f a n a l y s i s of any

    i n s t r u c t i o n ; t he summary o f c y c l e by c y c l e o p e r a t i o n o f t he .

    i n s t r u c t i o n s p r o v i d e d in Appendi x B sho u l d be s t u d i e d t o be

    a b l e t o do c y c l e by c y c l e a n a l y s i s , .

    The a d d r e s s i n g p a r t in t he TO; T l ; and T1COVLP3

    c y c l e s i s common t o a l l i ns t r u c t i ons o S i n c e t h e d i s c u s s i o n

    on t h e o p e r a t i o n s in t he s e c y c l e s has a l r e a d y been

    p r e s e n t e d ; o n l y t he o p e r a t i o n s i n t h e T2 c y c l e t h r o u g h t h e

    TO EOVLP 3 c y c l e w i l l be d i s c u s s e d as f o l l o ws , ,

    I mmed i a t e

    I mmed i a t e a d d r e s s i n g does not r e q u i r e any a d d i t i o n a l

  • 38

    c y c l e s . Thusj> t n e p r o c e s s o r t a k e s 2 c y c l e s t o p e r f o r m

    I mme d i a t e a d d r e s s i n g . S i n c e t h e i n s t r u c t i o n s u s i n g t he

    i mmed i a t e a d d r e s s i n g mode c o n s i s t o f two bytesj> an OP CODE

    and a c o n s t a n t va l ues INR must be used as an a d d r e s s i n g

    r e g i s t e r t h a t p r o v i d e s a X6^bi t addr ess on t he I ADBUS, The

    INR has t h e i n c r e me n t e d address p o i n t i n g t o t h e l o c a t i o n ,

    s t o r i n g t he OP. CODE f o l l o w i n g t h e c o n s t a n t v a l u e . The

    r e a d e r sh o u l d r e f e r t o t h e g e n e r a l sequence i n F i g u r e 4 f o r

    i mmedi a t e a d d r e s s i n g and i g n o r e t he T n - l s Tns and Tn - 1

    c y c l e s . Not e t h a t INR w i l l be s e l e c t e d among t h e a d d r e s s i n g

    r e g i s t e r s d u r i n g t he TOCOVLP] c y c l e ,

    A b s o l u t e

    A b s o l u t e a d d r e s s i n g r e q u e s t s a t l e a s t one a d d i t i o n a l

    c y c l e . The i n s t r u c t i o n s u t i l i z i n g t h e a b s o l u t e a d d r e s s i n g

    mode have an OP CODE* t h e low o r d e r b y t e of ah e f f e c t i v e

    addr ess * and t he h i gh o r d e r by t e of t h e e f f e c t i v e a d d r e s s .

    D u r i n g t h e TX c y c l e * t h e low o r d e r b y t e is f e t c h e d and

    T 2 : IADBUS = I NR I DL

  • addr ess i n c r e m e n t e d in t he T1 c y c l e °

    B e f o r e m o d i f i e d by t he h i gh o r d e r by t e» t h e low

    o r d e r b y t e must be t r a n s f e r r e d f r om DL i n t o TR o v e r t he

    IDBUS d u r i n g t he T2 eye I eo Then? t he low o r d e r b y t e in TR

    and h i g h o r d e r b y t e in DL a r e c a t e n a t e d t o make up a 1 6 - b i t

    e f f e c t i v e addr ess i n t h e T3 c y c l e * The d a t a t o be t r e a t e d

    J n l a t e r o p e r a t i o n s w i l l be f e t c h e d f rom t h e l o c a t i o n

    s p e c i f i e d by t h i s a d d r e s s * S i n c e t h e address f o r t he n e x t

    DP CODE f e t c h has been pr oduced and s t o r e d i n PC i n t h e T2

    and T3 cy c l e s ? PC is used as an a d d r e s s i n g r e g i s t e r d u r i n g

    t he T0C0VLP3 eye ! e*

    The above o p e r a t i o n s a r e a l l common to t he

    a d d r e s s i n g p a r t s of t he i n t e r n a l o p e r a t i o n s o f t h e

    i n s t r u c t i o n s us i ng t he a b s o l u t e a d d r e s s i n g mode e x c e p t t h e

    JSR and JMP i n s t r u c t i o n s * The JHP i n s t r u c t i o n uses DL and

    TR as a d d r e s s i n g r e g i s t e r s d u r i n g t h e T DC OVLP 3 * The r e a d e r

    can i g n o r e t h e R/W and SYNC o u t p u t s u n l e s s o t h e r w i s e

    i n d i c a t e d * The d e l i b e r a t e use o f PC as a d d r e s s i n g r e g i s t e r

    i s a r r a n g e d f o r t he e f f e c t i v e s y n t h e s i s o f t he i n t e r n a l

    o p e r a t i o n s i n r e l a t i o n to a b s o l u t e i ndexed a d d r e s s i n g

    d i s c u s s e d l a t e r *

    The a d d r e s s i n g o f t h e JSR i n s t r u c t i o n r e q u i r e s 4

    e x t r a c y c l e s ? t h a t i s t h e T2 c y c l e t h r o u g h t he T5 c y c l e *

    Because of t h e o p e r a t i o n t o s t o r e a r e t u r n i n g addr ess in t he

    s t ack ? A JSR a d d r e s s i n g sequence w i l l d i f f e r r e m a r k a b l y f rom

  • t he t y p i c a l a b s o l u t e a d d r e s s i n g S e q u e n c e «

    B e f o r e t h e TZ c y c l e , DL s t o r e s t he low or der byt e o f

    an e f f e c t i v e a d d r e s s , and INR keeps the n e x t c o n s e c u t i v e

    a d d r e s s , as an t h e g e n e r a l $ e q u e n c e 0 Then, d u r i n g t h e TZ

    c y c l e , t he low o r d e r b y t e is t r a n s f e r r e d i n t o TR, and t he

    addr e ss as moved i n t o PC„ The DL and INR w i l l become f r e e

    IADBUS = \ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 1 \ , S P | DL

  • 41

    a r e t u r n i n g a d d r e s s 0 I n a d d i t i o n ; t h e a dd r e s s i n PC os used

    t o f e t c h t he h i gh o r d e r b y t e o f t h e e f f e c t i v e addr ess d u r i n g

    t he T5 eye Deo The l o c a t i o n t h a t c o n t a i n s t he n e x t OP CODE

    is a dd r e s s e d by DL and TR t h a t s t o r e t he h i gh o r d e r b y t e and

    low o r d e r b y t e * r e s p e c t i v e l y .

    Ze r o Page

    Zer o page a d d r e s s i n g r e q u i r e s a t l e a s t t h e T2 c y c l e .

    The i n s t r u c t i o n s u s i n g t h e z e r o page a d d r e s s i n g mode c o n s i s t

    of an OP CODE and an e f f e c t i v e a dd r e s s in page z e r o ; which

    ar e f e t c h e d in t h e TO and T l c y c l e s . Now; by u s i n g t h e

    e f f e c t i v e addr ess in DL; t he p r o c e s s o r can a dd r e s s a

    l o c a t i o n i n page z e r o where e i t h e r a r ead o p e r a t i o n or w r i t e

    T 2 o I AD BUS = \ 0 ; 0 ; 0 ; 0 ; 0 ; 0 ; 0 ; 0 \ ; D L | SYNC « . \ 0 \ |RW s \ 0 \ | PC

  • 42

    mode have o n l y an OP CODEo The g e n e r a l sequence sho u l d be

    r e f e r r e d t o f o r t h i s addr e s s i ng; ,

    I m p l i e d

    As f a r as t he PHAj> PHPp PLAj, PLP» RT I f RTSp and BRK

    i n s t r u c t i o n s a r e no t concer ned^ t h e i m p l i e d a d d r e s s i n g i s

    c o m p l e t e l y t he same as a c c u m u l a t o r a d d r e s i n g * No

    e x p l a n a t i o n w i l l be n e c e s s a r y 0 The RTI i n s t r u c t i o n w i l l be

    e x p l a i n e d on b e h a l f o f t h e above i n s t r u c t i o n s as f o 1 1ows §

    As in t h e case o f t h e JSR i n s t r u c t i o n p t h e RTI

    a d d r e s s i n g empl oys t h e s t a c k p o i n t e r o An 8 - b i t b i n a r y one

    f o r page one i s f i r s t g e n e r a t e d by t h e p r o c e s s o r and t hen

    T 2: IADBUS = X Op Op Op Op Op Op Op 1 \ p S P 5 DL

  • 43

    d i r e c t l y t r a n s f e r r e d i n t o INRCOs7 3 o Th i s i s f o r a v o i d i n g a

    page c r o s s i n g o The p r e v i o u s c o n t e n t s o f t h e P r e g i s t e r a r e

    r e s t o r e d f rom t h e i n c r e m e n t e d s t a c k addr ess i n t h e T3 e y c l e 0

    I n t h e T3 and T4 eyclesj> t he s t a c k addr ess i s

    i n c r e m e n t e d t w i c e t o ge t back a 1 6 - b i t r e t u r n i n g addresso

    The low o r d e r b y t e o f t he r e t u r n i n g address i s f i r s t f e t c h e d

    and s t o r e d i n .01 d u r i n g t h e T4 e y e I e D Du r i n g t h e T5 c y c l e *

    w h i l e t h e h i gh o r d e r b y t e i s b e i n g f e t c h e d * t h e low o r d e r

    b y t e i s moved i n t o TR0 F i n a l l y * an e f f e c t i v e addr ess f rom

    0L and TR* whi ch is a l s o a r e t u r n i n g a dd r e ss i s p u t on t he

    IADBUS t o p e r f o r m t h e n e x t OP CODE f e t c h 0 The above

    sequence does not i n c l u d e any o p e r a t i o n s f o r t h e e x e c u t i o n

    p a r t d e s c r i b e d above = A c o mp l e t e i n t e r n a l o p e r a t i o n

    sequence o f RTI i s a t t a c h e d in Appendi x Co

    I n d e x e d I n d i r e c t

    I nde x e d i n d i r e c t a d d r e s s i n g r e q u i r e s t h e T2 c y c l e

    t h r o u g h t he T5 e y c l e 0 1 Fi r s t * p l a c i n g a base a d d r e ss low

    S t o r e d in DL and e i g h t 0 ° s f o r page z e r o on t h e IADBUS* t h e

    p r o c e s s o r f e t c h e s d a t a d u r i n g t he T2 c y c l e o I n t h e same

    c y c l e * t he i n c r e me n t e d addr ess in INR is t r a n s f e r r e d i n t o PC

    t o be saved u n t i l i t i s needed o Then* INREO s73 s t o r e s o n l y

    t h e h i g h o r d e r b y t e on t he IADBUS t h a t i n d i c a t e s page z e r o o

    The low o r d e r b y t e on t he IADBUS f r om DL i s p l a c e d on t h e

    ARGBUS f o r an a r i t h m e t i c o p e r a t i on o S i nc e t he add r e ss on

    t h e IADBUS is not a d d r e s s i n g an e x p e c t e d memory space in

  • page z e r o ? t h e d a t a f e t c h e d is s i m p l y d i sca r de d , ,

    To ge t t h e e x p e c t e d a d d r e s s , t he 8 - b i t da t a on t he

    ARGBUS and t he c o n t e n t s o f t h e X r e g i s t e r must be added in

    t h e ALUo Four a r gument s a r e r e q u i r e d in t he ALU„ Argument

    12 s IADBUS “ 0 , 0 , 0 , 0 , 0 , 0 , 0 \ , D L a DL

  • 45

    e f f e c t i v e addr ess i s f e t c h e d f rom t he add r e ssed l o c a t i o n and

    t h e n s t o r e d in D i o The addr ess on t h e I A D B U S i s i n c r e me n t e d

    i n XNCp ' b u t . o n l y t h e low o r de r b y t e i s t r a n s f e r r e d i n t o

    I N R C 8 s i 5 ] o The above o p e r a t i o n is d e v i s e d t o a v o i d not on l y

    a page c r o s s i n g but a l s o t he n e c e s s i t y o f an 8 - b i t

    i n c r e m e n t e r / d e c r e m e n t e r u n i t on t h e A H P l d e s c r i p t i o n

    d e v e l o p e d in t he n e x t c h a p t e r o The h i gh o r d e r b y t e o f t h e e f f

    a c t i v e add r e ss is f e t c h e d f rom t h e c o n s e c u t i v e l o c a t i o n

    a d d r e s s e d by INR in t he T4 eye Ie 0 The low o r d e r b y t e must

    be t r a n s f e r r e d i n t o TR b e f o r e d e l e t e d , , F i n a l l y * DL and TR

    p l a c e t h e e f f e c t i v e addr ess on t he I ADBUS d u r i n g t h e T5

    c y c l e ° The address of t h e l o c a t i o n where t h e n e x t OP CODE

    f e t c h w i l l be p e r f o r me d comes f r om PC k e e p i n g t h e addr ess

    s i n c e t h e T2 c y c l e o

    I n d i r e c t I n d e x e d

    I n d i r e c t i n d e x e d a d d r e s s i n g uses t h e Y r e g i s t e r as

    an argument of t he ALU f o r addr ess c a l c u l a t i o n , ) The

    c a t e n a t i o n of e i g h t 0 ? s and an i n d i r e c t a d d r e s s low i n DL

    pr oduces a 1 6 - b i t i n d i r e c t addr ess i n page z e r o to be used

    t o f e t c h a base addr ess low d u r i n g t he T2 eye I e

  • 46

    Wh i l e a base addr e ss -h igh i s b e i n g f e t c h e d f rom t he

    l o c a t i o n s p e c i f i e d by t he i n c r e m e n t e d i n d i r e c t addr ess

    s t o r e d i n I NR* t he base addr ess flow i n DL must be added t o

    J 2 i I ADBUS = \ { b O j > 0 » O j > 0 4 0 j > b # 6 \ j > D L ? DL

  • 47

    F i r s t s t he iow o r d e r b y t e on t he IADBUS f rom ALUREG

    must be t r a n s f e r r e d i n t o I NRC8S153 f o r . t he n e x t c y e i e o The

    d a t a f e t c h e d i n t h i s c y c l e i s d i s c a r d e d because o f an

    i n c o r r e c t a d d r e s s . Then* f o r a n o t h e r a r i t h m e t i c o p e r a t i o n s

    t h e base a dd r e ss h i gh c u r r e n t l y s t o r e d in DL i s p u t on t h e

    IDBUS and an 8 - b i t b i n a r y one is p l a c e d on t he ARGBUSo By

    t h e s e o p e r a t i o n s s t h e base a dd r e ss h i gh can be i n c r e me n t e d

    by 1 in o r d e r to r e f l e c t a page c r o s s i n g . I n t h e n e x t

    c y c l e s ALUREG and I NRC8S15] pr oduce a c o r r e c t address t o

    s p e c i f y a l o c a t i o n where r e a d and w r i t e o p e r a t i o n s can be

    done. The PC as an a d d r e s s i n g r e g i s t e r p l a c e s t h e addr ess

    f o r t h e ne x t OP CODE f e t c h on t h e IADBUS d u r i n g t he T0C0VLP3

    c y c l e .

    Zer o Page I nde x e d

    Zer o page i ndexed a d d r e s s i n g empl oys t h e ALU f o r

    e f f e c t i v e addr e ss c a l c u l a t i o n . The above i s t h e o n l y

    d i f f e r e n c e f r om z e r o page a d d r e s s i n g . Du r i n g t h e T2 cyc l e s

    T2s IADBUS = XOsOsOsOs OsOsOsOVsDL l DL < * DBUS5SYNC = \OX 5 RW = X1XJ I N R £ 0 S 7 3

  • 48

    t h e p r o c e s s o r p l a c e s an 8 - b l t b i n a r y ze r o and t h e base

    a dd r e ss low k e p t I n DL on t h e IADBUS to f e t c h d a t a »

    However ; t h e d a t a l a t c h e d I n t o DL I s c o m p l e t e l y v o i d because

    t he a dd r e ss I s port i t i n g t o a f a l s e I o c a t i on o The p r i ma r y

    aim o f t h i s c y c l e i s t o e x e c u t e t h e e f f e c t i v e addr ess

    c a l c u l a t i o n I n t he ALUo Thus; t h e low o r d e r b y t e on t he

    IADBUS f rom DL is c o n n e c t e d to a r gument 1 t h r o u g h t h e

    ARGBUS; and t he c o n t e n t s o f e i t h e r t h e X r e g i s t e r or Y

    r e g i s t e r a r e s e n t t o ar gument 2 over t he XDBUSo

    The r e s u l t a n t 8 - b i t d a t a f rom t h e ALU os s t o r e d in

    ALUREGo I n t h e same c y c l e ; onl y t he XADBUSEOs 73 i nd i c a t i n g

    page z e r o i s t r a n s f e r r e d i n t o XNRCOs73 The add r e ss f o r t h e

    n e x t OP CODE f e t c h in XNR is saved in PC u n t i l I i t i s

    n e c e s s a r y o I n t he n e x t c y c l e ; XNR CO $73 and ALUREG f orm an

    e f f e c t i v e a d d r e s s . The above sequence i n c l u d e s two

    a d d i t i o n a l c y c l e s f o r t he i n s t r u c t i o n s t h a t p e r f o r m a l o g i c

    o p e r a t i o n . The e f f e c t i v e addr ess d u r i n g t he T 4 and T5

    c y c l e s i s p r o v i d e d by XNR in whi ch t h e e f f e c t i v e addr ess on

    t h e XADBUS was s t o r e d d u r i n g t h e T3 c y c l e . No page c r o s s i n g

    i s a l l o w e d ; as in z e r o page a d d r e s s i n g .

    I n d i r e c t

    Onl y a c e r t a i n OP CODE can f o r c e t h e p r o c e s s o r t o

    p e r f o r m i n d i r e c t a d d r e s s i n g . The i n s t r u c t i o n u s i n g t he

    i n d i r e c t a d d r e s s i n g mode c o n t a i n s an OP CODE; an i n d i r e c t

    addr ess low; and an