Searching \ for '[PIC]: CCS goto question' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/microchip/devices.htm?key=pic
Search entire site for: 'CCS goto question'.

Exact match. Not showing close matches.
PICList Thread
'[PIC]: CCS goto question'
2002\07\23@162921 by Andy Shaw

flavicon
face
Hi,
Are there any CCS experts out there? I would basically like to jump directly
to the start of a CCS C function (rather then call it). Basically the
routine in question never returns (it does a direct jump to another part of
the program) and I would like to avoid using a stack location which would be
associated with a call. So essentially I would like to do the following

void f1()
{
....
}

void f2()
{
.....
#asm
   goto f1
#endasm
.....
}

I know I could do this by making use of the CCS label_address and
goto_address (or even setjmp, longjmp). But I would rather not have the RAM
and ROM overhead associated with these calls. I could also sort of do this
using #inline except I want to jump to the same function from many locations
in the code and only want one copy of f1(). I could also place f1 at a fixed
address and simply goto that but again I would rather not do it that way...

Other things I have tried (and which don't work)
1. Declaring a label inside the #asm/#endasm in f1 and using that as the
destination of the goto.
2. Adding a C style label (e.g. label: )at the start of f1 and using that as
the destination (of both and asm goto and a C goto from f2) again no luck.
2. Trying to reference the above label as f1.label (which is how it appears
in the CCS symbols provided to the debugger) - yes I am willing to try
anything!

Any help much appreciated......

Andy

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.


2002\07\23@165017 by Barry Gershenfeld

face picon face
If you never return, you can throw the stack away for all it cares.

Have you looked at the output code?  When I create a function, but
only use it from one place, CCS does compile a jump rather than
a call.   Maybe you can expand on this technique.

Barry



At 09:27 PM 7/23/02 +0100, you wrote:
{Quote hidden}

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.


2002\07\23@165224 by Scott Dattalo

face
flavicon
face
On Tue, 23 Jul 2002, Andy Shaw wrote:

{Quote hidden}

Andy,

Why do you want to do this? Are you running out of stack?

FYI, In SDCC all functions are automatically inlined (if possible) to save
the call/return overhead.
Oh, and no, I'm not a CCS expert.

Scott

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.


2002\07\23@165432 by uter van ooijen & floortje hanneman

picon face
> Are there any CCS experts out there? I would basically like to jump
directly
> to the start of a CCS C function (rather then call it). Basically the
> routine in question never returns (it does a direct jump to another part
of
> the program) and I would like to avoid using a stack location which would
be
> associated with a call. So essentially I would like to do the following

I am no CCS user, but what is the trouble? When you never return the stack
entry (and entries 'before' that entry) will never be used, so why bother?

Wouter

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.


2002\07\23@170056 by Andy Shaw

flavicon
face
Hi Barry,
> If you never return, you can throw the stack away for all it cares.
>
Good point problem is that the CCS compiler is smart about these things and
keeps track of how deep the call stack may be. I think it may even vary the
code it generates to try and keep below the stack limit. So if I can I would
like to avoid a call completely. Also this is one of those stupid things
that you just know that there must be some way of doing it! If all else
fails though I may go with this.....

> Have you looked at the output code?  When I create a function, but
> only use it from one place, CCS does compile a jump rather than
> a call.   Maybe you can expand on this technique.
>
Yeah I noticed that problem is I want to jump to this code from all over the
place! If you call a non inline function from more than one place the CCS
compiler uses call/return....

Andy

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.


2002\07\23@170506 by Andy Shaw

flavicon
face
Hi Scott,
> Andy,
>
> Why do you want to do this? Are you running out of stack?
>

Well I'm building a small cooperative RTOS for use with CCS and this is one
of several possible task switch mechanisms I'm playing around with. I've got
the thing working fine and now I'm into the "If I just change this I can
make it much smaller/faster/neater" stage and it is really bugging me that I
can't find a way to do this!

Andy

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.


2002\07\23@173421 by Dale Botkin

flavicon
face
On Tue, 23 Jul 2002, Andy Shaw wrote:

8< snip...

> 2. Adding a C style label (e.g. label: )at the start of f1 and using that as
> the destination (of both and asm goto and a C goto from f2) again no luck.

This didn't work??  Help file says it should.  Wonder if it only works
within a function?

Dale

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.


2002\07\23@185202 by Andy Shaw

flavicon
face
From: "Dale Botkin" <spam_OUTdaleTakeThisOuTspamBOTKIN.ORG>
> > 2. Adding a C style label (e.g. label: )at the start of f1 and using
that as
> > the destination (of both and asm goto and a C goto from f2) again no
luck.
>
> This didn't work??  Help file says it should.  Wonder if it only works
> within a function?
>

Got it in one Dale (unfortunately!). The labels seem to go out of scope
outside of the function (which I guess makes sense...).

Andy

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.


2002\07\23@192307 by Brendan Moran

flavicon
face
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

> Got it in one Dale (unfortunately!). The labels seem to go out of
> scope outside of the function (which I guess makes sense...).

Couldn't you make them globals?

Something like:

global label: xxxxx

I think there's a way of declaring scope, but I can't remember how.

- --Brendan

-----BEGIN PGP SIGNATURE-----
Version: PGPfreeware 6.5.8 for non-commercial use <http://www.pgp.com>

iQA/AwUBPT3lJwVk8xtQuK+BEQKnpgCdHSvgXmVbA0lwdo9XADv0z3r4QAIAnjkZ
xN/fJozf4M6QpMWhOVgUbv3H
=H9Zw
-----END PGP SIGNATURE-----

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.


2002\07\23@192949 by Scott Dattalo

face
flavicon
face
On Tue, 23 Jul 2002, Andy Shaw wrote:

> Hi Scott,
> > Andy,
> >
> > Why do you want to do this? Are you running out of stack?
> >
>
> Well I'm building a small cooperative RTOS for use with CCS and this is one
> of several possible task switch mechanisms I'm playing around with. I've got
> the thing working fine and now I'm into the "If I just change this I can
> make it much smaller/faster/neater" stage and it is really bugging me that I
> can't find a way to do this!

Does CCS support setjmp()/longjmp() by any chance? (Probably too
inefficient for this application).

Scott

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.


2002\07\24@005959 by Dale Botkin

flavicon
face
On Tue, 23 Jul 2002, Andy Shaw wrote:

> From: "Dale Botkin" <.....daleKILLspamspam@spam@BOTKIN.ORG>
> > > 2. Adding a C style label (e.g. label: )at the start of f1 and using
> that as
> > > the destination (of both and asm goto and a C goto from f2) again no
> luck.
> >
> > This didn't work??  Help file says it should.  Wonder if it only works
> > within a function?
> >
>
> Got it in one Dale (unfortunately!). The labels seem to go out of scope
> outside of the function (which I guess makes sense...).

Oof.  That sucks.  Too bad you'll probably not find much sympathy amongst
C folk for goto not working well enough to suit you <grin>.  Not me, of
course, I'll make work whatever works best personally.  Anyway, try it as
a normal void function call and take a look at the assembly listing -- you
may find it's not as inefficient as you thought.  Or it may be, I dunno.
Every time I think I need a goto it turns out I'm mistaken and there's a
better way, but I've never attempted a RTOS.

Dale

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email listservspamKILLspammitvma.mit.edu with SET PICList DIGEST in the body


More... (looser matching)
- Last day of these posts
- In 2002 , 2003 only
- Today
- New search...