Using 6502 assembly language : how anyone can program the Apple II 9780835981514, 0835981517

517 123 16MB

English Pages 286 [299] Year 1981

Report DMCA / Copyright

DOWNLOAD FILE

Using 6502 assembly language : how anyone can program the Apple II
 9780835981514, 0835981517

Table of contents :
Chapter 1
INTRODUCTION 1-1
Purpose of Manual 1-1
Scope of Manual 1-1
General 1-1
Chapter 2
SYMBOLISM 2-1
General 2-1
Bit Strings 2-3
Binary Arithmetic 2-8
Unsigned Integers 2-9
Nibbles (NYBBLES?), Bytes, and Words 2-10
Signed Integers 2-11
Hexadecimal Numbers 2-13
Radix and Other Nasty Diseases 2-14
ASCII Character Set 2-14
Using Bit Strings to Represent Instructions 2-16
Chapter 3
REGISTERS, INSTRUCTION FORMATS,
AND ADDRESSING 3-1
General 3-1
Accumulator (A or ACC) 3-3
X-Register (X) 3-3
Y-Register (Y) 3-3
Stack Pointer (SP) 3-4
Program Status Word (P or PWS) 3-4
Program Counter (PC) 3-4
Instruction Format (6502) 3-4
Two and 3-Byte Instructions 3-6
6502 Addressing Modes 3-8
Chapter 4
SOME SIMPLE INSTRUCTIONS 4-1
General 4-1
Assembly Language Source Format 4-1
Introduction to Real Instructions 4-4
Register Increments and Decrements 4-8
Labels and Variables 4-9
Expressions in the Operand Field 4-11
Chapter 5
ASSEMBLY LANGUAGE 5-1
General 5-1
Example Program 5-2
JMP Instruction 5-3
Processor Status (P) Register 5-5
Break Flag (B) 5-6
Decimal Flag (D) 5-6
Interrupt Disable Flag (Z) 5-6
Condition Code Flags (N, V, Z, C) 5-7
Branch Instructions (6502) 5-9
Loops 5-10
Comparisons 5-11
IF/THEN Statement Simulation 5-14
FOR/NEXT Loop Revisited 5-14
Testing Boolean Values 5-18
Chapter 6
ARITHMETIC OPERATIONS 6-1
General 6-1
Unsigned Integer (Binary) Arithmetic 6-1
Subtraction 6-4
Signed Arithmetic 6-5
Signed Comparisons 6-7
Binary Coded Decimal Arithmetic 6-8
Unsigned BCD Arithmetic 6-8
Signed BCD Arithmetic 6-10
Arithmetic Review 6-10
Chapter 7
SUBROUTINES AND STACK PROCESSING 7-1
General 7-1
Variable Problems 7-4
Passing Parameters 7-13
Chapter 8
ARRAYS, ZERO PAGE, INDEXED, AND
INDIRECT ADDRESSING 8-1
General 8-1
Zero Page Addressing 8-1
Arrays in Assembly Language 8-3
Initializing Arrays at Assembly Time 8-8
Using Index Registers to Access Array Elements 8-10
Indirect Addressing Mode 8-13
Indirect Indexed Addressing 8-16
Indexed Indirect Addressing Mode 8-18
Chapter 9
LOGICAL, MASKING, AND BIT OPERATIONS 9-1
General 9-1
Complement Function 9-2
AND Function 9-2
OR Function 9-3
EXCLUSIVE-OR Function 9-4
Bit String Operations 9-4
Instructions for Logical Operations 9-5
Masking Operations 9-7
Shift and Rotate Instructions 9-13
Shifting and Rotating Memory Locations 9-16
Using ASL to Perform Multiplication 9-17
Using Shifts to Unpack Data 9-19
Using Shifts and Rotates to Pack Data 9-20
Chapter 10
MULTIPLE-PRECISION OPERATIONS 10-1
General 10-1
Multiple-Precision Logical Operations 10-1
Multiple-Precision Shifts and Rotates 10-3
Multiple-Precision Logical Shift-Right Sequences 10-4
Multiple-Precision Rotate-Left Sequences 10-4
Multiple-Precision Rotate-Right Sequences 10-5
Multiple-Precision Unsigned Arithmetic 10-6
Multiple-Precision Unsigned Subtraction 10-8
Multiple-Precision Signed Arithmetic 10-9
Multiple-Precision Decimal Arithmetic 10-9
Multiple-Precision Increments 10-9
Multiple-Precision Decrements 10-10
Multiple-Precision Unsigned Comparisons 10-11
Signed Comparisons 10-14
Chapter 11
BASIC I/O 11-1
General 11-1
Character Output 11-1
Standard Output and Peripheral Devices 11-9
Character Input 11-11
Inputting a Line of Characters 11-13
Chapter 12
NUMERIC I/O 12-1
General 12-1
Hexadecimal Output 12-1
Outputting Byte Data as a Decimal Value 12-2
Outputting 16-Bit Unsigned Integers 12-4
Outputting Signed 16-Bit Integers 12-6
An Easy Method of Outputting Integers 12-6
Numeric Input 12-8
Unsigned Decimal Input 12-11
Signed Decimal Input 12-17
Chapter 13
MULTIPLICATION AND DIVISION 13-1
General 13-1
Multiplication 13-1
Division Algorithms 13-7
Chapter 14
STRING HANDLING OPERATIONS 14-1
String Handling 14-1
Declaring Literal Strings 14-5
String Assignments 14-5
String Functions 14-7
String Concatenation 14-9
Substring Operations 14-11
String Comparisons 14-12
Handling Arrays of Characters 14-17
Chapter 15
SPECIALIZED I/O 15-1
Apple I/O Structure 15-1
Chapter 16
AN INTRODUCTION TO SWEET-16 16-1
Sweet-16 16-2
Sweet-16 Hardware Requirements 16-10
Chapter 17
DEBUGGING 6502 MACHINE LANGUAGE
PROGRAMS 17-1
General 17-1
GO Command (G) 17-2
Initializing Registers and Memory 17-3
Modifying Instruction Code (Patching) 17-6
Program Debugging Session 17-10
Appendix A
APPLE II COMPUTER TABLES,
CHARTS, AND GRAPHS A-1

Polecaj historie