6502/65C02 Addressing Modes on the 65816 character, you can get an easy visualization of about how much storage 64K of memory is by thinking of that
Previous PDF | Next PDF |
[PDF] Visualizing a Classic CPU in Action: The 6502 - Visual 6502
Abstract We present a real-time interactive simulation and visualization of the classic 6502 microprocessor as it executes instructions and pro- cesses data
[PDF] Visualizing a Classic CPU in action : The 6502 - Visual 6502
All un-cited material and images are Copyright 2010, Greg James Page 3 MOS Technology's 6502 CPU Released 1975
[PDF] MOS Technology 6502
MOS Technology 6502 Overview ▷ Released in 1975 in 1975 saw a recession impact the silicon industry; 6502 sales flop as a result 6502 Visualization:
[PDF] PROGRAMMING ~ • INTERFACING THE 6502, - DigitalOcean
PET Interfacing • Programming and Interfacing the 6502, With Experiments Beginning programmers have a lot more trouble visualizing what is happening as
[PDF] Programming the 65816 - 6502org
6502/65C02 Addressing Modes on the 65816 character, you can get an easy visualization of about how much storage 64K of memory is by thinking of that
[PDF] 6502 emulator on FPGA Universiti Teknologi PETRONAS - UTPedia
The FPGA-based 6502 microprocessor had to emulate the functionality of a real 6502 Waveform viewers visualize the transitions of multiple signals over time
[PDF] CS6502 - APPLIED BIG DATA AND VISUALIZATION (Spring 2020
CS6502 - APPLIED BIG DATA AND VISUALIZATION (Spring 2020) Lab 9 In the previous 3 labs, you were asked to practice the ETL process learned from
[PDF] 6510 assembly
[PDF] 6510 cpu datasheet
[PDF] 6510 pinout
[PDF] 6510 xerox
[PDF] 65802 cpu
[PDF] 65816 addressing modes
[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
Programming the 65816
Including the 6502, 65C02 and 65802
Distributed and published under
COPYRIGHT LICENSE AND PUBLISHING AGREEMENT
withAuthors 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.comThe Western Design Center
2Table 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
3Power-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
4Absolute 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
56502 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
665802/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
Direct Page Indexed, X Addressing...................................................................................................................299
Direct Page Indexed, Y Addressing...................................................................................................................300
Direct Page Indexed Indirect, X Addressing.......................................................................................................301
Direct Page Indirect Addressing........................................................................................................................302
Direct Page Indirect Long Addressing...............................................................................................................303
Direct Page Indirect Indexed, Y Addressing.......................................................................................................304
Direct Page Indirect Long Indexed, Y Addressing..............................................................................................305
Immediate Addressing.......................................................................................................................................306
Implied Addressing...........................................................................................................................................307
Program Counter Relative Addressing...............................................................................................................308
Program Counter Relative Long Address...........................................................................................................309
Stack (Absolute) Addressing.............................................................................................................................310
Stack (Direct Page Indirect) Addressing............................................................................................................312
Stack (Interrupt) Addressing..............................................................................................................................314
Stack (Program Counter Relative) Addressing...................................................................................................316
Stack (Pull) Addressing.....................................................................................................................................317
Stack (Push) Addressing....................................................................................................................................319
Stack (RTI) Addressing.....................................................................................................................................321
Stack (RTL) Addressing....................................................................................................................................322
Stack (RTS) Addressing....................................................................................................................................323
Stack Relative Addressing.................................................................................................................................324
Stack Relative Indirect Indexed, Y Addressing..................................................................................................325
18)Chapter Eighteen..............................................................................................326
The Instruction Sets.................................................................................................................................326
Add With Carry..................................................................................................................................................327
And Accumulator with Memory.........................................................................................................................328
The Western Design Center
7Shift Memory or Accumulator Left....................................................................................................................329
Branch if Carry Clear.........................................................................................................................................330
Branch if Carry Set.............................................................................................................................................331
Branch if Equal...................................................................................................................................................332
Test Memory Bits against Accumulator.............................................................................................................333
Branch if Minus..................................................................................................................................................334
Branch if Not Equal............................................................................................................................................335
Branch if Plus......................................................................................................................................................336
Branch Always....................................................................................................................................................337
Software Break...................................................................................................................................................338
Branch Always Long...........................................................................................................................................340
Branch if Overflow Clear...................................................................................................................................341
Branch if Overflow Set.......................................................................................................................................342
Clear Carry Flag.................................................................................................................................................343
Clear Decimal Mode Flag...................................................................................................................................344
Clear Interrupt Disable Flag..............................................................................................................................345
Clear Overflow Flag............................................................................................................................................346
Compare Accumulator with Memory.................................................................................................................347
Co-Processor Enable...........................................................................................................................................349
Compare Index Register X with Memory...........................................................................................................350
Compare Index Register Y with Memory CPY..................................................................................................351
Decrement Index Register X...............................................................................................................................353
Decrement Index Register Y...............................................................................................................................354
Exclusive-OR Accumulator with Memory.........................................................................................................355
Increment Index Register X................................................................................................................................358
Increment Index Register Y................................................................................................................................359
Jump to Subroutine Long (Inter-Bank).............................................................................................................361
Jump to Subroutine.............................................................................................................................................362
Load Accumulator from Memory.......................................................................................................................363
Load Index Register X from Memory................................................................................................................364
Load Index Register Y from Memory................................................................................................................365
Logical Shift Memory or Accumulator Right.....................................................................................................366
Block Move Next.................................................................................................................................................367
Block Move Previous...........................................................................................................................................368
No Operation.......................................................................................................................................................369
OR Accumulator with Memory..........................................................................................................................370
Push Effective Absolute Address........................................................................................................................372
Push Effective Indirect Address.........................................................................................................................373
Push Effective PC Relative Indirect Address.....................................................................................................374
quotesdbs_dbs19.pdfusesText_25