Take the 2-minute tour ×

If I've written a compiler that translates my code into three address code, how do I decide whether to convert that three address code to, say, MIPS or ARM assembly code. Once that's done, how do I call the assembler to create a program from this code?

Possible Resolution: Seva Alekseyev pointed out GNU has a command as that will assemble assembly code. I had the assumption that I needed to pick any assembler I wanted and then figure out how to call the assembler using the programming language that I was writing my compiler in. It sounds like the assembler is not necessarily chosen but is usually specific to the machine that your code will be compiled on. This makes things a bit more clear to me.

share|improve this question

closed as too broad by Ken White, hardmath, nrz, Andrew Barber Nov 14 '13 at 20:07


Whether you generate MIPS code, ARM code, or both, or code for some other architecture, is simply a matter of what computers you want the code to run on. Nobody can do that decision for you. Did you mean to ask how to generate this code (as the title seems to imply)? That's still quite broad and possible a duplicate, but at least it makes sense as a question... –  delnan Nov 14 '13 at 18:56
The gcc family of compilers and assemblers might be studied in its source and as command line programs to get a feel for the subject. –  hardmath Nov 14 '13 at 19:01
Assembler is typically a command line program that takes sources (in assembly) and spits out object files and/or executable files. On systems with GCC-based toolchains, it's usually called as. –  Seva Alekseyev Nov 14 '13 at 20:03
Seva: true, but general three address code is like a assembler for a virtual CPU. You still need the translation from that virtual CPU to the real CPU, and that is more a compiler task (register allocation and all), not an assembler. –  Marco van de Voort Nov 15 '13 at 19:37

1 Answer 1

up vote 1 down vote accepted

I do not have any experience on this but as a guess I think you need to mat your 3 address code to some routines of assembly.

you can write a c code on visual studio and debug it into assembly mode you can see how instructions are mapped to assembly instructions (or set of them).

share|improve this answer
