Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You may be interested in <a href="http://en.wikipedia.org/wiki/Continuation_passing_style" rel="nofollow">continuation passing style</a>. Probably, <a href="http://gabriel.kerneis.info/software/cpc/" rel="nofollow">CPC</a> should interest you. Please notice that CPS transformation is a <em>whole program</em> transformation. Read also wikipages on <a href="http://en.wikipedia.org/wiki/Continuation" rel="nofollow">continuations</a>, <a href="http://en.wikipedia.org/wiki/Coroutine" rel="nofollow">coroutines</a>, <a href="http://en.wikipedia.org/wiki/Cooperative_multitasking" rel="nofollow">cooperative multitasking</a>, <a href="http://en.wikipedia.org/wiki/Nonpreemptive_multitasking" rel="nofollow">non-preemptive multitasking</a>, <a href="http://en.wikipedia.org/wiki/Callback_%28computer_programming%29" rel="nofollow">callbacks</a> ...</p> <p>Read Andrew <a href="http://www.ebook3000.com/-Compiling-with-Continuations--by-Andrew-W--Appel_80709.html" rel="nofollow">Appel's old book on <em>Compiling with Continuations</em></a> and the more recent paper <a href="http://research.microsoft.com/pubs/64044/compilingwithcontinuationscontinued.pdf" rel="nofollow">Compiling with Continuations, Continued</a> by A.Kennedy.</p> <p>You could use computed <a href="http://en.wikipedia.org/wiki/Goto" rel="nofollow">Goto</a>-s. In standard C99 it is not possible, but some compilers (notably <a href="http://gcc.gnu.org/" rel="nofollow">GCC</a>) provide <a href="http://gcc.gnu.org/onlinedocs/gcc/Labels-as-Values.html" rel="nofollow">labels as values</a> with indirect <code>goto</code> as an extension. This enables <a href="http://en.wikipedia.org/wiki/Threaded_code" rel="nofollow">threaded code</a> (for interpreters).</p> <p>I have no idea if your compiler on PIC is giving you all that. Perhaps you should consider implementing your own whole program source to source transformer (or find a language and a compiler more suited to your needs, or develop your own PIC compiler, which is an interesting project as such. See also <a href="http://www.algo-prog.info/ocapic/web/" rel="nofollow">ocapic</a>...).</p> <p>Perhaps you should consider porting <a href="http://gabriel.kerneis.info/software/cpc/" rel="nofollow">CPC</a> to your system or compiler....</p> <h3>addenda</h3> <p>your original code </p> <pre><code> #define resume_from(x) goto point##x unsigned char status = 0; void my_func(void) { resume_from(status); </code></pre> <p>should not even compile. The last line is expanded by the <a href="http://en.wikipedia.org/wiki/C_preprocessor" rel="nofollow">C preprocessor</a> as <code>goto pointstatus;</code> and you don't have any <code>pointstatus</code> label. Try to get the preprocessed form (e.g. with <code>gcc -C -E</code> or the equivalent). You probably want a <code>switch</code> or a computed goto (if your compiler gives you that).</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload