Keil Logo

Interfacing C to Assembler

You can easily interface your C programs to routines written in assembly language. By following a few programming rules, you can call assembly routines from C and vice versa. Public variables declared in the assembly module are available to your C programs.

There are several reasons why you may need to call an assembly routine from your C program.

  • You have assembly code already written that you wish to use.
  • You need to improve the speed of a particular function.
  • You want to manipulate Peripheral Registers or memory-mapped I/O devices directly from assembly.

This section describes how to write assembly routines that can be directly interfaced to C programs.

For an assembly routine to be called from C, it must be aware of the parameter passing and return value conventions used in C functions. For all practical purposes, the assembly routine must appear to be a C function.

  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.