SCMPU

String comparison

SCMPU

String CoMPare Until not equal


[Syntax]

SCMPU

 

[Operation]

unsigned char *R2, *R1, tmp0, tmp1;

unsigned long R3;

while ( R3 != 0 ) {

tmp0 = *R1++;

tmp1 = *R2++;

R3--;

if ( tmp0 != tmp1 || tmp0 == '\0' ) {

break;

}

}

Note

If this instruction is executed with R3 set to 0, it is ignored and has no effect on registers and flags.

 

[Function]

-

This instruction compares strings in successively higher addresses specified by R1, which indicates the source address for comparision, and R2, which indicates the destination address for comparision, until the values do not match or the null character "\0" (= 00h) is detected, with the number of bytes specified by R3 as the upper limit.

-

In execution of the instruction, the data may be prefetched from the source address for comparison specified by R1 and the destination address for comparison specified by R2, with R3 as the upper limit. For details of the data size to be prefetched, refer to the hardware manual of each product.

-

The contents of R1 and R2 are undefined upon completion of the instruction.

-

An interrupt request during execution of this instruction will be accepted, so processing of the instruction will be suspended. That is, execution of the instruction will continue on return from the interrupt processing routine. However, be sure to save the contents of the R1, R2, R3, and PSW when an interrupt is generated and restore them when execution is returned from the interrupt routine.

 

[Instruction Format]

Syntax

Processng Size

Code size

(Byte)

SCMPU

B

2

[Flag Change]

Flag

C

Z

S

O

Change

 

 

Conditions

C : This flag is set if the operation of (*R1 - *R2) as unsigned integers produces a value greater than or equal to 0; otherwise it is cleared.

Z : This flag is set if the two strings have matched; otherwise it is cleared.

 

[Description Example]

SCMPU