Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
Is there a tool that will convert C to assembly that will run on Windows?
The cpu architecture (8 bit and 16 bit) is in-house meaning that it has it own instruction set.
The C compiler should use our in-house assembly language. The language is not based on x86 nor ARM. I can not provide too many further details because it is company's Intellectual Property.
You will have to learn one of the open source Compilers which are using replaceable backend for their code generation. Gcc, and CLang, might be a good starting point.
Yes, Virginia, there are "tools to convert C to assembly" on Windows. GCC comes to mind; likewise MS Visual Studio.
I'm sure this isn't what you want, since the off-the-shelf versions for Windows tend to generate x86 object code. It sounds like you want a compiler for a special not-x86 instruction set.
Given that you have not provided any details, there's no way for anybody to respond if such a compiler already exists.
In the absence of such detail, all one can do is offer you generic advice. It is possible to configure GCC to generate code for relatively arbitrary instruction sets. It isn't a walk in the park to do this, but it has been done for many different instruction sets.
Related
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 3 years ago.
Improve this question
In recent months, I have been seeing mentions of "LLVM" all over the place. I've looked it up, but the description of a "modern compiler infrastructure" doesn't really tell me anything. I can't find much about it, other than some mention of a c compiler that comes along with it (which doesn't seem to be any different from any other C compiler out there.)
Is there some difference between this LLVM thing and any other compiler, say, GCC? Or is it an over-hyped replacement benefiting from being newer than the competition?
There is some academic literature on the matter, I recommend the AOSA book chapter on it, written by the principal author (Chris Lattner).
LLVM is a collection of libraries built to support compiler development and related tasks. Each library supports a particular component in a typical compiler pipeline (lexing, parsing, optimizations of a particular type, machine code generation for a particular architecture, etc.). What makes it so popular is that its modular design allows its functionality to be adapted and reused very easily. This is handy when you're developing a compiler for an existing language to target a new hardware architecture (you only have to write the hardware specific components, all the lexing, parsing, machine independent optimization, etc. are handled for you), or developing a compiler for a new language (all the back end stuff is handled for you), or when you're doing something compiler adjacent (like analyzing source code, embedding a language in a larger application, etc.).
In order to support this, LLVM employs a pretty sophisticated internal representation (called the LLVM IR, creatively enough) that is basically assembly language for a theoretical hardware architecture designed to make targeting it with a compiler very easy. Most of the LLVM libraries take the IR in, operate on it, and output the modified IR, supporting the project's aim of modularity. This is in contrast to GCC, which (historically, I haven't checked recently) has a less complete IR and thus the separate phases of compilation are very tightly coupled because they have to share a lot of information.
Clang is the flagship compiler built on the LLVM framework.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I am working or performance evaluation and I encountered a problem: when I add some instruction to the code it executes faster than the initial code, I think due to compilers optimization (without specifying any).
How do compiler optimization works? In particular are they performed while converting C to Assembly or in the step from Assembly to binary code?
I suppose both, however is possible to know which optimizations are performed in each step?
I have looked at assembly but I have found only slightly differences so I suppose that some architecture specific optimization is involved.
Thank you!
Assembly is binary code, to all intents and purposes BTW. Most optimisation occurs when the higher level language is compiled to assembly. It's weird that you add functionality and it gets faster... but compiler optimisation is kinda dark magic.
You may be able to get to the bottom of it, you could compile your C to assembly (gcc -S) and see what it did for your versions... Of course bear in mind not all instructions are created equally, this will help you more if you have some awareness of assembly and how CPUs and buses and memory, etc, work at a low level.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
I have built a compiler for my new programming language. It works perfectly. I am onto the last part. I need to put it into a runnable format (an executable). I was looking at the mach-o format (I am runnning on osx), but it is not well documented and I am not that advanced. So my question is:
What is a good output for my first compiler?
P.S. I would really like to be able to run my program in terminal
I would suggest you to use TAC as an output of your compiler. TAC is a context free language, which means it can easily be converted to assembly by a simple script. It is widely used by compilers to optimize the intermediate code, before it is translated to a processor specific assembly language and being optimized to the corresponding processor architecture.
If I'm not wrong, there are several types of TAC code, and you will need to find which one suits you better. I remember having used it as an output of my compiler in the compiler course of my graduation, because I could then run a python script which would translate it into x86 assembly
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
I am trying to implement a risc processor core in fpga. Is it a good idea to do such a project. I am confused whether to implement an arm core or mips core. Please tell me which would be a better option consider that i am a starter in this field.
Yes such a project would be pretty cool and you would learn a lot. That being said I believe you should build smaller things first. As for ARM vs. MIPS, the complexity is equivalent, but I would pick ARM cause it's actually the most popular processor architecture in the world right now, so the knowledge you would gain would be highly practical.
I recommend starting with a book called "CODE". It will teach you all the basics in a very clear way. Once you read that you should be able to build logic gates, full adders and even a simple generic purpose computer, all using nothing but relays and wires.
Once you've done those smaller projects then try something larger with transistors, protoboards or FGPA. One very interesting computer you could build is the IAS, also called the Von Neumann machine, which is the base for all modern computers (yet is very simple and elegant).
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I am trying to work through Jack Crenshaw's excellent compiler programming tutorial "Let's Build a Compiler" and have bumped into two hurdles. First the code is written in Pascal, a great language for which I have both respect and fondness from a brief exposure to it in the mid 1980s, but which I have not touched since. I currently program mostly in C.
The other hurdle is that the generated assembler is for the Motorola 68000 line of processors. While I may be able to find a translator for it, it would be preferable if I could generate Intel x86 assembler (either Intel or AT&T style).
I can work through the code on Linux, Mac OsX or Windows 7, if it makes anything easier. I have access to all of the named operating systems.
I do not feel fully qualified to do the transcription myself. Has anybody worked this out already, or do you have other suggestions?
Any ideas, feedback or suggestions welcome.
You could run the generated code on a 68K emulator—several of the entries on that page are open-source.
It might be easier to target the JVM instead of a native processor. as for translating Pascal to C... it'shouldn't be that much of a hurdle really.