SUNTIL

Searching for a string

SUNTIL

Search UNTIL equal string


[Syntax]

SUNTIL.size

 

[Operation]

unsigned { char | short | long } *R1;

unsigned long R2, R3, tmp;

while ( R3 != 0 ) {

tmp = ( unsigned long ) *R1++;

R3--;

if ( tmp == R2 ) {

break;

}

}

Note

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

Note

2. R1++: Incrementation is by the value corresponding to the size specifier (.size), i.e. by 1 for .B, 2 for .W, and 4 for .L.

[Function]

-

This instruction searches a string for comparison from the first address specified by R1 for a match with the value specified in R2, with the search proceeding in the direction of increasing addresses and the number specified by R3 as the upper limit on the number of comparisons. When the size specifier (.size) is .B or .W, the byte or word data on the memory is compared with the value in R2 after being zero-extended to form a longword of data.

-

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

-

Flags change according to the results of the operation "*R1 - R2".

-

The value in R1 upon completion of instruction execution indicates the next address where the data matched. Unless there was a match within the limit, the value in R1 is the next address in sequence from that for the last comparison.

-

The value in R3 on completion of instruction execution is the initial value minus the number of comparisons.

-

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

size

Processng Size

Code size

(Byte)

SUNTIL.size

B/W/L

L

2

[Flag Change]

Flag

C

Z

S

O

Change

 

 

Conditions

C : The flag is set if a comparison operation as unsigned integers results in any value equal to or greater than 0; otherwise it is cleared.

Z : The flag is set if matched data is found; otherwise it is cleared.

 

[Description Example]

SUNTIL.W