This section contains links to a variety of computer science topics, methods algorithms and software for the ubiquitous 6502 microprocessor. Much of the material is unique or not readily available elsewhere.
The contents of the navigation subsections are:
(image courtesy of http://microscopy.fsu.edu, used by permission)
The 6502 represented a major step forward in the microcomputer revolution. Many programmers, hackers, hobbyists and experimenters cut their binary and hex teeth on this device (myself included).
On this web site, you will find some unique support for the 6502. Among the files are a simulator/trainer which runs on Windows '95 and up. It is loosely based on the KIM-1. In the tools section there is a full-featured assembler and a source generator.
One of the earliest of the high quality floating point math packages available to the microcomputer community was called KIMath. The KIMath subroutine package, developed by MOS Technology for the KIM-1, was published with a complete manual and assembler source code. I have ported the manual to machine readable form, including the source code, and made all the files available here. John Cooper generously provided a pure ASCII port of the manual which is also included. The package contains a version of KIMath which is in a format readable by the assembler available elsewhere on this web site, and a version in Intel hex format. The assembler file can be easily edited to work with any other 6502 assembler. A recently discovered photocopy of the original manual was scanned into PDF format and is now included.
This is a 6502 simulator which resembles the early 6502 single board computers such as the KIM-1, but implemented in software and providing additional features made possible by the Windows operating system.
The simulator files, including a Windows help system and demonstration programs, can be downloaded here. This program is well-suited to training novices in assembler language programming and in 'resurrecting' 6502 software from the past. The simulator supports the complete 6502 instruction set and both binary and decimal operating modes. It does not support external interrupts.
The simulator and the software tools use a special file format with a file extender of 'h6x'. This format is intended to provide a simple representation of 6502 code in an ASCII environment for easy editing. For example,
0200 A9 23
0202 8D 01 80
0205 00
is a fragment from a file named 'test.h6x'. Each line begins with an address in hex format and one or more bytes of hex data separated by spaces. The example above is the 6502 code for loading the accumulator with 23 (hex) and storing that value in memory location 8001 (hex). A break instruction completes the fragment.
An early firmware extender for the Commodore PET 2001 computer. This is a reconstruction of the source code. Although the product is no longer manufactured, this project was undertaken for its educational and historic value.
I have recently reconstructed a source code version of Palo Alto ICs BASIC Programmer's Toolkit. This BASIC extender was one of the first firmware accessories for the PET and the first to use the BASIC 'wedge' technique for extending the capabilities of the resident BASIC.
The Toolkit adds the following commands:
AUTO - automatic user specified line numbering
DELETE - delete a range of line from a BASIC program
FIND - locate all program lines which contain a given string or variable
DUMP - list all simple variables and strings with their current values
RENUMBER - renumber the lines of a program with given starting value and step size
APPEND - add a tape program to the end of the current program
TRACE - trace program lines in scroll box on screen
STEP - execute a program one line at a time
OFF - turn off TRACE or STEP mode
HELP - display error line and highlight point of error
The reconstructed source code can be downloaded here. This version is optimized for assembly with the cbA65 assembler. An assembled listing may facilitate porting the source to another assembler.
This page provides access to several programmer's tools including a full-featured 65xx assembler and a handy source generator with manuals.
The assembler which was previously posted on this website has undergone a massive upgrade and is now superceded by cbA65.
This new assembler has a number of advanced features including:
Optional record of opcode statistics in log file
Listing format optimized for readability
Cycle count option including branch page crossing correction and indexing info
Support for anonymous labels including label skip option
Output file formats include Intel Hex, MOS Technology Hex, Motorola S-Record, ROM image, and more.
Cross-reference file sorted alphabetically or by line defined
Warning for page boundary crossing on indirect addresses
Memory alignment option with optional fill byte
Support for NULL or CR/LF terminated strings
Complete manual in Adobe Acrobat format with 65xx reference, charts and diagrams
cbA65.zip contains the assembler, the manual and a brief readme file. In the manual, an optimal algorithm for identifying 65xx mnemonics by 'perfect' hashing is disclosed.
In addition to the assembler, here is a source generator which can read raw binary ROM or H65 file format and create assembler source files. It will also read a user generated support file specifying label names or data types and addresses, if available. This capability can improve the readability of the resulting source file. If you ever wanted a degree as a "Reverse Engineer", this will put you on your way.
ReSource65 includes a User's Guide in Adobe Acrobat format and a sample binary file. The sample file is used as an example in the documentation to show new users how to take advantage of the capabilities of Resource65.
The article "Here's HUEY! -- supercalculator for the 6502" by Don Rindsberg, was published in an early issue of Kilobaud magazine. It included code for the software as a hex dump. This archive includes a scan of the article and a reconstructed version of the source code. Some errors were identified and corrected. Assembler source code, listing files, and other support materials are included in the archive. HUEY! is posted with permission of the publisher.
Screen Shot of Calc65
This may represent the epitome of dragging obsolete technology into the 21st century, but better late than never! Specifically, the 'engine' is a 6502 floating point scientific math package. It is interpreted by an x86 interpreter which is called by a C++Builder application providing the display, registers and keyboard.
Here you will find source code for a full-featured, 6502 floating point
scientific math package.
The routines
are coded for assembly with the cba65 assembler
described elsewhere on this page. Available
routines include add, subtract, multiply, divide, square root, and all the
trigonometric and inverse trigonometric functions. Natural log, exponential, and
all hyperbolic and inverse hyperbolic functions are also included, as well as a
few utility functions.
The calculator which demonstrates the math package consists of a Windows user interface, a 6502 emulator, and the assembled object code in H6X File format. Rounding has not been consistently implemented as yet, so there will sometimes be an unnecessarily large loss in precision when complexfunctions or multiple operations are involved. Caveat emptor.
Internally, the math routines use Cordic algorithms and similar strategies involving pseudo-multiplication and pseudo-division. The square root routine employs non-restoring pseudo-division as described in this paper. The BCD number format occupies 8 bytes and is described in the source code, a fragment of which is displayed here. Note that there are 12 mantissa digits and 3 exponent digits supporting a maximum value of +9.999999999 E+999.
Floating Point Number Format for fltpt65.cba
This internal format can be represented in printed form as:
D.DDDDDDDDDDD EDDD
where the 'D's represent mantissa or exponent digits.
This package is not production quality code. It is still at beta testing level, so be prepared to encounter bugs. There are unused functions and tables which have not been purged from the package, so it requires more RAM space than necessary. I will investigate any problems reported by users, but at the moment I am focusing my attention on an extended precision version of the routines which I will post later.
NOTE: This code could motivate a homebrew project to build a simple scientific calculator using an LCD or LED display, a 6502, a keypad, and suitable memory.