PLCcheck

S5 AWL Commands: +F, -F, +G (Integer Arithmetic)

S5 AWL arithmetic instructions: +F (INT add), -F (INT subtract), +G (DINT add). Operates on ACCU1 and ACCU2. S7 equivalents: +I, -I, +D.

·4 min read
S5AWL+F-F+GarithmeticINTDINTadditionsubtraction

Diesen Artikel auf Deutsch lesen

S5 AWL Commands: +F, -F, +G (Integer Arithmetic)

S5 AWL arithmetic operates on the two accumulators: ACCU2 (operator) and ACCU1 (operand). The result goes into ACCU1. ACCU2 is unchanged.

Instructions

S5 AWLOperationS7 STLData Type
+FACCU1 = ACCU2 + ACCU1+IINT (16-bit, -32768…+32767)
-FACCU1 = ACCU2 - ACCU1-IINT (16-bit)
+GACCU1 = ACCU2 + ACCU1+DDINT (32-bit, -2147483648…+2147483647)
-GACCU1 = ACCU2 - ACCU1-DDINT (32-bit)

Code Example — Add Two Values

L  MW 10            // Load first value → ACCU1
L  MW 20            // First value moves to ACCU2, second → ACCU1
+F                  // ACCU1 = MW10 + MW20 (INT addition)
T  MW 30            // Store result

S7 STL: L MW 10 / L MW 20 / +I / T MW 30 (identical logic, different mnemonic)

S7 SCL: MW30 := MW10 + MW20;

Important: Operand Order

The first L goes into ACCU2 (after the second L pushes it there). The second L is in ACCU1. For subtraction: ACCU2 - ACCU1 = first loaded - second loaded.

L  MW 10            // 100 → ACCU1, then pushed to ACCU2
L  MW 20            // 30 → ACCU1
-F                  // ACCU1 = 100 - 30 = 70
T  MW 30            // MW30 = 70

Overflow Detection

After +F/-F, the overflow flags (OV, OS) indicate if the result exceeded the INT range. Check with:

+F
SPO =OVERFLOW       // Jump if overflow occurred

S7 Equivalents Summary

S5S7 STLS7 SCLOperation
+F+Ia + bINT addition
-F-Ia - bINT subtraction
+G+Da + bDINT addition
-G-Da - bDINT subtraction
×F*Ia * bINT multiplication
:F/Ia / bINT division

Part of the S5 AWL Command Reference. Maintained by PLCcheck.ai.


Analyze Your S5 Code Automatically

PLCcheck Pro reads your complete S5 AWL program and explains every instruction — including this one — in plain language. Upload your code and get instant documentation, S7 equivalents, and migration guidance.

Upload S5 code for free analysis → | S5→S7 Migration Guide →

Related Articles

Analyze your PLC code with AI

PLCcheck Pro explains, documents, optimizes, and migrates PLC code — automatically.

Try PLCcheck Pro →
← Back to Blog

Not affiliated with Siemens AG. S5, S7, STEP 5, STEP 7, and TIA Portal are trademarks of Siemens AG.