Programming the 65816
Total Page:16
File Type:pdf, Size:1020Kb
Programming the 65816 Including the 6502, 65C02 and 65802 Distributed and published under COPYRIGHT LICENSE AND PUBLISHING AGREEMENT with Authors David Eyes and Ron Lichty EFFECTIVE APRIL 28, 1992 Copyright © 2007 by The Western Design Center, Inc. 2166 E. Brown Rd. Mesa, AZ 85213 480-962-4545 (p) 480-835-6442 (f) www.westerndesigncenter.com The Western Design Center Table of Contents 1) Chapter One .......................................................................................................... 12 Basic Assembly Language Programming Concepts..................................................................................12 Binary Numbers.................................................................................................................................................... 12 Grouping Bits into Bytes....................................................................................................................................... 13 Hexadecimal Representation of Binary................................................................................................................ 14 The ACSII Character Set ..................................................................................................................................... 15 Boolean Logic........................................................................................................................................................ 16 Logical And........................................................................................................................................................ 16 Logical Or .......................................................................................................................................................... 17 Logical Exclusive Or........................................................................................................................................... 17 Logical Complement........................................................................................................................................... 17 Signed Numbers .................................................................................................................................................... 18 Storing Numbers in Decimal Form....................................................................................................................... 19 Computer Arithmetic............................................................................................................................................ 20 Microprocessor Programming.............................................................................................................................. 20 Machine Language.............................................................................................................................................. 20 Assembly Language............................................................................................................................................ 22 Writing in Assembly Language ............................................................................................................................ 22 Basic Programming Concepts............................................................................................................................... 23 Selection Between Paths...................................................................................................................................... 24 Looping .............................................................................................................................................................. 24 Subroutines......................................................................................................................................................... 24 2) Chapter Two.......................................................................................................... 26 Architecture of the 6502 ............................................................................................................................26 Microprocessor Architecture................................................................................................................................ 26 The 6502 Registers ................................................................................................................................................ 26 The Accumulator ................................................................................................................................................ 27 The X and Y Index Registers............................................................................................................................... 29 The Status Register ............................................................................................................................................. 29 Abbrev................................................................................................................................................................ 30 Name.................................................................................................................................................................. 31 The Stack Pointer................................................................................................................................................ 31 The Program Counter.......................................................................................................................................... 33 Addressing Modes................................................................................................................................................. 33 Instructions ........................................................................................................................................................... 35 The 6502 System Design........................................................................................................................................ 38 Pipelining ........................................................................................................................................................... 38 Memory Order of Multiple-Byte Values .............................................................................................................. 39 Memory-Mapped Input/Output............................................................................................................................ 39 Interrupts ............................................................................................................................................................ 39 NMOS Process ...................................................................................................................................................... 40 Bugs and Quirks ................................................................................................................................................... 40 3) Chapter Three ....................................................................................................... 41 Architecture of the 65C02 .........................................................................................................................41 The 65C02 Architecture........................................................................................................................................ 41 Addressing Modes................................................................................................................................................. 41 Instructions ........................................................................................................................................................... 42 CMOS Process ...................................................................................................................................................... 42 Bugs and Quirks ................................................................................................................................................... 42 4) Chapter Four......................................................................................................... 44 Sixteen-Bit Architecture The 65816 and the 65802...................................................................................44 2 The Western Design Center Power-On Status: 6502 Emulation Mode..................................................................................................45 The Full-Featured 65x Processor: The 65816 in Native Mode ................................................................45 The Program Bank Register ................................................................................................................................. 47 The Data Bank Register........................................................................................................................................ 48 The Direct Page Register ...................................................................................................................................... 48 The Stack Pointer.................................................................................................................................................. 48 Accumulator and Index Registers ........................................................................................................................ 48 Switching Registers