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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
12/31/08 11:50
Read: times


 
#161238 - In principle this should work.
Responding to: ???'s previous message
If you write a subroutine in ASM, you would generally document:
1. The parameters used
2. The function performed and result that is returned
3. The registers and other resources that are used
4. The side-effects e.g. registers that are trashed

You (or someone else) can read the documentation and call this subroutine by just obeying the rules.

A C compiler uses exactly the same process. You will find how parameters are passed, registers and memory used etc from the C compiler manual.
The actual function signature is documented by the C library. You just obey the rules.

It is normally a C program that would link with an ASM function. Providing all the rules are followed then everything is fine.

An ASM program can link with compiled C functions in principle. You follow the rules.

The linker must be able to understand the .OBJ modules from both C and ASM. It is a lot easier to use a compiler and assembler from the same toolset. Or you and your assembler must understand the compiler generated ASM.

Neither method is for the faint-hearted. You need an intimate knowledge of both (a) your ASM style and (b) the C compiler style.

When (a) is unknown or undocumented you will have little success.

David.

List of 48 messages in thread
TopicAuthorDate
Asm and C            01/01/70 00:00      
   Depends!            01/01/70 00:00      
      Also            01/01/70 00:00      
         No! Not Inline!!            01/01/70 00:00      
            why not inline?            01/01/70 00:00      
               I agree with Andy (at least for Keil), but ....            01/01/70 00:00      
                  Keil specifically            01/01/70 00:00      
                     Keil and reasoning            01/01/70 00:00      
                        Jan...Take it from experience...            01/01/70 00:00      
                           can you please explain?            01/01/70 00:00      
                              Example??            01/01/70 00:00      
                                 I am curious            01/01/70 00:00      
                              Use these references in lieu of examples:            01/01/70 00:00      
                              I explained it earlier; example here            01/01/70 00:00      
                                 I now see the point with Keil...            01/01/70 00:00      
                                    Often intrinsic use of inline assembler            01/01/70 00:00      
                                       Not a safe assumption?            01/01/70 00:00      
                                          No, extrapolation not allowed            01/01/70 00:00      
                                          but if it is a macro...            01/01/70 00:00      
                                             A limited example            01/01/70 00:00      
                                                an opinion            01/01/70 00:00      
                     Keil specifically - more            01/01/70 00:00      
               Why Not inline C            01/01/70 00:00      
               Inline assembler - Avoid! Avoid!!            01/01/70 00:00      
                  in order to keep things together            01/01/70 00:00      
                     I do            01/01/70 00:00      
                        from where I sit...            01/01/70 00:00      
                           you said it            01/01/70 00:00      
                              this has nothing to do with it            01/01/70 00:00      
                                 asm *functions* embedded in C-majority source file            01/01/70 00:00      
                                 Whay Not???            01/01/70 00:00      
                                    My view point on ASM in C            01/01/70 00:00      
                                       That is the point            01/01/70 00:00      
                                 here is one - at least re Keil            01/01/70 00:00      
                     Maybe not here, but...            01/01/70 00:00      
            I do not disagree            01/01/70 00:00      
   Compiler ?            01/01/70 00:00      
      Get the manual when/where you get the compiler            01/01/70 00:00      
   and C in asm ?            01/01/70 00:00      
      C first?            01/01/70 00:00      
         not used to call compiler generated asm so translate by hand            01/01/70 00:00      
      if a compiler can do it            01/01/70 00:00      
      depends on the compiler            01/01/70 00:00      
         SDCC...            01/01/70 00:00      
            What assembler?            01/01/70 00:00      
               SB-asm            01/01/70 00:00      
                  In principle this should work.            01/01/70 00:00      
                  OTOH, why not simply write in ASM?            01/01/70 00:00      

Back to Subject List