BoxIdee

6502 ASSEMBLER

Recently, after a quite long period of silence, I got a request from a friend from Spain who has a passion for the AIM 65 board. He is a is very smart and dedicate guy and share with me the love for the fantastic primordial machines built around the 6502 CPU.
The request was to extract the Editor and Compiler sections from my original program to allow its use with the Rockwell AIM 65.

Despite of my very little knowledge about this platform, I thought it was an easy task...until I started to put hands and brain on this idea; wrong perception!
The main and unsolvable problem is my age! After several years passed from the original idea I lost a large amount of neurons, my memory is like a dynamic RAM not enough refreshed and, in the meantime, VB6 was abandoned by MS and I moved to C on PIC embedded projects...thus, I did recognized a little of what I created.

After a few attemps, the only valid solution found was to keep only the minimum core of the program e rebuild everything else, GUI included. The final result is a new program, surely with a quantity of bugs, but enough to write a code and assembly it.
The big difference respect the previous program is that this one in indipendent from the platform it is used with. An external auxiliary program, the MakeGlobal, allow to define the labels and addresses specific for the specific HW, if wished, like i.e. I/O devices, control ports, special HW chips.

What follows is the Help File, yet to be finished, contained within the program; it gives some short informations about how the program is done and how to use it.


Download

This is the link to download the zipped folder with all the necessary to run the program.
Zipped folder version 3.1
The source code is still in evolution and I hope to have the time to make it final.
I would pray anyone who will use it to send me an email with the first name and the country of origin, for my own curiosity, thanks.




Introduction

The program is aimed to convert a plain text file (.TXT), generated with the internal Editor or with any other standard text editor, in an assembly file (.HEX) to be programmed into an EEPROM or loaded in RAM on an HW development platform.
The expected instruction set is the 6502 standard, excluding the extra instructions of the 65C02 or other models. Anyway, it is possible to modifify the instruction's table inside the 'Tables' folder to include and reflect any other specific instruction.


Program Folders

To be executed the program requires a few special folders with some mandatory files inside; these are:

  • Tables: contains the tables used to translate the source:
    • Codes.txt: progressive list of recognized instructions with mnemonic, adrFormat, numBytes, cycles, boundary crossing.
      The two values are only for compatibility with the Simulator; not used here
    • Mnemonics.txt: alphabetical order of instructions with the hex value for each addressing format
    • Formats.txt: list of the 13 addressing modes used by the 6502
  • Includes: coontains the auxiliary files - NOT MANDATORY - generated for the Global labels (HW specific) and for the Monitor (or Kernel, if you prefer) which is a common program with customer's routines to be allocated in RAM
    • globals.lab: list of global declarations generated with the external exe MakeGlobals
    • Monitor.txt: source of the Monitor program
    • Monitor.lab:labels of the Monitor program
    • NOTE: if the Monitor has been compiled, there will be other two files: Monitor.lst and Monitor.exe
  • Projects: this will host all the projects created by user; the folfer is created at the very first launch of the program. Inside, the program generates a new folder for each project to collected all the produced files.


Program Structure

The window has three zones: the left one shows the raw text code; the middle one is the formatted vision and the right one present all the created projects.
A double click on a project name opens the text files, if the current one has been saved.
To delete a project visit the Projects folder and delete the folder with the project's name.
The top bar has the actions buttons: 'Create a new Project', 'Save the source', 'Open the Monitor'.
When the new or loaded text is completed it must be saved to enable its compilation.
After a succesful compilation with the 'Compile' button the right window list the result and the recognized labels in the source, in the Globals and in the Monitor, if it exists.
Within the Option it is possible to define whether to include or exclude the external labels.
The compiled file must be saved with the 'Save compiled' to create the .HEX, .LAB (labels) and .LST (listing) files.
In any error occurs during the loading or compiling phases, the lower message bar will report the error encountered and where. Fixed the offending line, the text file must be resaved e recompiled.
The bottom bar contains the field and command to find a text inside the source or to replace part of it with a differente value. Again, any change requires a new save and compile.


SYNTAX

Line of code

The source is a list of rows terminated by a CrLF; empty lines are allowed to permit blocks separation. It can be created with any text editor respecting these few rules:

  • CASE: the source is case insensitive since every row is internally converted to Upper, with the only exceptios of comments, ASCII strings or alphanumeric operand values.
  • LABEL: it must start at column 0 (first character of the row), with a max lenght of 10 chars. Chars allowed are all the letters A..Z, numbers 0..9 and the sign '_' (underscore): i.e. Lab_01
  • INSTRUCTION: must be preceeded and followed by at least a space o tab.
    Beside all the 6502 instruction mnemomics the program recognizes and accepts the directives listed further.
  • OPERAND: follow the 6502 standard as explained in the relevant paragraph
  • COMMENT: comment starts with a ';' (semicolon). It can occupy an entire row by itself starting at any position within the line or, tipically, it follows the operand.

Note that, as per default, any supplied value for operand or directives is considered to be a decimal value; it is anyway suggested to preceed it with the standard '#' sign. On the contrary, to input an hexadecimal value, it must be preceded with a '$' sign.

Directives

These directives are defined:

  • ORG: define the starting address for the generated code. NOTE: no checks is performed on the supplied value; it is user's responsability to give a valid value
  • EQU: assigns a value to a label in the range x00..xFFFF, as a numerica value or as a Label[+/-) a numeric value. I.e.
  • ASC: text string in plain text, min lenght of 1 char, included between a double quote pair
  • DFB: define a single byte value in binary or decimal
  • DWL: define a long binary value in little indian mode (low value first)
  • DWB: define a long binary value in big indian mode (high value first)
  • END: signal the end of code; it is not really required

Operand formats

The operand can be missing (for some implict instructions as 'CLC' or omitted for implicit as in 'LSR' or can be an 'A' as in ''PHP A', .
Numeric values are expressed in decimal mode (default) as '10' or, better, preceeded by an hash as '#10' or preceeded by dollar sign for hex as '$10'.
To enter an single ASCII code can be used in the form LDA #"H" including the letter within doublequotes.
In more complex operands it can be a label only or a label +/- a value to make a simple calculation as 'JMP HERE-$20'.
At last, it can be a standard 6502 format with or without a calculation, as in 'STA (TAB+10),Y'.
Please note that the +/- signs must follow and preceed the operands; no spaces are allowed.



SPECIAL FEATURES

Global labels

At launch the program searches for a file called Globals.lab inside the Includes folder. This file is created and modified by the auxiliary executable MakeGlobals.
It is a simple table where you can Add/Modify/Delete any label with its hex address/value and an optional comment.
The labels are typically the hardware resources available on the platform like I/O and ports controls.

Monitor

You can create a file with common routines or definitions to be called from your application. This is standard text file like any other project, but its name must be Monitor.
It is invoked from the command bar by hitting the Monitor button and the source, labels, listing and exe are stored inside the Includes folder.
At launch the program checks the Includes folder and, if the labels file exists, load the the Monitor labels and builds the specific Popup menu.

Labels Popup lists

A right click inside the editor window will open a Popup Menu with 3 sections for Program, Globals and Monitor labels (these last 2 if they exist). Selecting a label from the list will insert the label text in the code.
The Program labels are updated at any source saving.



Click any immagine to zoom in


Main window

ì