Compare Halfword (CH)
TheCOMPARE HALFWORD instruction compares a half word in storage with the contents of a register. For example,
assume that:
Register 44 contains FF FF80 00 = -32,768
10
Register 13 contains00 01 60 50 Storage lQ(;ations 16080-16081 contain 8000 = -32,768
1
0
When the instruction
Machine Format030 Assembler Format Op Code R
1
,O
2 (X
2
, 8
2
)
CH 4, X'30'(O, 13)
is executed, the contents oflocations16080-16081 are
fetched, expanded to 32 bits (the sign bit is propagated to
the left), and compared with the contents of register 4.Be cause the two numbers are equal, condition code 0 is set.
Comparelogical (Cl, ClR, CLI, ClC)
TheCOMPARE LOGICAL instructions differ from the
algebraic instructions (C, CR) in that all quantities are
handled as if unsigned.
Compare Logical (CL R)
Assume that:
Register 1 contains00 00 00 01 Register 2 contains FF FF FF FF
Execution of the instruction
Machine FormatOp Code R1 R2 Assembler Format Op Code R
1
, R2
CLR 1,2
sets condition code 1. A condition code 1 indicates that the
first operand is lower than the second. However, if an
algebraic compare instruction had been executed, condition
code 2 would have been set, indicating that the firstoper and is higher. During algebraic comparison, the contents of
register 1 are interpreted as + 1 and the contents of register
2 as -1. During logical comparison, the leftmost byte of
register 2 is compared with the leftmost byte of register 1;
each byte is interpreted as a binary number. In this case:
Leftmost byte of register 1:0000 0000 2 010 Leftmost byte of register 2: 1111 11112 =:: 25510
294System/370 Principles of Operation If the leftmost bytes are equal, the next two bytes are
compared, etc., until either an inequality is discovered or
the contents of the registers are exhausted.
Compare Logical Immediate(CLI) The CLI instruction logically compares a byte from the
instruction stream with a byte from storage. For example,
assume that:
Register10 contains 00 00 17 00 Storage location 1703 contains 7E
Execution of the instruction
Machine FormatOp Code 0
1 95
AFI A I 003 Assembler Format
o p Code0
1 (8
1
),12 CLI 3(10),X'AF'
sets condition code 1, indicating that the first operand (the
quantity in main storage) is lower than the second(imme diate) operand.
Compare Logical Characters (CLC)
TheCOMPARE LOGICAL CHARACTERS instruction can
be used to perform the logical comparison of storage fields
up to 256 bytes in length. For example, assume that the
following two fields of data are in storage:
Field 1
1886 1891I 01 1
06 1 C81 05
1 E2/ 06
1 05
1
68 I C1 1
48 I C2148 I Field 2 1900 1908 I 01 I 06 I C81 05
1 E2 I 06
1 05
1 68 I C
11
48 I C31 48 I Also assume:
Register 6 contains00 00 18 80 Register 7 con tains 00 00 19 00 Execution of the instruction
Machine FormatOp Code L 05 08 006 Assembler Format Op Code 0
1 (L, 8
1
),O
2 (8
2
)
CLC 6(12,6),0(7)000 sets condition code 2, indicating that the contents of field
1 are higher in value than the contents of field 2.
Because CLC compares bytes on an unsigned binary basis,
the instruction can be used to collate fields composed of
The
assume that:
Register 44 contains FF FF
10
Register 13 contains
1
0
When the instruction
Machine Format
1
,
2
2
, 8
2
)
CH 4, X'30'(O, 13)
is executed, the contents oflocations
fetched, expanded to 32 bits (the sign bit is propagated to
the left), and compared with the contents of register 4.
Compare
The
algebraic instructions (C, CR) in that all quantities are
handled as if unsigned.
Compare Logical (CL R)
Assume that:
Register 1 contains
Execution of the instruction
Machine Format
1
, R2
CLR 1,2
sets condition code 1. A condition code 1 indicates that the
first operand is lower than the second. However, if an
algebraic compare instruction had been executed, condition
code 2 would have been set, indicating that the first
register 1 are interpreted as + 1 and the contents of register
2 as -1. During logical comparison, the leftmost byte of
register 2 is compared with the leftmost byte of register 1;
each byte is interpreted as a binary number. In this case:
Leftmost byte of register 1:
294
compared, etc., until either an inequality is discovered or
the contents of the registers are exhausted.
Compare Logical Immediate
instruction stream with a byte from storage. For example,
assume that:
Register
Execution of the instruction
Machine Format
1
AF
o p Code
1
1
),
sets condition code 1, indicating that the first operand (the
quantity in main storage) is lower than the second
Compare Logical Characters (CLC)
The
be used to perform the logical comparison of storage fields
up to 256 bytes in length. For example, assume that the
following two fields of data are in storage:
Field 1
1886 1891
06
1
1
1
68
48
1
1
1
1
48
Register 6 contains
Machine Format
1
1
),
2
2
)
CLC 6(12,6),0(7)
1 are higher in value than the contents of field 2.
Because CLC compares bytes on an unsigned binary basis,
the instruction can be used to collate fields composed of