AH500 Programming Manual API 0058 Symbol: S 1 : Matrix source device 1 Word S 2 : Matrix source device 2 Word n : Length of the array Word D : Pointer Word Explanation: 1. The search for the bits whose states are different starts from the bits specified by the number gotten from the addition of one to the current value in D . After the bits whose states are different are found, the bit number is stored in D , and the comparison is finished. 2. The operand n should be within the range between 1 and 256. 3. When SM607 is ON, the equivalent values are compared. When SM607 is OFF, the different values are compared.
When the matching bits are compared, the comparison stops immediately, and SM610 is ON. When the last bits are compared, SM608 is ON, and the bit number is stored in D . The comparison starts from the 0 th bits in the next scan cycle, and SM609 is ON. When the value in D exceeds the range, SM611 is ON. 4. When the instruction MCMP is executed, users need a 16-bit register to specify a certain bit among the 16 n bits in the matrix for the operation. The register is called the pointer, and is specified by users. The value in the register is within the range between 0 and 16 n -1, and corresponds to the bit within the range between b0 and b16 n -1.
During the operation, users should be prevented from altering the value of the pointer in case the search for the matching bits is affected. If the value of the pointer exceeds the range, SM611 will be ON, and the instruction MCMP will not be executed. 5. If SM608 and SM610 occur simultaneously, they will be ON simultaneously. Example: 1. When X0.0 is switched from OFF to ON, SM609 is OFF. The search for the bits whose states are different (SM607 is OFF) starts from the bits specified by the number gotten from the addition of one to the current value of the pointer. 2. Suppose the current value in D20 is 2.
When X0.0 is switched from OFF to ON four times, users can get the following execution results. The value in D20 is 5, SM610 is ON, and SM608 is OFF. The value in D20 is 45, SM610 is ON, and SM608 is OFF. The value in D20 is 47, SM610 is OFF, and SM608 is ON. The value in D20 is 1, SM610 is ON, and SM608 is OFF. 6-29 Instruction code Operand Function MCMP P S , S , n, D 1 2 Matrix comparison Device X Y M S T C HC D L SM SR E PR K 16# “$” DF S 1 S 2 n D Pulse instruction 16-bit instruction (9 steps) 32-bit instruction AH500 AH500 -