1. Encoding ENCO
1. Encoding ENCO
1.1. Instruction Description
The ENCO instruction starts from the end of the range of input addresses (IN), finds the first ON bit from back to front, and outputs the offset address to (OUT).
The range of n is from 1 to 8, and the length of the input address lookup range is 2 to the power of n.
For example, in ENCO M10 K4Y0 K3, n is equal to 3, the nth power of 2 is 8, and the input range is M [10.. 17]. The first ON bit M16 is found, and the offset address 16-10=6 is saved in the word Y0Y1Y2Y3 composed of bits, that is, Y3=0, Y2=1, Y1=1, Y0=0.
图1 编码
1.2. The valid operands of the instruction
1.2.1. Encoding(ENCO)
| Input/Output | Data Type | operand | Description |
|---|---|---|---|
| IN | ON/OFF | Y/M/S, word positioning (D/V/Z) | Input |
| OUT | 16 bit integer | D/CV/TV/AO, bit composite word (Y/M/C/T/S) | Output |
| N | 16 bit integer | D/CV/TV/AI/AO/K/H/V/Z/FD, bit composite word (X/Y/M/C/T/S), local variable (LW) | quantity |
1.3. Example
Command table:
NETWORK 000
LDP X020
ENCO M10 K4Y0 K3 // Set Y0Y1Y2Y3 according to the setting in M [10.. 17].
图2 ENCO