Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Can LCC be targeted to a simple processor?

642 views
Skip to first unread message

Donn Stewart

unread,
Aug 28, 2019, 10:48:19 AM8/28/19
to
I made a simple 8-bit processor with TTL. It is a pure accumulator-memory machine, with 30 instructions. I have a good assembler. Is it possible to retarget LCC to this processor? How do I go about it?

Kelvin Sherlock

unread,
Aug 28, 2019, 5:52:50 PM8/28/19
to
Maybe. Read The lcc 4.x Code-Generation Interface at a minimum and
optionally the book (A Retargetable C Compiler: Design and
Implementation.

The existing backends are for machines with general purpose registers
so that might not work unless you end up emulating registers in memory.
There is a .NET MSIL lcc backend which is a stack machine so it's
certainly possible to use with non-register machines...


http://drhanson.s3.amazonaws.com/storage/documents/interface4.pdf

https://www.microsoft.com/en-us/research/publication/lcc-net-targeting-the-net-common-intermediate-language-from-standard-c/


kavv...@silexica.com

unread,
Feb 15, 2020, 3:58:39 PM2/15/20
to
Conceptually simple as a machine can be, the "Mov" machine has an LCC backend: https://esolangs.org/wiki/Mov . The LCC machine description is here: https://github.com/xoreaxeaxeax/movfuscator/blob/master/movfuscator/mov.md

kavv...@silexica.com

unread,
Feb 15, 2020, 4:35:41 PM2/15/20
to
On Saturday, 15 February 2020 21:58:39 UTC+1, kavv...@silexica.com wrote:
> Conceptually simple as a machine can be, the "Mov" machine has an LCC backend: https://esolangs.org/wiki/Mov . The LCC machine description is here: https://github.com/xoreaxeaxeax/movfuscator/blob/master/movfuscator/mov.md

And of course the rest of the devil: https://github.com/xoreaxeaxeax/movfuscator/blob/master/movfuscator/movfuscator.c

Donn Stewart

unread,
Feb 15, 2020, 7:35:42 PM2/15/20
to
Thanks, I will check those pages.

bill rowe

unread,
May 13, 2020, 9:28:15 AM5/13/20
to
On Wednesday, August 28, 2019 at 10:48:19 AM UTC-4, Donn Stewart wrote:
> I made a simple 8-bit processor with TTL. It is a pure accumulator-memory machine, with 30 instructions. I have a good assembler. Is it possible to retarget LCC to this processor? How do I go about it?

For sure. It has been done a number of times. One example is mine at https://sites.google.com/site/lcc1802/ I learned a lot from one at http://www.fpgacpu.org/usenet/lcc.html

The basic unit of a target is called a machine descriptor file - mine is xr18CX.md. The compiler front end understands C and converts it to an internal form. your md file contains rules that convert from the internal form to assembly language which you then process in a separate pass.

It's not trivial, but it's quite do-able. Traditionally, you start by taking one of the existing .md files and changing all the assembly output to something you can handle, and go from there.

I can maybe provide some help if you need it.
0 new messages