Chapter 5 Instruction Specifications

Item number

Application instructions-21

 

 

Name

 

Encode

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Ladder format

 

 

 

 

 

 

Condition code

 

 

 

 

Processing time (s)

Remark

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

R7F4

 

R7F3

 

R7F2

R7F1

 

R7F0

Average

Maximum

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

ENCO (d, s, n)

 

 

DER

 

ERR

 

SD

 

V

 

 

 

C

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

z

 

 

z

 

z

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Instruction format

 

 

 

 

 

 

Number of steps

 

 

 

 

As per the table

 

 

 

 

 

 

 

 

Condition

 

 

 

Steps

 

 

below.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

ENCO (d, s, n)

 

 

 

 

 

 

 

 

 

 

 

 

 

4

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Bit

 

 

 

 

 

 

 

Word

 

Double word

Constant

 

 

 

Usable I/O

X

 

Y

M

 

 

CU, CT

 

WX

WY

WM

 

TC

DX

DY

DM

 

Other

 

 

 

 

 

 

 

R,

 

 

TD, SS,

 

 

 

 

WR,

 

 

 

 

DR,

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

d

Decode destination head I/O

 

 

 

 

 

 

 

 

 

 

{

 

{

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

s

Word I/O to be encoded

 

 

 

{

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

n

Number of bits to be

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

{

 

1 to 8 (decimal)

encoded

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Function

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Encodes the bit location 2n in the range between s and s + 2n – 1 where the bit is “1,” and outputs the result to d (n = 1 to 8). Upper bits (16-n) of d are set to “0.”

If n is “0,” the instruction will not be executed and the contents of d retain the original values.

If there are more than one bits that are set to “1” between s and s + 2n – 1, the upper bit location will be encoded.

If all the bits from s to s + 2n – 1 are '0', '0' is output to d, and C (R7F0) is equal to '1.' In other cases, C (R7F0) is set to '0.'

s+2n-1

s+B

 

 

s

b15

b7

b0

 

0

 

1

 

0

0

 

d

 

 

0BH

 

 

 

 

2n

 

 

 

n bits (1 to 8)

Notes

Use this instruction so that s + 2n− 1 does not exceed the I/O range (R7BF and M3FFF). If it exceeds the I/O range, DER is set to '1' and the encoding is performed at the maximum range starting from s.

Use 1 to 8 for n.

Program example

X00001 DIF1

 

 

LD

X00001

 

 

AND

DIF1

ENCO (WR0000, R000, 4)

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

[

 

 

 

 

 

 

 

 

ENCO (WR0000, R000, 4)

]

Program description

Upon the leading of X00001, the most significant bit that is set to “1” is detected within the row of bits R000 to R00F (24 –1 = 15 bits), and a four-bit binary number is set in the word I/O of d.

Example) If “1” is set in the 7th and 6th bits of R000 to R00F, H0007 is set in WR0000.

n

Processing time (s)

Average

Maximum

 

1

128

2

128

3

128

4

187

5

126

6

126

7

126

8

126

ENCO (d, s, n)

5-93

Page 143
Image 143
Hitachi NJI-350B manual Application instructions-21, Encode, 128 187 126