Assembly and C

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

cross mob
Anonymous
Not applicable

Hi

   

I am using CY8C27443-24PXI and developing code in C.

   

At this point I want to make function call from main C code and I want to write function in assembly.

   

Please suggest how can I do it.

   

Regards,

0 Likes
2 Replies
pushekm_21
Employee
Employee
10 likes received 5 likes given First like received

 When you are declaring the function in assembly then make sure you have "_" appended in front of the function name. When you are appending "_" in front of the function name then you can call the function from C files. An example given below first of all exports the function for other assembly and C files.  "_MyFunc_Start" is for the C files and "MyFunc_Start" is for assembly files. Similarly at the time of definitiion as well, we have to use two names to make this name accessible to both assembly and C files.

   

Please note that from C file as well, you have to call the function with name MyFunc_Start only.

   

   

 

   

export _MyFunc_Start

   

export  MyFunc_Start

   
        
   
        
   
    
      SmartSense_Start:    
    
     _SmartSense_Start:    
    
          
    
          
    
     ; Your function code    
    
          
    
     ret    
    
          
    
     Once done, you can give the prototype of the function in a header file or the c file in which you want to call this function.    
    
          
    
          
    
     Best regards,    
    
     Pushek    
   
0 Likes
pushekm_21
Employee
Employee
10 likes received 5 likes given First like received

  When you are declaring the function in assembly then make sure you have "_" appended in front of the function name. When you are appending "_" in front of the function name then you can call the function from C files. An example given below first of all exports the function for other assembly and C files.  "_MyFunc_Start" is for the C files and "MyFunc_Start" is for assembly files. Similarly at the time of definitiion as well, we have to use two names to make this name accessible to both assembly and C files.

   

   

Please note that from C file as well, you have to call the function with name MyFunc_Start only.

   

 

   

 

   

export _MyFunc_Start

   

export  MyFunc_Start

   
        
   
        
   
    
      MyFunc_Start:    
    
     _MyFunc_Start:    
    
          
    
          
    
     ; Your function code    
    
          
    
     ret    
    
          
    
     Once done, you can give the prototype of the function in a header file or the c file in which you want to call this function.    
    
          
    
          
    
     Best regards,    
    
     Pushek    
   
0 Likes