wackazong Posted September 5, 2008 Report Share Posted September 5, 2008 Hello,using the sdcc sceleton and the mod_skel I made my own MIOS application (still pretty empty). I can now call an assembler function with multiple variables, and call a C function from assembler, but the C function called from assembler does not return to the assember code. Isn't "return" the correct statement to use? ///////////////////////////////////////////////////////////////////////////// // This function is called by pca9635 ///////////////////////////////////////////////////////////////////////////// void mod_skel_extfunc(unsigned char val1) __wparam { // Just a dummy empty function --mod_skel_var; MIOS_MIDI_TxBufferPut(val1); return; } The asm function looks as follows. The first call sends a MIDI Byte, then nothing more comes, not even the second call directly after the first. pca9635_interpolate #if _pca9635_def==1 ; note this is using the define from the fix in the asm file! incf _mod_skel_var, F, BANKED #endif call _mod_skel_extfunc call _mod_skel_extfunc movf MIOS_PARAMETER1, W call _mod_skel_extfunc movf MIOS_PARAMETER2, W call _mod_skel_extfunc return ALEXander. Quote Link to comment Share on other sites More sharing options...
cimo Posted September 5, 2008 Report Share Posted September 5, 2008 hidunno if i ve understood right but: C functions can t be called form within ASM code, the other way round is possible Quote Link to comment Share on other sites More sharing options...
wackazong Posted September 5, 2008 Author Report Share Posted September 5, 2008 Yes you can. I have another program where I do exactly that. I will have a look at the headers again, maybe something ist missing there. Quote Link to comment Share on other sites More sharing options...
cimo Posted September 5, 2008 Report Share Posted September 5, 2008 hidunno if i ve understood right yep probably i don t.. Quote Link to comment Share on other sites More sharing options...
TK. Posted September 6, 2008 Report Share Posted September 6, 2008 Why do you think, that the C function doesn't return to assembler?Could it be, that you interpreted the MIDI output incorrectly?I'm missing a defined value in WREG when mod_skel_extfunc() is called, accordingly anything (maybe invalid MIDI bytes?) will be sent out by the core.It is btw. a bad programming style if lower level functions (part of your module) are calling upper level functions (part of your application). Was this only done for testing purposes?Best Regards, Thorsten. Quote Link to comment Share on other sites More sharing options...
wackazong Posted September 6, 2008 Author Report Share Posted September 6, 2008 WREG contains the first parameter value of the C function call, and it is returned correctly. I have a bytewise monitor installed, so it can't be the interpretation of the MIDI signal. I will try to send the value of WREG via assembler to see whats going on.BTW: I was just testing the whole functionality of mod-skel, its not really relevant for my program, and I know its not the best programming style, but you never know, it might come in handy. Quote Link to comment Share on other sites More sharing options...
TK. Posted September 6, 2008 Report Share Posted September 6, 2008 No - you are calling the external function twice: call _mod_skel_extfunc call _mod_skel_extfuncAfter the first call, it isn't guaranteed that WREG still contains the previous WREG contentBest Regards, Thorsten. Quote Link to comment Share on other sites More sharing options...
wackazong Posted September 6, 2008 Author Report Share Posted September 6, 2008 Ah, see, that was occuring to me now, too. Thanks! I will check that out. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.