You are here

Interfacing Assembly and C | Cypress Semiconductor

Support & Community

Interfacing Assembly and C

Last Updated: June 13, 2016

How do I use a variable that is defined in a .C file in a .asm file of the same project?


If a variable is declared  in the .c file, no memory allocation is needed in the .asm file. Make sure to declare your variable outside of any functions so that it is global. Assembly is able to see all global variables, so we do not need to tell it about an “external” variable declaration. We must make sure that when we call it in the .asm file, we use with “_”.

For example:

In a C file following global variable is declared:

int OperandTwo

To use it  in assembly, just add an underscore and use the variable:

mov [ _OperandTwo],0x00

For more information on interfacing C and assembly functions, please refer to the application note, AN2129, at the following link:


Provide feedback on this article

Browse KB By Product

Browse KB by Type