Understanding LDmicro .int bytecode generation (by Caique Gabriel)
Hi everyone,
Recently I got allocated to a project where the final goal is to generate LDmicro's .int bytecode file.
I already implemented my own .ld parser/compiler for another application, so this is not a fork of LDmicro. However, I don't have much experience with virtual machines and bytecode generation, and I am currently stuck trying to understand the bytecode generation process.
I know about ldinterpret.c, and I understand that it implements the interpreter/VM side, but what I am trying to understand is the compiler side: how the ladder logic representation is transformed into the sequence of bytecode instructions.
Is there any documentation, design notes, or source files that explain the bytecode generation process?
For example:
How are ladder elements translated into bytecode instructions?
How are internal variables ($$bits, $$int16s) allocated?
How are jumps created for series/parallel logic?
Is the .int format generated directly during ladder compilation, or is there an intermediate representation?
Any pointers would be greatly appreciated.