[LLVMdev] MOS6502 target

Paul Gardner-Stephen paul at servalproject.org
Thu Jul 3 21:06:11 PDT 2014


Regarding strategies for the back end, it might be worth taking a look at
the following existing C compilers for the 6502 and related bits:

http://www.cc65.org/ (recent activity moved to to
http://cc65.github.io/cc65/)
https://groups.yahoo.com/neo/groups/staticrecompilers/conversations/topics/315

The topic of targeting the 4502 / 65C02 is an interesting one because it
contains features that seem to have been specifically included to support
compilation and execution of compiled software:

1. The are instructions that dereference pointers on the stack: LDA
(SP+#$nn),y / STA (SP+#$nn),y (but usually misleadingly written as
($nn,SP),y)
2. The stack can be switched to 16 bit mode with CLE (although it still
silently over/under flows).
3. Zero-page can be moved anywhere you like with TBA.
4. There is a third index, Z, that provides slight register pressure relief.
5. X, Y and Z can be pushed and pulled from the stack directly (PHX etc)

Ophis is an assembler with full support for the 4502.

I don't have the time to actively work on an llvm backend for 6502 or 4502,
but I would certainly welcome one and am happy to contribute my knowledge
of those CPUs and to run code on them etc.  For the C65GS it would be nice
to be able to create a new optional operating system written in C, rather
than assembler.

Paul.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140704/e22e7697/attachment.html>


More information about the llvm-dev mailing list