How to create a C compiler for custom CPU?

前端 未结 6 1439
长发绾君心
长发绾君心 2021-01-31 08:16

What would be the easiest way to create a C compiler for a custom CPU, assuming of course I already have an assembler for it?

Since a C compiler generates assembly, is t

6条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-31 08:18

    1) Short answer:

    "No. There's no such thing as a "compiler framework" where you can just add water (plug in your own assembly set), stir, and it's done."

    2) Longer answer: it's certainly possible. But challenging. And likely expensive.

    If you wanted to do it yourself, I'd start by looking at Gnu CC. It's already available for a large variety of CPUs and platforms.

    3) Take a look at this link for more ideas (including the idea of "just build a library of functions and macros"), that would be my first suggestion:

    http://www.instructables.com/answers/Custom-C-Compiler-for-homemade-instruction-set/

提交回复
热议问题