CMPC

VAX11

 

CMPC  COMPARE CHARACTERS

 

Purpose

to compare two character strings

Format

opcode len.rw, src1addr.ab, src2addr.ab                      3 operand

 

opcode src1len.rw, src1addr.ab, fill.rb, src2len.rw        5 operand

src2addr.ab

Operation

Compare bytes in order from start of string.

On 5 operand opcode, if one of the strings is shorter than the second one we use fill to compare to the rest of the characters of the second string.

Condition codes

Final Condition codes reflect last affecting of Condition Codes in Operation above.

 

N ß {first byte} LSS {second byte};

Z ß {first byte} EQL {second byte};

V ß 0;

C ß {first byte} LSSU {second byte};

 

Exceptions

None

Opcodes

29        CMPC3           Compare Characters 3 Operand

2D       CMPC5           Compare Characters 5 Operand

Description

In 3 operand format, the bytes of string 1 specified by the length and address 1 operands are compared with the bytes of string 2 specified by the length and address 2 operands. Comparison proceeds until inequality is detected or all the bytes of the strings hare been examined. Condition codes are affected by the result of the last byte comparison. In 5 operand format, the bytes of the string 1 specified by the length 1 and address operands are compared with the bytes of string 2 specified by the length 2 and address 2 operands. If one string is longer than the other, the shorter string is conceptually extended to the length of the longer by appending (at higher addresses) bytes equal to the fill operand. Comparison proceeds until inequality is detected or all the bytes of the strings have been examined. Condition codes are affected by the result of the last byte comparison.

Notes

1. After execution of CMPC3;

R0 = number of bytes remaining in string 1 (including byte which terminated comparison); R0 is zero only if strings are equal.

Rl = address of the byte in string 1 which terminated comparison; if strings are equal, Al = address of one byte beyond string 1.

R2 = R0

R3 = address of the byte in string 2 which terminated comparison: if strings are equal, R3 = address of one byte beyond string 2.

 

2. After execution of CMPC5:

R0 = number of bytes remaining in string 1 (including byte which terminated comparison); R0 is zero Only if string 1 and string 2 are of equal length and equal or string 1 was exhausted before comparison terminated.

Rl = address of the byte in string 1 which terminated comparison; if comparison did not terminate before string 1 exhausted, R1 = address of one byte beyond string 1.

R2 = number of bytes remaining in string 2 (including byte which terminated comparison): R2 is zero only if string 2 and string 1 are of equal length or string 2 was exhausted before comparison terminated.

R3 = address of the byte in string 2 which terminated comparison; if comparison did not terminate before string 2 was exhausted,
R3 = address of one byte beyond string.

3. If both strings have zero length, Z is set and N and C are cleared just as in the case of two equal strings.