Page 1 of 1

asm goto _function

Posted: 01 Dec 2016 21:02
by gotronics
may someone please tell me this doesn't work in mikroc but it does in maplab xc8 .

void function()
{
PORTD=~PORTD;

}

void main()
{
TRISD=0;
PORTD=0;
while(1) asm goto _function;


}

Re: asm goto _function

Posted: 02 Dec 2016 11:37
by uros.cvetinovic
Hi,

You did not call function() in the main, so the compiler didn't link it.
Therefore the goto can not find function().

Try like this, you will see it will work:

Code: Select all

void function()
{
PORTD=~PORTD;

}

void main()
{
TRISD=0;
PORTD=0;
function();
while(1) asm goto _function;


}
Best regards,

Uros

Re: asm goto _function

Posted: 02 Dec 2016 12:44
by gotronics
its working thank you

Uros :D

Re: asm goto _function

Posted: 02 Dec 2016 12:58
by janni
The #pragma funcall directive instructs linker to add function even if it's not called directly - you may use it in this case as well:

Code: Select all

#pragma funcall main your_function

Re: asm goto _function

Posted: 02 Dec 2016 15:14
by uros.cvetinovic
Hi Janni,

Yes, that is right, this also can be used.

Best regards,

Uros

Re: asm goto _function

Posted: 02 Dec 2016 16:49
by gotronics
thank you Janni :)