asm goto _function

Post your requests and ideas on the future development of mikroC PRO for PIC.
Post Reply
Author
Message
gotronics
Posts: 118
Joined: 20 May 2013 16:37

asm goto _function

#1 Post by gotronics » 01 Dec 2016 21:02

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;


}

User avatar
uros.cvetinovic
mikroElektronika team
Posts: 803
Joined: 14 Dec 2015 09:24

Re: asm goto _function

#2 Post by uros.cvetinovic » 02 Dec 2016 11:37

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

gotronics
Posts: 118
Joined: 20 May 2013 16:37

Re: asm goto _function

#3 Post by gotronics » 02 Dec 2016 12:44

its working thank you

Uros :D

janni
Posts: 5373
Joined: 18 Feb 2006 13:17
Contact:

Re: asm goto _function

#4 Post by janni » 02 Dec 2016 12:58

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

User avatar
uros.cvetinovic
mikroElektronika team
Posts: 803
Joined: 14 Dec 2015 09:24

Re: asm goto _function

#5 Post by uros.cvetinovic » 02 Dec 2016 15:14

Hi Janni,

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

Best regards,

Uros

gotronics
Posts: 118
Joined: 20 May 2013 16:37

Re: asm goto _function

#6 Post by gotronics » 02 Dec 2016 16:49

thank you Janni :)

Post Reply

Return to “mikroC PRO for PIC Wish List”