IEC Spec


Johan Bengtsson

I cannot point you (or more correct, a copy is located in my bookshelf but it is hard for you to look at it *grin*), but here they are:

Operator Modifiers Meaning
LD N Set current result equal to operand
ST N Store current result to operand location
S Set boolean operand to 1
R Reset boolean operand to 0
AND N, ( Boolean AND
& N, ( Boolean AND
OR N, ( Boolean OR
XOR N, ( Boolean Exclusive OR
ADD ( Addition
SUB ( Subtraktion
MUL ( Multiplication
DIV ( Division
GT ( Comparision >
GE ( Comparision >=
EQ ( Comparision =
NE ( Comparision <>
LE ( Comparision <=
LT ( Comparision <
JMP C, N Jump to label
CAL C, N Call function block
RET C, N Return from function or function block
) Evaluate deferred operation

(If someone actually can point, please do so...)

/Johan Bengtsson

P&L, the Academy of Automation
Box 252, S-281 23 H{ssleholm SWEDEN
Tel: +46 451 49 460, Fax: +46 451 89 833
E-mail: [email protected]

LinuxPLC mailing list
[email protected]
Hi List,

Here is the link for the winword version of 61131-3:

The actual document is called pt3e2wd1.doc. I don't have my original hardcopy version that I purchased from IEC, as somehow it got lost during
the move to Costa Rica; so I can't comment on how close this draft is to the final spec. I don't think it's too far off. I also don't know how it's
possible to post this on a website; I suspect it will go away as more people know of it.

As far as "subsetting", it makes sense to me that you can start by implementing all the opcodes for types BOOL, INT, and SINT. This gives you a working PLC.

I have just written a parser/generator for IL using JAVACC. Since the ops aren't typed, you have to get the implied type of the op from the variable used (cross-referencing to the variable declarations). The only trouble comes when you have a constant that might be ambiguous, for example, an int with a value of 128. This could be resolved by context. In my case, I don't care since my source code is being generated by another program, so I can make the constant declaration unambiguous to start with.

Related topic: In the best of all possible worlds, I would like to release the source code of my compiler to the list, and retain only some incidental chunks of translator code to generate revenue for my company. I still haven't figured out how to do this. Any suggestions would be appreciated. Mine is table driven, so may be adapted to any target processor (IL in,
executable out).


Willy Smith
Numatico SA
Costa Rica

LinuxPLC mailing list
[email protected]