Good output for first language [closed] - c

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

Related

Reverse engineering or Code from scratch [closed]

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 7 years ago.
Improve this question
I got a project that is already developed, in other words I have an API for some software that coded in C language, but the company haven't the source code, thus my mission is to write the source code for this application. Now I have the executable program and I want to write the source code, regarding to my less experience I'm asking, which is better, to write the source code from the scratch or to use some reverse engineering tool to find out the source code? But notice that reverse engineering tools results with some hard to read files since there are not enough comments!
No reverse-engineering tool will give you a source code (with or without the comments). So you can safely abandon this idea.
It is definitely better (in your case) to write new code from scratch using the existing executable as your black-box reference point.
Make sure to have many test cases that should cover as much of the original functionality as possible and when you are done writing your code run them all to affirm that your code is a reasonable replica of the original.

Compiler for custom cpu architecture [closed]

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.

Language choice for GameBoy Advance Homebrew Development [closed]

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 8 years ago.
Improve this question
I was reading a ton of tutorials and wanted to get into GBA Homebrew
Now, should i use C or assembly? I already know a bit of C, but asm wouldnt be difficult to me, and i was interested in learning it anyways.
So, which one?
C is easier to develope, specially complex and long programs, and it will take you way less time than making it in assembly, plus you can write assembly in c. Assembly on the other hand can get you better performance if done correctly and it's more flexible.
So I would say go ahead with C
The general rule for the asm vs C no matter what platform (that has both choices) is to use C and only if you really have to use asm for performance or other reasons use asm...

Why is Bash used in the Command Line for OSX [closed]

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 8 years ago.
Improve this question
According to Wikipedia, Mac OSX was written primarily in C (which makes sense because it is a UNIX like OS). Additional languages used were C++ and Objective-C. If this is the case, why do I have to use BASH to communicate with the OS on the Command Line? Why is BASH used in the command line in an OS that was written in C? Are there any reasons why C is not used, as this is the primary language used to create the OS.
The same could be said of Unix, Linux, etc. There's nothing special about OS X in your question.
Bash is interpreted. C is compiled. An interpreted language is required for something that can be typed live and run.
You really want to fat finger a regular expression and blow out your
hard drive because you messed up your array bounds checking? (Which is surprisingly easy to do in bash nonetheless.)
As for why bash and not csh, or heck, Python or Ruby, that's getting more historical and / or opinion based. Even if I were knowledgeable on this, that would be out of scope here.

Crenshaw's "Let's Build a Compiler": Transcription to C and x86 Assembler? [closed]

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.

Resources