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.

  • 2
    \$\begingroup\$ 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. \$\endgroup\$ Oct 13, 2020 at 5:39
  • 1
    \$\begingroup\$ 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. \$\endgroup\$ Oct 13, 2020 at 5:40
  • \$\begingroup\$ For which compiler do you have a license? \$\endgroup\$
    – Jeroen3
    Oct 13, 2020 at 5:50
  • \$\begingroup\$ instructables.com/… \$\endgroup\$
    – Codo
    Oct 13, 2020 at 6:13
  • \$\begingroup\$ 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. \$\endgroup\$
    – Justme
    Oct 13, 2020 at 8:03

1 Answer 1


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.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.