# .c to .hex file conversion without using any IDE

I am new to microcontroller programming. I have a program written in C or assembly language which I need to convert into a .HEX file to flash into the 8051 microcontroller. I do not want to use an IDE (Keil for example) and want to perform this conversion only using terminal commands incorporating some kind of compiler or executing any other program through terminal. I have read some other answers that address similar issues but they make use of IDE. Please help me with this issue and let me know if there is anything else I should know.

• Try a web search for a toolchain for your processor, eg maybe sdcc? Beware you will probably have to change the source a little and support files a lot when changing toolchains. – Chris Stratton Oct 13 '20 at 5:39
• first question: do you already know how this works with your IDE? If you do, find out what your IDE does "under the hood" (namely, it does what you want to do). If not, learn it. – Marcus Müller Oct 13 '20 at 5:40
• For which compiler do you have a license? – Jeroen3 Oct 13 '20 at 5:50
• instructables.com/… – Codo Oct 13 '20 at 6:13
• Yes, free assemblers and C compilers exist for 8051 architectures. Yes, they can be executed from command line, that is how IDEs execute the compilers too. – Justme Oct 13 '20 at 8:03

## 1 Answer

Source code in C for 8051 is always compiler specific. One reason is the crazy addressing space (data, idata, pdata, xdata, and no, I am not making this up).

Thus you always need to know which C compiler you want to code for.

Each Compiler call usually needs quite a lot of command line arguments - e.g. in order to select the correct MCU and memory model. Another issue: Header files - these are also MCU specific. It is about an order of magnitude simpler to manage these in an IDE.

If you needed a command line tool for whatever reason (automation comes to mind) either call the IDE (most of them can compile projects via command line) or write a Makefile to be used with make command line tool.