Chapter 7 Second Development PlatformVP3000
329
API Instruction code Operand Function
42 ENCO P S, D, n
Decode
Type
Operand
Bit devices Word devices
16-bit instruction (7 steps)
ENCO
Continuous
execution
type
ENCOP
Pulse
execution
type
32-bit instruction
- - - -
Associated flag: none
X Y M K H KnX KnY KnM T C D
S
D
n
Caution for using operand
When operand S is bit device, n = 1–8, and when operand S is word
device, n = 1–4.
Description
S: source device to be decoded
D: device for storing the decoded result
n: length of decoded bits
The instruction decodes the lower “n” bits of S and stores the result in D.
If several bits of S are 1, the first bit that is 1 will be processed orderly from high bit to low bit.
Example
Example 1
1. When S is used as a bit device, the valid range is 0 < n 8. Error occurs when n = 0 or n
> 8.
2. When n = 8, the maximum points to encode is 2
8
= 256 points.
3. When X0 = OFFON, this instruction encodes the content in 2
3
bits (M0–M7) and stores
in the lower 3-bit (b2–b0) of D0. The unused bits in D0 (b15–b3) become 0.
4. After the execution is completed, X0 becomes OFF, and the data in D remains
unchanged.
ENCOP M0 K3D0
X0