Mitsubishi — 5.6 Application Instructions

5 Categories and Use of Basic Application Instructions API 41 Operands: S : Source device to be decoded D : Device for storing the result n : Number of consecutive bits of S Explanation: 1. The instruction decodes the lower “ n ” bits of S and stores the result of “2 n ” bits in D . 2. When DECO is used as 16-bit instruction, Z device cannot be adopted; when DECO is used as 32-bit instruction, V device cannot be adopted. 3. This instruction is generally used in pulse execution mode (DECOP). 4. When operand D is a bit device, n = 1~8, when operand D is a word device, n = 1~4 Program Example 1: 1. When D is used as a bit device, n = 1 ~ 8. Errors will occur if n = 0 or n > 8. 2.

If n = 8, the decoded data is 2 8 = 256 bits data. 3. When X20 goes from OFF to ON, the data of X0~X2 will be decoded to M100~M107. 4. If the source data is 3, M103 (third bit from M100) = ON. 5. After the execution is completed, X20 is turned OFF. The decoded results or outputs will retain their operation. X20 Program Example 2: 1. When D is used as a word device, n = 1 ~ 4. Errors will occur if n = 0 or n > 4. 2. When n = 4, the decoded data is 2 4 = 16 bits. 3. When X20 goes from OFF to ON, the data in D10 (b2 to b0) will be decoded and stored in D20 (b7 to b0). The unused bits in D20 (b15 to b8) will be set to 0. 4.

The lower 3 bits of D10 are decoded and stored in the lower 8 bits of D20. The higher 8 bits of D20 are all 0. 5. After the execution is completed, X20 is turned OFF. The decoded results or outputs will retain their operation. X20 b0 D10 b15 b15 b0 D20 DVP-PM Operation Instruction 5-60 Mnemonic Operands Function Controllers 20PM 10PM DECO P Decode Type OP Bit Devices Word devices Program Steps X Y M S K H KnX KnY KnM KnS T C D E F DECO, DECOP: 7 steps S * * * * * * * * * * * D * * * * * * * * n * * DECOP X0 M100 K3 DECOP D10 D20 K3 0 1 0 1 0 1 0 1 0 1 0 1 0 0 1 1 4 2 1 all be 0 7 6 5 4 3 2 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0