Skip to content

Commit

Permalink
Added new sections to readme, update license
Browse files Browse the repository at this point in the history
Add more sections to README.md

Create new file structure for project.

Updated commented out code.

Reformatted all operations.

Add skeleton for processing statements.

Continue refactor.

Simplify Operation table.

Move operations into separate file.

Start adding directives to translate various addressing modes.

Now parses included files.

Better handling of translation function.

Add Operand class.

Add proper class for Symbols.

Add ability to translate some pseudo ops.

Sort out storing hex.

Try and solidify how to access hex values.
  • Loading branch information
craigthomas committed Dec 21, 2019
1 parent 41d9b85 commit 015b702
Show file tree
Hide file tree
Showing 15 changed files with 1,089 additions and 523 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*.pyc
.idea
6 changes: 1 addition & 5 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (C) 2013-2016 Craig Thomas
Copyright (C) 2013-2019 Craig Thomas

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
Expand All @@ -16,7 +16,3 @@ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Except as contained in this notice, the name(s) of the above copyright holders
shall not be used in advertising or otherwise to promote the sale, use or other
dealings in this Software without prior written authorization.
132 changes: 69 additions & 63 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,105 +1,111 @@
# Yet Another Color Computer 3 Assembler / Disassembler
# CoCo Assembler

## What is it?

This project is a Color Computer 3 assembler and disassembler written in
Python.
[![Build Status](https://img.shields.io/travis/craigthomas/CoCo3Assembler?style=flat-square)](https://travis-ci.org/craigthomas/CoCo3Assembler)
[![Codecov](https://img.shields.io/codecov/c/gh/craigthomas/CoCo3Assembler?style=flat-square)](https://codecov.io/gh/craigthomas/CoCo3Assembler)
[![Dependencies](https://img.shields.io/librariesio/github/craigthomas/CoCo3Assembler?style=flat-square)](https://libraries.io/github/craigthomas/CoCo3Assembler)
[![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)](https://opensource.org/licenses/MIT)

The Color Computer 3 is the third incarnation of the Tandy Radio Shack
Color Computer line (TRS-80). The CoCo 3 offered several improvements over the
original CoCo 1 and CoCo 2, most notably the introduction of a memory
management unit (MMU) and a new Advanced Color Video Chip (ACVC) - also known
as the Graphics Interrupt Memory Enhancer (GIME).
## Table of Contents

While the official name of the computer was the TRS-80 Color Computer 3,
the Color Computer family was quite different from the line of business
machines such as the TRS-80 Model I, II, III, and 4. While that family
of computers used a Zilog Z80 microprocessor, the Color Computer family used
a Motorola 6809E processor running at 0.89 MHz.
1. [What is it?](#what-is-it)
2. [Requirements](#requirements)
3. [License](#license)
4. [Installing](#installing)
5. [Usage](#usage)

## Current Status - May 27, 2013
## What is it?

The assembler is in its first phases of development, and is subject to
change. Check the documentation below for more information on how to use
it.
This project is an assembler for the Tandy Color Computer 1, 2 and 3 written in Python 3.6.
It is intended to be statement compatible with any code written for the EDTASM+ assembler.

## Roadmap
## Requirements

Under construction.
In order to run the assembler, you will need Python 3.6 or greater. If you
prefer to clone the repository, you will need Git (if you don't want to
install Git, then check the [Releases](https://github.com/craigthomas/CoCo3Assembler/releases)
section for the newest release of the package that you can download.

## License

This project makes use of an MIT style license. Please see the file called
LICENSE for more information.


## Installing

Simply copy the source files to a directory of your choice. In addition to
the source, you will need the following required software packages:
To install the source files, download the latest release from the
[Releases](https://github.com/craigthomas/CoCo3Assembler/releases)
section of the repository and unzip the contents in a directory of your
choice. Or, clone the repository in the directory of your choice with:

* [Python 2.7+ or 3](http://www.python.org)
git clone https://github.com/craigthomas/Chip8Assembler.git

I strongly recommend creating a virtual environment using the
[virtualenv](http://pypi.python.org/pypi/virtualenv) builder as well as the
[virtualenvwrapper](https://bitbucket.org/dhellmann/virtualenvwrapper) tools.
Next, you will need to install the required packages for the file:

pip install -r requirements.txt


## Usage

The assembler is used to transform assembly language statements into 6809E
machine code. A source file of assembly language statements is broken up into a
number of columns:
To run the assembler:

LABEL OPERATION OPERAND # COMMENT
python assembler.py input_file --output output_file

Where each column contains the following:
This will assemble the instructions found in file `input_file` and will generate
the associated Color Computer machine instructions in binary format in `output_file`.

* `LABEL` - a label to be applied to the operation or declaraion. A label may be
composed of any alphanumeric characters, and can be any length.
* `OPERATION` - the operation to execute.
* `OPERAND` - the data to apply to the operation.
* `COMMENT` - a textual comment to be applied to the operation, can be any length
and is terminated by a newline character.
### Input Format

A full example would be:
The input file needs to follow the format below:

BUFFER EQU $6100 # START OF BUFFER
BUFFEND EQU $7FFF # END OF BUFFER
START LDY #$0FF00 # LOAD INPUT PIA ADDRESS
LDX #BUFFER # LOAD BUFFER PNTR ADDRESS
INP000 LDB #10 # SELECT RIGHT,X
JSR $A9A2 # SELECT SUBROUTINE
LABEL MNEMONIC OPERANDS COMMENT

To run the assembler:
Where:

* `LABEL` is a 15 character label for the statement
* `MNEMONIC` is a Chip 8 operation mnemonic from the [Mnemonic Table](#mnemonic-table) below
* `OPERANDS` are registers, values or labels, as described in the [Operands](#operands) section
* `COMMENT` is a 30 character comment describing the statement (must have a `;` preceding it)

An example file:

# A comment line that contains nothing

python coco3asm.py input_file -o output_file

This will assemble the instructions found in file `input_file` and will generate the
associated CoCo machine instructions in binary format in `output_file`. Additional
options include printing the symbol table:
### Print Symbol Table

python coco3asm.py test.asm -s
To print the symbol table that is generated during assembly, use the `--symbols`
switch:

python assembler.py test.asm --symbols

Which will have the following output:

-- Symbol Table --
BUFFER $6100
START $6000
INP000 $6007
BUFFEND $7FFF
-- Symbol Table --


Print out the assembled version of the input:
### Print Assembled Statements

python chip8asm/chip8asm.py test.asm -p
To print out the assembled version of the program, use the `--print` switch:

python assembler.py test.asm --print

Which will have the following output:

-- Assembled Statements --
6000 108E FF00 START LDY #$0FF00 # LOAD INPUT PIA ADDRESS
6004 8E 6100 LDX #BUFFER # LOAD BUFFER PNTR ADDRESS
6007 C6 0A INP000 LDB #10 # SELECT RIGHT,X
6009 BD A9A2 JSR $A9A2 # SELECT SUBROUTINE

With this output, the first column is the offset in hex where the statement starts,
the second column contains the full machine-code operand, the third column is the
user-supplied label for the statement, the forth column is the mnemonic, the fifth
column is the register values of other numeric or label data the operation will
work on, and the fifth column is the comment string.

## Mnemonic Table

### Mnemonics

### Pseudo Operations

### Operands

## Further Documentation

Expand Down
57 changes: 57 additions & 0 deletions assembler.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
"""
Copyright (C) 2019 Craig Thomas
This project uses an MIT style license - see LICENSE for details.
A Color Computer Assembler - see the README.md file for details.
"""
# I M P O R T S ###############################################################

import argparse

from cocoasm.program import Program

# F U N C T I O N S ###########################################################


def parse_arguments():
"""
Parses the command-line arguments passed to the assembler.
"""
parser = argparse.ArgumentParser(
description="Assembler for the Tandy Color Computer 1, 2, and 3. See README.md for more "
"information, and LICENSE for terms of use."
)
parser.add_argument("filename", help="the input file")
parser.add_argument(
"--symbols", action="store_true", help="print out the symbol table"
)
parser.add_argument(
"--print", action="store_true",
help="print out the assembled statements when finished"
)
parser.add_argument(
"--output", metavar="FILE", help="stores the assembled program in FILE")
return parser.parse_args()


def main(args):
"""
Runs the assembler with the specified arguments.
:param args: the command-line arguments
"""
program = Program(args.filename)

if args.symbols:
program.print_symbol_table()

if args.print:
program.print_statements()

if args.output:
program.save_binary_file(args.output)


main(parse_arguments())

# E N D O F F I L E #######################################################
Loading

0 comments on commit 015b702

Please sign in to comment.