Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
08/17/07 19:12
Read: times


 
#143382 - You can call ASM from C...
Responding to: ???'s previous message
... you just have to play by the Compiler's rules - known more formally as its Calling Conventions

See: http://www.keil.com/support/m...ctoasm.htm

If you are writing new assembler routines, you can easily write them to be callable from 'C';

Existing assembler routines probably won't have been written to be callable from 'C', so the best approach is probably to write a "wrapper" in assembler that makes them so.

There would be very little point at all in writing something like
void cout(unsigned char value) 
{ 
   mov a, value 
   acall cout 
}
You would be far better off doing it directly in assembler!

The simplest way to create a Keil C51-callable assembler routine is to create a "skeleton" in 'C', then use the compiler with the SRC direcive to contert that to assembler source.
See: http://www.keil.com/support/m...51_src.htm

You know for sure that this assembler source will be fully compatible with C51, because it was created by the C51 compiler itself!

You can now throw away the initial 'C' skeleton, and work on the assembler file in assembler...

List of 39 messages in thread
TopicAuthorDate
C function with embeded ASM            01/01/70 00:00      
   You can call ASM from C...            01/01/70 00:00      
      I know nothing of Keil...            01/01/70 00:00      
         thanks            01/01/70 00:00      
      It seems to work.            01/01/70 00:00      
         Inelegant!            01/01/70 00:00      
            thanks for the article            01/01/70 00:00      
               I have certain examples available ...            01/01/70 00:00      
                  Make it public?            01/01/70 00:00      
                  Keil example            01/01/70 00:00      
                     It is a complete project with different files.            01/01/70 00:00      
                        Code library            01/01/70 00:00      
                           thanks!!!            01/01/70 00:00      
                              re;assembly language            01/01/70 00:00      
                                 ASM instructions in C            01/01/70 00:00      
                                    No, don\'t do that!            01/01/70 00:00      
                                 This is a really bad idea!            01/01/70 00:00      
                                    re;bad idea            01/01/70 00:00      
                                    re:bad idea II            01/01/70 00:00      
                                       The Best way is the C way            01/01/70 00:00      
   re: best way            01/01/70 00:00      
      Why not parameter passing?            01/01/70 00:00      
      What Compiler            01/01/70 00:00      
         re:parameter passing            01/01/70 00:00      
            Yes, but why?            01/01/70 00:00      
               re:            01/01/70 00:00      
               re:why            01/01/70 00:00      
                  Yes, But            01/01/70 00:00      
                  Parameter Passing R6, R7            01/01/70 00:00      
                     re:parameter passing using #pragma NOREGPARMS            01/01/70 00:00      
            REGPARMS/NOREGPARMS            01/01/70 00:00      
               re:NOREGPARMS            01/01/70 00:00      
                  ... and you always can use a global variable ...            01/01/70 00:00      
                     ???            01/01/70 00:00      
                        who said external???            01/01/70 00:00      
                           I            01/01/70 00:00      
                           re:??? 2            01/01/70 00:00      
                        re:???            01/01/70 00:00      
                           As long as you are aware of the issues.            01/01/70 00:00      

Back to Subject List