I am using a micro-controller with ARM Cortex M4 processor and GCC - GNU ARM compiler.

Some functions are written in c in .c file and in assembly in .asm file.

My questions are as follows :

  1. How can I share the addresses of the functions/variables between c and assembly files?

  2. How can I call c function from assembly and vice-verse?

  3. How can I pass function arguments in above cases?

  • \$\begingroup\$ Shouldn't this be on Stack Overflow? It is purely a software question not electronics. \$\endgroup\$ – Andrew Oct 4 '16 at 10:31
  • 1
    \$\begingroup\$ The linker (ld) should do that - use the same name in C and assembly, and ld should resolve them to the same address. Check its output. And you can use objdump to inspect the resulting object file. \$\endgroup\$ – user_1818839 Oct 4 '16 at 10:43
  • \$\begingroup\$ @Andrew Yeh.. u r right. I will over it to sack overflow. \$\endgroup\$ – Nama Oct 4 '16 at 10:50
  • \$\begingroup\$ Can anyone provide a example for this? \$\endgroup\$ – Nama Oct 4 '16 at 10:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.