• a simple 6502 compiler

    From mmphosis@21:1/5 to All on Wed Dec 30 15:01:04 2020
    A 6502 compiler specializing in 16-bit integer math and brute force loop unrolling

    https://github.com/glouw/ctl/blob/master/examples/6502.c

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Kent Dickey@21:1/5 to mmphosis@macgui.com on Wed Dec 30 17:22:34 2020
    In article <mmphosis-1609340460@macgui.com>,
    mmphosis <mmphosis@macgui.com> wrote:
    A 6502 compiler specializing in 16-bit integer math and brute force loop >unrolling

    https://github.com/glouw/ctl/blob/master/examples/6502.c

    It looks like it compiles something to 6502 code. But I'm not sure what.
    Can you provide a source example and the 6502 output as an example?
    It looks like "boids()" calls compile on some C-like code, but it's not C.

    Kent

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Michael Pohoreski@21:1/5 to Kent Dickey on Fri Mar 19 11:14:19 2021
    On Wednesday, December 30, 2020 at 3:22:40 PM UTC-8, Kent Dickey wrote:
    It looks like it compiles something to 6502 code. But I'm not sure what.
    Can you provide a source example and the 6502 output as an example?
    It looks like "boids()" calls compile on some C-like code, but it's not C.

    It's C with extensions.
    e.g.
    https://github.com/glouw/ctl/blob/master/examples/6502.c#L1068
    setup(void)
    keytype("i16", DEFAULT_WORD_SIZE);
    keytype("u16", DEFAULT_WORD_SIZE);
    keytype("u8", DEFAULT_BYTE_SIZE);
    keytype("i8", DEFAULT_BYTE_SIZE);
    keyword("unroll");
    keyword("if");

    The data type are just typedefs / aliases for standard "int16_t", "uint16_t", etc.

    What makes it non-standard is that the for-loop command, "unroll", is using a custom macro mark-up with $ for variables:
    "unroll($X, $I : x)\n"

    m.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)