tokenrove / m68k-assembler

A simple, mostly-DevPAC-compatible assembler for the Motorola 68k series of proccessors.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

The goal of this assembler is to eventually not be simply an M68K
assembler, but to be relatively easily retargetable.  Also, this
assembler should be callable from other CL applications, as well as
executable as a stand-alone program.

The code's not so clean right now, maybe, but I've been using it for
various Atari ST projects for a little while now to great personal
satisfaction.


The a.out object format supported here and by st-linker is not really
quite exactly a.out.  It's close, though.


To build this from scratch, you'll need to do something like:
(in the m68k-asm directory)

CL-USER> (asdf:oos 'asdf:load-op :lalr-parser-generator)
CL-USER> (load "m68k-grammar")
CL-USER> (with-open-file (stream "parser.lisp" :direction :output)
            (lalr:make-parser m68k-asm::*m68k-asm-grammar*
                              :package (find-package "M68K-ASSEMBLER")
                              :stream stream))

I'm going to make that a bit cleaner at some point.



Things to add in the grammar/parser/lexer:

Support for ' (single ASCII character?) -- only because the
	book I have says it's part of Motorola's standard.  Should it
	behave like double-quotes or what?
Support for floats (once FPU instructions are supported).


Things to add in the assembler:

Checking ranges of types, signed indices, etc.
	Also, type checking information stored in the symbol table.
Output listings (with cycle counts, et cetera).
Support for later chips in the m68k line, and enabling/disabling
	allowance of their added instructions.
Change lookup tables so that on load, they get converted to hash
	tables or whatever's appropriate. [half-done]
Nifty local labels a-la GNU as or similar.  (0f, 1b, etc)
BRA.S (currently you have to say BRA.B).
CL-style macros?  (that would be cool!)
	The natural thing to do is join this with my other experiment
	(assembly lisp) and use a sexp intermediary form still
	accessible to the user which would be more amenable to
	macrology.
Debugger info.
Output in object formats other than A.OUT.
Optimizations/data flow analysis.
Optional lispy object format.  (see st-linker README)
Stuff to make guesses about pairs of MOVEM instructions at head of
	function and just before RTS/RTE, and warn the user if they
	mismatch.
Cleaner abstract syntax.


THINGS TO DO BEFORE RELEASE

- remove debugging output.
- add a decent warning/error display and logging system.
- compile list of known issues, try to resolve.
- put together a basic automated test suite.
  (once object format has settled down, start a set of regression files,
   with sane output verified by hand; also, feed smaller files that
   should deliberately provoke certain conditions in, watch for those
   conditions.)
- skim all XXXs.
- once a better warning system is in place, allow routines like
  MODIFIER-BITS to guess the size of underspecified operations, and warn
  about them at suitable warning levels.
- test with sourcer68 output of various files.
- Things to test about relocation:
	are 8-bit indirect displacements being relocated correctly?
	verify all possible relocation combinations.	
- Update dependencies in ASDF file so that it compiles without warnings.
- *last-label* feels like a hack.  See if there's an alternative.
- DC needs some serious cleanups.
- undo some of the intentional braindamage induced to make us closer
  to devpac.
- various pseudo-ops need to work on list of operands rather than
  single operand.
- stifle horrible potential bug with MOVEQ optimizations and negative
  numbers/sign extension.
- add basic sexp mode.


THINGS TO PUT IN TEST SUITE

- conditional compilations;
- ensure directives like ALIGN and EVEN don't emit unnecessary padding;
- random instruction streams tested against disassembly;
- test that * (as comment) and * (as multiply) are being handled correctly;
- test (known broken) MOVE->MOVEQ sign extension bug;
- extensive macrology;
- files that end without newlines, that have funny characters in them, etc.


KNOWN ISSUES

- macro parameters are broken.  At least, <foo> style ones are still
  broken.  Also, \n always expands to an absolute symbol, so you can't
  use a register.  [assembler]
- size output is broken if ORG is used.
- Unfinished pseudo-ops: (all are quite easy)
	EQUR
	DCB
	END
	IFxx (IFEQ and IFNE are already done)
- branch-displacement-bits will behave badly in some unusual situations.
  It's ugly and needs to be cleaned up.


KNOWN MAJOR INCOMPATIBILITIES WITH DEVPAC

These are things which aren't likely to change soon.

Macros:

- we don't support < or > embedded in macro parameters which are
  already wrapped in < and >.  (eg: "<foo>>>>2>" => "foo>>2") [lexer]


ENHANCEMENTS FROM DEVPAC

- We support EXTERN/GLOBAL as synonyms for XREF/XDEF,
  respectively.  Also ALIGN as a simple version of CNOP.

About

A simple, mostly-DevPAC-compatible assembler for the Motorola 68k series of proccessors.


Languages

Language:Common Lisp 88.2%Language:Assembly 11.8%