
6F3B0253
7. Instructions
FUN 120
ENC
Encode
Expression
Input − [ A ENC (n) B ]− Output
Function
When the input is ON, this instruction finds the bit position of the most significant ON bit in the bit table, size 2n bits starting with 0 bit (LSB) of A, and stores it in B.
Execution condition
Input | Operation | Output | ERF |
OFF | No execution | OFF | − |
ON | Normal execution | ON | − |
| There is no ON bit (no execution) | OFF | Set |
Operand
| Name |
|
| Device |
|
|
|
|
|
|
|
| Register |
|
|
|
| Constant | Index | ||
|
| X | Y | R | S | T. | C. | XW | YW | RW | SW | T | C | D | I | J | K |
|
| ||
A | Start of table |
|
|
|
|
|
| √ | √ | √ | √ |
| √ | √ | √ |
|
|
|
|
|
|
n | Table size |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 - 8 |
|
B | Encode result |
|
|
|
|
|
|
| √ |
| √ | √ | √ | √ | √ | √ | √ | √ |
|
|
|
Example
25 (=32) bits starting with 0 bit of RW05 (R050 to R06F) are defined as the bit table.
When R010 is ON, the most significant ON (1) bit position in the bit table is searched, and the position is stored in D0010.
The following figure shows an operation example.
|
|
|
|
|
|
|
| RW06 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| RW05 | ||||
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 | 9 |
| |||||||||||||||||||||||||||
0 | 0 | 0 | 0 | 0 | 1 | 0 |
| 0 | 1 |
| 0 | 0 | 1 |
| 1 | 0 | 0 | 0 | 0 | 1 | 1 | 1 |
| 0 | 1 | 0 |
| ||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| D0010 |
|
|
| 26 |
|
|
|
|
| |||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 2 1 0
0 0 1 0
Note
• If there is no ON bit in the bit table, the instruction error flag (ERF = S051) is set to ON.
200