Jump to content

Recommended Posts

Posted

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.

Posted

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.

Posted

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.

Posted

No - you are calling the external function twice:

call _mod_skel_extfunc

call _mod_skel_extfunc

After the first call, it isn't guaranteed that WREG still contains the previous WREG content

Best Regards, Thorsten.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...