MOVE / MVM — Copy a Value
MOVE copies a literal or tag into a destination tag every scan in rungs.dev, converting between DINT and REAL when the types differ. MVM is a masked move that copies only selected bits.
MOVE
Source
source
Dest
dest
Copies a source value (literal or tag) into a destination tag. When the source and destination are different numeric types, MOVE is also how you convert between them.
Operands
| Name | Type |
|---|---|
source | DINT | REAL |
dest | DINT | REAL |
How It Works
When the rung is true, source is read and written to dest every scan. When the rung is false, MOVE does nothing and dest keeps its last value.
Example — Change a Timer Preset at Run Time
Set a timer's preset based on which mode the machine is in.
0
ModeFast
MOVE
Source
2000
Dest
CycleTimer.PRE
1
ModeSlow
MOVE
Source
8000
Dest
CycleTimer.PRE
While ModeFast is selected, CycleTimer.PRE is held at 2000. While ModeSlow is selected, it is held at 8000.
Example — Copy a Reading
0
SampleNow
MOVE
Source
TempSensor
Dest
LastSample
Type Conversion
Studio has no separate _TO_ conversion instructions (no REAL_TO_DINT, no DINT_TO_REAL). Conversion happens automatically when MOVE's source and destination types differ.
Modeled on Studio 5000 Logix Designer
Conversion behavior in rungs.dev follows the same conventions as Studio 5000 Logix Designer®.
DINT → REAL (lossless for most values)
A DINT value is copied into a REAL with a decimal point added. For everyday values this is exact:
Source (DINT) | Destination (REAL) |
|---|---|
7 | 7.0 |
-1000 | -1000.0 |
16777216 | 16777216.0 |
A REAL can represent integers exactly up to about 16.7 million. Above that, the conversion is rounded to the nearest representable value. For example, 16777217 becomes 16777216.0. You'll only hit this with large counters or accumulators — for everyday tags it's not something to worry about.
REAL → DINT (banker rounding)
The fractional part has to go somewhere, so Studio uses banker rounding — also called round half to even. Halves go to the nearest even integer; non-halves round normally.
Source (REAL) | Destination (DINT) |
|---|---|
0.5 | 0 |
1.5 | 2 |
2.5 | 2 |
3.5 | 4 |
-2.5 | -2 |
1.4 | 1 |
1.6 | 2 |
MOVE(2.5, DintTag) // DintTag = 2
MOVE(3.5, DintTag) // DintTag = 4For more on why halves round to the nearest even number rather than always up, see the Arithmetic and Comparison Operators page.
REAL → DINT overflow
After rounding, a finite REAL that is outside the DINT range overflows into the stored 32-bit DINT bit pattern. For example, 2147483648.0 stores as -2147483648.
REAL → DINT with non-finite values
If the source is +Infinity, -Infinity, or NaN (which can happen after a divide-by-zero), Studio clamps the value to the DINT range so an integer tag never holds a non-numeric value.
Source (REAL) | Destination (DINT) |
|---|---|
+Infinity | 2147483647 (MAX) |
-Infinity | -2147483648 (MIN) |
NaN | 0 |
Masked Move (MVM)
MVM
Source
source
Mask
mask
Dest
dest
MOVE overwrites the whole destination. MVM is a masked move. Copies the Source bits that the Mask lets through into the destination, leaving the destination bits under a 0 mask bit unchanged. Where a mask bit is 1, that bit of dest takes the Source value; where a mask bit is 0, that bit of dest keeps what it had.
| Name | Type |
|---|---|
source | DINT |
mask | DINT |
dest | DINT |
0
MVM
Source
StatusWord
Mask
16#00FF
Dest
Result
With mask 16#00FF, only the low 8 bits of StatusWord are copied into Result; the top 24 bits of Result are left untouched. A mask of 16#FFFFFFFF copies everything (the same as MOVE); a mask of 0 copies nothing. Write the mask in hexadecimal or binary so the passed-through bits are obvious.
Unlike MOVE, MVM works on bit patterns, so its operands are DINT only — there is no REAL masked move.
Common Mistakes
- Moving a
REALinto aDINTdestination without expecting rounding — the fractional part is gone, and halves snap to the nearest even integer (so2.5 → 2, not3). - Treating
MOVEas a free transfer between any two types — it works for numbers (DINT↔REAL), but not for structured types likeTIMERorCOUNTER. - Expecting
MVMto clear the bits the mask blocks — it doesn't. Bits under a0mask bit keep their current destination value; useCLRor a plainMOVEfirst for a clean slate.
Related
- Logical & bit instructions —
AND/OR/XOR/NOTcombine words bit-by-bit,CLRclears one, andBTDmoves a run of bits - Compare instructions — inspect values rather than move them
- Math instructions — compute values, then
MOVEor assign directly - Arithmetic and Comparison Operators — full division, rounding, and coercion rules
RES — Reset
RES in rungs.dev clears the accumulator and status bits of a TIMER or COUNTER tag back to zero — typically paired with RTO, CTU, or CTD on the same tag.
NOP / AFI — No Operation and Always False
NOP and AFI in rungs.dev — NOP is a placeholder that does nothing, AFI forces the rest of its rung false. Both are used while building and debugging programs, not in finished logic.