9 binary search (bsrch), 1 ) operation, 2 ) format – Yaskawa MP900 Series Ladder Programming Manual User Manual

Page 197

Advertising
background image

5.7 Data Shift Instructions

5.7.9 Binary Search (BSRCH)

5-128

5.7.9 Binary Search (BSRCH)

( 1 ) Operation

The BSRCH instruction searches for the search data using a binary search method in the area designated by the number
of words from the first address in the search range. The search result is output as the offset word number of the data that
matches the search data from the first register in the search range.

∗ 1. Always sort the search area in ascending order before executing the BSRCH instruction.
∗ 2. The conceptual diagram shown here is for integers. The instruction operates in the same way for double-length

integers and real numbers.

∗ 3. If the search data is not found, the instruction sets the search result to -1.

( 2 ) Format

∗ C and # registers cannot be used.

4

First register address

in the search range

7

8

20

60

MW†††††

MW††††† + 1

MW††††† + 2

MW††††† + 3

MW††††† + 4

Search data:

20

4

First register address

in the search range

7

8

20

60

Found at address + 3 from

the first address

in the search range.

Search result: 3 (offset)

Number of

words in

range

Search data

Search result

Number of words

in range

First address

of the search range

Icon:

Key entry: BSRCH

Parameter Name

Applicable Data Types

B

W

L

F

A

Index

Constant

First address of search
range (Src)

×

{

{

{

×

×

×

Number of words in range
(Width)

×

{

×

×

×

{

{

Search data (Data)

×

{

{

{

×

{

{

Search result (Result)

×

{

*

×

×

×

×

×

Advertising
This manual is related to the following products: