2 Replies Latest reply on Sep 25, 2011 12:20 AM by pmad

    Assembly and C

    user_146460820

      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,

        • 1. Re: Assembly and C
          pmad

           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    
             
          • 2. Re: Assembly and C
            pmad

              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