subroutines in Puffin IL

J

Thread Starter

Jiri Baum

Hello,

the Puffin IL now supports subroutines.

The semantics are as follows --- let me know if you'd prefer it another way, it's not yet too late to change it...

Subroutines are specified at the bottom of the ladder diagram (or they can be in a separate file). A subroutine starts with the SUB instruction and continues until the next SUB instruction or the end of the program.

The only way to get into a SUB is with a JSR. It is not valid to JMP in and out of subroutines or between different subroutines. If a SUB instruction is reached scanning down the program, scanning finishes (or the subroutine returns, if it happens in a subroutine).

Return is automatic when scanning reaches the bottom of the subroutine, but may be explicitly specified using the END instruction (for example when the subroutine uses JMP to jump between different parts).

It is valid for a subroutine to JSR to itself, directly or indirectly, but take care not to get infinite recursion. It's not all that useful anyway, because subroutines have no private variables and the rung stack is only 8 deep.

For an example, see demo/basic_il/chaser_il.il, which now uses JSR.

Jiri
--
Jiri Baum <[email protected]>
"In my opinion, the GPL is optimized to build a strong software community at the expense of a strong commercial software business model."
--Craig Mundie, Senior VP, Microsoft; 17 May 2001

_______________________________________________
LinuxPLC mailing list
[email protected]
http://linuxplc.org/mailman/listinfo/linuxplc
 
Thread starter Similar threads Forum Replies Date
A Open Control 0
C LinuxPLC Project 0
C LinuxPLC Project 5
Top