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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
08/06/06 13:13
Read: times


 
#121729 - mixing
Responding to: ???'s previous message
I have severe reservations on mixing asm and c in the same routine. It is so darn easy to screw it up e.g. who knows if the compiler is saving a value in R0 before and relying on it after the assembly in this 'example'
#pragma asm
mov r0,#7
#pragma endasm
Ok the 'example' may be too obvious, but what about things like CY, OV, acc.

Now that said, I am happily mixing C and asm , I just keep them in separate modules and, if asm call C this comment
 lcall Cfunc; NOTE C may screw up ANY register or flag
is always there.

I have seen this failing because somebody 'tested' which registers the Cfunc affected and relied on that. A later release of the compiler used different registers, it is essential that the caution is applied to ALL registers and flags.

Erik

List of 7 messages in thread
TopicAuthorDate
Getting result of inline asm with Keil            01/01/70 00:00      
   Return value from an auto            01/01/70 00:00      
   Do not fight you tools            01/01/70 00:00      
      Adding some C code afterwards            01/01/70 00:00      
         That will be another post            01/01/70 00:00      
      The asm routines in a a51 file            01/01/70 00:00      
   mixing            01/01/70 00:00      

Back to Subject List