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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
06/09/06 07:29
Read: times


 
#118074 - SDCC assembly interfacing
Hello,

I want to interface existing routines written in assembly language from SDCC. My problem is that parameter passing between SDCC and the routines is not compatible so I need to write a wrapper which will call the functions correctly.

The asm routines I want to call generally have the same structure:
- known jump point
- parameter input via Acc / or result output via Acc

Now SDCC does not use the accumulator to pass parameters. Is there a simple way to make the following work?

/* C function which passes a parameter to my routine */
void routine_a(unsigned char c)
{
   _asm
   ; how can I access my variable c from here to put it into the acc 

   ljmp MY_ASSEMBLYROUTINE
   _endasm;
}

/* reverse one - getting a result back */
void routine_b()
{
   _asm
   ljmp MY_ASSEMBLYROUTINE_WITH_RESULT
   ; how can I achieve the same as return(...); with the contents of Acc after my routine?
  _endasm;
}


I tried a few things but SDCC always complained about "unused function parameters" or missing return() statements.

I do not want to let SDCC create the asm code and hack that as I want to make sure it will still work if parameter passing changes one day.

thanks,
Matthias

List of 6 messages in thread
TopicAuthorDate
SDCC assembly interfacing            01/01/70 00:00      
   read the manual            01/01/70 00:00      
      I did (ofcourse)            01/01/70 00:00      
         whichever tools the easy way is to ..            01/01/70 00:00      
         _naked            01/01/70 00:00      
            well....            01/01/70 00:00      

Back to Subject List