Motorola 6800/01 absolute assembler
by Joel Matthew Rees between 10 October and 17 October 1985.
Copyright 2010 Joel Matthew Rees.
Written for cs432 at Brigham Young University for J. J. Ekstrom
The author(s) grant permission to use or distribute this program
under the terms of version 3.0 of the GNU General Public License (GPL).
(See <http://www.gnu.org/>.)
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
Refer to the file LICENSE.text included with the source.
If that file was not included, see <http://www.gnu.org/licenses>.
The original project should be at <http://asm68c.sourceforge.net>.
The fig-FORTH model code for the 6800 is included as a sample,
and for more extensive testing. The GPL does not cover the model
source code files. The model is provided courtesy of the
FORTH Interest Group and its successors, see the model files
themselves for conditions for distribution, etc.
=============================================
No makefile necessary:
cc -Wall -o asm68c *.c
will do the trick just fine, for now.
(It's a really simple assembler.)
However, we now have a simple Makefile,
with simple automated testing against
goal output.
make test
to invoke only the tests, and
make testclean
to remove the test by-products.
No make install at this time.
Copy the asm68c executable to ~/bin, or
/usr/local/bin or your other equivalent,
to install.
=============================================
Run the assembler as
asm68c <source>.68c
if you hand-install, or
path/asm68c <source>.68c
if you don't install by hand.
Look in asm68c.c for the main function for such options as there are.
Presently, the options must be specified in order.
If you use "LD A" instead of "LDA A" (or "LDB" instead of "LDAB") syntax,
you'll want the "-a" option.
Restrictions on source code locations and names/extensions have been
removed.
---------------------------------------------------------------------------
Files in the distribution:
asm68c.c defines the main funtion and the overall flow.
asm68c.h is the global header information.
asmspec is the specification which was approved by the teacher for the project.
exp.c/h is the expression evaluater code (easy recursive descent).
mne68c.c/h is the mnemonics table.
The table is sorted and converted to a balanced binary tree at startup.
It contains 6801 extensions.
I may be able to add 68HC11 extensions, as well.
(Added the sorting and balancing, August 2012 -- JMR).
ops68c.c/h is the operand parser.
LICENSE.text is the license (GPL3) extended by the original author.
(.text because I sometimes thumb my nose at certain lax practices.)
README.text is this file.
Makefile is the usual make file.
teststuff contains files for testing.
teststuff/Makefile runs the (crude) regression tests.
teststuff/chk_600?.ods are two files that I used in manually
checking the output, to bootstrap the automated tests. Format is
Libreoffice spreadsheet.
teststuff/autotest_680*.68c contain all the mnemonics and enough
addressing modes to pretty thoroughly test the output.
teststuff/*.goal are reference output files, the goals for testing
to match against.
Other files in teststuff are short files for specific testing purposes.
newtestlc.68c is newtest.68c in lower case.
(No, the current version doesn't.)
tek.68c was something that shouldn't have been here, but was.
(No it doesn't assemble, either.)
The leftovers directory contains things that might be of interest.
The tools directory contains tools that were useful and might still be.
The fig-forth directory contains the fig FORTH model code and some tools
I used in getting the model code transcribed and debugged. The file
fig-forth_exorsim.68c contains modifications for running the model under
Joe Allen's exorsim exorcisor emulator. See the README in that directory
for more.
---------------------------------------------------------------------------
Notes:
Two tricks I slipped in that I shouldn't have:
Write "LDAA" and "LDAB" as "LDA" and LDB";
likewise, "STAA" and "STAB" as "STA" and STB", also OR.
But I have now made the standard syntax the default. The shorter
syntax is still available by the -a command line option, but the
code that enables it is really, really brittle.
I was wishing for a 6809 at the time, I think.
I'll have to untangle them from LDD and STD to make them standard.
Or maybe I'll add dual syntax by macros. Or something.
(Stupid fetish with pulling the A/B/D parameters off
the ends of the operator mnemonics.
Logical games that waste time.)
The short funtion names and file names derive from the work
environment we had back then. (6~8 significant characters.)
Much of the structure derives from my prior experience with BASIC,
ForTran, Pascal, FORTH, early M6800 assemblers etc., my lack of
experience with separate compile, and my personal take on the
older K&R syntax.
The brittle hand-optimized binary tree symbol table was something
I repeated in BIF-6809, and it remains in bif-c as I write this.
This program took too much of my time relative to the class.
The quality of my implementation caused one of the TAs to suspect
I had copied the code from somewhere. She grilled me on the
techniques, and I guess she was satisfied. But I ran out of time,
had to take an incomplete and finish the coursework after I
dropped out.
Oh, BIF-6809, my FORTH was what I finished the course with.
I still don't understand what level the teachers intended us to
work at on the homework. Why bother having students do any
homework if there's no time for understanding, only time for
going through the motions?
And, ultimately, you just copy what the teacher shows you and
try to fill in the gaps, and if you're unlucky enough to be off
the teacher's wavelength, you're dead meat.
Well, everybody else just copied from the board. I tried to
really understand. I was dead meat.
I think this was the course that I let do me in, trying too hard.
---------------------------------------------------------------------------
Began code cleanup on 23 July 2010.
Completed initial cleanup on 26 July 2010,
cleanly compiled on gcc and assembled a short test file.
More code cleanup, added op-code table sorting and balancing, 20-24 August 2012.
After some intermediate work at various dates, I was able to implement
standard LDA/STA syntax (keeping the short LD/ST syntax as the -a option)
between March 20th and April 2nd, 2013.
---------------------------------------------------------------------------
To do (if I could ever justify the time, in no particular order):
Find or produce a real test file that does something useful.
(And what would I run it on?)
(Looking at the fig-FORTH that I hand-loaded on my micro-chroma68
prototyping board thirty years ago. That's a lot of typing, but no real
programming. Maybe I can get one of my kids to do it at the Japanese
minimum wage. Or I could convert the fig-FORTH to subroutine threading,
to make it sort of more compatible with other 6800 low-level source code.)
* Full mnemonic/address mode testing implemented Fall of 2012.
* Automated the tests April 2, 2013.
Fix the S1/S9 object output (or was it S1/S10?) and checksum code.
(I'm sure it's wrong.)
* Checksum fixed, 2012.08.21.
* S9 record needs some way to know the entry point (pseudo-op).
* Workaround: ORG <start> at the end, with no code following.
Convert the symbol table code to better support adding mnemonics.
(Such as macro definitions and relative pseudo-ops?)
* Partial, fall 2012 to spring 2013, but the code is not robust.
Build an emulator to run the code on. (Fun stuff! 8-))
I should be able to relax the checks that require the image array.
Convert it to assemble M6809 source code.
(Lost opportunities. Oh, the lost opportunities. <:-< )
(And 6805/8/etc.?
Dig out my 68K code generator and turn that into an assembler?
Would require a thorough re-write.
I made too many beginner mistakes.
The re-write could be fun or quick. Maybe even both?)