[PDF] [PDF] Programming the 65816 - 6502org

6502/65C02 Addressing Modes on the 65816 New 65816 Addressing Modes Pushing and Pulling the 65816's Additional Registers



Previous PDF Next PDF





[PDF] Programming the 65816 - 6502org

6502/65C02 Addressing Modes on the 65816 New 65816 Addressing Modes Pushing and Pulling the 65816's Additional Registers



[PDF] W65C816S Microprocessor DATA SHEET - Description

calculates the effective address for relative and indexed addressing modes The BRK instruction for the NMOS 6502, 65C02 and 65C816 is actually a 2 byte  



[PDF] W65C816S 8/16–bit Microprocessor - Western Design Center

9 nov 2018 · register augments the Direct Page addressing mode (formerly Zero Page See Programming the 65816 Manual for more information



[PDF] AE 65816 16 bit Card - Apple-iigsinfo

Meg of memory, the full capability of the 65816 processor This Beta powerful instruction set and addressing modes make it an excellent choice for new 16-bit 



[PDF] THE 65816 - American Radio History

new absolute long addressing mode has been applied to the ¡SR (jump to sub- routine) instruction In addition to re- storing the program counter, RTL also



[PDF] ACORN COMMUNICATOR OFFICE WORK STATION

function keys, and mode switching between 6502 instructions and addressing modes It Like that of the CMOS 65C02, the instruction set of the 65816



[PDF] Exploring The Apple IIgs_HiRespdf - Apple Asimov

The 65816 Addressing Modes 30 Implied 30 · Accumulator 32 · Immediate 32 · Program Counter Relative 33 · Program Counter Relative Long 33 · Stack 33 · 



[PDF] C74-6502 Datasheetpages - WordPresscom

•24-bit address bus •Additional 65816 instructions and addressing modes • Software selectable implements the NMOS 6502 instruction set also, but replaces 

[PDF] 65816 computer

[PDF] 65816 coprocessor

[PDF] 65816 datasheet

[PDF] 65816 opcode table

[PDF] 65816 primer

[PDF] 65816 registers

[PDF] 65816 snes

[PDF] 65c02 assembler

[PDF] 65c02 digikey

[PDF] 65c02 emulator

[PDF] 65c02 opcodes

[PDF] 65c02 pinout

[PDF] 65c02 processor

[PDF] 65c22 datasheet

[PDF] 65c816 assembly language

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

2

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

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

The Stack Pointer................................................................................................................................................31

The Program Counter..........................................................................................................................................33

Addressing Modes.................................................................................................................................................33

The 6502 System Design........................................................................................................................................38

Memory Order of Multiple-Byte Values..............................................................................................................39

Memory-Mapped Input/Output............................................................................................................................39

NMOS Process......................................................................................................................................................40

Bugs and Quirks...................................................................................................................................................40

3)Chapter Three.......................................................................................................41

Architecture of the 65C02.........................................................................................................................41

The 65C02 Architecture........................................................................................................................................41

Addressing Modes.................................................................................................................................................41

CMOS Process......................................................................................................................................................42

Bugs and Quirks...................................................................................................................................................42

4)Chapter Four.........................................................................................................44

Sixteen-Bit Architecture The 65816 and the 65802...................................................................................44

The Western Design Center

3

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 Between Eight and Sixteen Bits............................................................................................50

The Status Register...............................................................................................................................................50

6502/65C02 Addressing Modes on the 65816........................................................................................................51

New 65816 Addressing Modes..............................................................................................................................52

The 65802 Native Mode.............................................................................................................................55

Emulation Mode....................................................................................................................................................58

Emulation Mode Registers....................................................................................................................................60

Switching Between 6502 Emulation and Native Modes............................................................................61

Switching from Emulation to Native Mode..........................................................................................................61

Switching from Native to Emulation Mode..........................................................................................................61

65802/65816 Bugs and Quirks...................................................................................................................62

5)Chapter Five..........................................................................................................64

SEP, REP, and Other Details....................................................................................................................64

The Assembler Used in This Book........................................................................................................................66

Address Notation...................................................................................................................................................68

6)Chapter Six............................................................................................................69

First Examples: Moving Data....................................................................................................................69

Loading and Storing Registers.............................................................................................................................71

Effect of Load and Store Operations on Status Flags............................................................................................73

Moving Data Using the Stack..............................................................................................................................73

Pushing the Basic 65x Registers..........................................................................................................................76

Pulling the Basic 65x Registers...........................................................................................................................76

Pushing and Pulling the 65816's Additional Registers..........................................................................................78

Pushing Effective Addresses................................................................................................................................79

Other Attributes of Push and Pull........................................................................................................................79

Moving Data Between Registers...........................................................................................................................79

Storing Zero to Memory.......................................................................................................................................86

Block Moves..........................................................................................................................................................87

7)Chapter Seven.......................................................................................................89

SimpleAddressing Modes..........................................................................................................................89

Immediate Addressing..........................................................................................................................................90

Absolute Addressing.............................................................................................................................................92

Direct Page Addressing.........................................................................................................................................94

Absolute Indexed with X and Absolute Indexed with Y Addressing...................................................................98

Direct Page Indexed with X and Direct Page Indexed with Y Addressing........................................................101

Accumulator Addressing....................................................................................................................................103

Implied Addressing.............................................................................................................................................103

Direct Page Indirect Addressing.........................................................................................................................104

Absolute Long Addressing..................................................................................................................................105

The Western Design Center

4

Absolute Long Indexed with X Addressing........................................................................................................108

Direct Page Indirect Long...................................................................................................................................109

Block Move..........................................................................................................................................................110

8)Chapter Eight......................................................................................................111

The Flow of Control.................................................................................................................................111

Jump Instructions...............................................................................................................................................112

Conditional Branching........................................................................................................................................114

Branching Based on the Zero Flag.....................................................................................................................115

Branching Based on the Carry Flag...................................................................................................................117

Branching Based on the Negative Flag..............................................................................................................118

Branching Based on the Overflow Flag..............................................................................................................119

Limitations of Conditional Branches..................................................................................................................119

Unconditional Branching....................................................................................................................................119

9)Chapter Nine.......................................................................................................122

Built-In Arithmetic Functions.................................................................................................................122

Increment and Decrement..................................................................................................................................123

Addition and Subtraction: Unsigned Arithmetic..............................................................................................127

Signed Arithmetic...............................................................................................................................................134

Signed Comparisons............................................................................................................................................136

Decimal Mode.....................................................................................................................................................137

10)Chapter Ten......................................................................................................139

Logic and Bit Manipulation Operations.................................................................................................139

Logic Functions...................................................................................................................................................139

Logical AND....................................................................................................................................................140

Logical OR.......................................................................................................................................................142

Logical Exclusive-Or........................................................................................................................................143

Bit Manipulation.................................................................................................................................................145

Shifts and Rotates...............................................................................................................................................146

11)Chapter Eleven.................................................................................................154

The Complex Addressing Modes.............................................................................................................154

Relocating the Direct Page..................................................................................................................................155

Assembler Addressing Mode Assumptions.........................................................................................................156

Direct Page Indirect Indexed With Y Addressing..............................................................................................158

Direct Page Indexing Indirect Addressing.........................................................................................................161

Absolute Indexed Indirect Addressing...............................................................................................................163

Direct Page Indirect Long Indexed with Y Addressing......................................................................................165

Stack Relative Addressing..................................................................................................................................166

Stack Relative Indirect Indexed Addressing......................................................................................................168

Push Effective Instructions.................................................................................................................................169

12)Chapter Twelve.................................................................................................174

The Basic Building Block:.......................................................................................................................174

The Subroutine....................................................................................................................................................174

The Jump-To-Subroutine Instruction................................................................................................................175

The Return-from-Subroutine Instruction..........................................................................................................175

JRS Using Absolute Indexed Indirect Addressing.............................................................................................177

The Long Jump to Subroutine............................................................................................................................178

Return from Subroutine Long............................................................................................................................178

Branch to Subroutine..........................................................................................................................................179

Coding a Subroutine: How and When................................................................................................................180

6502 Eight-Bit Negation - A Library Example..................................................................................................180

65C02, 65802, and 65816 Eight-Bit Negation....................................................................................................181

The Western Design Center

5

6502 Sixteen-Bit Negation................................................................................................................................181

65802 and 65816 Sixteen-Bit Negation..............................................................................................................181

Parameter Passing..............................................................................................................................................182

13)Chapter Thirteen..............................................................................................192

Interrupts and System Control Instructions...........................................................................................192

Processing Interrupts.........................................................................................................................................197

Interrupt Response Time...................................................................................................................................200

Status Register Control Instruction....................................................................................................................201

No Operation Instructions..................................................................................................................................202

14)Chapter Fourteen.............................................................................................204

Selected Code Samples.............................................................................................................................204

6502 Multiplication...........................................................................................................................................205

65C02 Multiplication........................................................................................................................................205

65802 and 65816 Multiplication........................................................................................................................205

6502 Division...................................................................................................................................................209

65C02 Division.................................................................................................................................................211

65802/65816 Division.......................................................................................................................................211

Calling an Arbitrary 6502 Routine.....................................................................................................................213

Testing Processor Type.......................................................................................................................................219

Compiler-Generated 65816 Code for a RecursiveProgram...............................................................................220

The Same Example Hand-Coded in Assembly Language...................................................................................224

The Sieve of Eratosthenes Benchmark...............................................................................................................226

15)Chapter Fifteen................................................................................................230

DEGUG16 - A 65816 Programming Tool...............................................................................................230

16)Chapter Sixteen................................................................................................276

Design and Debugging.............................................................................................................................276

Debugging Checklist...........................................................................................................................................276

Decimal Flag....................................................................................................................................................276

Adjusting Carry Prior to Add / Subtract.............................................................................................................276

65x Left-to-Right Syntax...................................................................................................................................276

65x Branches....................................................................................................................................................277

6502 Jump Bug.................................................................................................................................................277

Interrupt-Handling Code....................................................................................................................................277

65802/65816: Emulation Versus Native Mode...................................................................................................277

65802/65816: Eight-Bit Versus Sixteen-Bit Registers........................................................................................278

65802/65816: The Direct Page..........................................................................................................................278

The Western Design Center

6

65802/65816: Stack Overruns Program or Data.................................................................................................278

65802/65816: JSR/JSL and RTS/RTL................................................................................................................278

65802/65816: MVN/MVP.................................................................................................................................278

Return Address.................................................................................................................................................279

Inconsistent Assembler Syntax..........................................................................................................................279

Generic Bugs: They Can Happen Anywhere......................................................................................................279

Uninitialized Variables......................................................................................................................................279

Missing Code....................................................................................................................................................279

Failure to Increment the Index in a Loop............................................................................................................279

Failure to Clean Up Stack..................................................................................................................................280

Immediate Data Versus Memory Location.........................................................................................................280

Initializing the Stack Pointer from a Subroutine.................................................................................................280

Top-Down Design and Structured Programming..............................................................................................280

17)Chapter Seventeen............................................................................................283

The Addressing Modes............................................................................................................................283

Absolute Addressing.........................................................................................................................................288

Absolute Indexed, X Addressing.......................................................................................................................289

Absolute Indexed, Y Addressing.......................................................................................................................290

Absolute Indexed Indirect Addressing...............................................................................................................291

Absolute Indirect Addressing............................................................................................................................292

Absolute Indirect Long Addressing...................................................................................................................293

JMP [addr]........................................................................................................................................................293

Absolute Long Addressing................................................................................................................................294

Absolute Long Indexed, X Addressing..............................................................................................................295

Accumulator Addressing...................................................................................................................................296

Block Move Addressing....................................................................................................................................297

Direct Page Addressing.....................................................................................................................................298

quotesdbs_dbs4.pdfusesText_8