News:

  • April 21, 2026, 07:00:01 AM

Login with username, password and session length

Author Topic: CALL instruction mnemonic text  (Read 17158 times)

Watermark_JS

  • Full Member
  • ***
  • Posts: 47
CALL instruction mnemonic text
« on: March 31, 2025, 01:15:42 PM »
I've been playing around with some refactoring using an LLM and mnemonic text exports/imports with DoMore Designer.  It's been going quite well but the text version of the CALL instruction has me a bit confused.

Here's an example:
CALL s900_TestSub 0x1 DST511 "3 2 V22 1 R4000 R20 1 R4001 R21 1" "3 C20 C3000 1 C22 C3001 1"

Can anyone clarify the purpose of:
  • 0x1
  • DST511
  • The number "3" - used twice, but does not appear to be a row counter

This is my best guess for how the instruction is represented as text, so far  :P:
  • s900_TestSub -- subroutine name
  • 0x1 -- purpose unknown
  • DST511 -- purpose unknown
  • 3 -- purpose unknown
  • Input Parameters:
    • 2 V22 -- sets the value of V22 to 2
    • 1 -- Count value?
    • R4000 R20 -- sets the value of R20 to the value of R4000
    • 1 -- Count value?
    • R4001 R21
    • 1 -- Count value?
  • Output Parameters:
    • 3 -- purpose unknown
    • C20 C3000 -- sets the value of C3000 to the value of C20
    • 1 -- Count value?
    • C22 C3001 -- sets the value of C3001 to the value of C22
    • 1 -- Count value?

Clarification would be helpful, particularly if I need to change the "0x1", "3" or "1" values under certain conditions.

Thanks!
« Last Edit: March 31, 2025, 01:36:52 PM by Watermark_JS »
If you don't make mistakes, you aren't doing anything.

franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3803
    • Host Engineering
Re: CALL instruction mnemonic text
« Reply #1 on: March 31, 2025, 02:18:07 PM »
0x1 hexadecimal flag as Power Flow Enabled (0x0 is edge-triggered enabled)
DST511 CALL Counter - unspecified (DST511 is a "bit bucket" for numeric unused parameters)
The first number in the INPUT string (table) and OUTPUT string (table) is the number of elements (columns) per ROW of THAT table
"3 1 2 3 C10 C11 C12 D10 D11 D12 -1 -2 -3" says there are 3 elements (columns) in each row.  The first row contains the three elements 1, 2, 3.  The second row contains the three elements C10, C11, C12.  The third row's three elements are D10, D11, D12, the 4th row's three elements are -1 -2 -3.

Be careful with the 0x hex flags in most instructions.  Most of them are too complex to document without using Designer to enter the instruction!  These are internal flags and are NOT documented!  Caveat Emptor (you can break the PLC).

Watermark_JS

  • Full Member
  • ***
  • Posts: 47
Re: CALL instruction mnemonic text
« Reply #2 on: March 31, 2025, 06:05:05 PM »
Be careful with the 0x hex flags in most instructions.  Most of them are too complex to document without using Designer to enter the instruction!  These are internal flags and are NOT documented!  Caveat Emptor (you can break the PLC).

Thanks for the heads-up!  I'll be careful!  Your reply was extremely helpful and gave me enough information to figure out the mnemonic version of INIT as well.

 8)
If you don't make mistakes, you aren't doing anything.

franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3803
    • Host Engineering
Re: CALL instruction mnemonic text
« Reply #3 on: April 01, 2025, 08:53:45 AM »
Your reply was extremely helpful and gave me enough information to figure out the mnemonic version of INIT as well.
CALL, COPY, INIT are all similar in how they handle their "matrix" of elements as a single parameter (text in quoted string).
Caveat emptor take 2 - string literal encoding is more complex inside this "matrix".  String literal encoding that contains double quotes themselves takes it to the "next level".
He said, "How are you?"

in IEC 61131, string literals use $-based escape sequences
"He said, $"How are you?$""
This is how you must enter that string literal in the instruction.

When a quoted string is in an EXPORT TEXT file, that used quoted strings for a matrix of elements, they use CSV double quote escape sequence (first and last double quotes demark the beginning and end of the text file's string literal, but any embedded double quotes must be DOUBLED-UP, so TWO double quotes for every double quote within the quote.  Got it?   ;D

So if I was CALLing with 3 input parameters (no output parameters), all string parameters, into SL0 and SL1 and SL2, passing in respectively
1. Short String 0
SS0
2. the string literal
ABC
3. and the string literal from above,
He said, "How are you?"

it would look like the following:

CALL MySub 0x1 DST511 "3 SS0 SL0 1 ""ABC"" SL1 1 ""He said, $""How are you?$"""" SL2 1" "3"

If you understand that, you get an A+ for double quoted escape sequence grammar! (realize the last quoted "3" is the empty output parameter matrix of the CALL instruction, not part of the input parameter matrix.  "3" is saying there are 3 columns, but no rows of groups of 3 columns  ;D)
« Last Edit: April 01, 2025, 08:56:57 AM by franji1 »