Summary
Performs a data search in block units, starting from the first item in the specified range. Compares data blocks, starting from the specified (offset) blocks and returns (saves) the search result to the specified storage address. When a matching block is found, the offset value of the block (1 or higher) is saved. When no matching block is found, "FFFFh" is saved. When an error occurs, the error status value is written to LS9153.
Format
_memsearch ([Searched Block Address], [Search Start
Address], [Search End Address], [Search Result Storage Address], Offset
from Start Block, Number of Compared Words, Words in 1 Block)
Parameter 1: Internal Device
Parameter 2: Internal Device
Parameter 3: Internal Device
Parameter 4: Internal Device
Parameter 5: Numeric Value (0 to 639), Internal Device, Temporary variable
Parameter 6: Numeric Value (1 to 640)
Parameter 7: Numeric Value (1 to 640)
Data to be written
When there are matching blocks: The block's offset value ("1" or higher)
When there are no matching blocks: "FFFFh"
Make sure the search block address, search start address, and search end address are set to the same type of device (LS or USR). However, the [Searched Block Address] and [Search Result Storage Address] can be set to the Internal Device.
Be sure that [Parameter 2] is less than [Parameter 3]. Otherwise, an error occurs.
Define multiple blocks for the search range. This function does not run on a single block. To search a single block, use compare memory (_memcmp).
Example expression 1:
_memsearch([w:[#INTERNAL]LS1000],[w:[#INTERNAL]LS1005],[w:[#INTERNAL]LS1025],[w:[#INTERNAL]LS0100],0,1,5)
(Searches from LS1005 to LS1025 for a 1 word block with the same value. Starts from offset 0 of the source search block, and stores the result in LS0100.)
In this case, the value of "Block 1" matches the value of "the source search block". As a result the search result "1" is stored in LS0100.
Example expression 2:
_memsearch([w:[#INTERNAL]LS1000],[w:[#INTERNAL]LS1005],[w:[#INTERNAL]LS1025],[w:[#INTERNAL]LS0100],3,2,5)
(Searches from LS1005 to LS1025 for a 2 word block with the same value. Uses two words, starting from an offset of 3, and stores the result in LS0100.)
In this case, the value of "Block 4" matches the value of "the source search block". As a result the search result "4" is stored in LS0100.
Error Status
Editor Function Name |
LS Area |
Error Status |
Cause |
_memsearch ( ) |
LS9153 |
0000h |
Completed Successfully |
0001h |
Parameter error |
||
0003h |
Write/Read error |
The processing time required is proportional to the range designated by the start and end addresses. The larger the designated range, the longer the processing time becomes. The Part is not refreshed until processing is completed.
The effective internal address range that you can specify for the start address and end address is limited to the user area (LS20 to LS2031, LS2096 to LS8191, and USR00000 to USR29999).