Just so we're clear, this is nowhere near complete, thanks

I'm working on a C compiler to compile C code to assembly for the ti83+ series and ti84+CSE series in haskell. I don't know much about making compilers, and I don't know much about haskell either, so I'm using this as a way to learn about both. Don't expect optimized code for awhile, the first step is getting it working Smile

If you want to check it out, code is here. The repo contains an example input file 'test.c'


Right now it supports adding and subtracting, assigning variables, calling functions, and asm blocks. Strings aren't supported yet, neither are pointers.

and here's a screenshot of running an executable

If you wanna try it out, go here. Paste on left, click compile, output shows up on the right.


If it barfs on you, you probably have a syntax error or did something unsupported.

you can use this file to test it
Nice work Unknownloner, this is something that people have been wanting for like 20 years Smile.

What data-types do you plan on supporting?
As far as primitive types go, I'm going for 8/16 bit unsigned and signed ints. MAYBE 32 bit, not sure, but I know that could be useful in some cases.

I want to have built in support for strings (null terminated).
Also I want to make structs works.

Fixed point numbers maybe, but that could just be implemented as a .c file with a bunch of functions for manipulating ints as fixed point nums really.

OH ALSO I forgot, order of operations has yet to be implemented, it's just left to right for now (and parentheses of course). order of operations is planned though.
Added an assembler to the code because it felt like a good way to get more comfortable with haskell syntax, and I wanted to do it anyway
Taking another detour to make a FORTH compiler, in the process finding bugs in the assembler and fixing them as I find em. The FORTH compiler does no optimization yet

I also decided to change the way words are defined to something more newline-friendly, and added a way to define words in assembly. Variables are also implemented, and strings only get added to the data once. no ifs or loops yet though. I took a safe approach of saving SP at the start of the program, and restoring it at the end, that way anything extra pushed on the stack doesn't crash the calc.





    xor a
    ld (curRow), a
    ld (curCol), a

    ld h,0
    ld l,a
    push hl ;Honestly this is just to test the stack restoring stuff right now

    pop hl

Nice! I've looking for something like this, this will help me make asm programs for the cse.
I haven't gotten around to learning asm, but C is good.
Keep up the good work.
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum