16bit and 32bit data comparison

 

Relational operators with Logical operators for 16Bit(Word) and 32Bit(Double word) Data

 

Relational operators compare two values or strings to provide a true and false result.

If the comparison is true, the result is 1. (Instruction will carry on)

If the comparison is false, the result is 0. (Instruction will no carry on)

 

Format : Relational Operator(=,<>, <, >, <=, >=) value(S1) value(S2)

(Example : <= X00 D1)

If relational operator is double word (LDD, ANDD, ORD), write D in front of relational operator.

(Example : D<= 1000000 D10)

Instruction

Device address

No. of Steps

Flag

M

X

Y

K

L

F

T

C

S

Z

D

@D

Int.

Error

Zero

Carry

LD x,

LDD x

AND X,

ANDD x,

OR x,

ORD x

S1

o

o

o

o

o

o

o

o

-

o

o

o

o

3

o

-

-

S2

o

o

o

o

o

o

o

o

-

o

o

o

o

 

 

LD x, LDD x (x : =, <, >, <=, >=, <>)

Functions

  • Compare two values S1 and S2 and if the comparison is true, the instruction will carry on.

  • S1 and S2 are signed number.

LD x : h8000 (-32768) ~ hFFFF (-1) < 0 ~ h7FFF (32767)

LDD x : h80000000 (-2147483648) ~ hFFFFFFFF (-1) < 0 ~ h7FFFFFFF (2147483647)

 

Comparison

Operator

Result

= Equal

S1 = S2

True

< Less than

S1 < S2

True

<= Less than or equal

S1 <= S2

True

> Greater than

S1 > S2

True

>= Greater than or equal

S1 >= S2

True

<> Not equal

S1 ≠ S2

True

 

Example)

If X00 equals D01 then Y10 will be turned ON.

 

 

If D1 is greater than or equals to 1000 then Y10 will be turned ON.

 

 

If 1000000 is less than or equal to D10 then Y10 will be turned ON.

 

 

 

AND x, ANDD x (x : =, <, >, <=, >=, <>)

Functions

  • Compare two values S1 and S2 and if the comparison is true and multiple conditions are also true then the instruction will carry on.

  • S1 and S2 are signed number.

AND x : h8000 (-32768) ~ hFFFF (-1) < 0 ~ h7FFF (32767)

ANDD x : h80000000 (-2147483648) ~ hFFFFFFFF (-1) < 0 ~ h7FFFFFFF (2147483647)

Comparison

Operator

Result

= Equal

S1 = S2

True

< Less than

S1 < S2

True

<= Less than or equal

S1 <= S2

True

> Greater than

S1 > S2

True

>= Greater than or equal

S1 >= S2

True

<> Not equal

S1 ≠ S2

True

 

Example)

If M11 is ON and 100 equal to D2 then Y10 will be turned ON.

 

 

If X00 is ON and D0(double word) is not equal to D2(double word) then Y20 will be turned ON.

 

 

OR x, ORD x (x : =, <, >, <=, >=, <>)

Functions

  • Compare two values S1 and S2 and if either the comparison is true or other condition is true then the instruction will carry on.

  • S1 and S2 are signed number.

AND x : h8000 (-32768) ~ hFFFF (-1) < 0 ~ h7FFF (32767)

ANDD x : h80000000 (-2147483648) ~ hFFFFFFFF (-1) < 0 ~ h7FFFFFFF (2147483647)

Comparison

Operator

Result

= Equal

S1 = S2

True

< Less than

S1 < S2

True

<= Less than or equal

S1 <= S2

True

> Greater than

S1 > S2

True

>= Greater than or equal

S1 >= S2

True

<> Not equal

S1 ≠ S2

True

 

Example)

If either M1A is ON or M30 is greater than or equal to D2 then Y11 will be turned ON.

 

 

If either X0 is ON or D0 is less than D2, Y31 will be turned ON.