Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob

Interfacing Assembly and C

Interfacing Assembly and C

Anonymous
Not applicable

How to 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, at the following link.

 

Translation - Japanese: アセンブリとCのインターフェース - Community Translated (JA)

0 Likes
409 Views